Source

sjl.bitbucket.org / clojure-lanterna / reference / index.html

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
<!DOCTYPE html>
<html><head><meta charset="utf-8"/><title>Reference / clojure-lanterna</title><link rel="stylesheet" href="../_dmedia/bootstrap.css"/><link rel="stylesheet" href="../_dmedia/tango.css"/><link rel="stylesheet/less" type="text/css" href="../_dmedia/style.less"/><script src="../_dmedia/less.js" type="text/javascript">
        </script></head><body class="content">
        <div class="wrap">
            <header><h1><a href="..">clojure-lanterna</a></h1></header><div class="markdown">
<h1 id="reference"><a href="">Reference</a></h1><p>Here's the deep dive.</p>
<p>If you haven't read the <a href="../terminals/">terminal</a> and <a href="../screens/">screen</a>
documentation you should read those to wrap your brain around the structure of
things first.</p>
<div class="toc">
<ul><li><a href="#constants">Constants</a><ul><li><a href="#colors">Colors</a></li>
<li><a href="#styles">Styles</a></li>
<li><a href="#key-codes">Key Codes</a></li>
<li><a href="#charsets">Charsets</a></li>
<li><a href="#consoles">Consoles</a></li>
<li><a href="#palettes">Palettes</a></li>
<li><a href="#font-names">Font Names</a></li>
</ul></li>
<li><a href="#terminals">Terminals</a><ul><li><a href="#lanternaterminalget-terminal">lanterna.terminal/get-terminal</a></li>
<li><a href="#lanternaterminalstart">lanterna.terminal/start</a></li>
<li><a href="#lanternaterminalstop">lanterna.terminal/stop</a></li>
<li><a href="#lanternaterminalin-terminal">lanterna.terminal/in-terminal</a></li>
<li><a href="#lanternaterminalget-size">lanterna.terminal/get-size</a></li>
<li><a href="#lanternaterminalmove-cursor">lanterna.terminal/move-cursor</a></li>
<li><a href="#lanternaterminalput-character">lanterna.terminal/put-character</a></li>
<li><a href="#lanternaterminalput-string">lanterna.terminal/put-string</a></li>
<li><a href="#lanternaterminalclear">lanterna.terminal/clear</a></li>
<li><a href="#lanternaterminalset-fg-color">lanterna.terminal/set-fg-color</a></li>
<li><a href="#lanternaterminalset-bg-color">lanterna.terminal/set-bg-color</a></li>
<li><a href="#lanternaterminalset-style">lanterna.terminal/set-style</a></li>
<li><a href="#lanternaterminalremove-style">lanterna.terminal/remove-style</a></li>
<li><a href="#lanternaterminalreset-styles">lanterna.terminal/reset-styles</a></li>
<li><a href="#lanternaterminalget-key">lanterna.terminal/get-key</a></li>
<li><a href="#lanternaterminalget-key-blocking">lanterna.terminal/get-key-blocking</a></li>
<li><a href="#lanternaterminaladd-resize-listener">lanterna.terminal/add-resize-listener</a></li>
<li><a href="#lanternaterminalremove-resize-listener">lanterna.terminal/remove-resize-listener</a></li>
<li><a href="#lanternaterminalget-available-fonts">lanterna.terminal/get-available-fonts</a></li>
</ul></li>
<li><a href="#screens">Screens</a><ul><li><a href="#lanternascreenget-screen">lanterna.screen/get-screen</a></li>
<li><a href="#lanternascreenstart">lanterna.screen/start</a></li>
<li><a href="#lanternascreenstop">lanterna.screen/stop</a></li>
<li><a href="#lanternascreenin-screen">lanterna.screen/in-screen</a></li>
<li><a href="#lanternascreenget-size">lanterna.screen/get-size</a></li>
<li><a href="#lanternascreenredraw">lanterna.screen/redraw</a></li>
<li><a href="#lanternascreenmove-cursor">lanterna.screen/move-cursor</a></li>
<li><a href="#lanternascreenput-string">lanterna.screen/put-string</a></li>
<li><a href="#lanternascreenclear">lanterna.screen/clear</a></li>
<li><a href="#lanternascreenget-key">lanterna.screen/get-key</a></li>
<li><a href="#lanternascreenget-key-blocking">lanterna.screen/get-key-blocking</a></li>
<li><a href="#lanternascreenadd-resize-listener">lanterna.screen/add-resize-listener</a></li>
<li><a href="#lanternascreenremove-resize-listener">lanterna.screen/remove-resize-listener</a></li>
</ul></li>
</ul></div>
<h2 id="constants">Constants</h2>
<p>clojure-lanterna uses Clojure keywords where you need to supply constants.  It
will handle the filthy details of converting them to the appropriate Java enum
elements when needed so you don't need to worry about it.</p>
<h3 id="colors">Colors</h3>
<p>Lanterna (and thus clojure-lanterna) supports the 8 common terminal colors, as
well as a "default" color:</p>
<ul><li><code>:black</code></li>
<li><code>:white</code></li>
<li><code>:red</code></li>
<li><code>:green</code></li>
<li><code>:blue</code></li>
<li><code>:cyan</code></li>
<li><code>:magenta</code></li>
<li><code>:yellow</code></li>
<li><code>:default</code></li>
</ul><h3 id="styles">Styles</h3>
<p>Lanterna (and thus clojure-lanterna) supports 4 common styles:</p>
<ul><li><code>:bold</code></li>
<li><code>:reverse</code></li>
<li><code>:underline</code></li>
<li><code>:blinking</code></li>
</ul><h3 id="key-codes">Key Codes</h3>
<p>When you get a key of user input from clojure-lanterna it will be one of two
things: a Character like <code>\a</code> or <code>\$</code> representing what the user typed, or
a keyword for special keys like Delete or Page Up.</p>
<p>Note that the Tab key is returned as <code>:tab</code> and not <code>\tab</code>.</p>
<p>Here are the keywords for special keys that may be returned:</p>
<ul><li><code>:escape</code></li>
<li><code>:backspace</code></li>
<li><code>:left</code></li>
<li><code>:right</code></li>
<li><code>:up</code></li>
<li><code>:down</code></li>
<li><code>:insert</code></li>
<li><code>:delete</code></li>
<li><code>:home</code></li>
<li><code>:end</code></li>
<li><code>:page-up</code></li>
<li><code>:page-down</code></li>
<li><code>:tab</code></li>
<li><code>:reverse-tab</code></li>
<li><code>:enter</code></li>
</ul><p>There are also two other special keywords:</p>
<ul><li><code>:unknown</code> - The user typed something Lanterna couldn't figure out.</li>
<li><code>:cursor-location</code> - I'm not sure about this.  I think it's an internal
  Lanterna thing.</li>
