Added colons.
[unix-history] / usr / src / lib / libcurses / PSD.doc / fns.doc
CommitLineData
00f9495f
EA
1.\" Copyright (c) 1992 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.roff%
5.\"
5a00022e 6.\" @(#)fns.doc 1.6 (Berkeley) %G%
00f9495f
EA
7.\"
8.Ds
531d985f 9.Fn addch "char ch" \(dg
00f9495f
EA
10.De
11Add the character
12.Vn ch
13on the window
14at the current \*y.
15If the character is a newline
16(\'\en\')
17the line will be cleared to the end,
18and the current \*y will be changed to the
19beginning off the next line
20if newline mapping is on,
21or to the next line at the same x co-ordinate
22if it is off.
23A return
24(\'\er\')
25will move to the beginning of the line on the window.
26Tabs
27(\'\et\')
28will be expanded into spaces
29in the normal tabstop positions of
30every eight characters.
31\*(Es
32.Ds
531d985f 33.Fn addstr "char *str" \(dg
00f9495f
EA
34.De
35Add the string pointed to by
36.Vn str
37on the window at the current \*y.
38\*(Es
39In this case, it will put on as much as it can.
40.Ds
531d985f 41.Fn baudrate "" \(dg
00f9495f
EA
42.De
43Returns the output baud rate of the terminal.
44This is a system dependent constant
45(defined in
46.b <sys/tty.h>
47on BSD systems,
48which is included by
49.b <curses.h> ).
50.Ds
531d985f 51.Fn box "WINDOW win" "char vert" "char hor"
00f9495f
EA
52.De
53.Pp
54Draws a box around the window using
55.Vn vert
56as the character for drawing the vertical sides, and
57.Vn hor
58for drawing the horizontal lines.
59If scrolling is not allowed,
60and the window encompasses the lower right-hand corner of the terminal,
61the corners are left blank to avoid a scroll.
62.Ds
531d985f 63.Fn cbreak "" \(dg
00f9495f
EA
64.De
65Set or the terminal to cbreak mode.
66.Ds
531d985f 67.Fn clear "" \(dg
00f9495f
EA
68.De
69Resets the entire window to blanks.
70If
71.Vn win
72is a screen,
73this sets the clear flag,
74which will cause a clear-screen sequence to be sent
75on the next
76.Fn refresh
77call.
78This also moves the current \*y
79to (0\*,0).
80.Ds
531d985f 81.Fn clearok "WINDOW *scr" "int boolf" \(dg
00f9495f
EA
82.De
83Sets the clear flag for the screen
84.Vn scr .
85If
86.Vn boolf
2b70b628 87is non-zero,
00f9495f
EA
88this will force a clear-screen to be printed on the next
89.Fn refresh ,
90or stop it from doing so if
91.Vn boolf
2b70b628 92is 0.
00f9495f
EA
93This only works on screens,
94and,
95unlike
96.Fn clear ,
97does not alter the contents of the screen.
98If
99.Vn scr
100is
101.Vn curscr ,
102the next
103.Fn refresh
104call will cause a clear-screen,
105even if the window passed to
106.Fn refresh
107is not a screen.
108.Ds
531d985f 109.Fn clrtobot "" \(dg
00f9495f
EA
110.De
111Wipes the window clear from the current \*y to the bottom.
112This does not force a clear-screen sequence on the next refresh
113under any circumstances.
114\*(Nm
115.Ds
531d985f 116.Fn clrtoeol "" \(dg
00f9495f
EA
117.De
118Wipes the window clear from the current \*y to the end of the line.
119\*(Nm
120.Ds
531d985f 121.Fn crmode "" \(dg
00f9495f
EA
122.De
123Identical to
124.Fn cbreak .
125The misnamed macro
126.Fn crmode
127and
128.Fn nocrmode
129is retained for backwards compatibility
130with ealier versions of the library.
131.Ds
531d985f 132.Fn delch ""
00f9495f
EA
133.De
134Delete the character at the current \*y.
135Each character after it on the line shifts to the left,
136and the last character becomes blank.
137.Ds
531d985f 138.Fn deleteln ""
00f9495f
EA
139.De
140Delete the current line.
141Every line below the current one will move up,
142and the bottom line will become blank.
143The current \*y will remain unchanged.
144.Ds
531d985f 145.Fn delwin "WINDOW *win"
00f9495f
EA
146.De
147Deletes the window from existence.
148All resources are freed for future use by
149.b calloc (3).
150If a window has a
151.Fn subwin
152allocated window inside of it,
153deleting the outer window
154the subwindow is not affected,
155even though this does invalidate it.
156Therefore,
157subwindows should be deleted before their
158outer windows are.
159.Ds
531d985f 160.Fn echo "" \(dg
00f9495f
EA
161.De
162Sets the terminal to echo characters.
163.Ds
531d985f 164.Fn endwin ""
00f9495f
EA
165.De
166Finish up window routines before exit.
167This restores the terminal to the state it was before
168.Fn initscr
169(or
170.Fn gettmode
171and
172.Fn setterm )
173was called.
174It should always be called before exiting and before the final calls to
175.Fn delwin .
176It does not exit.
177This is especially useful for resetting tty stats
178when trapping rubouts via
179.b signal (2).
180.Ds
531d985f 181.Fn erase "" \(dg
00f9495f
EA
182.De
183Erases the window to blanks without setting the clear flag.
184This is analagous to
185.Fn clear ,
186except that it never causes a clear-screen sequence to be generated
187on a
188.Fn refresh .
189\*(Nm
190.Ds
531d985f 191.Fn erasechar "" \(dg
00f9495f
EA
192.De
193Returns the erase character
194for the terminal,
195.i i.e. ,
196the character used by the user to erase a single character from the input.
197.Ds
531d985f 198.Fn flushok "WINDOW *win" "int boolf"
00f9495f
EA
199.De
200Normally,
201.Fn refresh
202.Fn fflush 's
203.Vn stdout
204when it is finished.
205.Fn flushok
206allows you to control this.
207if
208.Vn boolf
2b70b628 209is non-zero
00f9495f
EA
210(\c
211.i i.e. ,
212non-zero)
213it will do the
2b70b628
EA
214.Fn fflush ,
215otherwise it will not.
00f9495f 216.Ds
531d985f 217.Fn getch "" \(dg
00f9495f
EA
218.De
219Gets a character from the terminal and (if necessary)
220echos it on the window.
221\*(Es
222Otherwise, the character gotten is returned.
223If
224.i noecho
225has been set, then the window is left unaltered.
226In order to retain control of the terminal,
227it is necessary to have one of
228.i noecho ,
229.i cbreak ,
230or
231.i rawmode
232set.
233If you do not set one,
234whatever routine you call to read characters will set
235.i cbreak
236for you,
237and then reset to the original mode when finished.
238.Ds
531d985f 239.Fn getstr "char *str" \(dg
00f9495f
EA
240.De
241Get a string through the window
242and put it in the location pointed to by
243.Vn str ,
244which is assumed to be large enough to handle it.
245It sets tty modes if necessary,
246and then calls
247.Fn getch
248(or
531d985f 249.Fn wgetch )
00f9495f
EA
250to get the characters needed to fill in the string
251until a newline or EOF is encountered.
252The newline stripped off the string.
253\*(Es
254.Ds
531d985f 255.Fn gettmode ""
00f9495f
EA
256.De
257Get the tty stats.
258This is normally called by
259.Fn initscr .
260.Ds
531d985f 261.Fn getyx "WINDOW *win" "int y" "int x"
00f9495f
EA
262.De
263Puts the current \*y of
264.Vn win
265in the variables
266.Vn y
267and
268.Vn x .
269Since it is a macro,
270not a function,
271you do not pass the address
272of
273.Vn y
274and
275.Vn x .
276.Ds
531d985f 277.Fn idlok "WINDOW *win" "int boolf"
00f9495f
EA
278.De
279Reserved for future use.
280This will eventually signal to
281.Fn refresh
282that it is all right to use the insert and delete line sequences
283when updating the window.
284.Ds
531d985f 285.Fn inch "" \(dg
00f9495f
EA
286.De
287Returns the character at the current position on the given window.
288This does not make any changes to the window.
289.Ds
531d985f 290.Fn initscr ""
00f9495f
EA
291.De
292Initialize the screen routines.
293This must be called before any of the screen routines are used.
294It initializes the terminal-type data and such,
295and without it none of the routines can operate.
296If standard input is not a tty,
297it sets the specifications to the terminal
298whose name is pointed to by
299.Vn Def\*_term
2b70b628 300(initially "dumb").
00f9495f
EA
301If the boolean
302.Vn My\*_term
2b70b628 303is non-zero,
00f9495f
EA
304.Vn Def\*_term
305is always used.
306If the system supports the
307.b TIOCGWINSZ
2b70b628 308.i ioctl(2)
00f9495f
EA
309call,
310it is used to get the number of lines and columns for the terminal,
311otherwise it is taken from the
312.b termcap
313description.
314.Ds
531d985f 315.Fn insch "char c"
00f9495f
EA
316.De
317Insert
318.Vn c
319at the current \*y
320Each character after it shifts to the right,
321and the last character disappears.
322\*(Es
323.Ds
531d985f 324.Fn insertln ""
00f9495f
EA
325.De
326Insert a line above the current one.
327Every line below the current line
328will be shifted down,
329and the bottom line will disappear.
330The current line will become blank,
331and the current \*y will remain unchanged.
332.Ds
531d985f 333.Fn killchar "" \(dg
00f9495f
EA
334.De
335Returns the line kill character
336for the terminal,
337.i i.e. ,
338the character used by the user to erase an entire line from the input.
339.Ds
531d985f 340.Fn leaveok "WINDOW *win" "int boolf" \(dg
00f9495f
EA
341.De
342Sets the boolean flag for leaving the cursor after the last change.
343If
344.Vn boolf
2b70b628 345is non-zero,
00f9495f
EA
346the cursor will be left after the last update on the terminal,
347and the current \*y for
348.Vn win
349will be changed accordingly.
2b70b628
EA
350If
351.Vn boolf
352 is 0 the cursor will be moved to the current \*y.
00f9495f 353This flag
2b70b628 354(initially 0)
00f9495f
EA
355retains its value until changed by the user.
356.Ds
531d985f 357.Fn move "int y" "int x"
00f9495f
EA
358.De
359Change the current \*y of the window to
360.Vn y\*,x ). (
361\*(Es
362.Ds
531d985f 363.Fn mvcur "int lasty" "int lastx" "int newy" "int newx"
00f9495f
EA
364.De
365Moves the terminal's cursor from
366.Vn lasty\*,lastx ) (
367to
368.Vn newy\*,newx ) (
369in an approximation of optimal fashion.
370This routine uses the functions borrowed from
371.i ex
372version 2.6.
373It is possible to use this optimization
374without the benefit of the screen routines.
375With the screen routines, this should not be called by the user.
376.Fn move
377and
378.Fn refresh
379should be used to move the cursor position,
380so that the routines know what's going on.
381.Ds
cfde7e65
EA
382.Fn mvprintw "int y" "int x" "const char *fmt" "..."
383.De
384Equivalent to:
385.(l
386move(y, x);
387printw(fmt, ...);
388.)l
389.Ds
390.Fn mvscanw "int y" "int x" "const char *fmt" "..."
391.De
392Equivalent to:
393.(l
394move(y, x);
395scanw(fmt, ...);
396.)l
397.Ds
531d985f 398.Fn mvwin "WINDOW *win" "int y" "int x"
00f9495f
EA
399.De
400Move the home position of the window
401.Vn win
402from its current starting coordinates
403to
404.Vn y\*,x ). (
405If that would put part or all of the window
406off the edge of the terminal screen,
407.Fn mvwin
408returns ERR and does not change anything.
409For subwindows,
410.Fn mvwin
411also returns ERR if you attempt to move it off its main window.
412If you move a main window,
413all subwindows are moved along with it.
414.Ds
cfde7e65
EA
415.Fn mvwprintw "WINDOW *win" "int y" "int x" "const char *fmt" "..."
416.De
5a00022e 417Equivalent to:
cfde7e65
EA
418.(l
419wmove(win, y, x);
420printw(fmt, ...);
421.)l
422.Ds
423.Fn mvwscanw "WINDOW *win" "int y" "int x" "const char *fmt" "..."
424.De
5a00022e 425Equivalent to:
cfde7e65
EA
426.(l
427wmove(win, y, x);
428scanw(fmt, ...);
429.)l
430.Ds
531d985f
EA
431.Ft "WINDOW *"
432.Fn newwin "int lines" "int cols" "int begin_y" "int begin_x"
00f9495f
EA
433.De
434Create a new window with
435.Vn lines
436lines and
437.Vn cols
438columns starting at position
439.Vn begin\*_y\*,begin\*_x ). (
440If either
441.Vn lines
442or
443.Vn cols
444is 0 (zero),
445that dimension will be set to
446.Vn "LINES \- begin\*_y" ) (
447or
448.Vn "COLS \- begin\*_x" ) (
449respectively.
450Thus, to get a new window of dimensions
451.Vn LINES
452\(mu
453.Vn COLS ,
454use
531d985f 455.Fn newwin 0 0 0 0 .
00f9495f 456.Ds
531d985f 457.Fn nl "" \(dg
00f9495f
EA
458.De
459Set the terminal to nl mode,
460.i i.e. ,
461start/stop the system from mapping
462.b <RETURN>
463to
464.b <LINE-FEED> .
465If the mapping is not done,
466.Fn refresh
467can do more optimization,
468so it is recommended, but not required, to turn it off.
469.Ds
531d985f 470.Fn nocbreak "" \(dg
00f9495f
EA
471.De
472Unset the terminal from cbreak mode.
473.Ds
531d985f 474.Fn nocrmode "" \(dg
00f9495f
EA
475.De
476Identical to
477.Fn nocbreak .
478The misnamed macro
479.Fn nocrmode
480is retained for backwards compatibility
481with ealier versions of the library.
482.Ds
531d985f 483.Fn noecho "" \(dg
00f9495f
EA
484.De
485Turn echoing of characters off.
486.Ds
531d985f 487.Fn nonl "" \(dg
00f9495f
EA
488.De
489Unset the terminal to from nl mode. See
490.Fn nl .
491.Ds
531d985f 492.Fn noraw "" \(dg
00f9495f
EA
493.De
494Unset the terminal from raw mode. See
495.Fn raw .
496.Ds
531d985f 497.Fn overlay "WINDOW *win1" "WINDOW *win2"
00f9495f
EA
498.De
499Overlay
500.Vn win1
501on
502.Vn win2 .
503The contents of
504.Vn win1 ,
505insofar as they fit,
506are placed on
507.Vn win2
508at their starting \*y.
509This is done non-destructively,
510i.e., blanks on
511.Vn win1
512leave the contents of the space on
513.Vn win2
2b70b628
EA
514untouched. Note that all non-blank characters are overwritten
515destructively in the overlay.
00f9495f 516.Ds
531d985f 517.Fn overwrite "WINDOW *win1" "WINDOW *win2"
00f9495f
EA
518.De
519Overwrite
520.Vn win1
521on
522.Vn win2 .
523The contents of
524.Vn win1 ,
525insofar as they fit,
526are placed on
527.Vn win2
528at their starting \*y.
529This is done destructively,
530.i i.e. ,
531blanks on
532.Vn win1
533become blank on
534.Vn win2 .
535.Ds
531d985f 536.Fn printw "char *fmt" "..."
00f9495f
EA
537.De
538Performs a
539.Fn printf
540on the window starting at the current \*y.
541It uses
542.Fn addstr
543to add the string on the window.
544It is often advisable to use the field width options of
545.Fn printf
546to avoid leaving things on the window from earlier calls.
547\*(Es
548.Ds
531d985f 549.Fn raw "" \(dg
00f9495f
EA
550.De
551Set the terminal to raw mode.
552On version 7
553.Un \**
554.(f
555\**
556.Un
cfde7e65 557is a trademark of Unix System Laboratories.
00f9495f 558.)f
cfde7e65 559this also turns off newline mapping
00f9495f
EA
560(see
561.Fn nl ).
562.Ds
531d985f 563.Fn refresh "" \(dg
00f9495f
EA
564.De
565Synchronize the terminal screen with the desired window.
566If the window is not a screen,
567only that part covered by it is updated.
568\*(Es
569In this case, it will update whatever it can
570without causing the scroll.
571.sp
572As a special case,
573if
574.Fn wrefresh
575is called with the window
576.Vn curscr
577the screen is cleared
578and repainted as it is currently.
579This is very useful for allowing the redrawing of the screen
580when the user has garbage dumped on his terminal.
581.Ds
531d985f 582.Fn resetty "" \(dg
00f9495f
EA
583.De
584.Fn resetty
585restores them to what
586.Fn savetty
587stored.
588These functions are performed automatically by
589.Fn initscr
590and
cfde7e65
EA
591.Fn endwin .
592This function should not be used by the user.
00f9495f 593.Ds
531d985f 594.Fn savetty "" \(dg
00f9495f
EA
595.De
596.Fn savetty
597saves the current tty characteristic flags. See
598.Fn resetty .
cfde7e65 599This function should not be used by the user.
00f9495f 600.Ds
531d985f 601.Fn scanw "char *fmt" "..."
00f9495f
EA
602.De
603Perform a
604.Fn scanf
605through the window using
606.Vn fmt .
531d985f
EA
607It does this using consecutive calls to
608.Fn getch
00f9495f 609(or
531d985f 610.Fn wgetch ).
00f9495f
EA
611\*(Es
612.Ds
531d985f 613.Fn scroll "WINDOW *win"
00f9495f
EA
614.De
615Scroll the window upward one line.
616This is normally not used by the user.
617.Ds
531d985f 618.Fn scrollok "WINDOW *win" "int boolf" \(dg
00f9495f
EA
619.De
620Set the scroll flag for the given window.
621If
622.Vn boolf
2b70b628 623is 0, scrolling is not allowed.
00f9495f
EA
624This is its default setting.
625.Ds
531d985f 626.Fn standend "" \(dg
00f9495f
EA
627.De
628End standout mode initiated by
629.Fn standout .
630.Ds
531d985f 631.Fn standout "" \(dg
00f9495f
EA
632.De
633Causes any characters added to the window
634to be put in standout mode on the terminal
635(if it has that capability).
636.Ds
531d985f
EA
637.Ft "WINDOW *"
638.Fn subwin "WINDOW *win" "int lines" "int cols" "int begin_y" "int begin_x"
00f9495f
EA
639.De
640Create a new window with
641.Vn lines
642lines and
643.Vn cols
644columns starting at position
645.Vn begin\*_y\*,begin\*_x ) (
646inside the window
647.i win .
648This means that any change made to either window
649in the area covered
650by the subwindow will be made on both windows.
651.Vn begin\*_y\*,begin\*_x
652are specified relative to the overall screen,
653not the relative (0\*,0) of
654.Vn win .
655If either
656.Vn lines
657or
658.Vn cols
659is 0 (zero),
660that dimension will be set to
661.Vn "LINES \- begin\*_y" ) (
662or
663.Vn "COLS \- begin\*_x" ) (
664respectively.
665.Ds
531d985f 666.Fn touchline "WINDOW *win" "int y" "int startx" "int endx"
00f9495f
EA
667.De
668This function performs a function similar to
669.Fn touchwin
670on a single line.
671It marks the first change for the given line
672to be
673.Vn startx ,
674if it is before the current first change mark,
675and
676the last change mark is set to be
677.Vn endx
678if it is currently less than
679.Vn endx .
680.Ds
531d985f 681.Fn touchoverlap "WINDOW *win1" "WINDOW *win2"
00f9495f
EA
682.De
683Touch the window
684.Vn win2
685in the area which overlaps with
686.Vn win1 .
687If they do not overlap,
688no changes are made.
689.Ds
531d985f 690.Fn touchwin "WINDOW *win"
00f9495f
EA
691.De
692Make it appear that the every location on the window
693has been changed.
694This is usually only needed for refreshes with overlapping windows.
695.Ds
531d985f 696.Fn tstp
00f9495f 697.De
cfde7e65 698This function
00f9495f
EA
699will save the current tty state
700and then put the process to sleep.
701When the process gets restarted,
cfde7e65 702it restores the saved tty state
00f9495f 703and then calls
531d985f 704.Fn wrefresh "curscr"
00f9495f 705to redraw the screen.
2b70b628 706.Fn Initscr
00f9495f
EA
707sets the signal
708SIGTSTP
709to trap to this routine.
710.Ds
cfde7e65
EA
711.Fn unctrl "char *ch" \(dg
712.De
713Returns a string which is an ASCII representation of
714.Vn ch .
715Characters are 8 bits long.
716.Ds
717.Fn unctrllen "char *ch" \(dg
718.De
719Returns the length of the ASCII representation of
720.Vn ch .
721.Ds
531d985f 722.Fn vwprintw "WINDOW *win" "const char *fmt" "va_list ap"
00f9495f
EA
723.De
724Identical to
725.Fn printw
726except that it takes both a window specification and a pointer to a variable
727length argument list.
728.Ds
531d985f 729.Fn vwscanw "WINDOW *win" "const char *fmt" "va_list ap"
00f9495f
EA
730.De
731Identical to
732.Fn scanw
733except that it takes both a window specification and a pointer to a variable
734length argument list.
cfde7e65
EA
735.Ds
736.Fn waddbytes "WINDOW *win" "char *str" "int len"
737.De
738This function is the low level character output function.
739.Vn Len
740characters of the string
741.Vn str
742are output to the current \*y position of the window specified by
743.Vn win.
00f9495f
EA
744.sp 2
745.pp
cfde7e65 746\fIThe following functions differ from the standard functions only in their
00f9495f 747specification of a window, rather than the use of the default
cfde7e65 748.Vn stdscr.\fP
00f9495f 749.Ds
89bacdf2
EA
750.Fn waddch "WINDOW *win" "char ch"
751.Fn waddstr "WINDOW *win" "char *str"
752.Fn wclear "WINDOW *win"
753.Fn wclrtobot "WINDOW *win"
754.Fn wclrtoeol "WINDOW *win"
755.Fn wdelch "WINDOW *win"
756.Fn wdeleteln "WINDOW *win"
757.Fn werase "WINDOW *win"
758.Fn wgetch "WINDOW *win"
759.Fn wgetstr "WINDOW *win" "char *str"
531d985f 760.Fn winch "WINDOW *win" \(dg
89bacdf2
EA
761.Fn winsch "WINDOW *win" "char c"
762.Fn winsertln "WINDOW *win"
763.Fn wmove "WINDOW *win" "int y" int x"
764.Fn wprintw "WINDOW *win" "char *fmt" "..."
765.Fn wrefresh "WINDOW *win"
766.Fn wscanw "WINDOW *win" "char *fmt" "..."
767.Fn wstandend "WINDOW *win"
768.Fn wstandout "WINDOW *win"
00f9495f 769.Dg