Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | .\"*************************************************************************** |
| 2 | .\" Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * |
| 3 | .\" * |
| 4 | .\" Permission is hereby granted, free of charge, to any person obtaining a * |
| 5 | .\" copy of this software and associated documentation files (the * |
| 6 | .\" "Software"), to deal in the Software without restriction, including * |
| 7 | .\" without limitation the rights to use, copy, modify, merge, publish, * |
| 8 | .\" distribute, distribute with modifications, sublicense, and/or sell * |
| 9 | .\" copies of the Software, and to permit persons to whom the Software is * |
| 10 | .\" furnished to do so, subject to the following conditions: * |
| 11 | .\" * |
| 12 | .\" The above copyright notice and this permission notice shall be included * |
| 13 | .\" in all copies or substantial portions of the Software. * |
| 14 | .\" * |
| 15 | .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 16 | .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 17 | .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 18 | .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 19 | .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 20 | .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 21 | .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 22 | .\" * |
| 23 | .\" Except as contained in this notice, the name(s) of the above copyright * |
| 24 | .\" holders shall not be used in advertising or otherwise to promote the * |
| 25 | .\" sale, use or other dealings in this Software without prior written * |
| 26 | .\" authorization. * |
| 27 | .\"*************************************************************************** |
| 28 | .\" |
| 29 | .\" $Id: curs_util.3x,v 1.27 2008/10/25 23:45:41 tom Exp $ |
| 30 | .TH curs_util 3X "" |
| 31 | .na |
| 32 | .hy 0 |
| 33 | .SH NAME |
| 34 | \fBdelay_output\fR, |
| 35 | \fBfilter\fR, |
| 36 | \fBflushinp\fR, |
| 37 | \fBgetwin\fR, |
| 38 | \fBkey_name\fR, |
| 39 | \fBkeyname\fR, |
| 40 | \fBnofilter\fR, |
| 41 | \fBputwin\fR, |
| 42 | \fBunctrl\fR, |
| 43 | \fBuse_env\fR, |
| 44 | \fBwunctrl\fR - miscellaneous \fBcurses\fR utility routines |
| 45 | .ad |
| 46 | .hy |
| 47 | .SH SYNOPSIS |
| 48 | \fB#include <curses.h>\fR |
| 49 | .sp |
| 50 | \fBchar *unctrl(chtype c);\fR |
| 51 | .br |
| 52 | \fBwchar_t *wunctrl(cchar_t *c);\fR |
| 53 | .br |
| 54 | \fBchar *keyname(int c);\fR |
| 55 | .br |
| 56 | \fBchar *key_name(wchar_t w);\fR |
| 57 | .br |
| 58 | \fBvoid filter(void);\fR |
| 59 | .br |
| 60 | \fBvoid nofilter(void);\fR |
| 61 | .br |
| 62 | \fBvoid use_env(bool f);\fR |
| 63 | .br |
| 64 | \fBint putwin(WINDOW *win, FILE *filep);\fR |
| 65 | .br |
| 66 | \fBWINDOW *getwin(FILE *filep);\fR |
| 67 | .br |
| 68 | \fBint delay_output(int ms);\fR |
| 69 | .br |
| 70 | \fBint flushinp(void);\fR |
| 71 | .br |
| 72 | .SH DESCRIPTION |
| 73 | The \fBunctrl\fR routine returns a character string which is a printable |
| 74 | representation of the character \fIc\fR, ignoring attributes. |
| 75 | Control characters are displayed in the \fB^\fR\fIX\fR notation. |
| 76 | Printing characters are displayed as is. |
| 77 | The corresponding \fBwunctrl\fR returns a printable representation of |
| 78 | a wide-character. |
| 79 | .PP |
| 80 | The \fBkeyname\fR routine returns a character string corresponding to the key \fIc\fR: |
| 81 | .RS 3 |
| 82 | .TP 3 |
| 83 | - |
| 84 | Printable characters are displayed as themselves, e.g., a one-character string containing the key. |
| 85 | .TP 3 |
| 86 | - |
| 87 | Control characters are displayed in the \fB^\fR\fIX\fR notation. |
| 88 | .TP 3 |
| 89 | - |
| 90 | DEL (character 127) is displayed as \fB^?\fP. |
| 91 | .TP 3 |
| 92 | - |
| 93 | Values above 128 are either meta characters |
| 94 | (if the screen has not been initialized, |
| 95 | or if \fBmeta\fP has been called with a TRUE parameter), |
| 96 | shown in the \fBM-\fR\fIX\fR notation, |
| 97 | or are displayed as themselves. |
| 98 | In the latter case, the values may not be printable; |
| 99 | this follows the X/Open specification. |
| 100 | .TP 3 |
| 101 | - |
| 102 | Values above 256 may be the names of the names of function keys. |
| 103 | .TP 3 |
| 104 | - |
| 105 | Otherwise (if there is no corresponding name) the function returns null, |
| 106 | to denote an error. |
| 107 | X/Open also lists an "UNKNOWN KEY" return value, which some implementations |
| 108 | return rather than null. |
| 109 | .RE |
| 110 | .LP |
| 111 | The corresponding \fBkey_name\fR returns a character string corresponding |
| 112 | to the wide-character value \fIw\fR. |
| 113 | The two functions do not return the same set of strings; |
| 114 | the latter returns null where the former would display a meta character. |
| 115 | .PP |
| 116 | The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or |
| 117 | \fBnewterm\fR are called. The effect is that, during those calls, \fBLINES\fR |
| 118 | is set to 1; the capabilities \fBclear\fR, \fBcup\fR, \fBcud\fR, \fBcud1\fR, |
| 119 | \fBcuu1\fR, \fBcuu\fR, \fBvpa\fR are disabled; and the \fBhome\fR string is |
| 120 | set to the value of \fBcr\fR. |
| 121 | .PP |
| 122 | The \fBnofilter\fP routine cancels the effect of a preceding \fBfilter\fP |
| 123 | call. |
| 124 | That allows the caller to initialize a screen on a different device, |
| 125 | using a different value of \fB$TERM\fP. |
| 126 | The limitation arises because the \fBfilter\fP routine modifies the |
| 127 | in-memory copy of the terminal information. |
| 128 | .PP |
| 129 | The \fBuse_env\fR routine, if used, is called before \fBinitscr\fR or |
| 130 | \fBnewterm\fR are called. When called with \fBFALSE\fR as an |
| 131 | argument, the values of \fBlines\fR and \fBcolumns\fR specified in the |
| 132 | \fIterminfo\fR database will be used, even if environment variables |
| 133 | \fBLINES\fR and \fBCOLUMNS\fR (used by default) are set, or if |
| 134 | \fBcurses\fR is running in a window (in which case default behavior |
| 135 | would be to use the window size if \fBLINES\fR and \fBCOLUMNS\fR are |
| 136 | not set). |
| 137 | Note that setting \fBLINES\fR or \fBCOLUMNS\fR overrides the |
| 138 | corresponding size which may be obtained from the operating system. |
| 139 | .PP |
| 140 | The \fBputwin\fR routine writes all data associated with window \fIwin\fR into |
| 141 | the file to which \fIfilep\fR points. This information can be later retrieved |
| 142 | using the \fBgetwin\fR function. |
| 143 | .PP |
| 144 | The \fBgetwin\fR routine reads window related data stored in the file by |
| 145 | \fBputwin\fR. The routine then creates and initializes a new window using that |
| 146 | data. It returns a pointer to the new window. |
| 147 | .PP |
| 148 | The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause |
| 149 | in output. This routine should not be used extensively because |
| 150 | padding characters are used rather than a CPU pause. |
| 151 | If no padding character is specified, this uses \fBnapms\fR to perform the delay. |
| 152 | .PP |
| 153 | The \fBflushinp\fR routine throws away any typeahead that has been typed by the |
| 154 | user and has not yet been read by the program. |
| 155 | .SH RETURN VALUE |
| 156 | Except for \fBflushinp\fR, routines that return an integer return \fBERR\fR |
| 157 | upon failure and \fBOK\fR (SVr4 specifies only "an integer value other than |
| 158 | \fBERR\fR") upon successful completion. |
| 159 | .PP |
| 160 | Routines that return pointers return \fBNULL\fR on error. |
| 161 | .PP |
| 162 | X/Open does not define any error conditions. |
| 163 | In this implementation |
| 164 | .RS 3 |
| 165 | .TP 5 |
| 166 | \fBflushinp\fR |
| 167 | returns an error if the terminal was not initialized. |
| 168 | .TP 5 |
| 169 | \fBmeta\fR |
| 170 | returns an error if the terminal was not initialized. |
| 171 | .TP 5 |
| 172 | \fBputwin\fP |
| 173 | returns an error if the associated \fBfwrite\fP calls return an error. |
| 174 | .RE |
| 175 | .SH PORTABILITY |
| 176 | The XSI Curses standard, Issue 4 describes these functions. |
| 177 | It states that \fBunctrl\fR and \fBwunctrl\fR will return a null pointer if |
| 178 | unsuccessful, but does not define any error conditions. |
| 179 | This implementation checks for three cases: |
| 180 | .RS |
| 181 | .TP 5 |
| 182 | - |
| 183 | the parameter is a 7-bit US-ASCII code. |
| 184 | This is the case that X/Open Curses documented. |
| 185 | .TP 5 |
| 186 | - |
| 187 | the parameter is in the range 128-159, i.e., a C1 control code. |
| 188 | If \fBuse_legacy_coding\fP has been called with a \fB2\fP parameter, |
| 189 | \fBunctrl\fP returns the parameter, i.e., a one-character string with |
| 190 | the parameter as the first character. |
| 191 | Otherwise, it returns ``~@'', ``~A'', etc., analogous to ``^@'', ``^A'', C0 controls. |
| 192 | .IP |
| 193 | X/Open Curses does not document whether \fBunctrl\fP can be called before |
| 194 | initializing curses. |
| 195 | This implementation permits that, |
| 196 | and returns the ``~@'', etc., values in that case. |
| 197 | .TP 5 |
| 198 | - |
| 199 | parameter values outside the 0 to 255 range. |
| 200 | \fBunctrl\fP returns a null pointer. |
| 201 | .RE |
| 202 | .PP |
| 203 | The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest |
| 204 | terms. The description here is adapted from the XSI Curses standard (which |
| 205 | erroneously fails to describe the disabling of \fBcuu\fR). |
| 206 | .PP |
| 207 | The strings returned by \fBunctrl\fR in this implementation are determined |
| 208 | at compile time, |
| 209 | showing C1 controls from the upper-128 codes with a `~' prefix rather than `^'. |
| 210 | Other implementations have different conventions. |
| 211 | For example, they may show both sets of control characters with `^', |
| 212 | and strip the parameter to 7 bits. |
| 213 | Or they may ignore C1 controls and treat all of the upper-128 codes as |
| 214 | printable. |
| 215 | This implementation uses 8 bits but does not modify the string to reflect |
| 216 | locale. |
| 217 | The \fBuse_legacy_coding\fP function allows the caller to |
| 218 | change the output of \fBunctrl\fP. |
| 219 | .PP |
| 220 | Likewise, the \fBmeta\fP function allows the caller to change the |
| 221 | output of \fBkeyname\fP, i.e., |
| 222 | it determines whether to use the `M-' prefix |
| 223 | for ``meta'' keys (codes in the range 128 to 255). |
| 224 | Both \fBuse_legacy_coding\fP and \fBmeta\fP succeed only after |
| 225 | curses is initialized. |
| 226 | X/Open Curses does not document the treatment of codes 128 to 159. |
| 227 | When treating them as ``meta'' keys |
| 228 | (or if \fBkeyname\fP is called before initializing curses), |
| 229 | this implementation returns strings ``M-^@'', ``M-^A'', etc. |
| 230 | .PP |
| 231 | The \fBkeyname\fP function may return the names of user-defined |
| 232 | string capabilities which are defined in the terminfo entry via the \fB-x\fP |
| 233 | option of \fBtic\fP. |
| 234 | This implementation automatically assigns at run-time keycodes to |
| 235 | user-defined strings which begin with "k". |
| 236 | The keycodes start at KEY_MAX, but are not guaranteed to be |
| 237 | the same value for different runs because user-defined codes are |
| 238 | merged from all terminal descriptions which have been loaded. |
| 239 | The \fBuse_extended_names\fP function controls whether this data is |
| 240 | loaded when the terminal description is read by the library. |
| 241 | .PP |
| 242 | The \fBnofilter\fP routine is specific to ncurses. |
| 243 | It was not supported on Version 7, BSD or System V implementations. |
| 244 | It is recommended that any code depending on ncurses extensions |
| 245 | be conditioned using NCURSES_VERSION. |
| 246 | .SH SEE ALSO |
| 247 | \fBlegacy_coding\fR(3X), |
| 248 | \fBcurses\fR(3X), |
| 249 | \fBcurs_initscr\fR(3X), |
| 250 | \fBcurs_kernel\fR(3X), |
| 251 | \fBcurs_scr_dump\fR(3X), |
| 252 | \fBlegacy_coding\fR(3X). |
| 253 | .\"# |
| 254 | .\"# The following sets edit modes for GNU EMACS |
| 255 | .\"# Local Variables: |
| 256 | .\"# mode:nroff |
| 257 | .\"# fill-column:79 |
| 258 | .\"# End: |