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