05c8042d7ce3c67905eadd078f68ee5c2755f4a9
[dragonfly.git] / lib / libncurses / man / curs_get_wch.3
1 .\"***************************************************************************
2 .\" Copyright (c) 2002,2003 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.5 2003/05/10 20:33:49 jmc Exp $
30 .\" $DragonFly: src/lib/libncurses/man/curs_get_wch.3,v 1.1 2005/03/12 19:13:54 eirikn Exp $
31 .TH curs_get_wch 3X ""
32 .SH NAME
33 \fBget_wch\fR,
34 \fBwget_wch\fR,
35 \fBmvget_wch\fR,
36 \fBmvwget_wch\fR,
37 \fBunget_wch\fR \- get (or push back) a wide character from curses terminal keyboard
38 .SH SYNOPSIS
39 \fB#include <curses.h>\fR
40 .sp
41 \fBint get_wch(wint_t *\fR\fIwch\fR\fB);\fR
42 .br
43 \fBint wget_wch(WINDOW *\fR\fIwin\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
44 .br
45 \fBint mvget_wch(int \fR\fIy\fR\fB, int \fR\fIx\fR\fB, wint_t *\fR\fIwch\fR\fB);\fR
46 .br
47 \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
48 .br
49 \fBint unget_wch(const wchar_t \fR\fIwch\fR\fB);\fR
50 .SH DESCRIPTION
51 The
52 \fBget_wch\fR,
53 \fBwget_wch\fR,
54 \fBmvget_wch\fR, and
55 \fBmvwget_wch\fR
56 functions read a character
57 from the terminal associated with the current or specified window.
58 In no-delay mode,
59 if no input is waiting, the value \fBERR\fR is returned.
60 In delay mode,
61 the program waits until the system passes text through to the program.
62 Depending on the setting of \fBcbreak\fR,
63 this is after one character (cbreak mode),
64 or after the first newline (nocbreak mode).
65 In half-delay mode,
66 the program waits until the user types a character or the specified
67 timeout interval has elapsed.
68
69 Unless \fBnoecho\fR has been set,
70 these routines echo the character into the designated window.
71
72 If the window is not a pad and has been moved or modified since the
73 last call to \fBwrefresh\fR,
74 \fBwrefresh\fR will be called before another character is read.
75
76 If \fBkeypad\fR is enabled,
77 these functions respond to
78 the pressing of a function key by setting the object pointed to by
79 \fIwch\fR
80 to the corresponding
81 \fBKEY_\fR
82 value defined
83 in
84 \fB<curses.h>\fR
85 and returning
86 \fBKEY_CODE_YES\fR.
87 If a character (such as escape) that could be the
88 beginning of a function key is received, curses sets a timer.
89 If the remainder
90 of the sequence does arrive within the designated time, curses passes through
91 the character; otherwise, curses returns the function key value.
92 For this
93 reason, many terminals experience a delay between the time a user presses
94 the escape key and the time the escape is returned to the program.
95 .PP
96 The
97 \fBunget_wch\fR
98 function pushes the wide character
99 \fIwch\fR
100 back onto the head of the input queue, so the wide character
101 is returned by the next call to
102 \fBget_wch\fR.
103 The pushback of
104 one character is guaranteed.
105 If the program calls
106 \fBunget_wch\fR
107 too many times without an intervening call to
108 \fBget_wch\fR,
109 the operation may fail.
110 .SH NOTES
111 The header file
112 \fB<curses.h>\fR
113 automatically
114 includes the header file
115 \fB<stdio.h>\fR.
116 .PP
117 Applications should not define the escape key by itself as a single-character
118 function.
119 .PP
120 When using
121 \fBget_wch\fR,
122 \fBwget_wch\fR,
123 \fBmvget_wch\fR, or
124 \fBmvwget_wch\fR, applications should
125 not use
126 \fBnocbreak\fR
127 mode and
128 \fBecho\fR
129 mode
130 at the same time.
131 Depending on the state of the tty driver when each character
132 is typed, the program may produce undesirable results.
133 .PP
134 All functions except \fBwget_wch\fR and \fBunget_wch\fR
135 may be macros.
136 .SH RETURN VALUES
137 When
138 \fBget_wch\fR,
139 \fBwget_wch\fR,
140 \fBmvget_wch\fR, and
141 \fBmvwget_wch\fR
142 functions successfully
143 report the pressing of a function key, they return
144 \fBKEY_CODE_YES\fR.
145 When they successfully report a wide character, they return
146 \fBOK\fR.
147 Otherwise, they return
148 \fBERR\fR.
149 .PP
150 Upon successful completion,
151 \fBunget_wch\fR
152 returns
153 \fBOK\fR.
154 Otherwise, the function returns
155 \fBERR\fR.
156 .SH SEE ALSO
157 \fBcurses\fR(3X),
158 \fBcurs_getch\fR(3X),
159 \fBcurs_ins_wch\fR(3X),
160 \fBcurs_inopts\fR(3X),
161 \fBcurs_move\fR(3X),
162 \fBcurs_refresh\fR(3X)