Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 3 | .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | .\" * |
| 5 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | .\" copy of this software and associated documentation files (the * |
| 7 | .\" "Software"), to deal in the Software without restriction, including * |
| 8 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 11 | .\" furnished to do so, subject to the following conditions: * |
| 12 | .\" * |
| 13 | .\" The above copyright notice and this permission notice shall be included * |
| 14 | .\" in all copies or substantial portions of the Software. * |
| 15 | .\" * |
| 16 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | .\" * |
| 24 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 25 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 26 | .\" sale, use or other dealings in this Software without prior written * |
| 27 | .\" authorization. * |
| 28 | .\"*************************************************************************** |
| 29 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 30 | .\" $Id: curs_initscr.3x,v 1.69 2024/04/20 21:24:19 tom Exp $ |
| 31 | .TH curs_initscr 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
| 32 | .ie \n(.g \{\ |
| 33 | .ds `` \(lq |
| 34 | .ds '' \(rq |
| 35 | .\} |
| 36 | .el \{\ |
| 37 | .ie t .ds `` `` |
| 38 | .el .ds `` "" |
| 39 | .ie t .ds '' '' |
| 40 | .el .ds '' "" |
| 41 | .\} |
| 42 | . |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 43 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 44 | .ie n .IP \(bu 4 |
| 45 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 46 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 47 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | \fB\%initscr\fP, |
| 49 | \fB\%newterm\fP, |
| 50 | \fB\%endwin\fP, |
| 51 | \fB\%isendwin\fP, |
| 52 | \fB\%set_term\fP, |
| 53 | \fB\%delscreen\fP \- |
| 54 | initialize, manipulate, or tear down \fIcurses\fR terminal interface |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 56 | .nf |
| 57 | \fB#include <curses.h> |
| 58 | .PP |
| 59 | \fBWINDOW *initscr(void); |
| 60 | \fBint endwin(void); |
| 61 | .PP |
| 62 | \fBbool isendwin(void); |
| 63 | .PP |
| 64 | \fBSCREEN *newterm(const char *\fItype\fP, FILE *\fIoutf\fP, FILE *\fIinf\fP); |
| 65 | \fBSCREEN *set_term(SCREEN *\fInew\fP); |
| 66 | \fBvoid delscreen(SCREEN* \fIsp\fP); |
| 67 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 68 | .SH DESCRIPTION |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 69 | .SS initscr |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 70 | \fBinitscr\fP is normally the first \fBcurses\fP routine to call when |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 71 | initializing a program. |
| 72 | A few special routines sometimes need to be called before it; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 73 | these are \fBslk_init\fP(3X), \fBfilter\fP, \fBripoffline\fP, |
| 74 | \fBuse_env\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 75 | For multiple-terminal applications, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 76 | \fBnewterm\fP may be called before \fBinitscr\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 77 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 78 | The initscr code determines the terminal type and initializes all \fBcurses\fP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 79 | data structures. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 80 | \fBinitscr\fP also causes the first call to \fBrefresh\fP(3X) |
| 81 | to clear the screen. |
| 82 | If errors occur, \fBinitscr\fP writes an appropriate error |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 83 | message to standard error and exits; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 84 | otherwise, a pointer is returned to \fBstdscr\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 85 | .SS newterm |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 86 | A program that outputs to more than one terminal should use the \fBnewterm\fP |
| 87 | routine for each terminal instead of \fBinitscr\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 88 | A program that needs to inspect capabilities, |
| 89 | so it can continue to run in a line-oriented mode if the |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 90 | terminal cannot support a screen-oriented program, would also use |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 91 | \fBnewterm\fP. |
| 92 | .PP |
| 93 | The routine \fBnewterm\fP should be called once for each terminal. |
| 94 | It returns a variable of type \fISCREEN *\fP which should be saved |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 95 | as a reference to that terminal. |
| 96 | \fBnewterm\fP's arguments are |
| 97 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 98 | the \fItype\fP of the terminal to be used in place of \fB$TERM\fP, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 99 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 100 | an output stream connected to the terminal, and |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 101 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 102 | an input stream connected to the terminal |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 103 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 104 | If the \fItype\fP parameter is \fBNULL\fP, \fB$TERM\fP will be used. |
| 105 | .PP |
| 106 | The file descriptor of the output stream is passed to \fBsetupterm\fP(3X), |
| 107 | which returns a pointer to a \fI\%TERMINAL\fP structure. |
| 108 | \fBnewterm\fP's return value holds a pointer to the \fI\%TERMINAL\fP structure. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 109 | .SS endwin |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 110 | The program must also call |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 111 | \fBendwin\fP for each terminal being used before exiting from \fBcurses\fP. |
| 112 | If \fBnewterm\fP is called more than once for the same terminal, the first |
| 113 | terminal referred to must be the last one for which \fBendwin\fP is called. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 115 | A program should always call \fBendwin\fP before exiting or escaping from |
| 116 | \fBcurses\fP mode temporarily. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 117 | This routine |
| 118 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 119 | resets colors to correspond with the default color pair 0, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 120 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 121 | moves the cursor to the lower left-hand corner of the screen, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 122 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | clears the remainder of the line so that it uses the default colors, |
| 124 | .bP |
| 125 | sets the cursor to normal visibility (see \fBcurs_set\fP(3X)), |
| 126 | .bP |
| 127 | stops cursor-addressing mode using the \fIexit_ca_mode\fP terminal capability, |
| 128 | .bP |
| 129 | restores tty modes (see \fBreset_shell_mode\fP(3X)). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 130 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 131 | Calling \fBrefresh\fP(3X) or \fBdoupdate\fP(3X) after a |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 132 | temporary escape causes the program to resume visual mode. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 133 | .SS isendwin |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 134 | The \fBisendwin\fP routine returns \fBTRUE\fP if \fBendwin\fP has been |
| 135 | called without any subsequent calls to \fBwrefresh\fP, |
| 136 | and \fBFALSE\fP otherwise. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 137 | .SS set_term |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 138 | The \fBset_term\fP routine is used to switch between different terminals. |
| 139 | The screen reference \fInew\fP becomes the new current terminal. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 140 | The previous terminal is returned by the routine. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 141 | This is the only routine which manipulates \fISCREEN\fP pointers; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 142 | all other routines affect only the current terminal. |
| 143 | .SS delscreen |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 144 | The \fBdelscreen\fP routine frees storage associated with the |
| 145 | \fISCREEN\fP data structure. |
| 146 | The \fBendwin\fP routine does not do |
| 147 | this, so \fBdelscreen\fP should be called after \fBendwin\fP if a |
| 148 | particular \fISCREEN\fP is no longer needed. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 149 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 150 | \fBendwin\fP returns the integer \fBERR\fP upon failure and \fBOK\fP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 151 | upon successful completion. |
| 152 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 153 | Routines that return pointers always return \fBNULL\fP on error. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 154 | .PP |
| 155 | X/Open defines no error conditions. |
| 156 | In this implementation |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 157 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 158 | \fBendwin\fP returns an error if |
| 159 | .RS |
| 160 | .bP |
| 161 | the terminal was not initialized, or |
| 162 | .bP |
| 163 | \fBendwin\fP is called more than once without updating the screen, or |
| 164 | .bP |
| 165 | \fBreset_shell_mode\fP(3X) returns an error. |
| 166 | .RE |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 167 | .bP |
| 168 | \fBnewterm\fP |
| 169 | returns an error if it cannot allocate the data structures for the screen, |
| 170 | or for the top-level windows within the screen, |
| 171 | i.e., |
| 172 | \fBcurscr\fP, \fBnewscr\fP, or \fBstdscr\fP. |
| 173 | .bP |
| 174 | \fBset_term\fP |
| 175 | returns no error. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 176 | .SH PORTABILITY |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 177 | These functions were described in X/Open Curses, Issue 4. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 178 | As of 2015, the current document is X/Open Curses, Issue 7. |
| 179 | .SS Differences |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 180 | X/Open Curses specifies that portable applications must not |
| 181 | call \fBinitscr\fP more than once: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 182 | .bP |
| 183 | The portable way to use \fBinitscr\fP is once only, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 184 | using \fB\%refresh\fP(3X) |
| 185 | to restore the screen after \fBendwin\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 186 | .bP |
| 187 | This implementation allows using \fBinitscr\fP after \fBendwin\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 188 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 189 | Old versions of curses, e.g., BSD 4.4, would return a null pointer |
| 190 | from \fBinitscr\fP when an error is detected, rather than exiting. |
| 191 | It is safe but redundant to check the return value of \fBinitscr\fP |
| 192 | in X/Open Curses. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 193 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 194 | Calling \fBendwin\fP does not dispose of the memory allocated in \fBinitscr\fP |
| 195 | or \fBnewterm\fP. |
| 196 | Deleting a \fISCREEN\fP provides a way to do this: |
| 197 | .bP |
| 198 | X/Open Curses does not say what happens to \fI\%WINDOW\fPs when \fBdelscreen\fP |
| 199 | \*(``frees storage associated with the \fISCREEN\fP\*('' |
| 200 | nor does the SVr4 documentation help, |
| 201 | adding that it should be called after \fBendwin\fP if a \fISCREEN\fP |
| 202 | is no longer needed. |
| 203 | .bP |
| 204 | However, \fI\%WINDOW\fPs are implicitly associated with a \fISCREEN\fP. |
| 205 | so that it is reasonable to expect \fBdelscreen\fP to deal with these. |
| 206 | .bP |
| 207 | SVr4 curses deletes the standard \fI\%WINDOW\fP structures |
| 208 | \fBstdscr\fP and \fBcurscr\fP as well as a work area \fBnewscr\fP. |
| 209 | SVr4 curses ignores other windows. |
| 210 | .bP |
| 211 | Since version 4.0 (1996), |
| 212 | \fI\%ncurses\fP has maintained a list of all windows for each screen, |
| 213 | using that information to delete those windows when \fBdelscreen\fP is called. |
| 214 | .bP |
| 215 | NetBSD copied this feature of \fI\%ncurses\fP in 2001. |
| 216 | PDCurses follows the SVr4 model, |
| 217 | deleting only the standard \fI\%WINDOW\fP structures. |
| 218 | .SS "High-level versus Low-level" |
| 219 | Different implementations may disagree regarding the level of some functions. |
| 220 | For example, \fISCREEN\fP (returned by \fBnewterm\fP) and |
| 221 | \fI\%TERMINAL\fP (returned by \fBsetupterm\fP(3X)) hold file descriptors for |
| 222 | the output stream. |
| 223 | If an application switches screens using \fBset_term\fR, |
| 224 | or switches terminals using \fBset_curterm\fP(3X), |
| 225 | applications which use the output file descriptor can have different |
| 226 | behavior depending on which structure holds the corresponding descriptor. |
| 227 | .PP |
| 228 | For example |
| 229 | .bP |
| 230 | NetBSD's \fBbaudrate\fP(3X) function uses the descriptor in \fI\%TERMINAL\fP. |
| 231 | \fI\%ncurses\fP and SVr4 use the descriptor in \fISCREEN\fP. |
| 232 | .bP |
| 233 | NetBSD and \fI\%ncurses\fP use the descriptor |
| 234 | in \fI\%TERMINAL\fP |
| 235 | for terminal I/O modes, |
| 236 | e.g., |
| 237 | \fBdef_shell_mode\fP(3X), |
| 238 | \fBdef_prog_mode\fP(3X). |
| 239 | SVr4 curses uses the descriptor in \fISCREEN\fP. |
| 240 | .SS "Unset \fITERM\fP Variable" |
| 241 | If the \fITERM\fP variable is missing or empty, \fBinitscr\fP uses the |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 242 | value \*(``unknown\*('', |
| 243 | which normally corresponds to a terminal entry with the \fIgeneric\fP |
| 244 | (\fIgn\fP) capability. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 245 | Generic entries are detected by \fBsetupterm\fP(3X) |
| 246 | and cannot be used for full-screen operation. |
| 247 | Other implementations may handle |
| 248 | a missing/empty \fITERM\fP variable differently. |
| 249 | .SS "Signal Handlers" |
| 250 | Quoting from X/Open Curses Issue 7, section 3.1.1: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 251 | .RS 5 |
| 252 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 253 | Curses implementations may provide for special handling of the |
| 254 | \%SIGINT, |
| 255 | \%SIGQUIT, |
| 256 | and \%SIGTSTP signals if their disposition is \%SIG_DFL at the time |
| 257 | .I \%initscr |
| 258 | is called.\|.\|. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 259 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 260 | Any special handling for these signals may remain in effect for the |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 261 | life of the process or until the process changes the disposition of |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 262 | the signal. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 263 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 264 | None of the Curses functions are required to be safe |
| 265 | with respect to signals.\|.\|. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 266 | .RE |
| 267 | .PP |
| 268 | This implementation establishes signal handlers during initialization, |
| 269 | e.g., \fBinitscr\fP or \fBnewterm\fP. |
| 270 | Applications which must handle these signals should set up the corresponding |
| 271 | handlers \fIafter\fP initializing the library: |
| 272 | .TP 5 |
| 273 | .B SIGINT |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 274 | The handler \fIattempts\fP to clean up the screen on exit. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 275 | Although it \fIusually\fP works as expected, there are limitations: |
| 276 | .RS 5 |
| 277 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 278 | Walking the \fISCREEN\fP list is unsafe, since all list management |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 279 | is done without any signal blocking. |
| 280 | .bP |
| 281 | On systems which have \fBREENTRANT\fP turned on, \fBset_term\fP uses |
| 282 | functions which could deadlock or misbehave in other ways. |
| 283 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 284 | \fBendwin\fP calls other functions, |
| 285 | many of which use \fI\%stdio\fP(3) or other library functions which are |
| 286 | clearly unsafe. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 287 | .RE |
| 288 | .TP 5 |
| 289 | .B SIGTERM |
| 290 | This uses the same handler as \fBSIGINT\fP, with the same limitations. |
| 291 | It is not mentioned in X/Open Curses, but is more suitable for this |
| 292 | purpose than \fBSIGQUIT\fP (which is used in debugging). |
| 293 | .TP 5 |
| 294 | .B SIGTSTP |
| 295 | This handles the \fIstop\fP signal, used in job control. |
| 296 | When resuming the process, this implementation discards pending |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 297 | input with \fB\%flushinp\fP(3X), and repaints the screen |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 298 | assuming that it has been completely altered. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 299 | It also updates the saved terminal modes with |
| 300 | \fB\%def_shell_mode\fP(3X). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 301 | .TP 5 |
| 302 | .B SIGWINCH |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 303 | This handles the window-size changes which were ignored in |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 304 | the standardization efforts. |
| 305 | The handler sets a (signal-safe) variable |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 306 | which is later tested in \fB\%wgetch\fP(3X). |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 307 | If \fBkeypad\fP has been enabled for the corresponding window, |
| 308 | \fBwgetch\fP returns the key symbol \fBKEY_RESIZE\fP. |
| 309 | At the same time, \fBwgetch\fP calls \fBresizeterm\fP to adjust the |
| 310 | standard screen \fBstdscr\fP, |
| 311 | and update other data such as \fBLINES\fP and \fBCOLS\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 312 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 313 | \fB\%curses\fP(3X), |
| 314 | \fB\%curs_kernel\fP(3X), |
| 315 | \fB\%curs_refresh\fP(3X), |
| 316 | \fB\%curs_slk\fP(3X), |
| 317 | \fB\%curs_terminfo\fP(3X), |
| 318 | \fB\%curs_util\fP(3X), |
| 319 | \fB\%curs_variables\fP(3X) |