2 ****************************************************************************
3 * Copyright 2018-2023,2024 Thomas E. Dickey *
4 * Copyright 2002-2016,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: curs_get_wch.3x,v 1.40 2024/04/20 19:23:03 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>curs_get_wch 3x 2024-04-20 ncurses 6.4 Library calls</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">curs_get_wch 3x 2024-04-20 ncurses 6.4 Library calls</H1>
44 <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG> Library calls <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>get_wch</STRONG>, <STRONG>wget_wch</STRONG>, <STRONG>mvget_wch</STRONG>, <STRONG>mvwget_wch</STRONG>, <STRONG>unget_wch</STRONG> - get (or push
51 back) a wide character from <EM>curses</EM> terminal keyboard
54 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
55 <STRONG>#include</STRONG> <STRONG><curses.h></STRONG>
57 <STRONG>int</STRONG> <STRONG>get_wch(wint_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>);</STRONG>
58 <STRONG>int</STRONG> <STRONG>wget_wch(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>wint_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>);</STRONG>
59 <STRONG>int</STRONG> <STRONG>mvget_wch(int</STRONG> <EM>y</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>x</EM><STRONG>,</STRONG> <STRONG>wint_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>);</STRONG>
60 <STRONG>int</STRONG> <STRONG>mvwget_wch(WINDOW</STRONG> <STRONG>*</STRONG><EM>win</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>y</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>x</EM><STRONG>,</STRONG> <STRONG>wint_t</STRONG> <STRONG>*</STRONG><EM>wch</EM><STRONG>);</STRONG>
62 <STRONG>int</STRONG> <STRONG>unget_wch(const</STRONG> <STRONG>wchar_t</STRONG> <EM>wc</EM><STRONG>);</STRONG>
65 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
67 </PRE><H3><a name="h3-Reading-Characters">Reading Characters</a></H3><PRE>
68 <STRONG>wget_wch</STRONG> gathers a key stroke <EM>wch</EM> from the terminal keyboard associated
69 with a <EM>curses</EM> window <EM>win</EM>, returning <STRONG>OK</STRONG> if a wide character is read,
70 <STRONG>KEY_CODE_YES</STRONG> if a function key is read, and <STRONG>ERR</STRONG> if no key event is
71 available. <STRONG><A HREF="ncurses.3x.html">ncurses(3x)</A></STRONG> describes the variants of this function.
73 When input is pending, <STRONG>wget_wch</STRONG> stores an integer identifying the key
74 stroke in <EM>wch</EM>; for alphanumeric and punctuation keys, this value
75 corresponds to the character encoding used by the terminal. Use of the
76 control key as a modifier often results in a distinct code. The
77 behavior of other keys depends on whether <EM>win</EM> is in keypad mode; see
78 subsections "Keypad Mode" and "Predefined Key Codes" in <STRONG><A HREF="curs_getch.3x.html">getch(3x)</A></STRONG>.
80 If no input is pending, then if the no-delay flag is set in the window
81 (see <STRONG><A HREF="nodelay.3x.html">nodelay(3x)</A></STRONG>), the function returns <STRONG>ERR</STRONG>; otherwise, <EM>curses</EM> waits
82 until the terminal has input. If <STRONG><A HREF="curs_inopts.3x.html">cbreak(3x)</A></STRONG> has been called, this
83 happens after one character is read. If <STRONG><A HREF="curs_inopts.3x.html">nocbreak(3x)</A></STRONG> has been called,
84 it occurs when the next newline is read. If <STRONG><A HREF="curs_inopts.3x.html">halfdelay(3x)</A></STRONG> has been
85 called, <EM>curses</EM> waits until a character is typed or the specified delay
88 If <STRONG><A HREF="curs_inopts.3x.html">echo(3x)</A></STRONG> has been called, and the window is not a pad, <EM>curses</EM> writes
89 <EM>wch</EM> to the window (at the cursor position) per the following rules.
91 <STRONG>o</STRONG> If <EM>wch</EM> matches the terminal's erase character, the cursor moves
92 leftward one position and the new position is erased as if
93 <STRONG><A HREF="curs_move.3x.html">wmove(3x)</A></STRONG> and then <STRONG><A HREF="curs_delch.3x.html">wdelch(3x)</A></STRONG> were called. When the window's
94 keypad mode is enabled (see below), <STRONG>KEY_LEFT</STRONG> and <STRONG>KEY_BACKSPACE</STRONG> are
97 <STRONG>o</STRONG> <EM>curses</EM> writes any other <EM>wch</EM> to the window, as with <STRONG><A HREF="curs_add_wch.3x.html">wecho_wchar(3x)</A></STRONG>.
99 <STRONG>o</STRONG> If the window has been moved or modified since the last call to
100 <STRONG><A HREF="curs_refresh.3x.html">wrefresh(3x)</A></STRONG>, <EM>curses</EM> calls <STRONG>wrefresh</STRONG>.
102 If <EM>wch</EM> is a carriage return and <STRONG><A HREF="curs_inopts.3x.html">nl(3x)</A></STRONG> has been called, <STRONG>wgetch</STRONG> stores
103 the the character code for newline (line feed) in <EM>wch</EM> instead.
106 </PRE><H3><a name="h3-Ungetting-Characters">Ungetting Characters</a></H3><PRE>
107 <STRONG>unget_wch</STRONG> places <EM>wch</EM> into the input queue to be returned by the next
108 call to <STRONG>wget_wch</STRONG>. A single input queue serves all windows.
111 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
112 <STRONG>wget_wch</STRONG> returns <STRONG>OK</STRONG> when it reads a wide character and <STRONG>KEY_CODE_YES</STRONG>
113 when it reads a function key code. It returns <STRONG>ERR</STRONG> if
115 <STRONG>o</STRONG> the <EM>WINDOW</EM> pointer is <STRONG>NULL</STRONG>, or
117 <STRONG>o</STRONG> its timeout expires without any data arriving, or
119 <STRONG>o</STRONG> execution was interrupted by a signal, in which case <STRONG>errno</STRONG> is set
120 to <STRONG>EINTR</STRONG>.
122 Functions prefixed with "mv" first perform cursor movement and fail if
123 the position (<EM>y</EM>, <EM>x</EM>) is outside the window boundaries.
125 <STRONG>unget_wch</STRONG> returns <STRONG>OK</STRONG> on success and <STRONG>ERR</STRONG> if there is no more room in the
129 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
130 See the "NOTES" section of <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG>.
132 All of these functions except <STRONG>wget_wch</STRONG> and <STRONG>unget_wch</STRONG> may be implemented
135 Unlike <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG>, <STRONG>wget_wch</STRONG> and its variants store the value of the
136 input character in an additional <EM>wch</EM> parameter instead of the return
139 Unlike <STRONG>ungetch</STRONG>, <STRONG>unget_wch</STRONG> cannot distinguish function key codes
140 <STRONG>wget_wch</STRONG> from conventional character codes. An application can
141 overcome this limitation by pushing function key codes with <STRONG>ungetch</STRONG> and
142 subsequently checking the return value of <STRONG>wget_wch</STRONG> for a match with
143 <STRONG>KEY_CODE_YES</STRONG>.
146 </PRE><H2><a name="h2-EXTENSIONS">EXTENSIONS</a></H2><PRE>
147 See the "EXTENSIONS" section of <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG>.
150 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
151 Applications employing <EM>ncurses</EM> extensions should condition their use on
152 the visibility of the <STRONG>NCURSES_VERSION</STRONG> preprocessor macro.
154 X/Open Curses, Issue 4 describes these functions. It specifies no
155 error conditions for them.
157 See the "PORTABILITY" section of <STRONG><A HREF="curs_getch.3x.html">wgetch(3x)</A></STRONG> regarding the interaction
158 of <STRONG>wget_wch</STRONG> with signal handlers.
161 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
162 <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> describes comparable functions of the <EM>ncurses</EM> library in
163 its non-wide-character configuration.
165 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="curs_add_wch.3x.html">curs_add_wch(3x)</A></STRONG>, <STRONG><A HREF="curs_inopts.3x.html">curs_inopts(3x)</A></STRONG>, <STRONG><A HREF="curs_move.3x.html">curs_move(3x)</A></STRONG>,
166 <STRONG><A HREF="curs_refresh.3x.html">curs_refresh(3x)</A></STRONG>
170 ncurses 6.4 2024-04-20 <STRONG><A HREF="curs_get_wch.3x.html">curs_get_wch(3x)</A></STRONG>
174 <li><a href="#h2-NAME">NAME</a></li>
175 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
176 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
178 <li><a href="#h3-Reading-Characters">Reading Characters</a></li>
179 <li><a href="#h3-Ungetting-Characters">Ungetting Characters</a></li>
182 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
183 <li><a href="#h2-NOTES">NOTES</a></li>
184 <li><a href="#h2-EXTENSIONS">EXTENSIONS</a></li>
185 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
186 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>