]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_get_wch.3x
ncurses 6.4 - patch 20231125
[ncurses.git] / man / curs_get_wch.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 2002-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
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:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
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.                               *
23 .\"                                                                          *
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       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: curs_get_wch.3x,v 1.30 2023/11/25 13:58:47 tom Exp $
31 .TH curs_get_wch 3X 2023-11-25 "ncurses 6.4" "Library calls"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .\}
36 .el \{\
37 .ie t .ds `` ``
38 .el   .ds `` ""
39 .ie t .ds '' ''
40 .el   .ds '' ""
41 .\}
42 .
43 .de bP
44 .ie n  .IP \(bu 4
45 .el    .IP \(bu 2
46 ..
47 .SH NAME
48 \fB\%get_wch\fP,
49 \fB\%wget_wch\fP,
50 \fB\%mvget_wch\fP,
51 \fB\%mvwget_wch\fP,
52 \fB\%unget_wch\fP \-
53 get (or push back) a wide character from \fIcurses\fR terminal keyboard
54 .SH SYNOPSIS
55 .nf
56 \fB#include <curses.h>
57 .PP
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);
62 .PP
63 \fBint unget_wch(const wchar_t \fIwch\fP);
64 .fi
65 .SH DESCRIPTION
66 .SS wget_wch
67 The
68 \fBget_wch\fP,
69 \fBwget_wch\fP,
70 \fBmvget_wch\fP, and
71 \fBmvwget_wch\fP
72 functions read a character
73 from the terminal associated with the current or specified window.
74 In no-delay mode,
75 if no input is waiting, the value \fBERR\fP is returned.
76 In delay mode,
77 the program waits until the system passes text through to the program.
78 Depending on the setting of \fBcbreak\fP,
79 this is after one character (cbreak mode),
80 or after the first newline (nocbreak mode).
81 In half-delay mode,
82 the program waits until the user types a character or the specified
83 timeout interval has elapsed.
84 .PP
85 Unless \fBnoecho\fP has been set,
86 these routines echo the character into the designated window.
87 .PP
88 If the window is not a pad and has been moved or modified since the
89 last call to \fBwrefresh\fP,
90 \fBwrefresh\fP will be called before another character is read.
91 .PP
92 If \fBkeypad\fP is enabled,
93 these functions respond to
94 the pressing of a function key by setting the object pointed to by
95 \fIwch\fP
96 to the keycode assigned to the function key,
97 and returning \fBKEY_CODE_YES\fP.
98 If a character (such as escape) that could be the
99 beginning of a function key is received, curses sets a timer.
100 If the remainder
101 of the sequence does arrive within the designated time, curses passes through
102 the character; otherwise, curses returns the function key value.
103 For this
104 reason, many terminals experience a delay between the time a user presses
105 the escape key and the time the escape is returned to the program.
106 .PP
107 The keycodes returned by these functions are the same as those
108 returned by \fBwgetch\fP:
109 .bP
110 The predefined function
111 keys are listed in \fB<curses.h>\fP as macros with values outside the range
112 of 8-bit characters.
113 Their names begin with \fBKEY_\fP.
114 .bP
115 Other (user-defined) function keys
116 which may be defined using \fBdefine_key\fP(3X) have no names,
117 but also are expected to have values outside the range of 8-bit characters.
118 .SS unget_wch
119 The
120 \fBunget_wch\fP
121 function pushes the wide character
122 \fIwch\fP
123 back onto the head of the input queue, so the wide character
124 is returned by the next call to
125 \fBget_wch\fP.
126 The pushback of
127 one character is guaranteed.
128 If the program calls
129 \fBunget_wch\fP
130 too many times without an intervening call to
131 \fBget_wch\fP,
132 the operation may fail.
133 .PP
134 Unlike \fBungetch\fP and \fBwgetch\fP,
135 \fBunget_wch\fP cannot distinguish special characters
136 returned by \fBwget_wch\fP from ordinary characters.
137 An application can push special keys
138 which it may read via \fBwget_wch\fP
139 by checking for the \fBKEY_CODE_YES\fP result,
140 and using \fBungetch\fP for those special keys.
141 .SH RETURN VALUE
142 When
143 \fBget_wch\fP,
144 \fBwget_wch\fP,
145 \fBmvget_wch\fP, and
146 \fBmvwget_wch\fP
147 functions successfully
148 report the pressing of a function key, they return
149 \fBKEY_CODE_YES\fP.
150 When they successfully report a wide character, they return
151 \fBOK\fP.
152 Otherwise, they return
153 \fBERR\fP.
154 .PP
155 Upon successful completion,
156 \fBunget_wch\fP
157 returns
158 \fBOK\fP.
159 Otherwise, the function returns
160 \fBERR\fP.
161 .PP
162 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
163 \fBwmove\fP, and return an error if the position is outside the window,
164 or if the window pointer is null.
165 .SH NOTES
166 Applications should not define the escape key by itself as a single-character
167 function.
168 .PP
169 When using
170 \fBget_wch\fP,
171 \fBwget_wch\fP,
172 \fBmvget_wch\fP, or
173 \fBmvwget_wch\fP, applications should
174 not use
175 \fBnocbreak\fP
176 mode and
177 \fBecho\fP
178 mode
179 at the same time.
180 Depending on the state of the tty driver when each character
181 is typed, the program may produce undesirable results.
182 .PP
183 All of these symbols except
184 \fB\%wget_wch\fP and
185 \fB\%unget_wch\fP
186 may be available as macros.
187 .SH PORTABILITY
188 These functions are described in the XSI Curses standard, Issue 4.
189 .SH SEE ALSO
190 \fB\%curses\fP(3X),
191 \fB\%curs_getch\fP(3X),
192 \fB\%curs_inopts\fP(3X),
193 \fB\%curs_ins_wch\fP(3X),
194 \fB\%curs_move\fP(3X),
195 \fB\%curs_refresh\fP(3X)