]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_util.3x
ncurses 5.6 - patch 20081011
[ncurses.git] / man / curs_util.3x
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.26 2008/10/11 20:32:56 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
165 .TP 5
166 \fBflushinp\fR
167 returns an error if the terminal was not initialized.
168 .TP 5
169 \fBputwin\fP
170 returns an error if the associated \fBfwrite\fP calls return an error.
171 .RE
172 .SH PORTABILITY
173 The XSI Curses standard, Issue 4 describes these functions.
174 It states that \fBunctrl\fR and \fBwunctrl\fR will return a null pointer if
175 unsuccessful, but does not define any error conditions.
176 This implementation checks for three cases:
177 .RS
178 .TP 5
179 -
180 the parameter is a 7-bit US-ASCII code.
181 This is the case that X/Open Curses documented.
182 .TP 5
183 -
184 the parameter is in the range 128-159, i.e., a C1 control code.
185 If \fBuse_legacy_coding\fP has been called with a \fB2\fP parameter,
186 \fBunctrl\fP returns the parameter, i.e., a one-character string with
187 the parameter as the first character.
188 Otherwise, it returns ``~@'', ``~A'', etc., analogous to ``^@'', ``^A'', C0 controls.
189 .IP
190 X/Open Curses does not document whether \fBunctrl\fP can be called before
191 initializing curses.
192 This implementation permits that,
193 and returns the ``~@'', etc., values in that case.
194 .TP 5
195 -
196 parameter values outside the 0 to 255 range.
197 \fBunctrl\fP returns a null pointer.
198 .RE
199 .PP
200 The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest
201 terms.  The description here is adapted from the XSI Curses standard (which
202 erroneously fails to describe the disabling of \fBcuu\fR).
203 .PP
204 The strings returned by \fBunctrl\fR in this implementation are determined
205 at compile time,
206 showing C1 controls from the upper-128 codes with a `~' prefix rather than `^'.
207 Other implementations have different conventions.
208 For example, they may show both sets of control characters with `^',
209 and strip the parameter to 7 bits.
210 Or they may ignore C1 controls and treat all of the upper-128 codes as
211 printable.
212 This implementation uses 8 bits but does not modify the string to reflect
213 locale.
214 The \fBuse_legacy_coding\fP function allows the caller to
215 change the output of \fBunctrl\fP.
216 .PP
217 Likewise, the \fBmeta\fP function allows the caller to change the
218 output of \fBkeyname\fP, i.e.,
219 it determines whether to use the `M-' prefix
220 for ``meta'' keys (codes in the range 128 to 255).
221 Both \fBuse_legacy_coding\fP and \fBmeta\fP succeed only after
222 curses is initialized. 
223 X/Open Curses does not document the treatment of codes 128 to 159.
224 When treating them as ``meta'' keys
225 (or if \fBkeyname\fP is called before initializing curses),
226 this implementation returns strings ``M-^@'', ``M-^A'', etc.
227 .PP
228 The \fBkeyname\fP function may return the names of user-defined
229 string capabilities which are defined in the terminfo entry via the \fB-x\fP
230 option of \fBtic\fP.
231 This implementation automatically assigns at run-time keycodes to 
232 user-defined strings which begin with "k".
233 The keycodes start at KEY_MAX, but are not guaranteed to be 
234 the same value for different runs because user-defined codes are
235 merged from all terminal descriptions which have been loaded.
236 The \fBuse_extended_names\fP function controls whether this data is
237 loaded when the terminal description is read by the library.
238 .PP
239 The \fBnofilter\fP routine is specific to ncurses.
240 It was not supported on Version 7, BSD or System V implementations.
241 It is recommended that any code depending on ncurses extensions
242 be conditioned using NCURSES_VERSION.
243 .SH SEE ALSO
244 \fBlegacy_coding\fR(3X),
245 \fBcurses\fR(3X),
246 \fBcurs_initscr\fR(3X),
247 \fBcurs_kernel\fR(3X),
248 \fBcurs_scr_dump\fR(3X),
249 \fBlegacy_coding\fR(3X).
250 .\"#
251 .\"# The following sets edit modes for GNU EMACS
252 .\"# Local Variables:
253 .\"# mode:nroff
254 .\"# fill-column:79
255 .\"# End: