Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 1 | '\" t |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 2 | .\"*************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 3 | .\" Copyright 2018-2023,2024 Thomas E. Dickey * |
| 4 | .\" Copyright 1998-2015,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 5 | .\" * |
| 6 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 7 | .\" copy of this software and associated documentation files (the * |
| 8 | .\" "Software"), to deal in the Software without restriction, including * |
| 9 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 10 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 11 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 12 | .\" furnished to do so, subject to the following conditions: * |
| 13 | .\" * |
| 14 | .\" The above copyright notice and this permission notice shall be included * |
| 15 | .\" in all copies or substantial portions of the Software. * |
| 16 | .\" * |
| 17 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 18 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 19 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 20 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 21 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 22 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 23 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 24 | .\" * |
| 25 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 26 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 27 | .\" sale, use or other dealings in this Software without prior written * |
| 28 | .\" authorization. * |
| 29 | .\"*************************************************************************** |
| 30 | .\" |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 31 | .\" $Id: curs_util.3x,v 1.101 2024/04/20 21:20:07 tom Exp $ |
| 32 | .TH curs_util 3X 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls" |
| 33 | .ie \n(.g \{\ |
| 34 | .ds `` \(lq |
| 35 | .ds '' \(rq |
| 36 | .\} |
| 37 | .el \{\ |
| 38 | .ie t .ds `` `` |
| 39 | .el .ds `` "" |
| 40 | .ie t .ds '' '' |
| 41 | .el .ds '' "" |
| 42 | .\} |
| 43 | . |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 44 | .de bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 45 | .ie n .IP \(bu 4 |
| 46 | .el .IP \(bu 2 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 47 | .. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 48 | .SH NAME |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 49 | \fB\%delay_output\fP, |
| 50 | \fB\%filter\fP, |
| 51 | \fB\%flushinp\fP, |
| 52 | \fB\%getwin\fP, |
| 53 | \fB\%key_name\fP, |
| 54 | \fB\%keyname\fP, |
| 55 | \fB\%nofilter\fP, |
| 56 | \fB\%putwin\fP, |
| 57 | \fB\%unctrl\fP, |
| 58 | \fB\%use_env\fP, |
| 59 | \fB\%use_tioctl\fP, |
| 60 | \fB\%wunctrl\fP \- |
| 61 | miscellaneous \fIcurses\fR utility routines |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 62 | .SH SYNOPSIS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 63 | .nf |
| 64 | \fB#include <curses.h> |
| 65 | .PP |
| 66 | \fBconst char *unctrl(chtype \fIch\fP); |
| 67 | \fBwchar_t *wunctrl(cchar_t *\fIwch\fP); |
| 68 | .PP |
| 69 | \fBconst char *keyname(int \fIc\fP); |
| 70 | \fBconst char *key_name(wchar_t \fIwc\fP); |
| 71 | .PP |
| 72 | \fBvoid filter(void); |
| 73 | .PP |
| 74 | \fBvoid use_env(bool \fIf\fP); |
| 75 | .PP |
| 76 | \fBint putwin(WINDOW *\fIwin\fP, FILE *\fIfilep\fP); |
| 77 | \fBWINDOW *getwin(FILE *\fIfilep\fP); |
| 78 | .PP |
| 79 | \fBint delay_output(int \fIms\fP); |
| 80 | \fBint flushinp(void); |
| 81 | .PP |
| 82 | \fI/* extensions */ |
| 83 | \fBvoid nofilter(void); |
| 84 | \fBvoid use_tioctl(bool \fIf\fP); |
| 85 | .fi |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 86 | .SH DESCRIPTION |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 87 | .SS unctrl |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 88 | The \fBunctrl\fP routine returns a character string which is a printable |
| 89 | representation of the character \fIch\fP: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 90 | .bP |
| 91 | Printable characters are displayed as themselves, |
| 92 | e.g., a one-character string containing the key. |
| 93 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 94 | Control characters are displayed in the \fB^\fIX\fR notation. |
| 95 | .bP |
| 96 | Printing characters are displayed as is. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 97 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 98 | DEL (character 127) is displayed as \fB^?\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 99 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 100 | Values above 128 are either meta characters |
| 101 | (if the screen has not been initialized, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 102 | or if \fBmeta\fP(3X) has been called with a \fBTRUE\fP parameter), |
| 103 | shown in the \fBM\-\fIX\fR notation, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 104 | or are displayed as themselves. |
| 105 | In the latter case, the values may not be printable; |
| 106 | this follows the X/Open specification. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 107 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 108 | The corresponding \fBwunctrl\fP returns a printable representation of |
| 109 | a complex character \fIwch\fP. |
| 110 | .PP |
| 111 | In both \fBunctrl\fP and \fBwunctrl\fP the attributes and color associated |
| 112 | with the character parameter are ignored. |
| 113 | .SS "keyname, key_name" |
| 114 | The \fBkeyname\fP routine returns a character string |
| 115 | corresponding to the key \fIc\fP. |
| 116 | Key codes are different from character codes. |
| 117 | .bP |
| 118 | Key codes below 256 are characters. |
| 119 | They are displayed using \fBunctrl\fP. |
| 120 | .bP |
| 121 | Values above 256 may be the codes for function keys. |
| 122 | The function key name is displayed. |
| 123 | .bP |
| 124 | Otherwise (if there is no corresponding name and the key is not a character) |
| 125 | the function returns null, to denote an error. |
| 126 | X/Open also lists an \*(``UNKNOWN KEY\*('' return value, |
| 127 | which some implementations return rather than null. |
| 128 | .LP |
| 129 | The corresponding \fBkey_name\fP returns |
| 130 | a multibyte character string corresponding |
| 131 | to the wide-character value \fIw\fP. |
| 132 | The two functions (\fBkeyname\fP and \fBkey_name\fP) |
| 133 | do not return the same set of strings: |
| 134 | .bP |
| 135 | \fBkeyname\fP returns null where \fBkey_name\fP would display a meta character. |
| 136 | .bP |
| 137 | \fBkey_name\fP does not return the name of a function key. |
| 138 | .SS "filter, nofilter" |
| 139 | The \fBfilter\fP routine, if used, must be called before \fBinitscr\fP or |
| 140 | \fBnewterm\fP are called. |
| 141 | Calling \fBfilter\fP causes these changes in initialization: |
| 142 | .bP |
| 143 | \fBLINES\fP is set to 1; |
| 144 | .bP |
| 145 | the capabilities |
| 146 | \fBclear\fP, |
| 147 | \fBcud1\fP, |
| 148 | \fBcud\fP, |
| 149 | \fBcup\fP, |
| 150 | \fBcuu1\fP, |
| 151 | \fBcuu\fP, |
| 152 | \fBvpa\fP |
| 153 | are disabled; |
| 154 | .bP |
| 155 | the capability \fBed\fP is disabled if \fBbce\fP is set; |
| 156 | .bP |
| 157 | and the \fBhome\fP string is set to the value of \fBcr\fP. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 158 | .PP |
| 159 | The \fBnofilter\fP routine cancels the effect of a preceding \fBfilter\fP |
| 160 | call. |
| 161 | That allows the caller to initialize a screen on a different device, |
| 162 | using a different value of \fB$TERM\fP. |
| 163 | The limitation arises because the \fBfilter\fP routine modifies the |
| 164 | in-memory copy of the terminal information. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 165 | .SS use_env |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 166 | The \fBuse_env\fP routine, if used, |
| 167 | should be called before \fBinitscr\fP or |
| 168 | \fBnewterm\fP are called |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 169 | (because those compute the screen size). |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 170 | It modifies the way \fI\%ncurses\fP treats environment variables |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 171 | when determining the screen size. |
| 172 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 173 | Normally \fI\%ncurses\fP looks first at the terminal database for the |
| 174 | screen size. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 175 | .IP |
| 176 | If \fBuse_env\fP was called with \fBFALSE\fP for parameter, |
| 177 | it stops here unless |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 178 | \fBuse_tioctl\fP was also called with \fBTRUE\fP for parameter. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 179 | .bP |
| 180 | Then it asks for the screen size via operating system calls. |
| 181 | If successful, |
| 182 | it overrides the values from the terminal database. |
| 183 | .bP |
| 184 | Finally (unless \fBuse_env\fP was called with \fBFALSE\fP parameter), |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 185 | \fI\%ncurses\fP examines the \fILINES\fP or \fI\%COLUMNS\fP environment |
| 186 | variables, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 187 | using a value in those to override the results |
| 188 | from the operating system or terminal database. |
| 189 | .IP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 190 | \fI\%curses\fP also updates the screen size in response to |
| 191 | \fBSIGWINCH\fP, |
| 192 | unless overridden by the \fILINES\fP or \fI\%COLUMNS\fP environment |
| 193 | variables, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 194 | .SS use_tioctl |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 195 | The \fBuse_tioctl\fP routine, if used, |
| 196 | should be called before \fBinitscr\fP or \fBnewterm\fP are called |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 197 | (because those compute the screen size). |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 198 | After \fBuse_tioctl\fP is called with \fBTRUE\fP as an argument, |
| 199 | \fI\%ncurses\fP modifies the last step in its computation |
| 200 | of screen size as follows: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 201 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 202 | checks if the \fILINES\fP and \fI\%COLUMNS\fP environment variables |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 203 | are set to a number greater than zero. |
| 204 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 205 | for each, \fI\%ncurses\fP updates the corresponding environment variable |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 206 | with the value that it has obtained via operating system call |
| 207 | or from the terminal database. |
| 208 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 209 | \fI\%ncurses\fP re-fetches the value of the environment variables so |
| 210 | that it is still the environment variables which set the screen size. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 211 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 212 | The \fB\%use_env\fP and \fB\%use_tioctl\fP routines combine as follows. |
| 213 | .IP |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 214 | .TS |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 215 | lB lB lB |
| 216 | lB lB lx. |
| 217 | use_env use_tioctl Summary |
| 218 | _ |
| 219 | TRUE FALSE T{ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 220 | This is the default behavior. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 221 | \fI\%ncurses\fP uses operating system calls |
| 222 | unless overridden by \fILINES\fP or \fI\%COLUMNS\fP environment |
| 223 | variables; |
| 224 | default. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 225 | T} |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 226 | TRUE TRUE T{ |
| 227 | \fI\%ncurses\fP updates \fILINES\fP and \fI\%COLUMNS\fP based on |
| 228 | operating system calls. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 229 | T} |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 230 | FALSE TRUE T{ |
| 231 | \fI\%ncurses\fP ignores \fILINES\fP and \fI\%COLUMNS\fP, |
| 232 | using operating system calls to obtain size. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 233 | T} |
| 234 | .TE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 235 | .SS "putwin, getwin" |
| 236 | The \fBputwin\fP routine writes all data associated |
| 237 | with window (or pad) \fIwin\fP into |
| 238 | the file to which \fIfilep\fP points. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 239 | This information can be later retrieved |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 240 | using the \fBgetwin\fP function. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 241 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 242 | The \fBgetwin\fP routine reads window related data stored in the file by |
| 243 | \fBputwin\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 244 | The routine then creates and initializes a new window using that |
| 245 | data. |
| 246 | It returns a pointer to the new window. |
| 247 | There are a few caveats: |
| 248 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 249 | the data written is a copy of the \fI\%WINDOW\fP structure, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 250 | and its associated character cells. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 251 | The format differs between the wide-character (\fI\%ncursesw\fP) and |
| 252 | non-wide (\fI\%ncurses\fP) libraries. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 253 | You can transfer data between the two, however. |
| 254 | .bP |
| 255 | the retrieved window is always created as a top-level window (or pad), |
| 256 | rather than a subwindow. |
| 257 | .bP |
| 258 | the window's character cells contain the color pair \fIvalue\fP, |
| 259 | but not the actual color \fInumbers\fP. |
| 260 | If cells in the retrieved window use color pairs which have not been |
| 261 | created in the application using \fBinit_pair\fP, |
| 262 | they will not be colored when the window is refreshed. |
| 263 | .SS delay_output |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 264 | The \fBdelay_output\fP routine inserts an \fIms\fP millisecond pause |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 265 | in output. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 266 | Employ this function judiciously when terminal output uses padding, |
| 267 | because \fI\%ncurses\fP transmits null characters |
| 268 | (consuming CPU and I/O resources) |
| 269 | instead of sleeping and requesting resumption from the operating system. |
| 270 | Padding is used unless: |
| 271 | .bP |
| 272 | the terminal description has \fBnpc\fP (\fBno_pad_char\fP) capability, or |
| 273 | .bP |
| 274 | the environment variable \fB\%NCURSES_NO_PADDING\fP is set. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 275 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 276 | If padding is not in use, |
| 277 | \fI\%ncurses\fP uses \fBnapms\fP to perform the delay. |
| 278 | If the value of \fIms\fP exceeds 30,000 |
| 279 | (thirty seconds), |
| 280 | it is capped at that value. |
| 281 | .SS flushinp |
| 282 | The \fBflushinp\fP routine throws away any typeahead that has been typed by the |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 283 | user and has not yet been read by the program. |
| 284 | .SH RETURN VALUE |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 285 | Except for \fBflushinp\fP, routines that return an integer return \fBERR\fP |
| 286 | upon failure and \fBOK\fP (SVr4 specifies only "an integer value other than |
| 287 | \fBERR\fP") upon successful completion. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 288 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 289 | Routines that return pointers return \fBNULL\fP on error. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 290 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 291 | X/Open Curses does not specify any error conditions. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 292 | In this implementation |
| 293 | .RS 3 |
| 294 | .TP 5 |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 295 | \fBflushinp\fP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 296 | returns an error if the terminal was not initialized. |
| 297 | .TP 5 |
| 298 | \fBputwin\fP |
| 299 | returns an error if the associated \fBfwrite\fP calls return an error. |
| 300 | .RE |
| 301 | .SH PORTABILITY |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 302 | .SS filter |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 303 | The SVr4 documentation describes the action of \fBfilter\fP only in the vaguest |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 304 | terms. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 305 | The description here is adapted from X/Open Curses (which |
| 306 | erroneously fails to describe the disabling of \fBcuu\fP). |
| 307 | .SS "delay_output padding" |
| 308 | The limitation to 30 seconds |
| 309 | and the use of \fBnapms\fP |
| 310 | differ from other implementations. |
| 311 | .bP |
| 312 | SVr4 curses does not delay if no padding character is available. |
| 313 | .bP |
| 314 | NetBSD curses uses \fBnapms\fP when no padding character is available, |
| 315 | but does not take timing into account when using the padding character. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 316 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 317 | Neither limits the delay. |
| 318 | .SS keyname |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 319 | The \fBkeyname\fP function may return the names of user-defined |
| 320 | string capabilities which are defined in the terminfo entry via the \fB\-x\fP |
| 321 | option of \fB@TIC@\fP. |
| 322 | This implementation automatically assigns at run-time keycodes to |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 323 | user-defined strings which begin with \*(``k\*(''. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 324 | The keycodes start at KEY_MAX, but are not guaranteed to be |
| 325 | the same value for different runs because user-defined codes are |
| 326 | merged from all terminal descriptions which have been loaded. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 327 | The \fBuse_extended_names\fP(3X) function controls whether this data is |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 328 | loaded when the terminal description is read by the library. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 329 | .SS "nofilter, use_tioctl" |
| 330 | The \fBnofilter\fP and \fBuse_tioctl\fP routines are specific to |
| 331 | \fI\%ncurses\fP. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 332 | They were not supported on Version 7, BSD or System V implementations. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 333 | It is recommended that any code depending on \fI\%ncurses\fP extensions |
| 334 | be conditioned using \fBNCURSES_VERSION\fP. |
| 335 | .SS "putwin/getwin file-format" |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 336 | The \fBputwin\fP and \fBgetwin\fP functions have several issues with |
| 337 | portability: |
| 338 | .bP |
| 339 | The files written and read by these functions |
| 340 | use an implementation-specific format. |
| 341 | Although the format is an obvious target for standardization, |
| 342 | it has been overlooked. |
| 343 | .IP |
| 344 | Interestingly enough, according to the copyright dates in Solaris source, |
| 345 | the functions (along with \fBscr_init\fP, etc.) originated with |
| 346 | the University of California, Berkeley (in 1982) |
| 347 | and were later (in 1988) incorporated into SVr4. |
| 348 | Oddly, there are no such functions in the 4.3BSD curses sources. |
| 349 | .bP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 350 | Most implementations simply dump the binary \fI\%WINDOW\fP structure |
| 351 | to the file. |
| 352 | These include SVr4 curses, NetBSD and PDCurses, |
| 353 | as well as older \fI\%ncurses\fP versions. |
| 354 | This implementation |
| 355 | (as well as the X/Open variant of Solaris curses, dated 1995) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 356 | uses textual dumps. |
| 357 | .IP |
| 358 | The implementations which use binary dumps use block-I/O |
| 359 | (the \fBfwrite\fP and \fBfread\fP functions). |
| 360 | Those that use textual dumps use buffered-I/O. |
| 361 | A few applications may happen to write extra data in the file using |
| 362 | these functions. |
| 363 | Doing that can run into problems mixing block- and buffered-I/O. |
| 364 | This implementation reduces the problem on writes by flushing the output. |
| 365 | However, reading from a file written using mixed schemes may not be successful. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 366 | .SS "unctrl, wunctrl" |
| 367 | X/Open Curses, Issue 4 describes these functions. |
| 368 | It states that \fBunctrl\fP and \fBwunctrl\fP will return a null pointer if |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 369 | unsuccessful, but does not define any error conditions. |
| 370 | This implementation checks for three cases: |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 371 | .bP |
| 372 | the parameter is a 7-bit US\-ASCII code. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 373 | This is the case that X/Open Curses documented. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 374 | .bP |
| 375 | the parameter is in the range 128\-159, i.e., a C1 control code. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 376 | If \fBuse_legacy_coding\fP(3X) has been called with a \fB2\fP parameter, |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 377 | \fBunctrl\fP returns the parameter, i.e., a one-character string with |
| 378 | the parameter as the first character. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 379 | Otherwise, it returns \*(``~@\*('', \*(``~A\*('', etc., |
| 380 | analogous to \*(``^@\*('', \*(``^A\*('', C0 controls. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 381 | .IP |
| 382 | X/Open Curses does not document whether \fBunctrl\fP can be called before |
| 383 | initializing curses. |
| 384 | This implementation permits that, |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 385 | and returns the \*(``~@\*('', etc., values in that case. |
| 386 | .bP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 387 | parameter values outside the 0 to 255 range. |
| 388 | \fBunctrl\fP returns a null pointer. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 389 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 390 | The strings returned by \fBunctrl\fP in this implementation are determined |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 391 | at compile time, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 392 | showing C1 controls from the upper-128 codes |
| 393 | with a \*(``~\*('' prefix rather than \*(``^\*(''. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 394 | Other implementations have different conventions. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 395 | For example, they may show both sets of control characters with \*(``^\*('', |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 396 | and strip the parameter to 7 bits. |
| 397 | Or they may ignore C1 controls and treat all of the upper-128 codes as |
| 398 | printable. |
| 399 | This implementation uses 8 bits but does not modify the string to reflect |
| 400 | locale. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 401 | The \fBuse_legacy_coding\fP(3X) function allows the caller to |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 402 | change the output of \fBunctrl\fP. |
| 403 | .PP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 404 | Likewise, the \fBmeta\fP(3X) function allows the caller to change the |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 405 | output of \fBkeyname\fP, i.e., |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 406 | it determines whether to use the \*(``M\-\*('' prefix |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 407 | for \*(``meta\*('' keys (codes in the range 128 to 255). |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 408 | Both \fBuse_legacy_coding\fP(3X) and \fBmeta\fP(3X) succeed only after |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 409 | curses is initialized. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 410 | X/Open Curses does not document the treatment of codes 128 to 159. |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 411 | When treating them as \*(``meta\*('' keys |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 412 | (or if \fBkeyname\fP is called before initializing curses), |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 413 | this implementation returns strings \*(``M\-^@\*('', \*(``M\-^A\*('', etc. |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 414 | .PP |
| 415 | X/Open Curses documents \fBunctrl\fP as declared in \fB<unctrl.h>\fP, |
| 416 | which \fI\%ncurses\fP does. |
| 417 | However, \fI\%ncurses\fP' \fB<curses.h>\fP includes \fB<unctrl.h>\fP, |
| 418 | matching the behavior of SVr4 curses. |
| 419 | Other implementations may not do that. |
| 420 | .SS "use_env, use_tioctl" |
| 421 | If \fI\%ncurses\fP is configured to provide the sp-functions extension, |
| 422 | the state of \fBuse_env\fP and \fBuse_tioctl\fP may be updated before |
| 423 | creating each \fIscreen\fP rather than once only |
| 424 | (\fBcurs_sp_funcs\fP(3X)). |
| 425 | This feature of \fBuse_env\fP |
| 426 | is not provided by other implementations of curses. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 427 | .SH SEE ALSO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 428 | \fB\%curses\fP(3X), |
| 429 | \fB\%curs_initscr\fP(3X), |
| 430 | \fB\%curs_inopts\fP(3X), |
| 431 | \fB\%curs_kernel\fP(3X), |
| 432 | \fB\%curs_scr_dump\fP(3X), |
| 433 | \fB\%curs_sp_funcs\fP(3X), |
| 434 | \fB\%curs_variables\fP(3X), |
| 435 | \fB\%legacy_coding\fP(3X) |