</ul><h3 id="charsets">Charsets</h3>
<p>Currently there's only one charset clojure-lanterna constant defines.  Open an
issue as a feature request if you want others -- I'll be happy to add the
constants.</p>
<ul><li><code>:utf-8</code></li>
</ul><h3 id="consoles">Consoles</h3>
<p>When creating a Terminal or Screen, you can optionally specify a specific kind
of Terminal or Screen to create.</p>
<p>If it's not supported (e.g.: trying to create a Swing Terminal on a system
without X) then who knows what will happen.  Make sure you know what you're
doing if you use anything other than <code>:auto</code>.</p>
<ul><li><code>:auto</code> - Let Lanterna try to guess the appropriate kind of console to use.
  If there's a windowing environment present the Swing console will be used,
  otherwise an appropriate text console will be used.</li>
<li><code>:swing</code> - Force a Swing-based console.</li>
<li><code>:text</code> - Force a text-based (i.e.: non-Swing) console.  Lanterna will try to guess the
  appropriate kind of console (UNIX or Cygwin) by the OS.</li>
<li><code>:unix</code> - Force a UNIX text-based console.</li>
<li><code>:cygwin</code> - Force a Cygwin text-based console.</li>
</ul><h3 id="palettes">Palettes</h3>
<p>When creating a Swing Terminal or Screen, you can choose the color palette to
use.  Text-based Terminals and Screens will use the user's color scheme, of
course.</p>
<p>The following palettes are supported:</p>
<ul><li><code>:gnome</code> - Gnome Terminal's colors.</li>
<li><code>:windows-xp</code> - The colors of the Windows XP command prompt.</li>
<li><code>:xterm</code> - Xterm's colors.</li>
<li><code>:putty</code> - Putty's colors.</li>
<li><code>:mac-os-x</code> - The colors of Mac OS X's Terminal.app.</li>
</ul><h3 id="font-names">Font Names</h3>
<p>When giving a font name, it should be a string naming a font family on your
system.  For example: <code>"Consolas"</code>, <code>"Courier New"</code>, or <code>"Monaco"</code>.</p>
<p>To see a the fonts available on your system you can call
<a href="#lanternaterminalget-available-fonts"><code>get-available-fonts</code></a>.</p>
<h2 id="terminals">Terminals</h2>
<p>The terminal layer is the lowest-level layer.  Read the <a href="../terminals/">terminal
documentation</a> for an overview.</p>
<h3 id="lanternaterminalget-terminal">lanterna.terminal/get-terminal</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-terminal</span><span class="p">)</span>
<span class="p">(</span><span class="nf">get-terminal</span> <span class="nv">kind</span><span class="p">)</span>
<span class="p">(</span><span class="nf">get-terminal</span> <span class="nv">kind</span> <span class="nv">options</span><span class="p">)</span>
</pre></div>


