# HG changeset patch
# User Steve Losh
It has no other dependencies (aside from Lanterna itself, of course).
Add this to your project.clj
:
[clojure-lanterna "1.0.0"] +diff -r 871d17fdead1 -r f903877193f4 clojure-lanterna/reference/index.html --- a/clojure-lanterna/reference/index.html Sat Jul 07 15:23:49 2012 -0400 +++ b/clojure-lanterna/reference/index.html Thu Jul 12 22:35:18 2012 -0400 @@ -17,9 +17,11 @@[clojure-lanterna "0.9.1"]
Use this if you don't need detailed control of the terminal starting and stopping process.
+(get-size terminal) +
Return the current size of the terminal as [cols rows]
.
(move-cursor terminal x y)
Draw the string at the specified cursor location.
The cursor will end up at the position directly after the string.
+(clear terminal) +
Clear the given terminal.
+The cursor will be at the coordinates 0, 0 after the clearing.
(set-fg-color terminal color)
Use this if you don't need detailed control of the screen starting and stopping process.
+(get-size screen) +
Return the current size of the screen as [cols rows]
.
(redraw screen)
:default
).
:styles
- Styles to apply to the text. Must be a set containing zero or
more style constants (default #{}
). CURRENTLY BROKEN, SORRY(clear screen) +
Clear the given screen.
+Note that this is buffered just like every other screen-related action. You
+need to redraw
to actually see it happen.
(get-key screen)
Go back and read the terminal docs if you don't understand those functions.
-Resizing works the same way as the terminal layer. Pass a resize listening -function when you create your screen:
+Sizing works the same way as the terminal layer. Screen have a get-size
+function of their own:
(s/get-size scr) +; => [130 44] +
You can pass a resize listening function when you create your screen:
(def screen-size (ref [0 0])) (defn handle-resize [cols rows] diff -r 871d17fdead1 -r f903877193f4 clojure-lanterna/terminals/index.html --- a/clojure-lanterna/terminals/index.html Sat Jul 07 15:23:49 2012 -0400 +++ b/clojure-lanterna/terminals/index.html Thu Jul 12 22:35:18 2012 -0400 @@ -12,7 +12,7 @@
The final piece of Lantera's terminal layer is the concept of resizing.
+The final piece of Lantera's terminal layer is the concept of terminal sizes.
When writing a terminal application, you're at the mercy of the user when it comes to how big (or small) the window is going to be.
Obviously in a console environment the user can resize their xterm window. Lanterna's Swing terminal emulator can be resized by dragging normally as well.
+First of all, you can get the size of the terminal at any time with get-size
:
(t/get-size term) +; => [80 24] +
But getting the size at a single point in time usually won't be enough.
Your application needs to be able to handle resized windows. To do this you can provide a function when you create the terminal. This function will be called by Lanterna whenever the window is resized and passed the new columns and rows.