summaryrefslogtreecommitdiffstats
path: root/upstream/opensuse-tumbleweed/man3/get_wch.3ncurses
blob: 9349b5e4b6166c3b3464432ca3654e118c56deb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
.\"***************************************************************************
.\" Copyright 2018-2023,2024 Thomas E. Dickey                                *
.\" Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
.\"                                                                          *
.\" Permission is hereby granted, free of charge, to any person obtaining a  *
.\" copy of this software and associated documentation files (the            *
.\" "Software"), to deal in the Software without restriction, including      *
.\" without limitation the rights to use, copy, modify, merge, publish,      *
.\" distribute, distribute with modifications, sublicense, and/or sell       *
.\" copies of the Software, and to permit persons to whom the Software is    *
.\" furnished to do so, subject to the following conditions:                 *
.\"                                                                          *
.\" The above copyright notice and this permission notice shall be included  *
.\" in all copies or substantial portions of the Software.                   *
.\"                                                                          *
.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
.\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
.\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
.\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
.\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
.\"                                                                          *
.\" Except as contained in this notice, the name(s) of the above copyright   *
.\" holders shall not be used in advertising or otherwise to promote the     *
.\" sale, use or other dealings in this Software without prior written       *
.\" authorization.                                                           *
.\"***************************************************************************
.\"
.\" $Id: curs_get_wch.3x,v 1.40 2024/04/20 19:23:03 tom Exp $
.TH get_wch 3NCURSES 2024-04-20 "ncurses 6.5" "Library calls"
.ie \n(.g \{\
.ds `` \(lq
.ds '' \(rq
.\}
.el \{\
.ie t .ds `` ``
.el   .ds `` ""
.ie t .ds '' ''
.el   .ds '' ""
.\}
.
.de bP
.ie n  .IP \(bu 4
.el    .IP \(bu 2
..
.SH NAME
\fB\%get_wch\fP,
\fB\%wget_wch\fP,
\fB\%mvget_wch\fP,
\fB\%mvwget_wch\fP,
\fB\%unget_wch\fP \-
get (or push back) a wide character from \fIcurses\fR terminal keyboard
.SH SYNOPSIS
.nf
\fB#include <ncursesw/curses.h>
.PP
\fBint get_wch(wint_t *\fIwch\fP);
\fBint wget_wch(WINDOW *\fIwin\fP, wint_t *\fIwch\fP);
\fBint mvget_wch(int \fIy\fP, int \fIx\fP, wint_t *\fIwch\fP);
\fBint mvwget_wch(WINDOW *\fIwin\fP, int \fIy\fP, int \fIx\fP, wint_t *\fIwch\fP);
.PP
\fBint unget_wch(const wchar_t \fIwc\fP);
.fi
.SH DESCRIPTION
.SS "Reading Characters"
.B \%wget_wch
gathers a key stroke
.I wch
from the terminal keyboard associated with a
.I curses
window
.IR win ,
returning
.B OK
if a wide character is read,
.B \%KEY_CODE_YES
if a function key is read,
and
.B ERR
if no key event is available.
\fB\%ncurses\fP(3NCURSES) describes the variants of this function.
.PP
When input is pending,
.B \%wget_wch
stores an integer
identifying the key stroke in
.IR wch ;
for alphanumeric and punctuation keys,
this value corresponds to the character encoding used by the terminal.
Use of the control key as a modifier often results in a distinct code.
The behavior of other keys depends on whether
.I win
is in keypad mode;
see subsections \*(``Keypad Mode\*('' and \*(``Predefined Key Codes\*(''
in \fB\%getch\fP(3NCURSES).
.PP
If no input is pending,
then if the no-delay flag is set in the window
(see \fB\%nodelay\fP(3NCURSES)),
the function returns
.BR ERR ;
otherwise,
.I curses
waits until the terminal has input.
If \fB\%cbreak\fP(3NCURSES)
has been called,
this happens after one character is read.
If \fB\%nocbreak\fP(3NCURSES)
has been called,
it occurs when the next newline is read.
If \fB\%halfdelay\fP(3NCURSES)
has been called,
.I curses
waits until a character is typed or the specified delay elapses.
.PP
If \fB\%echo\fP(3NCURSES) has been called,
and the window is not a pad,
.I curses
writes
.I wch
to the window
(at the cursor position)
per the following rules.
.bP
If
.I wch
matches the terminal's erase character,
the cursor moves leftward one position
and the new position is erased
as if \fB\%wmove\fP(3NCURSES) and then \fB\%wdelch\fP(3NCURSES) were called.
When the window's keypad mode is enabled
(see below),
.B \%KEY_LEFT
and
.B \%KEY_BACKSPACE
are handled the same way.
.bP
.I curses
writes any other
.I wch
to the window,
as with \fB\%wecho_wchar\fP(3NCURSES).
.bP
If the window has been moved or modified since the last call to
\fB\%wrefresh\fP(3NCURSES),
.I curses
calls
.BR \%wrefresh .
.PP
If
.I wch
is a carriage return and \fB\%nl\fP(3NCURSES) has been called,
.B \%wgetch
stores the the character code for newline
(line feed)
in
.I wch
instead.
.SS "Ungetting Characters"
.B \%unget_wch
places
.I wch
into the input queue to be returned by the next call to
.BR \%wget_wch .
A single input queue serves all windows.
.SH RETURN VALUE
.B \%wget_wch
returns
.B OK
when it reads a wide character and
.B \%KEY_CODE_YES
when it reads a function key code.
It returns
.B ERR
if
.bP
the
.I \%WINDOW
pointer is
.BR NULL ,
or
.bP
its timeout expires without any data arriving,
or
.bP
execution was interrupted by a signal,
in which case
.B \%errno
is set to
.BR \%EINTR .
.PP
Functions prefixed with \*(``mv\*('' first perform cursor movement and
fail if the position
.RI ( y ,
.IR x )
is outside the window boundaries.
.PP
.B \%unget_wch
returns
.B OK
on success and
.B ERR
if there is no more room in the input queue.
.SH NOTES
See the \*(``NOTES\*('' section of \fB\%wgetch\fP(3NCURSES).
.PP
All of these functions except
.B \%wget_wch
and
.B \%unget_wch
may be implemented as macros.
.PP
Unlike \fB\%wgetch\fP(3NCURSES),
.B \%wget_wch
and its variants store the value of the input character in an additional
.I wch
parameter instead of the return value.
.PP
Unlike
.BR \%ungetch ,
.B \%unget_wch
cannot distinguish function key codes
.B \%wget_wch
from conventional character codes.
An application can overcome this limitation by pushing function key
codes with
.B \%ungetch
and subsequently checking the return value of
.B \%wget_wch
for a match with
.BR \%KEY_CODE_YES .
.SH EXTENSIONS
See the \*(``EXTENSIONS\*('' section of \fB\%wgetch\fP(3NCURSES).
.SH PORTABILITY
Applications employing
.I \%ncurses
extensions should condition their use on the visibility of the
.B \%NCURSES_VERSION
preprocessor macro.
.PP
X/Open Curses,
Issue 4 describes these functions.
It specifies no error conditions for them.
.PP
See the \*(``PORTABILITY\*('' section of \fB\%wgetch\fP(3NCURSES) regarding
the interaction of
.B \%wget_wch
with signal handlers.
.SH SEE ALSO
\fB\%getch\fP(3NCURSES) describes comparable functions of the
.I \%ncurses
library in its non-wide-character configuration.
.PP
\fB\%ncurses\fP(3NCURSES),
\fB\%add_wch\fP(3NCURSES),
\fB\%inopts\fP(3NCURSES),
\fB\%move\fP(3NCURSES),
\fB\%refresh\fP(3NCURSES)