<p>Get a terminal object.</p>
<p><code>kind</code> is a <a href="#consoles">console constant</a> describing the type of terminal you
want.  If unspecified it defaults to <code>:auto</code>.</p>
<p>The <code>options</code> map can contain any of the following mappings:</p>
<ul><li><code>:cols</code> - Width of the desired terminal in characters (default <code>80</code>).</li>
<li><code>:rows</code> - Height of the desired terminal in characters (default <code>24</code>).</li>
<li><code>:charset</code> - Charset of the desired terminal.  This should be a <a href="#charsets">charset
  constant</a> (default <code>:utf-8</code>).</li>
<li><code>:resize-listener</code> - A function to call when the terminal is resized.  This
  function should take two parameters: the new number of columns, and the new
  number of rows.</li>
<li><code>:font</code> - A single <a href="#font-names">font name</a> or sequence of <a href="#font-names">font
  names</a>.  If a sequence is given, the first font that exists on
  the system will be used (much like a CSS <code>font-family</code> declaration).
  Will fall back to a monospaced default font if none of the given ones exist.</li>
</ul><p>The <code>:rows</code>, <code>:cols</code>, <code>:font</code>, <code>:font-size</code>, <code>:palette</code> and <code>:charset</code> options
are really just a suggestion!</p>
<p>The text-based terminals will ignore rows, columns, fonts and palettes.  They
will be determined by the user's terminal window.</p>
<p>The Swing terminal will start out at the given size but can be resized later by
the user, and will ignore the charset entirely.</p>
<p>God only know what Cygwin will do.</p>
<p>Your application needs to be flexible and handle sizes on the fly.</p>
<h3 id="lanternaterminalstart">lanterna.terminal/start</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">start</span> <span class="nv">terminal</span><span class="p">)</span>
</pre></div>


<p>Start the given terminal.  Terminals must be started before they can be used.</p>
<p>Consider using <a href="#lanternaterminalin-terminal"><code>in-terminal</code></a> instead if you
don't need detailed control of the starting and stopping.</p>
<h3 id="lanternaterminalstop">lanterna.terminal/stop</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">stop</span> <span class="nv">terminal</span><span class="p">)</span>
</pre></div>


<p>Stop the given terminal.  Terminals must be stopped after you're done with them,
otherwise you risk corrupting the user's console.</p>
<p>Don't try to do anything to the Terminal after you stop it.</p>
<p>I'm not sure if you can "restart" a terminal once it's been stopped.  TODO: Find
out.</p>
<p>Consider using <a href="#lanternaterminalin-terminal"><code>in-terminal</code></a> instead if you
don't need detailed control of the starting and stopping.</p>
<h3 id="lanternaterminalin-terminal">lanterna.terminal/in-terminal</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">in-terminal</span> <span class="nv">terminal</span> <span class="o">&amp;</span> <span class="nv">body</span><span class="p">)</span>
</pre></div>


