       ;; Enter
       13 (do (eval-input state)
              (. event preventDefault))
+      (swap! state assoc :ready? false :input "" :cursor 0))))
 
       ;; Escape
       27 (do (swap! state clear-input)

(defn on-repl-result [state num [ns result]]
  (if num
    (swap! state #(-> %
                      (assoc :ns ns)
                      (update-in [:history num] assoc :result result)))
    (swap! state assoc :ns ns)))

(defn on-repl-print [state num [s]]
  (when num

      (put! from-repl [:repl/eval num (:ns @state) expression])
      (put! to-repl [:repl/eval num expression])
      (recur (inc num)))
    (swap! state assoc :running? false :ready? false :crashed? false)
    (close! to-eval)
    (close! to-repl)))

(defn reset-repl! [state]
  (when-let [{:keys [from-repl to-repl]} (:repl @state)]
    (swap! state assoc :running? false :ready? false :crashed? false)
    (close! from-repl)
    (close! to-repl))

