Liking cljdoc? Tell your friends :D

lanterna.screen


add-resize-listenerclj

(add-resize-listener screen listener-fn)

Create a listener that will call the supplied fn when the screen is resized.

The function must take two arguments: the new number of columns and the new number of rows.

The listener itself will be returned. You don't need to do anything with it, but you can use it to remove it later with remove-resize-listener.

Create a listener that will call the supplied fn when the screen is resized.

The function must take two arguments: the new number of columns and the new
number of rows.

The listener itself will be returned.  You don't need to do anything with it,
but you can use it to remove it later with remove-resize-listener.

sourceraw docstring

clearclj

(clear screen)

Clear the screen.

Note that this is buffered like everything else, so you'll need to redraw the screen to see the effect.

Clear the screen.

Note that this is buffered like everything else, so you'll need to redraw
the screen to see the effect.

sourceraw docstring

get-cursorclj

(get-cursor screen)

Return the cursor position as [col row].

Return the cursor position as [col row].
sourceraw docstring

get-keyclj

(get-key screen)

Get the next keypress from the user, or nil if none are buffered.

If the user has pressed a key, that key will be returned (and popped off the buffer of input).

If the user has not pressed a key, nil will be returned immediately. If you want to wait for user input, use get-key-blocking instead.

Get the next keypress from the user, or nil if none are buffered.

If the user has pressed a key, that key will be returned (and popped off the
buffer of input).

If the user has *not* pressed a key, nil will be returned immediately.  If you
want to wait for user input, use get-key-blocking instead.

sourceraw docstring

get-key-blockingclj

(get-key-blocking screen)
(get-key-blocking screen {:keys [interval timeout] :as opts})

Get the next keypress from the user.

If the user has pressed a key, that key will be returned (and popped off the buffer of input).

If the user has not pressed a key, this function will block, checking every 50ms. If you want to return nil immediately, use get-key instead.

Options can include any of the following keys:

:interval - sets the interval between checks :timeout - sets the maximum amount of time blocking will occur before returning nil

Get the next keypress from the user.

If the user has pressed a key, that key will be returned (and popped off the
buffer of input).

If the user has *not* pressed a key, this function will block, checking every
50ms.  If you want to return nil immediately, use get-key instead.

Options can include any of the following keys:

:interval - sets the interval between checks
:timeout  - sets the maximum amount of time blocking will occur before
            returning nil

sourceraw docstring

get-sizeclj

(get-size screen)

Return the current size of the screen as [cols rows].

Return the current size of the screen as [cols rows].
sourceraw docstring

in-screencljmacro

(in-screen screen & body)

Start the given screen, perform the body, and stop the screen afterward.

Start the given screen, perform the body, and stop the screen afterward.
sourceraw docstring

move-cursorclj

(move-cursor screen [x y])
(move-cursor screen x y)

Move the cursor to a specific location on the screen.

This won't affect where text is printed when you use put-string -- the coordinates passed to put-string determine that.

This is only used to move the cursor, presumably right before a redraw so it appears in a specific place.

Move the cursor to a specific location on the screen.

This won't affect where text is printed when you use put-string -- the
coordinates passed to put-string determine that.

This is only used to move the cursor, presumably right before a redraw so it
appears in a specific place.

sourceraw docstring

put-sheetclj

(put-sheet screen x y sheet)

EXPERIMENTAL! Turn back now!

Draw a sheet to the screen (buffered, of course).

A sheet is a two-dimentional sequence of things to print to the screen. It will be printed with its upper-left corner at the given x and y coordinates.

Sheets can take several forms. The simplest sheet is a vector of strings:

(put-sheet scr 2 0 ["foo" "bar" "hello!"])

This would print something like

0123456789 0 foo 1 bar 2 hello!

As you can see, the rows of a sheet do not need to all be the same size. Shorter rows will not be padded in any way.

Rows can also be sequences themselves, of characters or strings:

(put-sheet scr 5 0 [[\s \p \a \m] ["e" "g" "g" "s"]])

0123456789 0 spam 1 eggs

