source: project/release/2/ncurses/ncurses.html @ 8751

Last change on this file since 8751 was 8751, checked in by felix winkelmann, 12 years ago

rrb2 move completion

File size: 11.7 KB
Line 
1<html><head><title>Eggs Unlimited - ncurses</title></head>
2<body>
3
4<center><img src="egg.jpg"></center>
5<center><a href="http://www.call-with-current-continuation.org/eggs/index.html">back</a></center>
6
7<h2>ncurses</h2>
8
9<h3>Description:</h3>
10Provides text-mode and terminal operations for text-based user interfaces.
11
12<h3>Author:</h3>
13<a href="mailto:felix@call-with-current-continuation.org">felix</a>
14
15<h3>Version:</h3>
16<ul>
17<li>1.8
18Fixed bug introduced by last change [Thanks to Benedikt Rosenau]
19<li>1.7
20Uses externalized easyffi extension
21<li>1.6
22Fixed bug in handling of return-type for <code>ACS_...</code> routines
23<li>1.5
24Added several border-, box- and line-drawing functions
25<li>1.4
26Input-routines return characters instead of integers
27<li>1.3
28<code>ACS_HLINE</code>, etc have been turned into variables; fixed bug in character code handling
29</li><li>1.2
30Adapted to new FFI macro names
31</li><li>1.1
32Adapted to new setup scheme
33</li><li>1.0
34</li></ul>
35
36<h3>Usage:</h3>
37<pre>(require-extension ncurses)
38</pre>
39
40<h3>Download:</h3>
41<a href="http://www.call-with-current-continuation.org/eggs/ncurses.egg">ncurses.egg</a>
42
43<h3>Documentation:</h3>
44
45The following definitions are provided (full documentation can be found in your system's
46<code>man</code> pages):
47
48<ul>
49<li><b><i>Constants:</i></b>
50<pre>A_ALTCHARSET
51A_ATTRIBUTES
52A_BLINK
53A_BOLD
54A_CHARTEXT
55A_COLOR
56A_DIM
57A_INVIS
58A_LEFT
59A_LOW
60A_NORMAL
61A_PROTECT
62A_REVERSE
63A_RIGHT
64A_STANDOUT
65A_TOP
66A_UNDERLINE
67A_VERTICAL
68COLOR_BLACK
69COLOR_BLUE
70COLOR_CYAN
71COLOR_GREEN
72COLOR_MAGENTA
73COLOR_PAIR
74COLOR_RED
75COLOR_WHITE
76COLOR_YELLOW
77KEY_A1
78KEY_A3
79KEY_B2
80KEY_BACKSPACE
81KEY_BEG
82KEY_BREAK
83KEY_BTAB
84KEY_C1
85KEY_C3
86KEY_CANCEL
87KEY_CATAB
88KEY_CLEAR
89KEY_CLOSE
90KEY_CODE_YES
91KEY_COMMAND
92KEY_COPY
93KEY_CREATE
94KEY_CTAB
95KEY_DC
96KEY_DL
97KEY_DOWN
98KEY_EIC
99KEY_END
100KEY_ENTER
101KEY_EOL
102KEY_EOS
103KEY_EXIT
104KEY_F0
105KEY_FIND
106KEY_HELP
107KEY_HOME
108KEY_IC
109KEY_IL
110KEY_LEFT
111KEY_LL
112KEY_MARK
113KEY_MESSAGE
114KEY_MIN
115KEY_MOUSE
116KEY_MOVE
117KEY_NEXT
118KEY_NPAGE
119KEY_OPEN
120KEY_OPTIONS
121KEY_PPAGE
122KEY_PREVIOUS
123KEY_PRINT
124KEY_REDO
125KEY_REFERENCE
126KEY_REFRESH
127KEY_REPLACE
128KEY_RESET
129KEY_RESIZE
130KEY_RESTART
131KEY_RESUME
132KEY_RIGHT
133KEY_SAVE
134KEY_SBEG
135KEY_SCANCEL
136KEY_SCOMMAND
137KEY_SCOPY
138KEY_SCREATE
139KEY_SDC
140KEY_SDL
141KEY_SELECT
142KEY_SEND
143KEY_SEOL
144KEY_SEXIT
145KEY_SF
146KEY_SFIND
147KEY_SHELP
148KEY_SHOME
149KEY_SIC
150KEY_SLEFT
151KEY_SMESSAGE
152KEY_SMOVE
153KEY_SNEXT
154KEY_SOPTIONS
155KEY_SPREVIOUS
156KEY_SPRINT
157KEY_SR
158KEY_SREDO
159KEY_SREPLACE
160KEY_SRESET
161KEY_SRIGHT
162KEY_SRSUME
163KEY_SSAVE
164KEY_SSUSPEND
165KEY_STAB
166KEY_SUNDO
167KEY_SUSPEND
168KEY_UNDO
169KEY_UP
170</pre>
171
172<p></p></li><li><b><i>Variables:</i></b>
173
174<p>
175</p><pre>(ACS_BLOCK) -&gt; INT
176(ACS_BTEE) -&gt; INT
177(ACS_BULLET) -&gt; INT
178(ACS_CKBOARD) -&gt; INT
179(ACS_DARROW) -&gt; INT
180(ACS_DEGREE) -&gt; INT
181(ACS_DIAMOND) -&gt; INT
182(ACS_HLINE) -&gt; INT
183(ACS_LANTERN) -&gt; INT
184(ACS_LARROW) -&gt; INT
185(ACS_LLCORNER) -&gt; INT
186(ACS_LRCORNER) -&gt; INT
187(ACS_LTEE) -&gt; INT
188(ACS_PLMINUS) -&gt; INT
189(ACS_PLUS) -&gt; INT
190(ACS_RARROW) -&gt; INT
191(ACS_RTEE) -&gt; INT
192(ACS_S1) -&gt; INT
193(ACS_S9) -&gt; INT
194(ACS_TTEE) -&gt; INT
195(ACS_UARROW) -&gt; INT
196(ACS_ULCORNER) -&gt; INT
197(ACS_URCORNER) -&gt; INT
198(ACS_VLINE) -&gt; INT
199
200(COLORS) -&gt; INT
201(COLOR_PAIRS) -&gt; INT
202(LINES) -&gt; INT
203(COLS) -&gt; INT
204(stdscr) -&gt; WINDOW
205(curscr) -&gt; WINDOW
206</pre>
207
208<p></p></li><li><b><i>Procedures:</i></b>
209<pre>(KEY_F INT) -&gt; INT
210(PAIR_NUMBER INT) -&gt; INT
211(addch CHAR)
212(addnstr STRING INT)
213(addstr STRING)
214(attroff INT)
215(attron INT)
216(attrset INT)
217(beep)
218(border CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR)
219(box WINDOW CHAR CHAR)
220(can_change_color) -&gt; BOOL
221(cbreak)
222(clear)
223(clearok WINDOW BOOL)
224(clrtobot)
225(clrtoeol)
226(copywin WINDOW WINDOW INT INT INT INT INT INT BOOL)
227(curs_set INT)
228(def_prog_mode)
229(def_shell_mode)
230(delay_output INT)
231(delch)
232(deleteln)
233(delwin WINDOW)
234(derwin WINDOW INT INT INT INT)
235(doupdate)
236(echo)
237(echochar WINDOW CHAR)
238(endwin)
239(erase)
240(erasechar) -&gt; CHAR
241(flash)
242(flushinp)
243(getbegyx WINDOW) -&gt; INT INT
244(getch) -&gt; CHAR
245(getmaxyx WINDOW) -&gt; INT INT
246(getnstr STRING INT)
247(getparyx WINDOW) -&gt; INT INT
248(getstr STRING)
249(getsyx) -&gt; INT INT
250(getyx WINDOW) -&gt; INT INT
251(halfdelay INT)
252(has_colors) -&gt; BOOL
253(has_ic) -&gt; BOOL
254(has_il) -&gt; BOOL
255(hline CHAR INT)
256(idlok WINDOW BOOL)
257(inch) -&gt; CHAR
258(init_color INT INT INT INT)
259(init_pair INT INT INT)
260(initscr) -&gt; WINDOW
261(insch CHAR) -&gt; CHAR
262(insertln)
263(intrflush WINDOW BOOL)
264(is_linetouched WINDOW INT) -&gt; BOOL
265(is_wintouched WINDOW) -&gt; BOOL
266(isendwin) -&gt; BOOL
267(keyname INT) -&gt; STRING
268(keypad WINDOW BOOL)
269(killchar CHAR)
270(leaveok WINDOW BOOL)
271(longname) -&gt; STRING
272(meta WINDOW BOOL)
273(move INT INT)
274(mvaddch INT INT CHAR)
275(mvaddnstr INT INT STRING INT)
276(mvaddstr INT INT STRING)
277(mvcur INT INT INT INT)
278(mvdelch INT INT)
279(mvgetnstr INT INT STRING INT)
280(mvgetstr INT INT STRING)
281(mvhline INT INT CHAR INT)
282(mvinch INT INT) -&gt; CHAR
283(mvinsch INT INT CHAR) -&gt; CHAR
284(mvprintw INT INT FORMATSTRING ARG ...)
285(mvvline INT INT CHAR INT)
286(mvwaddch INT INT CHAR)
287(mvwaddnstr WINDOW INT INT STRING INT)
288(mvwaddstr WINDOW INT INT STRING)
289(mvwdelch WINDOW INT INT)
290(mvwgetnstr WINDOW INT INT STRING INT)
291(mvwgetstr WINDOW INT INT STRING)
292(mvwhline WINDOW INT INT CHAR INT)
293(mvwin WINDOW INT INT)
294(mvwinch WINDOW INT INT) -&gt; CHAR
295(mvwinsch WINDOW INT INT CHAR) -&gt; CHAR
296(mvwprintw WINDOW INT INT FORMATSTRING ARG ...)
297(mvwvline WINDOW INT INT CHAR INT)
298(newpad INT INT) -&gt; WINDOW
299(newwin INT INT INT INT) -&gt; WINDOW
300(nl)
301(nocbreak)
302(nodelay WINDOW BOOL)
303(noecho)
304(nonl)
305(noraw)
306(notimeout WINDOW BOOL)
307(overlay WINDOW WINDOW)
308(overwrite WINDOW WINDOW)
309(pair_content INT) -&gt; INT INT
310(pnoutrefresh WINDOW INT INT INT INT INT INT)
311(prefresh WINDOW INT INT INT INT INT INT)
312(printw FORMATSTRING ARG ...)
313(raw)
314(refresh)
315(reset_prog_mode)
316(reset_shell_mode)
317(resetty)
318(savetty)
319(scr_dump STRING)
320(scr_init STRING)
321(scr_restore STRING)
322(scr_set STRING)
323(scrl INT)
324(scroll WINDOW)
325(scrollok WINDOW BOOL)
326(setscrreg INT INT)
327(setsyx INT INT)
328(standend)
329(standout)
330(start_color)
331(subpad WINDOW INT INT INT INT) -&gt; WINDOW
332(subwin WINDOW INT INT INT INT) -&gt; WINDOW
333(timeout INT)
334(touchline WINDOW INT INT)
335(touchwin WINDOW)
336(unctrl CHAR) -&gt; STRING
337(ungetch INT)
338(untouchwin WINDOW)
339(vline CHAR INT)
340(waddch WINDOW CHAR)
341(waddnstr WINDOW STRING INT)
342(waddstr WINDOW STRING)
343(wattroff WINDOW INT)
344(wattron WINDOW INT)
345(wattrset WINDOW INT)
346(wborder WINDOW CHAR CHAR CHAR CHAR CHAR CHAR CHAR CHAR)
347(wclear WINDOW)
348(wclrtobot WINDOW)
349(wclrtoeol WINDOW)
350(wdelch WINDOW)
351(wdeleteln WINDOW)
352(wechochar WINDOW CHAR)
353(werase WINDOW)
354(wgetch WINDOW) -&gt; CHAR
355(wgetnstr WINDOW STRING INT)
356(whline WINDOW CHAR INT)
357(winch WINDOW) -&gt; CHAR
358(winsch WINDOW CHAR) -&gt; CHAR
359(winsertln WINDOW)
360(wvline WINDOW CHAR INT)
361(wmove WINDOW INT INT)
362(wnoutrefresh WINDOW)
363(wprintw WINDOW FORMATSTRING ARG ...)
364(wrefresh WINDOW)
365(wscrl WINDOW INT)
366(wsetscrreg WINDOW INT INT)
367(wstandend WINDOW)
368(wstandout WINDOW)
369(wtimeout WINDOW INT)
370(wtouchln WINDOW INT INT BOOL)
371</pre>
372
373</li></ul>
374
375<p>Notes:
376
377</p><ul>
378<li>Arguments of type CHAR may be either characters or integers (the caracter code)
379</li><li>Procedures that normally return an error code are checked, and a condition of the kind <code>(exn curses)</code> is
380raised.
381</li><li>The <code>...printw</code> procedures accept <code>printf</code> style format-strings (not the C <code>printf</code>,
382but the <code>printf</code> in Chicken's <code>extras</code> library unit).
383</li></ul>
384
385<p></p><h3>Examples:</h3>
386
387<pre>;;;; life
388
389(declare (block) (fixnum) (usual-integrations))
390
391(require 'ncurses 'srfi-25)
392
393(define STARTX 0)
394(define STARTY 0)
395(define ENDX 79)
396(define ENDY 24)
397
398(define CELL_CHAR #\#)
399(define TIME_OUT 300)
400
401(define oldstate car)
402(define newstate cdr)
403(define oldstate-set! set-car!)
404(define newstate-set! set-cdr!)
405
406(define cols #f)
407(define lines #f)
408
409(define (life-display win area startx starty endx endy)
410  (wclear win)
411  (do ([i startx (add1 i)])
412      ((&gt;= i endx))
413    (do ([j starty (add1 j)])
414        ((&gt;= j endy))
415      (unless (zero? (newstate (array-ref area i j)))
416        (mvwaddch win j i CELL_CHAR) ) ) )
417  (wrefresh win) )
418
419(define (calc area i j)
420  (let ([neighbours
421         (+ (oldstate (array-ref area (modulo (+ i -1 cols) cols) j))
422            (oldstate (array-ref area (modulo (+ i -1 cols) cols) (modulo (+ j -1 lines) lines)))
423            (oldstate (array-ref area (modulo (+ i -1 cols) cols) (modulo (add1 j) lines)))
424            (oldstate (array-ref area (modulo (add1 i) cols) j))
425            (oldstate (array-ref area (modulo (add1 i) cols) (modulo (+ j -1 lines) lines)))
426            (oldstate (array-ref area (modulo (add1 i) cols) (modulo (add1 j) lines)))
427            (oldstate (array-ref area i (modulo (+ j -1 lines) lines)))
428            (oldstate (array-ref area i (modulo (add1 j) lines))) ) ] )
429    (newstate-set!
430     (array-ref area i j)
431     (if (and (not (zero? (oldstate (array-ref area i j))))
432              (or (= 2 neighbours) (= 3 neighbours)) )
433         1
434         (if (and (zero? (oldstate (array-ref area i j)))
435                  (= 3 neighbours) )
436             1
437             0) ) ) ) )
438
439(define (update-state area startx starty endx endy)
440  (do ([i startx (add1 i)])
441      ((&gt;= i endx))
442    (do ([j starty (add1 j)])
443        ((&gt;= j endy))
444      (let ([cell (array-ref area i j)])
445        (oldstate-set! cell (newstate cell)) ) ) ) )
446
447(define (main)
448  (initscr)
449  (cbreak)
450  (timeout TIME_OUT)
451  (keypad (stdscr) #t)
452  (curs_set 0)
453  (set! cols (COLS))
454  (set! lines (LINES))
455  (set! ENDX (sub1 cols))
456  (set! ENDY (sub1 lines))
457  (let ([workarea (make-array (shape 0 cols 0 lines))])
458    (do ([i 0 (add1 i)])
459        ((&gt;= i cols))
460      (do ([j 0 (add1 j)])
461          ((&gt;= j lines))
462        (array-set! workarea i j (cons 0 0)) ) )
463    (newstate-set! (array-ref workarea 39 15) 1)
464    (newstate-set! (array-ref workarea 40 15) 1)
465    (newstate-set! (array-ref workarea 41 15) 1)
466    (newstate-set! (array-ref workarea 39 16) 1)
467    (newstate-set! (array-ref workarea 39 17) 1)
468    (newstate-set! (array-ref workarea 41 16) 1)
469    (newstate-set! (array-ref workarea 41 17) 1)
470    (update-state workarea STARTX STARTY ENDX ENDY)
471    (life-display (stdscr) workarea STARTX STARTY ENDX ENDY)
472    (let loop ()
473      (unless (= (char->integer (getch)) (KEY_F 1))
474        (do ([i STARTX (add1 i)])
475            ((&gt;= i ENDX))
476          (do ([j STARTY (add1 j)])
477              ((&gt;= j ENDY))
478            (calc workarea i j) ) )
479        (update-state workarea STARTX STARTY ENDX ENDY)
480        (life-display (stdscr) workarea STARTX STARTY ENDX ENDY)
481        (loop) ) ) )
482  (endwin) )
483
484(main)
485</pre>
486
487<h3>License:</h3>
488<pre>Copyright (c) 2003, Felix L. Winkelmann
489All rights reserved.
490
491Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
492conditions are met:
493
494  Redistributions of source code must retain the above copyright notice, this list of conditions and the following
495    disclaimer.
496  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
497    disclaimer in the documentation and/or other materials provided with the distribution.
498  Neither the name of the author nor the names of its contributors may be used to endorse or promote
499    products derived from this software without specific prior written permission.
500
501THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
502OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
503AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
504CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
505CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
506SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
507THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
508OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
509POSSIBILITY OF SUCH DAMAGE.
510</pre>
511
512
513<hr><a href="http://www.call-with-current-continuation.org/eggs/index.html">back</a>
514
515</body></html>
Note: See TracBrowser for help on using the repository browser.