]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_util.3x
ncurses 5.6 - patch 20070310
[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.23 2007/02/24 15:59:07 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 .PP
150 The SVr4 documentation describes the action of \fBfilter\fR only in the vaguest
151 terms.  The description here is adapted from the XSI Curses standard (which
152 erroneously fails to describe the disabling of \fBcuu\fR).
153 .PP
154 The strings returned by \fBunctrl\fR in this implementation are determined
155 at compile time,
156 showing C1 controls from the upper-128 codes with a `~' prefix rather than `^'.
157 Other implementations have different conventions.
158 For example, they may show both sets of control characters with `^',
159 and strip the parameter to 7 bits.
160 Or they may ignore C1 controls and treat all of the upper-1280 codes as
161 printable.
162 This implementation uses 8 bits but does not modify the string to reflect
163 locale.
164 The \fBuse_legacy_coding\fP function allows the caller to
165 change the output of \fBunctrl\fP.
166 .PP
167 The \fBkeyname\fP function may return the names of user-defined
168 string capabilities which are defined in the terminfo entry via the \fB-x\fP
169 option of \fBtic\fP.
170 This implementation automatically assigns at run-time keycodes to 
171 user-defined strings which begin with "k".
172 The keycodes start at KEY_MAX, but are not guaranteed to be 
173 the same value for different runs because user-defined codes are
174 merged from all terminal descriptions which have been loaded.
175 .PP
176 The \fBnofilter\fP routine is specific to ncurses.
177 It was not supported on Version 7, BSD or System V implementations.
178 It is recommended that any code depending on ncurses extensions
179 be conditioned using NCURSES_VERSION.
180 .SH SEE ALSO
181 \fBlegacy_coding\fR(3X),
182 \fBcurses\fR(3X),
183 \fBcurs_initscr\fR(3X),
184 \fBcurs_kernel\fR(3X),
185 \fBcurs_scr_dump\fR(3X).
186 .\"#
187 .\"# The following sets edit modes for GNU EMACS
188 .\"# Local Variables:
189 .\"# mode:nroff
190 .\"# fill-column:79
191 .\"# End: