1curs_kernel(3X) curs_kernel(3X)
2
3
4
6 def_prog_mode, def_shell_mode, reset_prog_mode, reset_shell_mode,
7 resetty, savetty, getsyx, setsyx, ripoffline, curs_set, napms - low-
8 level curses routines
9
11 #include <curses.h>
12
13 int def_prog_mode(void);
14 int def_shell_mode(void);
15 int reset_prog_mode(void);
16 int reset_shell_mode(void);
17 int resetty(void);
18 int savetty(void);
19 void getsyx(int y, int x);
20 void setsyx(int y, int x);
21 int ripoffline(int line, int (*init)(WINDOW *, int));
22 int curs_set(int visibility);
23 int napms(int ms);
24
26 The following routines give low-level access to various curses capabil‐
27 ities. Theses routines typically are used inside library routines.
28
29 The def_prog_mode and def_shell_mode routines save the current terminal
30 modes as the "program" (in curses) or "shell" (not in curses) state for
31 use by the reset_prog_mode and reset_shell_mode routines. This is done
32 automatically by initscr. There is one such save area for each screen
33 context allocated by newterm().
34
35 The reset_prog_mode and reset_shell_mode routines restore the terminal
36 to "program" (in curses) or "shell" (out of curses) state. These are
37 done automatically by endwin and, after an endwin, by doupdate, so they
38 normally are not called.
39
40 The resetty and savetty routines save and restore the state of the ter‐
41 minal modes. savetty saves the current state in a buffer and resetty
42 restores the state to what it was at the last call to savetty.
43
44 The getsyx routine returns the current coordinates of the virtual
45 screen cursor in y and x. If leaveok is currently TRUE, then -1,-1 is
46 returned. If lines have been removed from the top of the screen, using
47 ripoffline, y and x include these lines; therefore, y and x should be
48 used only as arguments for setsyx.
49
50 The setsyx routine sets the virtual screen cursor to y, x. If y and x
51 are both -1, then leaveok is set. The two routines getsyx and setsyx
52 are designed to be used by a library routine, which manipulates curses
53 windows but does not want to change the current position of the pro‐
54 gram's cursor. The library routine would call getsyx at the beginning,
55 do its manipulation of its own windows, do a wnoutrefresh on its win‐
56 dows, call setsyx, and then call doupdate.
57
58 The ripoffline routine provides access to the same facility that
59 slk_init [see curs_slk(3X)] uses to reduce the size of the screen.
60 ripoffline must be called before initscr or newterm is called. If line
61 is positive, a line is removed from the top of stdscr; if line is nega‐
62 tive, a line is removed from the bottom. When this is done inside
63 initscr, the routine init (supplied by the user) is called with two ar‐
64 guments: a window pointer to the one-line window that has been allocat‐
65 ed and an integer with the number of columns in the window. Inside
66 this initialization routine, the integer variables LINES and COLS (de‐
67 fined in <curses.h>) are not guaranteed to be accurate and wrefresh or
68 doupdate must not be called. It is allowable to call wnoutrefresh dur‐
69 ing the initialization routine.
70
71 ripoffline can be called up to five times before calling initscr or
72 newterm.
73
74 The curs_set routine sets the cursor state is set to invisible, normal,
75 or very visible for visibility equal to 0, 1, or 2 respectively. If
76 the terminal supports the visibility requested, the previous cursor
77 state is returned; otherwise, ERR is returned.
78
79 The napms routine is used to sleep for ms milliseconds.
80
82 Except for curs_set, these routines always return OK.
83
84 curs_set returns the previous cursor state, or ERR if the requested
85 visibility is not supported.
86
87 X/Open defines no error conditions. In this implementation
88
89 def_prog_mode, def_shell_mode, reset_prog_mode, reset_shell_mode
90 return an error if the terminal was not initialized, or if
91 the I/O call to obtain the terminal settings fails.
92
93 ripoffline
94 returns an error if the maximum number of ripped-off lines
95 exceeds the maximum (NRIPS = 5).
96
98 Note that getsyx is a macro, so & is not necessary before the variables
99 y and x.
100
101 Older SVr4 man pages warn that the return value of curs_set "is cur‐
102 rently incorrect". This implementation gets it right, but it may be
103 unwise to count on the correctness of the return value anywhere else.
104
105 Both ncurses and SVr4 will call curs_set in endwin if curs_set has been
106 called to make the cursor other than normal, i.e., either invisible or
107 very visible. There is no way for ncurses to determine the initial
108 cursor state to restore that.
109
111 The functions setsyx and getsyx are not described in the XSI Curses
112 standard, Issue 4. All other functions are as described in XSI Curses.
113
114 The SVr4 documentation describes setsyx and getsyx as having return
115 type int. This is misleading, as they are macros with no documented se‐
116 mantics for the return value.
117
119 curses(3X), curs_initscr(3X), curs_outopts(3X), curs_refresh(3X),
120 curs_scr_dump(3X), curs_slk(3X)
121
122
123
124 curs_kernel(3X)