1 .\"***************************************************************************
2 .\" Copyright 2018-2023,2024 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.43 2024/06/08 20:25:25 tom Exp $
31 .TH curs_get_wch 3X 2024-06-08 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "Library calls"
53 get (or push back) a wide character from \fIcurses\fR terminal keyboard
56 \fB#include <curses.h>
58 \fBint get_wch(wint_t *\fIwch\fP);
59 \fBint wget_wch(WINDOW *\fIwin\fP, wint_t *\fIwch\fP);
60 \fBint mvget_wch(int \fIy\fP, int \fIx\fP, wint_t *\fIwch\fP);
61 \fBint mvwget_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wint_t *\fIwch\fP);
63 \fBint unget_wch(const wchar_t \fIwc\fP);
66 .SS "Reading Characters"
68 gathers a key event from the terminal keyboard associated with a
74 if a wide character is read,
76 if a function key is read,
79 if no key event is available.
80 \fB\%ncurses\fP(3X) describes the variants of this function.
82 When input is pending,
85 identifying the key event in
87 for alphanumeric and punctuation keys,
88 this value corresponds to the character encoding used by the terminal.
89 Use of the control key as a modifier,
90 by holding it down while pressing and releasing another key,
91 often results in a distinct code.
92 The behavior of other keys depends on whether
95 see subsections \*(``Keypad Mode\*('' and \*(``Predefined Key Codes\*(''
98 If no input is pending,
99 then if the no-delay flag is set in the window
100 (see \fB\%nodelay\fP(3X)),
105 waits until the terminal has input.
106 If \fB\%cbreak\fP(3X)
108 this happens after one character is read.
109 If \fB\%nocbreak\fP(3X) or \fB\%noraw\fP(3X)
111 it occurs when the next newline is read.
112 (Because the terminal's normal or \*(``cooked\*('' mode
116 calls may then be necessary to empty the input queue.)
117 If \fB\%halfdelay\fP(3X)
120 waits until input is available or the specified delay elapses.
122 If \fB\%echo\fP(3X) has been called,
123 and the window is not a pad,
125 writes the wide character
128 (at the cursor position)
129 per the following rules.
131 If the wide character
132 matches the terminal's erase character
133 (see \fB\%erasewchar\fP(3X)),
134 the cursor moves leftward one position
135 and the new position is erased
136 as if \fB\%wmove\fP(3X) and then \fB\%wdelch\fP(3X) were called.
137 When the window's keypad mode is enabled
142 are handled the same way.
148 as with \fB\%wecho_wchar\fP(3X).
152 has been moved or modified since the last call to
153 \fB\%wrefresh\fP(3X),
159 If the wide character
160 is a carriage return and \fBnl\fP(3X) has been called,
162 stores the the wide character code for line feed in
165 .SS "Ungetting Characters"
169 into the input queue to be retrieved by the next call to
171 A single input queue serves all windows associated with the terminal.
176 when it reads a wide character and
178 when it reads a function key code.
189 its timeout expires without any data arriving,
192 execution was interrupted by a signal,
198 Functions prefixed with \*(``mv\*('' first perform cursor movement and
202 is outside the window boundaries.
209 if there is no more room in the input queue.
211 See the \*(``NOTES\*('' section of \fB\%wgetch\fP(3X).
213 All of these functions except
217 may be implemented as macros.
219 Unlike \fB\%wgetch\fP(3X),
221 and its variants store the value of the input character in an additional
223 parameter instead of the return value.
228 cannot distinguish function key codes from conventional character codes.
229 An application can overcome this limitation by pushing function key
232 and subsequently checking the return value of
235 .BR \%KEY_CODE_YES "."
237 See the \*(``EXTENSIONS\*('' section of \fB\%wgetch\fP(3X).
239 Applications employing
241 extensions should condition their use on the visibility of the
246 Issue 4 describes these functions.
247 It specifies no error conditions for them.
249 See the \*(``PORTABILITY\*('' section of \fB\%wgetch\fP(3X) regarding
252 with signal handlers.
254 \fB\%curs_getch\fP(3X) describes comparable functions of the
256 library in its non-wide-character configuration.
259 \fB\%curs_add_wch\fP(3X),
260 \fB\%curs_inopts\fP(3X),
261 \fB\%curs_move\fP(3X),
262 \fB\%curs_refresh\fP(3X)