]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/curs_get_wch.3x
ncurses 6.1 - patch 20191214
[ncurses.git] / man / curs_get_wch.3x
1 .\"***************************************************************************
2 .\" Copyright (c) 2002-2018,2019 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: curs_get_wch.3x,v 1.12 2019/11/30 21:06:30 tom Exp $
30 .TH curs_get_wch 3X ""
31 .na
32 .hy 0
33 .ie \n(.g .ds `` \(lq
34 .el       .ds `` ``
35 .ie \n(.g .ds '' \(rq
36 .el       .ds '' ''
37 .de bP
38 .ie n  .IP \(bu 4
39 .el    .IP \(bu 2
40 ..
41 .SH NAME
42 \fBget_wch\fR,
43 \fBwget_wch\fR,
44 \fBmvget_wch\fR,
45 \fBmvwget_wch\fR,
46 \fBunget_wch\fR \- get (or push back) a wide character from curses terminal keyboard
47 .ad
48 .hy
49 .SH SYNOPSIS
50 \fB#include <curses.h>\fR
51 .sp
52 \fBint get_wch(wint_t *\fR\fIwch\fR\fB);\fR
53 .br
54 \fBint wget_wch(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
55 .br
56 \fBint mvget_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
57 .br
58 \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
59 .br
60 \fBint unget_wch(const wchar_t \fR\fIwch\fR\fB);\fR
61 .SH DESCRIPTION
62 The
63 \fBget_wch\fR,
64 \fBwget_wch\fR,
65 \fBmvget_wch\fR, and
66 \fBmvwget_wch\fR
67 functions read a character
68 from the terminal associated with the current or specified window.
69 In no-delay mode,
70 if no input is waiting, the value \fBERR\fR is returned.
71 In delay mode,
72 the program waits until the system passes text through to the program.
73 Depending on the setting of \fBcbreak\fR,
74 this is after one character (cbreak mode),
75 or after the first newline (nocbreak mode).
76 In half-delay mode,
77 the program waits until the user types a character or the specified
78 timeout interval has elapsed.
79 .PP
80 Unless \fBnoecho\fR has been set,
81 these routines echo the character into the designated window.
82 .PP
83 If the window is not a pad and has been moved or modified since the
84 last call to \fBwrefresh\fR,
85 \fBwrefresh\fR will be called before another character is read.
86 .PP
87 If \fBkeypad\fR is enabled,
88 these functions respond to
89 the pressing of a function key by setting the object pointed to by
90 \fIwch\fR
91 to the keycode assigned to the function key,
92 and returning \fBKEY_CODE_YES\fR.
93 If a character (such as escape) that could be the
94 beginning of a function key is received, curses sets a timer.
95 If the remainder
96 of the sequence does arrive within the designated time, curses passes through
97 the character; otherwise, curses returns the function key value.
98 For this
99 reason, many terminals experience a delay between the time a user presses
100 the escape key and the time the escape is returned to the program.
101 .PP
102 The keycodes returned by these functions are the same as those
103 returned by \fBwgetch\fP:
104 .bP
105 The predefined function
106 keys are listed in \fB<curses.h>\fR as macros with values outside the range
107 of 8-bit characters.
108 Their names begin with \fBKEY_\fR.
109 .bP
110 Other (user-defined) function keys
111 which may be defined using \fBdefine_key\fP(3X) have no names,
112 but also are expected to have values outside the range of 8-bit characters.
113 .PP
114 The
115 \fBunget_wch\fR
116 function pushes the wide character
117 \fIwch\fR
118 back onto the head of the input queue, so the wide character
119 is returned by the next call to
120 \fBget_wch\fR.
121 The pushback of
122 one character is guaranteed.
123 If the program calls
124 \fBunget_wch\fR
125 too many times without an intervening call to
126 \fBget_wch\fR,
127 the operation may fail.
128 .SH NOTES
129 The header file
130 \fB<curses.h>\fR
131 automatically
132 includes the header file
133 \fB<stdio.h>\fR.
134 .PP
135 Applications should not define the escape key by itself as a single-character
136 function.
137 .PP
138 When using
139 \fBget_wch\fR,
140 \fBwget_wch\fR,
141 \fBmvget_wch\fR, or
142 \fBmvwget_wch\fR, applications should
143 not use
144 \fBnocbreak\fR
145 mode and
146 \fBecho\fR
147 mode
148 at the same time.
149 Depending on the state of the tty driver when each character
150 is typed, the program may produce undesirable results.
151 .PP
152 All functions except \fBwget_wch\fR and \fBunget_wch\fR
153 may be macros.
154 .SH RETURN VALUE
155 When
156 \fBget_wch\fR,
157 \fBwget_wch\fR,
158 \fBmvget_wch\fR, and
159 \fBmvwget_wch\fR
160 functions successfully
161 report the pressing of a function key, they return
162 \fBKEY_CODE_YES\fR.
163 When they successfully report a wide character, they return
164 \fBOK\fR.
165 Otherwise, they return
166 \fBERR\fR.
167 .PP
168 Upon successful completion,
169 \fBunget_wch\fR
170 returns
171 \fBOK\fR.
172 Otherwise, the function returns
173 \fBERR\fR.
174 .PP
175 Functions with a \*(``mv\*('' prefix first perform a cursor movement using
176 \fBwmove\fP, and return an error if the position is outside the window,
177 or if the window pointer is null.
178 .SH SEE ALSO
179 \fBcurses\fR(3X),
180 \fBcurs_getch\fR(3X),
181 \fBcurs_ins_wch\fR(3X),
182 \fBcurs_inopts\fR(3X),
183 \fBcurs_move\fR(3X),
184 \fBcurs_refresh\fR(3X)