]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_get_wch.3x
ncurses 6.0 - patch 20160702
[ncurses.git] / man / curs_get_wch.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2002-2012,2016 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_get_wch.3x,v 1.9 2016/05/15 01:12:50 tom Exp $
30 .TH curs_get_wch 3X ""
31 .na
32 .hy 0
33 .de bP
34 .IP \(bu 4
35 ..
36 .SH NAME
37 \fBget_wch\fR,
38 \fBwget_wch\fR,
39 \fBmvget_wch\fR,
40 \fBmvwget_wch\fR,
41 \fBunget_wch\fR \- get (or push back) a wide character from curses terminal keyboard
42 .ad
43 .hy
44 .SH SYNOPSIS
45 \fB#include <curses.h>\fR
46 .sp
47 \fBint get_wch(wint_t *\fR\fIwch\fR\fB);\fR
48 .br
49 \fBint wget_wch(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
50 .br
51 \fBint mvget_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
52 .br
53 \fBint mvwget_wch(WINDOW *\fR\fIwin\fR\fB, int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
54 .br
55 \fBint unget_wch(const wchar_t \fR\fIwch\fR\fB);\fR
56 .SH DESCRIPTION
57 The
58 \fBget_wch\fR,
59 \fBwget_wch\fR,
60 \fBmvget_wch\fR, and
61 \fBmvwget_wch\fR
62 functions read a character
63 from the terminal associated with the current or specified window.
64 In no-delay mode,
65 if no input is waiting, the value \fBERR\fR is returned.
66 In delay mode,
67 the program waits until the system passes text through to the program.
68 Depending on the setting of \fBcbreak\fR,
69 this is after one character (cbreak mode),
70 or after the first newline (nocbreak mode).
71 In half-delay mode,
72 the program waits until the user types a character or the specified
73 timeout interval has elapsed.
74 .PP
75 Unless \fBnoecho\fR has been set,
76 these routines echo the character into the designated window.
77 .PP
78 If the window is not a pad and has been moved or modified since the
79 last call to \fBwrefresh\fR,
80 \fBwrefresh\fR will be called before another character is read.
81 .PP
82 If \fBkeypad\fR is enabled,
83 these functions respond to
84 the pressing of a function key by setting the object pointed to by
85 \fIwch\fR
86 to the keycode assigned to the function key,
87 and returning \fBKEY_CODE_YES\fR.
88 If a character (such as escape) that could be the
89 beginning of a function key is received, curses sets a timer.
90 If the remainder
91 of the sequence does arrive within the designated time, curses passes through
92 the character; otherwise, curses returns the function key value.
93 For this
94 reason, many terminals experience a delay between the time a user presses
95 the escape key and the time the escape is returned to the program.
96 .PP
97 The keycodes returned by these functions are the same as those
98 returned by \fBwgetch\fP:
99 .bP
100 The predefined function
101 keys are listed in \fB<curses.h>\fR as macros with values outside the range
102 of 8-bit characters.
103 Their names begin with \fBKEY_\fR.
104 .bP
105 Other (user-defined) function keys which may be defined using \fBdefine_key\fP(3X)
106 have no names, but also are expected to have values outside the range of
107 8-bit characters.
108 .PP
109 The
110 \fBunget_wch\fR
111 function pushes the wide character
112 \fIwch\fR
113 back onto the head of the input queue, so the wide character
114 is returned by the next call to
115 \fBget_wch\fR.
116 The pushback of
117 one character is guaranteed.
118 If the program calls
119 \fBunget_wch\fR
120 too many times without an intervening call to
121 \fBget_wch\fR,
122 the operation may fail.
123 .SH NOTES
124 The header file
125 \fB<curses.h>\fR
126 automatically
127 includes the header file
128 \fB<stdio.h>\fR.
129 .PP
130 Applications should not define the escape key by itself as a single-character
131 function.
132 .PP
133 When using
134 \fBget_wch\fR,
135 \fBwget_wch\fR,
136 \fBmvget_wch\fR, or
137 \fBmvwget_wch\fR, applications should
138 not use
139 \fBnocbreak\fR
140 mode and
141 \fBecho\fR
142 mode
143 at the same time.
144 Depending on the state of the tty driver when each character
145 is typed, the program may produce undesirable results.
146 .PP
147 All functions except \fBwget_wch\fR and \fBunget_wch\fR
148 may be macros.
149 .SH RETURN VALUE
150 When
151 \fBget_wch\fR,
152 \fBwget_wch\fR,
153 \fBmvget_wch\fR, and
154 \fBmvwget_wch\fR
155 functions successfully
156 report the pressing of a function key, they return
157 \fBKEY_CODE_YES\fR.
158 When they successfully report a wide character, they return
159 \fBOK\fR.
160 Otherwise, they return
161 \fBERR\fR.
162 .PP
163 Upon successful completion,
164 \fBunget_wch\fR
165 returns
166 \fBOK\fR.
167 Otherwise, the function returns
168 \fBERR\fR.
169 .PP
170 Functions with a "mv" prefix first perform a cursor movement using
171 \fBwmove\fP, and return an error if the position is outside the window,
172 or if the window pointer is null.
173 .SH SEE ALSO
174 \fBcurses\fR(3X),
175 \fBcurs_getch\fR(3X),
176 \fBcurs_ins_wch\fR(3X),
177 \fBcurs_inopts\fR(3X),
178 \fBcurs_move\fR(3X),
179 \fBcurs_refresh\fR(3X)