Thursday, September 24, 2015

How to clear terminal screen in Clojure

Print some ANSI characters
(print (str (char 27) "[2J")) ; clear screen
(print (str (char 27) "[;H")) ; move cursor to the top left corner of the screen
Credit: http://codereview.stackexchange.com/questions/17603/critique-my-clojure-game-of-life-code

3 comments:

Julian Laffey said...

Works well, thank you!

Brendon Williams said...

Awesome, perfect. Thanks.

Brendon Williams said...

Unfortunately, the cursor moving ANSI hasn't worked in any console I've tried it in (including the native Window's console). I had to resort to using this hack function:

(defn move-cursor-to [x y]
(let [r #(apply str (repeat % %2))]
(print (str (r y \newline)
(r x \space)))))

[PostgreSQL] How to create read-only standby replica (follower)

This link  and this link explain it really well and concise