+;; This is a Light Table plugin that will allow you to rapidly
+;; change the value of a number with the mouse or keyboard, then
+;; automatically evaluate your code so you can get instant feedback.
+;; It works great for visualizing CSS changes live, as well as
+;; for getting a feel for data flow thorugh Clojure/Clojurescript code
+;; with form-eval and watches.
+;;
+;; This code is largely a port of Peter Flynn's everyscrub extension
+;; for the Brackets editor: https://github.com/peterflynn/everyscrub
+;;
+;; I am also hugely inspired by Bret Victor's awesome work. In this case
+;; specifically Tangle (http://worrydream.com/Tangle/). I'm hoping
+;; we can push the limits of programming UX with Light Table!
+
+;; Here we're requiring the bare minimum Light Table namespaces
 (ns lt.plugins.lt-scrubber
   (:require [lt.object :as object]
             [lt.objs.command :as cmd]
             [lt.objs.editor :as editor]
-            [lt.objs.editor.pool :as pool])
+            [lt.objs.editor.pool :as pool]
+            [lt.util.dom :as dom])
   (:require-macros [lt.macros :refer [behavior]]))
 
 ;; These are some regex helper functions to find the position
 ;; of matches. This is currently not built into Clojurescript.
 ;; We will be using various regex to match for the different
-;; types of values that can be scrubbed
+;; types of values that can be scrubbed.
 ;;
 ;; http://stackoverflow.com/questions/18735665/how-can-i-get-the-positions-of-regex-matches-in-clojurescript
 (defn regex-modifiers

(find-match-near-pos simple-number-regex "I have 1 cookie 30" 17)

;; We then parse a line of text using a
;; TODO: is this extraneous?
(defn parse-for-scrub [line-text target-pos]
  (let [match (find-match-near-pos simple-number-regex line-text target-pos)]
    (flatten match)))

(defn adder [x y]
  (+ x y))

(defn circle-radius [r]
  (* 3.1492653 (* r r)))

(adder 144 244)

(circle-radius 219.6)

;; This holds the global state for this plugin
(def app-state (atom {:last-range 0}))

;; This returns the number of places to the right of a decimal point
;; in a string representation of an integer or floating point number

  (filter (fn [x]
            (let [[match-pos match-str] x
                  end-pos (+ match-pos (count match-str))]
              (and (<= match-pos target-pos)
                       (>= end-pos target-pos))))
          (re-pos regex string)))
