Copyright 2018-2023,2024 Thomas E. Dickey *
Copyright 2002-2016,2017 Free Software Foundation, Inc. *
*
Permission is hereby granted, free of charge, to any person obtaining a *
copy of this software and associated documentation files (the *
"Software"), to deal in the Software without restriction, including *
without limitation the rights to use, copy, modify, merge, publish, *
distribute, distribute with modifications, sublicense, and/or sell *
copies of the Software, and to permit persons to whom the Software is *
furnished to do so, subject to the following conditions: *
*
The above copyright notice and this permission notice shall be included *
in all copies or substantial portions of the Software. *
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
*
Except as contained in this notice, the name(s) of the above copyright *
holders shall not be used in advertising or otherwise to promote the *
sale, use or other dealings in this Software without prior written *
authorization. *
***************************************************************************
$Id: curs_get_wch.3x,v 1.40 2024/04/20 19:23:03 tom Exp $
#include <curses.h>int get_wch(wint_t *wch); int wget_wch(WINDOW *win, wint_t *wch); int mvget_wch(int y, int x, wint_t *wch); int mvwget_wch(WINDOW *win, int y, int x, wint_t *wch);
int unget_wch(const wchar_t wc);
When input is pending, \%wget_wch stores an integer identifying the key stroke in wch ; for alphanumeric and punctuation keys, this value corresponds to the character encoding used by the terminal. Use of the control key as a modifier often results in a distinct code. The behavior of other keys depends on whether win is in keypad mode; see subsections \*(``Keypad Mode\*('' and \*(``Predefined Key Codes\*('' in \%getch(3X).
If no input is pending, then if the no-delay flag is set in the window (see \%nodelay(3X)), the function returns ERR ; otherwise, curses waits until the terminal has input. If \%cbreak(3X) has been called, this happens after one character is read. If \%nocbreak(3X) has been called, it occurs when the next newline is read. If \%halfdelay(3X) has been called, curses waits until a character is typed or the specified delay elapses.
If \%echo(3X) has been called, and the window is not a pad, curses writes wch to the window (at the cursor position) per the following rules. .bP If wch matches the terminal's erase character, the cursor moves leftward one position and the new position is erased as if \%wmove(3X) and then \%wdelch(3X) were called. When the window's keypad mode is enabled (see below), \%KEY_LEFT and \%KEY_BACKSPACE are handled the same way. .bP curses writes any other wch to the window, as with \%wecho_wchar(3X). .bP If the window has been moved or modified since the last call to \%wrefresh(3X), curses calls \%wrefresh .
If wch is a carriage return and nl(3X) has been called, \%wgetch stores the the character code for newline (line feed) in wch instead.
Functions prefixed with \*(``mv\*('' first perform cursor movement and fail if the position ( y , x ) is outside the window boundaries.
\%unget_wch returns OK on success and ERR if there is no more room in the input queue.
All of these functions except \%wget_wch and \%unget_wch may be implemented as macros.
Unlike \%wgetch(3X), \%wget_wch and its variants store the value of the input character in an additional wch parameter instead of the return value.
Unlike \%ungetch , \%unget_wch cannot distinguish function key codes \%wget_wch from conventional character codes. An application can overcome this limitation by pushing function key codes with \%ungetch and subsequently checking the return value of \%wget_wch for a match with \%KEY_CODE_YES .
X/Open Curses, Issue 4 describes these functions. It specifies no error conditions for them.
See the \*(``PORTABILITY\*('' section of \%wgetch(3X) regarding the interaction of \%wget_wch with signal handlers.
\%curses(3X), \%curs_add_wch(3X), \%curs_inopts(3X), \%curs_move(3X), \%curs_refresh(3X)