 (ns flense-nw.app
   (:require [cljs.core.async :as async :refer [<!]]
             [cljs.reader :as rdr]
-            [flense.actions :refer [actions defaction]]
+            [flense.actions :refer [default-actions]]
             [flense.actions.history :as hist]
-            flense.actions.clipboard
-            flense.actions.clojure
-            flense.actions.movement
-            flense.actions.paredit
             [flense.editor :refer [editor-view]]
             [flense.model :as model]
             [flense-nw.cli :refer [cli-view]]

  (when-let [action (bound-action ev)]
    (if (model/stringlike? form)
      ;; prevent all keybinds except those that end editing
      (#{:flense/text-command :move/up :paredit/insert-outside} (:name action))
      ;; prevent delete keybind unless text fully selected
      (or (not= (:name action) :flense/remove)
          (fully-selected? (.-target ev))))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

     :tree {:children
            (->> (fs/slurp fpath) model/string->forms (mapv model/form->tree))}}))

(def actions
  (assoc default-actions :flense/text-command
         ;; dummy action to trap ctrl+x keybind
         (with-meta identity {:tags #{:end-text-editing :text-command}})))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; text commands
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
