       (.addKeyListener textArea 
         (proxy [java.awt.event.KeyAdapter] []          
           (keyPressed [#^java.awt.event.KeyEvent e]
+            (when (= (.getKeyCode e) java.awt.event.KeyEvent/VK_UP)
+              (try 
+                (let [startPosition 0]
+                  (.remove (.getDocument textArea) startPosition (- (.getLength (.getDocument textArea)) startPosition 1))                  
+                  (.setText textArea (nth @repl-input (- (dec (count @repl-input)) @repl-input-index)))
+                  (reset! repl-input-index (min (inc @repl-input-index) (dec (count @repl-input))))
+                  #_(.setText textArea (last @repl-input)))
+                (catch Exception e (println (.getMessage e))))
+              (.consume e))
+            (when (= (.getKeyCode e) java.awt.event.KeyEvent/VK_DOWN)
+              (try 
+                (let [startPosition 0]
+                  (.remove (.getDocument textArea) startPosition (- (.getLength (.getDocument textArea)) startPosition 1))                  
+                  (.setText textArea (nth @repl-input (- (dec (count @repl-input)) @repl-input-index)))
+                  (reset! repl-input-index (max (dec @repl-input-index) 0))
+                  #_(.setText textArea (last @repl-input)))
+                (catch Exception e (println (.getMessage e))))
+              (.consume e))
             (when (= (.getKeyCode e) java.awt.event.KeyEvent/VK_ENTER)
               (.append textArea "\n")
               ;; This shouldn't be here:

  "Evaluate something, print all outputs, and print the final returned value."
  [thing echo?]
  (when echo?
    (write-form-repl (str "> " thing)))
  (let [response-vals (nrepl/message (:client @repl) {:op "eval" :code thing})]
    (doseq [resp response-vals]

(defn write-stdout-repl
  "Write a stdout message for to the REPL output."
  [s]
  (swap! repl-output conj s);; probably should limit history
  (update-repl-output))

(def write-value-repl write-stdout-repl)
