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