              :input (:expression (nth history (- c new-cursor))))
       state)))
 
-(defn history-next [props]
-  (debugf "History next")
-  (let [state (:state props)]
-    (swap! state history-next*)))
-
-(defn input-key-down [props event]
+(defn clear-input [state]
+  (assoc state
+         :cursor 0
+         :input ""))
+
+(defn eval-input [state]
+  (let [input (trim (:input @state))]
+    (when-not (= "" input)
+      (eval-str state input))))
+
+(defn input-key-down [state event]
   (case (.-which event)
     ;; Enter
-    13 (do (eval-input props)
+    13 (do (eval-input state)
            (. event preventDefault))
 
     ;; Escape
-    27 (do (clear-input props)
+    27 (do (swap! state clear-input)
            (. event preventDefault))
 
     ;; Tab
     9  (. event preventDefault)
 
     ;; Up
-    38 (do (history-prev props)
+    38 (do (swap! state history-prev)
            (. event preventDefault))
 
     ;;Down
-    40 (do (history-next props)
+    40 (do (swap! state history-next)
            (. event preventDefault))
     nil))
 
-(defn input-on-change [props event]
-  (swap! (:state props) assoc
+(defn input-on-change [state event]
+  (assoc state
          :cursor 0
          :input (-> event .-target .-value)))
 

             :input (:expression (nth history (- c new-cursor))))
      state)))

(defn history-prev [props]
  (let [state (:state props)]
    (swap! state history-prev*)))

(defn history-next* [{:keys [cursor history] :as state}]
  (let [c          (count history)
        new-cursor (dec cursor)]
    (if (> new-cursor 0)

    :refer-macros (tracef debugf infof warnf errorf)]))

(defonce state
  (let [repl (repl/new-repl)]
    (atom {:repl    repl
           :ns      (repl/get-ns repl)
           :input   "(+ 1 2)"
           :next    1
           :cursor  0
           :history []})))

(defn clipboard [child]
  (let [clipboard-atom (atom nil)]