<p>Start the given terminal, perform the body of expressions, and stop the terminal
afterward.</p>
<p>This is a macro.</p>
<p>The stopping will be done in a try/finally block, so you can be confident it
will actually happen.</p>
<p>Use this if you don't need detailed control of the terminal starting and
stopping process.</p>
<h3 id="lanternaterminalget-size">lanterna.terminal/get-size</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-size</span> <span class="nv">terminal</span><span class="p">)</span>
</pre></div>


<p>Return the current size of the terminal as <code>[cols rows]</code>.</p>
<h3 id="lanternaterminalmove-cursor">lanterna.terminal/move-cursor</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">move-cursor</span> <span class="nv">terminal</span> <span class="nv">x</span> <span class="nv">y</span><span class="p">)</span>
</pre></div>


<p>Move the cursor to a specific location on the screen.</p>
<h3 id="lanternaterminalput-character">lanterna.terminal/put-character</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">put-character</span> <span class="nv">terminal</span> <span class="nv">ch</span><span class="p">)</span>
</pre></div>


<p>Draw the character at the current cursor location.</p>
<p>Also moves the cursor one character to the right, so a sequence of calls will
output next to each other.</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">put-character</span> <span class="nv">terminal</span> <span class="nv">ch</span> <span class="nv">x</span> <span class="nv">y</span><span class="p">)</span>
</pre></div>


<p>Draw the character at the specified cursor location.</p>
<p>Also moves the cursor one character to the right.</p>
<h3 id="lanternaterminalput-string">lanterna.terminal/put-string</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">put-string</span> <span class="nv">terminal</span> <span class="nv">s</span><span class="p">)</span>
</pre></div>


<p>Draw the string at the current cursor location.</p>
<p>The cursor will end up at the position directly after the string.</p>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">put-string</span> <span class="nv">terminal</span> <span class="nv">s</span> <span class="nv">x</span> <span class="nv">y</span><span class="p">)</span>
</pre></div>


<p>Draw the string at the specified cursor location.</p>
<p>The cursor will end up at the position directly after the string.</p>
<h3 id="lanternaterminalclear">lanterna.terminal/clear</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">clear</span> <span class="nv">terminal</span><span class="p">)</span>
</pre></div>


<p>Clear the given terminal.</p>
<p>The cursor will be at the coordinates 0, 0 after the clearing.</p>
<h3 id="lanternaterminalset-fg-color">lanterna.terminal/set-fg-color</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">set-fg-color</span> <span class="nv">terminal</span> <span class="nv">color</span><span class="p">)</span>
</pre></div>


<p>Set the foreground color for text drawn by subsequent
<a href="#lanternaterminalput-character"><code>put-character</code></a> and
<a href="#lanternaterminalput-string"><code>put-string</code></a> calls.</p>
<p>Color is a <a href="#colors">color constant</a> like <code>:red</code>.</p>
<h3 id="lanternaterminalset-bg-color">lanterna.terminal/set-bg-color</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">set-bg-color</span> <span class="nv">terminal</span> <span class="nv">color</span><span class="p">)</span>
</pre></div>


<p>Set the background color for text drawn by subsequent
<a href="#lanternaterminalput-character"><code>put-character</code></a> and
<a href="#lanternaterminalput-string"><code>put-string</code></a> calls.</p>
<p>Color is a <a href="#colors">color constant</a> like <code>:red</code>.</p>
<h3 id="lanternaterminalset-style">lanterna.terminal/set-style</h3>
<p>Broken right now, sorry.</p>
<h3 id="lanternaterminalremove-style">lanterna.terminal/remove-style</h3>
<p>Broken right now, sorry.</p>
<h3 id="lanternaterminalreset-styles">lanterna.terminal/reset-styles</h3>
<p>Broken right now, sorry.</p>
<h3 id="lanternaterminalget-key">lanterna.terminal/get-key</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-key</span> <span class="nv">terminal</span><span class="p">)</span>
</pre></div>


