]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_get_wch.3x
ncurses 6.2 - patch 20200919
[ncurses.git] / man / curs_get_wch.3x
1 .\"***************************************************************************
2 .\" Copyright 2018-2019,2020 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.13 2020/02/02 23:34:34 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 .br
61 \fBint unget_wch(const wchar_t \fR\fIwch\fR\fB);\fR
62 .SH DESCRIPTION
63 The
64 \fBget_wch\fR,
65 \fBwget_wch\fR,
66 \fBmvget_wch\fR, and
67 \fBmvwget_wch\fR
68 functions read a character
69 from the terminal associated with the current or specified window.
70 In no-delay mode,
71 if no input is waiting, the value \fBERR\fR is returned.
72 In delay mode,
73 the program waits until the system passes text through to the program.
74 Depending on the setting of \fBcbreak\fR,
75 this is after one character (cbreak mode),
76 or after the first newline (nocbreak mode).
77 In half-delay mode,
78 the program waits until the user types a character or the specified
79 timeout interval has elapsed.
80 .PP
81 Unless \fBnoecho\fR has been set,
82 these routines echo the character into the designated window.
83 .PP
84 If the window is not a pad and has been moved or modified since the
85 last call to \fBwrefresh\fR,
86 \fBwrefresh\fR will be called before another character is read.
87 .PP
88 If \fBkeypad\fR is enabled,
89 these functions respond to
90 the pressing of a function key by setting the object pointed to by
91 \fIwch\fR
92 to the keycode assigned to the function key,
93 and returning \fBKEY_CODE_YES\fR.
94 If a character (such as escape) that could be the
95 beginning of a function key is received, curses sets a timer.
96 If the remainder
97 of the sequence does arrive within the designated time, curses passes through
98 the character; otherwise, curses returns the function key value.
99 For this
100 reason, many terminals experience a delay between the time a user presses
101 the escape key and the time the escape is returned to the program.
102 .PP
103 The keycodes returned by these functions are the same as those
104 returned by \fBwgetch\fP:
105 .bP
106 The predefined function
107 keys are listed in \fB<curses.h>\fR as macros with values outside the range
108 of 8-bit characters.
109 Their names begin with \fBKEY_\fR.
110 .bP
111 Other (user-defined) function keys
112 which may be defined using \fBdefine_key\fP(3X) have no names,
113 but also are expected to have values outside the range of 8-bit characters.
114 .PP
115 The
116 \fBunget_wch\fR
117 function pushes the wide character
118 \fIwch\fR
119 back onto the head of the input queue, so the wide character
120 is returned by the next call to
121 \fBget_wch\fR.
122 The pushback of
123 one character is guaranteed.
124 If the program calls
125 \fBunget_wch\fR
126 too many times without an intervening call to
127 \fBget_wch\fR,
128 the operation may fail.
129 .SH NOTES
130 The header file
131 \fB<curses.h>\fR
132 automatically
133 includes the header file
134 \fB<stdio.h>\fR.
135 .PP
136 Applications should not define the escape key by itself as a single-character
137 function.
138 .PP
139 When using
140 \fBget_wch\fR,
141 \fBwget_wch\fR,
142 \fBmvget_wch\fR, or
143 \fBmvwget_wch\fR, applications should
144 not use
145 \fBnocbreak\fR
146 mode and
147 \fBecho\fR
148 mode
149 at the same time.
150 Depending on the state of the tty driver when each character
151 is typed, the program may produce undesirable results.
152 .PP
153 All functions except \fBwget_wch\fR and \fBunget_wch\fR
154 may be macros.
155 .SH RETURN VALUE
156 When
157 \fBget_wch\fR,
158 \fBwget_wch\fR,
159 \fBmvget_wch\fR, and
160 \fBmvwget_wch\fR
161 functions successfully
162 report the pressing of a function key, they return
163 \fBKEY_CODE_YES\fR.
164 When they successfully report a wide character, they return
165 \fBOK\fR.
166 Otherwise, they return
167 \fBERR\fR.
168 .PP
169 Upon successful completion,
170 \fBunget_wch\fR
171 returns
172 \fBOK\fR.
173 Otherwise, the function returns
174 \fBERR\fR.
175 .PP
176 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
177 \fBwmove\fP, and return an error if the position is outside the window,
178 or if the window pointer is null.
179 .SH SEE ALSO
180 \fBcurses\fR(3X),
181 \fBcurs_getch\fR(3X),
182 \fBcurs_ins_wch\fR(3X),
183 \fBcurs_inopts\fR(3X),
184 \fBcurs_move\fR(3X),
185 \fBcurs_refresh\fR(3X)