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