<p>Get the next keypress from the user, or <code>nil</code> if none are buffered.</p>
<p>If there is one or more keystroke buffered, that key will be returned (and
popped off the buffer of input).  The returned key will be a <a href="#key-codes">key code
constant</a>.</p>
<p>If there are no keystrokes buffered, <code>nil</code> will be returned immediately.</p>
<p>If you want to wait for user input, use
<a href="#lanternaterminalget-key-blocking"><code>get-key-blocking</code></a> instead.</p>
<h3 id="lanternaterminalget-key-blocking">lanterna.terminal/get-key-blocking</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-key-blocking</span> <span class="nv">terminal</span><span class="p">)</span>
<span class="p">(</span><span class="nf">get-key-blocking</span> <span class="nv">terminal</span> <span class="nv">options</span><span class="p">)</span>
</pre></div>


<p>Get the next keypress from the user.</p>
<p>If there is one or more keystroke buffered, that key will be returned (and
popped off the buffer of input).  The returned key will be a <a href="#key-codes">key code
constant</a>.</p>
<p>If there are no keystrokes buffered the function will sleep, checking every 50
milliseconds for input.  Once there is a character buffered it will be popped
off and returned as normal.</p>
<p>If you want to return immediately instead of blocking when no input is buffered,
use <a href="#lanternaterminalget-key"><code>get-key</code></a> instead.</p>
<p>The <code>options</code> map can contain any of the following mappings:</p>
<ul><li><code>:interval</code> - The interval between checks, in milliseconds (default <code>50</code>).</li>
<li><code>:timeout</code> - The maximum amount of time blocking will occur before returning
  <code>nil</code> (default infinity).</li>
</ul><h3 id="lanternaterminaladd-resize-listener">lanterna.terminal/add-resize-listener</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">add-resize-listener</span> <span class="nv">terminal</span> <span class="nv">listener-fn</span><span class="p">)</span>
</pre></div>


<p>Create a listener that will call the supplied function when the terminal is
resized.</p>
<p>The function must take two arguments: the new number of columns and the new
number of rows.</p>
<p>You probably don't need this because you can specify a resize listener function
when you call <a href="#lanternaterminalget-terminal"><code>get-terminal</code></a>.  It's here if you
<em>do</em> need it though.</p>
<h3 id="lanternaterminalremove-resize-listener">lanterna.terminal/remove-resize-listener</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">remove-resize-listener</span> <span class="nv">terminal</span> <span class="nv">listener</span><span class="p">)</span>
</pre></div>


<p>Remove the given resize listener from the given terminal.</p>
<h3 id="lanternaterminalget-available-fonts">lanterna.terminal/get-available-fonts</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-available-fonts</span><span class="p">)</span>
</pre></div>


<p>Return a set of strings of the names of available fonts on the current system.</p>
<h2 id="screens">Screens</h2>
<p>The screen layer is an abstraction that provides buffering on top of the
terminal layer.  Read the <a href="../screens/">screen documentation</a> for an overview.</p>
<h3 id="lanternascreenget-screen">lanterna.screen/get-screen</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-screen</span><span class="p">)</span>
<span class="p">(</span><span class="nf">get-screen</span> <span class="nv">kind</span><span class="p">)</span>
<span class="p">(</span><span class="nf">get-screen</span> <span class="nv">kind</span> <span class="nv">options</span><span class="p">)</span>
</pre></div>


<p>Get a screen object.</p>
<p><code>kind</code> is a <a href="#consoles">console constant</a> describing the type of screen you
want.  If unspecified it defaults to <code>:auto</code>.</p>
<p>The <code>options</code> map can contain any of the following mappings:</p>
<ul><li><code>:cols</code> - Width of the desired screen in characters (default <code>80</code>).</li>
<li><code>:rows</code> - Height of the desired screen in characters (default <code>24</code>).</li>
<li><code>:charset</code> - Charset of the desired screen.  This should be a <a href="#charsets">charset
  constant</a> (default <code>:utf-8</code>).</li>