Finally, instead of single characters of strings, you can pass a vector of a [char-or-string options-map], like so:

(put-sheet scr 1 0 [[[\r {:fg :red}] [\g {:fg :green}]] [[\b {:fg :blue}]]])

0123456789 0 rg 1 b

And the letters would be colored appropriately.

Finally, you can mix and match any and all of these within a single sheet or row:

(put-sheet scr 2 0 ["foo" ["b" \a [\r {:bg :yellow :fg :black}])

EXPERIMENTAL!  Turn back now!

Draw a sheet to the screen (buffered, of course).

A sheet is a two-dimentional sequence of things to print to the screen.  It
will be printed with its upper-left corner at the given x and y coordinates.

Sheets can take several forms.  The simplest sheet is a vector of strings:

  (put-sheet scr 2 0 ["foo" "bar" "hello!"])

This would print something like

   0123456789
  0  foo
  1  bar
  2  hello!

As you can see, the rows of a sheet do not need to all be the same size.
Shorter rows will *not* be padded in any way.

Rows can also be sequences themselves, of characters or strings:

  (put-sheet scr 5 0 [[\s \p \a \m] ["e" "g" "g" "s"]])

   0123456789
  0     spam
  1     eggs

Finally, instead of single characters of strings, you can pass a vector of a
[char-or-string options-map], like so:

  (put-sheet scr 1 0 [[[\r {:fg :red}] [\g {:fg :green}]]
                      [[\b {:fg :blue}]]])

   0123456789
  0 rg
  1 b

And the letters would be colored appropriately.

Finally, you can mix and match any and all of these within a single sheet or
row:

  (put-sheet scr 2 0 ["foo"
                      ["b" \a [\r {:bg :yellow :fg :black}])

sourceraw docstring

put-stringclj

(put-string screen x y s)
(put-string screen
            col
            row
            s
            {:keys [fg bg styles] :or {fg :default bg :default styles #{}}})

Put a string on the screen buffer, ready to be drawn at the next redraw.

x and y are the column and row to start the string. s is the actual string to draw.

Options can contain any of the following:

:fg - Foreground color. Can be any one of (keys lanterna.constants/colors). (default :default)

:bg - Background color. Can be any one of (keys lanterna.constants/colors). (default :default)

:styles - Styles to apply to the text. Can be a set containing some/none/all of (keys lanterna.constants/styles). (default #{})

Put a string on the screen buffer, ready to be drawn at the next redraw.

x and y are the column and row to start the string.
s is the actual string to draw.

Options can contain any of the following:

:fg - Foreground color.
Can be any one of (keys lanterna.constants/colors).
(default :default)

:bg - Background color.
Can be any one of (keys lanterna.constants/colors).
(default :default)

:styles - Styles to apply to the text.
Can be a set containing some/none/all of (keys lanterna.constants/styles).
(default #{})

sourceraw docstring

redrawclj

(redraw screen)

Draw the screen.

This flushes any changes you've made to the actual user-facing terminal. You need to call this for any of your changes to actually show up.

Draw the screen.

This flushes any changes you've made to the actual user-facing terminal.  You
need to call this for any of your changes to actually show up.

sourceraw docstring

remove-resize-listenerclj

(remove-resize-listener screen listener)

Remove a resize listener from the given screen.

Remove a resize listener from the given screen.
sourceraw docstring

startclj

(start screen)

Start the screen. Consider using in-screen instead.

This must be called before you do anything else to the screen.

Start the screen.  Consider using in-screen instead.

This must be called before you do anything else to the screen.

sourceraw docstring

stopclj

(stop screen)

Stop the screen. Consider using in-screen instead.

This should be called when you're done with the screen. Don't try to do anything else to it after stopping it.

TODO: Figure out if it's safe to start, stop, and then restart a screen.

Stop the screen.  Consider using in-screen instead.

This should be called when you're done with the screen.  Don't try to do
anything else to it after stopping it.

TODO: Figure out if it's safe to start, stop, and then restart a screen.

sourceraw docstring

terminal-screenclj

(terminal-screen terminal)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close