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