Skip to content

Commit 93ab1e1

Browse files
committed
Add get-cursor to screen
get-cursor wraps .getCursorPosition. Introduce new arity for move-cursor so position vectors returned by get-cursor can be passed to it directly.
1 parent 495f496 commit 93ab1e1

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/lanterna/screen.clj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,20 @@
139139
appears in a specific place.
140140
141141
"
142-
[^Screen screen x y]
143-
(.setCursorPosition screen x y))
142+
([^Screen screen x y]
143+
(.setCursorPosition screen x y))
144+
([^Screen screen pos]
145+
(apply #(.setCursorPosition screen %1 %2) pos)))
146+
147+
148+
(defn get-cursor
149+
"Return the cursor position as [col row]."
150+
[^Screen screen]
151+
(let [pos (.getCursorPosition screen)
152+
col (.getColumn pos)
153+
row (.getRow pos)]
154+
[col row]))
155+
144156

145157
(defn put-string
146158
"Put a string on the screen buffer, ready to be drawn at the next redraw.

0 commit comments

Comments
 (0)