<li><code>:resize-listener</code> - A function to call when the screen is resized.  This
  function should take two parameters: the new number of columns, and the new
  number of rows.</li>
<li><code>:font</code> - A single <a href="#font-names">font name</a> or sequence of <a href="#font-names">font
  names</a>.  If a sequence is given, the first font that exists on
  the system will be used (much like a CSS <code>font-family</code> declaration).
  Will fall back to a monospaced default font if none of the given ones exist.</li>
</ul><p>The <code>:rows</code>, <code>:cols</code>, and <code>:charset</code> options are really just a suggestion!</p>
<p>The text-based screens will ignore rows and columns and will be the size of
the user's window.</p>
<p>The Swing screen will start out at this size but can be resized later by the
user, and will ignore the charset entirely.</p>
<p>God only know what Cygwin will do.</p>
<p>Your application needs to be flexible and handle sizes on the fly.</p>
<h3 id="lanternascreenstart">lanterna.screen/start</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">start</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Start the given screen.  Screens must be started before they can be used.</p>
<p>Consider using <a href="#lanternascreenin-screen"><code>in-screen</code></a> instead if you don't need
detailed control of the starting and stopping.</p>
<h3 id="lanternascreenstop">lanterna.screen/stop</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">stop</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Stop the given screen.  Screens must be stopped after you're done with them,
otherwise you risk corrupting the user's console.</p>
<p>Don't try to do anything to the screen after you stop it.</p>
<p>I'm not sure if you can "restart" a screen once it's been stopped.  TODO: Find
out.</p>
<p>Consider using <a href="#lanternascreenin-screen"><code>in-screen</code></a> instead if you don't need
detailed control of the starting and stopping.</p>
<h3 id="lanternascreenin-screen">lanterna.screen/in-screen</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">in-screen</span> <span class="nv">screen</span> <span class="o">&amp;</span> <span class="nv">body</span><span class="p">)</span>
</pre></div>


<p>Start the given screen, perform the body of expressions, and stop the screen
afterward.</p>
<p>This is a macro.</p>
<p>The stopping will be done in a try/finally block, so you can be confident it
will actually happen.</p>
<p>Use this if you don't need detailed control of the screen starting and stopping
process.</p>
<h3 id="lanternascreenget-size">lanterna.screen/get-size</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-size</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Return the current size of the screen as <code>[cols rows]</code>.</p>
<h3 id="lanternascreenredraw">lanterna.screen/redraw</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">redraw</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Redraw the given screen.</p>
<p>This is how you actually flush any changes to the user's display.</p>
<h3 id="lanternascreenmove-cursor">lanterna.screen/move-cursor</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">move-cursor</span> <span class="nv">screen</span> <span class="nv">x</span> <span class="nv">y</span><span class="p">)</span>
</pre></div>


<p>Move the cursor to a specific location on the screen.</p>
<p>You'll need to <a href="#lanternascreenredraw"><code>redraw</code></a> the screen to actually see it
happen.</p>
<p>The cursor will stay where you move it, even if you later draw some text in
a different place and redraw.  If you want it to move, you need to call this
function again.</p>
<h3 id="lanternascreenput-string">lanterna.screen/put-string</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">put-string</span> <span class="nv">screen</span> <span class="nv">x</span> <span class="nv">y</span> <span class="nv">s</span><span class="p">)</span>
<span class="p">(</span><span class="nf">put-string</span> <span class="nv">screen</span> <span class="nv">x</span> <span class="nv">y</span> <span class="nv">s</span> <span class="nv">options</span><span class="p">)</span>
</pre></div>


<p>Put a string on the screen buffer, ready to be drawn at the next
<a href="#lanternascreenredraw"><code>redraw</code></a>.</p>
<p><code>x</code> and <code>y</code> are the column and row to start the string.</p>
<p><code>s</code> is the actual string to draw.</p>
<p>The <code>options</code> map can contain any of the following mappings:</p>
<ul><li><code>:fg</code> - Foreground color of the text.  Must be a <a href="#colors">color constant</a>
  (default <code>:default</code>).</li>
