]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_util.3x
ncurses 5.6 - patch 20080823
[ncurses.git] / man / curs_util.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2006,2007 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.25 2007/05/26 21:44:42 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 Control characters are displayed in the \fB^\fR\fIX\fR notation.
82 Values above 128 are either meta characters, shown in the \fBM-\fR\fIX\fR notation,
83 or the names of function keys, or null.
84 The corresponding \fBkey_name\fR returns a character string corresponding
85 to the wide-character value \fIw\fR.
86 The two functions do not return the same set of strings;
87 the latter returns null where the former would display a meta character.
88 .PP
89 The \fBfilter\fR routine, if used, must be called before \fBinitscr\fR or
90 \fBnewterm\fR are called.  The effect is that, during those calls, \fBLINES\fR
91 is set to 1; the capabilities \fBclear\fR, \fBcup\fR, \fBcud\fR, \fBcud1\fR,
92 \fBcuu1\fR, \fBcuu\fR, \fBvpa\fR are disabled; and the \fBhome\fR string is
93 set to the value of \fBcr\fR.
94 .PP
95 The \fBnofilter\fP routine cancels the effect of a preceding \fBfilter\fP
96 call.
97 That allows the caller to initialize a screen on a different device,
98 using a different value of \fB$TERM\fP.
99 The limitation arises because the \fBfilter\fP routine modifies the
100 in-memory copy of the terminal information.
101 .PP
102 The \fBuse_env\fR routine, if used, is called before \fBinitscr\fR or
103 \fBnewterm\fR are called.  When called with \fBFALSE\fR as an
104 argument, the values of \fBlines\fR and \fBcolumns\fR specified in the
105 \fIterminfo\fR database will be used, even if environment variables
106 \fBLINES\fR and \fBCOLUMNS\fR (used by default) are set, or if
107 \fBcurses\fR is running in a window (in which case default behavior
108 would be to use the window size if \fBLINES\fR and \fBCOLUMNS\fR are
109 not set).
110 Note that setting \fBLINES\fR or \fBCOLUMNS\fR overrides the
111 corresponding size which may be obtained from the operating system.
112 .PP
113 The \fBputwin\fR routine writes all data associated with window \fIwin\fR into
114 the file to which \fIfilep\fR points.  This information can be later retrieved
115 using the \fBgetwin\fR function.
116 .PP
117 The \fBgetwin\fR routine reads window related data stored in the file by
118 \fBputwin\fR.  The routine then creates and initializes a new window using that
119 data.  It returns a pointer to the new window.
120 .PP
121 The \fBdelay_output\fR routine inserts an \fIms\fR millisecond pause
122 in output.  This routine should not be used extensively because
123 padding characters are used rather than a CPU pause.
124 If no padding character is specified, this uses \fBnapms\fR to perform the delay.
125 .PP
126 The \fBflushinp\fR routine throws away any typeahead that has been typed by the
127 user and has not yet been read by the program.
128 .SH RETURN VALUE
129 Except for \fBflushinp\fR, routines that return an integer return \fBERR\fR
130 upon failure and \fBOK\fR (SVr4 specifies only "an integer value other than
131 \fBERR\fR") upon successful completion.
132 .PP
133 Routines that return pointers return \fBNULL\fR on error.
134 .PP
135 X/Open does not define any error conditions.
136 In this implementation
137 .RS
138 .TP 5
139 \fBflushinp\fR
140 returns an error if the terminal was not initialized.
141 .TP 5
142 \fBputwin\fP
143 returns an error if the associated \fBfwrite\fP calls return an error.
144 .RE
145 .SH PORTABILITY
146 The XSI Curses standard, Issue 4 describes these functions.
147 It states that \fBunctrl\fR and \fBwunctrl\fR will return a null pointer if
148 unsuccessful, but does not define any error conditions.
149 This implementation checks for three cases:
150 .RS
151 .TP 5
152 -
153 the parameter is a 7-bit US-ASCII code.
154 This is the case that X/Open Curses documented.
155 .TP 5
156 -
157 the parameter is in the range 128-159, i.e., a C1 control code.
158 If \fBuse_legacy_coding\fP has been called with a \fB2\fP parameter,
159 \fBunctrl\fP returns the parameter, i.e., a one-character string with
160 the parameter as the first character.
161 Otherwise, it returns ``~@'', ``~A'', etc., analogous to ``^@'', ``^A'', C0 controls.
162 .IP
163 X/Open Curses does not document whether \fBunctrl\fP can be called before
164 initializing curses.
165 This implementation permits that,
166 and returns the ``~@'', etc., values in that case.
167 .TP 5
168 -
169 parameter values outside the 0 to 255 range.
170 \fBunctrl\fP returns a null pointer.
171 .RE
172 .PP
173 The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest
174 terms.  The description here is adapted from the XSI Curses standard (which
175 erroneously fails to describe the disabling of \fBcuu\fR).
176 .PP
177 The strings returned by \fBunctrl\fR in this implementation are determined
178 at compile time,
179 showing C1 controls from the upper-128 codes with a `~' prefix rather than `^'.
180 Other implementations have different conventions.
181 For example, they may show both sets of control characters with `^',
182 and strip the parameter to 7 bits.
183 Or they may ignore C1 controls and treat all of the upper-128 codes as
184 printable.
185 This implementation uses 8 bits but does not modify the string to reflect
186 locale.
187 The \fBuse_legacy_coding\fP function allows the caller to
188 change the output of \fBunctrl\fP.
189 .PP
190 Likewise, the \fBmeta\fP function allows the caller to change the
191 output of \fBkeyname\fP, i.e.,
192 it determines whether to use the `M-' prefix
193 for ``meta'' keys (codes in the range 128 to 255).
194 Both \fBuse_legacy_coding\fP and \fBmeta\fP succeed only after
195 curses is initialized. 
196 X/Open Curses does not document the treatment of codes 128 to 159.
197 When treating them as ``meta'' keys
198 (or if \fBkeyname\fP is called before initializing curses),
199 this implementation returns strings ``M-^@'', ``M-^A'', etc.
200 .PP
201 The \fBkeyname\fP function may return the names of user-defined
202 string capabilities which are defined in the terminfo entry via the \fB-x\fP
203 option of \fBtic\fP.
204 This implementation automatically assigns at run-time keycodes to 
205 user-defined strings which begin with "k".
206 The keycodes start at KEY_MAX, but are not guaranteed to be 
207 the same value for different runs because user-defined codes are
208 merged from all terminal descriptions which have been loaded.
209 .PP
210 The \fBnofilter\fP routine is specific to ncurses.
211 It was not supported on Version 7, BSD or System V implementations.
212 It is recommended that any code depending on ncurses extensions
213 be conditioned using NCURSES_VERSION.
214 .SH SEE ALSO
215 \fBlegacy_coding\fR(3X),
216 \fBcurses\fR(3X),
217 \fBcurs_initscr\fR(3X),
218 \fBcurs_kernel\fR(3X),
219 \fBcurs_scr_dump\fR(3X),
220 \fBlegacy_coding\fR(3X).
221 .\"#
222 .\"# The following sets edit modes for GNU EMACS
223 .\"# Local Variables:
224 .\"# mode:nroff
225 .\"# fill-column:79
226 .\"# End: