1 .\"***************************************************************************
2 .\" Copyright 2018-2021,2022 Thomas E. Dickey *
3 .\" Copyright 2002-2016,2017 Free Software Foundation, Inc. *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a *
6 .\" copy of this software and associated documentation files (the *
7 .\" "Software"), to deal in the Software without restriction, including *
8 .\" without limitation the rights to use, copy, modify, merge, publish, *
9 .\" distribute, distribute with modifications, sublicense, and/or sell *
10 .\" copies of the Software, and to permit persons to whom the Software is *
11 .\" furnished to do so, subject to the following conditions: *
13 .\" The above copyright notice and this permission notice shall be included *
14 .\" in all copies or substantial portions of the Software. *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 .\" Except as contained in this notice, the name(s) of the above copyright *
25 .\" holders shall not be used in advertising or otherwise to promote the *
26 .\" sale, use or other dealings in this Software without prior written *
28 .\"***************************************************************************
30 .\" $Id: curs_get_wch.3x,v 1.17 2022/02/12 20:07:29 tom Exp $
31 .TH curs_get_wch 3X ""
47 \fBunget_wch\fP \- get (or push back) a wide character from curses terminal keyboard
51 \fB#include <curses.h>\fP
53 \fBint get_wch(wint_t *\fIwch\fB);\fR
55 \fBint wget_wch(WINDOW *\fIwin\fB, wint_t *\fIwch\fB);\fR
57 \fBint mvget_wch(int \fIy\fB, int \fIx\fB, wint_t *\fIwch\fB);\fR
59 \fBint mvwget_wch(WINDOW *\fIwin\fB, int \fIy\fB, int \fIx\fB, wint_t *\fIwch\fB);\fR
61 \fBint unget_wch(const wchar_t \fIwch\fB);\fR
69 functions read a character
70 from the terminal associated with the current or specified window.
72 if no input is waiting, the value \fBERR\fP is returned.
74 the program waits until the system passes text through to the program.
75 Depending on the setting of \fBcbreak\fP,
76 this is after one character (cbreak mode),
77 or after the first newline (nocbreak mode).
79 the program waits until the user types a character or the specified
80 timeout interval has elapsed.
82 Unless \fBnoecho\fP has been set,
83 these routines echo the character into the designated window.
85 If the window is not a pad and has been moved or modified since the
86 last call to \fBwrefresh\fP,
87 \fBwrefresh\fP will be called before another character is read.
89 If \fBkeypad\fP is enabled,
90 these functions respond to
91 the pressing of a function key by setting the object pointed to by
93 to the keycode assigned to the function key,
94 and returning \fBKEY_CODE_YES\fP.
95 If a character (such as escape) that could be the
96 beginning of a function key is received, curses sets a timer.
98 of the sequence does arrive within the designated time, curses passes through
99 the character; otherwise, curses returns the function key value.
101 reason, many terminals experience a delay between the time a user presses
102 the escape key and the time the escape is returned to the program.
104 The keycodes returned by these functions are the same as those
105 returned by \fBwgetch\fP:
107 The predefined function
108 keys are listed in \fB<curses.h>\fP as macros with values outside the range
110 Their names begin with \fBKEY_\fP.
112 Other (user-defined) function keys
113 which may be defined using \fBdefine_key\fP(3X) have no names,
114 but also are expected to have values outside the range of 8-bit characters.
118 function pushes the wide character
120 back onto the head of the input queue, so the wide character
121 is returned by the next call to
124 one character is guaranteed.
127 too many times without an intervening call to
129 the operation may fail.
131 Unlike \fBungetch\fP and \fBwgetch\fP,
132 \fBunget_wch\fP cannot distinguish special characters
133 returned by \fBwget_wch\fP from ordinary characters.
134 An application can push special keys
135 which it may read via \fBwget_wch\fP
136 by checking for the \fBKEY_CODE_YES\fP result,
137 and using \fBungetch\fP for those special keys.
142 includes the header file
145 Applications should not define the escape key by itself as a single-character
152 \fBmvwget_wch\fP, applications should
159 Depending on the state of the tty driver when each character
160 is typed, the program may produce undesirable results.
162 All functions except \fBwget_wch\fP and \fBunget_wch\fP
170 functions successfully
171 report the pressing of a function key, they return
173 When they successfully report a wide character, they return
175 Otherwise, they return
178 Upon successful completion,
182 Otherwise, the function returns
185 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
186 \fBwmove\fP, and return an error if the position is outside the window,
187 or if the window pointer is null.
190 \fBcurs_getch\fP(3X),
191 \fBcurs_ins_wch\fP(3X),
192 \fBcurs_inopts\fP(3X),
194 \fBcurs_refresh\fP(3X)