<li><code>:bg</code> - Background color of the text.  Must be a <a href="#colors">color constant</a>
  (default <code>:default</code>).</li>
<li><code>:styles</code> - Styles to apply to the text.  Must be a set containing zero or
  more <a href="#styles">style constants</a> (default <code>#{}</code>).  <strong>CURRENTLY BROKEN, SORRY</strong></li>
</ul><h3 id="lanternascreenclear">lanterna.screen/clear</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">clear</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Clear the given screen.</p>
<p>Note that this is buffered just like every other screen-related action.  You
need to <a href="#lanternascreenredraw"><code>redraw</code></a> to actually see it happen.</p>
<h3 id="lanternascreenget-key">lanterna.screen/get-key</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-key</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Get the next keypress from the user, or <code>nil</code> if none are buffered.</p>
<p>If there is one or more keystroke buffered, that key will be returned (and
popped off the buffer of input).  The returned key will be a <a href="#key-codes">key code
constant</a>.</p>
<p>If there are no keystrokes buffered, <code>nil</code> will be returned immediately.</p>
<p>If you want to wait for user input, use
<a href="#lanternascreenget-key-blocking"><code>get-key-blocking</code></a> instead.</p>
<h3 id="lanternascreenget-key-blocking">lanterna.screen/get-key-blocking</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">get-key-blocking</span> <span class="nv">screen</span><span class="p">)</span>
</pre></div>


<p>Get the next keypress from the user.</p>
<p>If there is one or more keystroke buffered, that key will be returned (and
popped off the buffer of input).  The returned key will be a <a href="#key-codes">key code
constant</a>.</p>
<p>If there are no keystrokes buffered the function will sleep, checking every 50
milliseconds for input.  Once there is a character buffered it will be popped
off and returned as normal.</p>
<p>If you want to return immediately instead of blocking when no input is buffered,
use <a href="#lanternascreenget-key"><code>get-key</code></a> instead.</p>
<p>The <code>options</code> map can contain any of the following mappings:</p>
<ul><li><code>:interval</code> - The interval between checks, in milliseconds (default <code>50</code>).</li>
<li><code>:timeout</code> - The maximum amount of time blocking will occur before returning
  <code>nil</code> (default infinity).</li>
</ul><h3 id="lanternascreenadd-resize-listener">lanterna.screen/add-resize-listener</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">add-resize-listener</span> <span class="nv">screen</span> <span class="nv">listener-fn</span><span class="p">)</span>
</pre></div>


<p>Create a listener that will call the supplied function when the screen is
resized.</p>
<p>The function must take two arguments: the new number of columns and the new
number of rows.</p>
<p>You probably don't need this because you can specify a resize listener function
when you call <a href="#lanternascreenget-screen"><code>get-screen</code></a>.  It's here if you <em>do</em>
need it though.</p>
<h3 id="lanternascreenremove-resize-listener">lanterna.screen/remove-resize-listener</h3>
<div class="codehilite"><pre><span class="p">(</span><span class="nf">remove-resize-listener</span> <span class="nv">screen</span> <span class="nv">listener</span><span class="p">)</span>
</pre></div>


<p>Remove the given resize listener from the given screen.</p>
                </div>
            <footer><p>Created by <a href="http://stevelosh.com">Steve Losh</a>.
Documentation created with <a href="http://sjl.bitbucket.org/d/">d</a>.</p>
<p><br/><a id="rochester-made" href="http://rochestermade.com" title="Rochester Made"><img src="http://rochestermade.com/media/images/rochester-made-dark-on-light.png" alt="Rochester Made" title="Rochester Made"/></a></p>
<script type="text/javascript">
  var _gauges = _gauges || [];
  (function() {
    var t   = document.createElement('script');
    t.type  = 'text/javascript';
    t.async = true;
    t.id    = 'gauges-tracker';
    t.setAttribute('data-site-id', '4f843f8c613f5d65280000e6');
    t.src = '//secure.gaug.es/track.js';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(t, s);
  })();
</script></footer></div>
    </body></html>