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