📄 curs_getch.3x.html
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><!-- * t **************************************************************************** * Copyright (c) 1998-2003,2005 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_getch.3x,v 1.29 2005/06/25 22:03:09 tom Exp @--><HTML><HEAD><TITLE>curs_getch 3x</TITLE><link rev=made href="mailto:bug-ncurses@gnu.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD><BODY><H1>curs_getch 3x</H1><HR><PRE><!-- Manpage converted by man2html 3.0.1 --><STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG> <STRONG><A HREF="curs_getch.3x.html">curs_getch(3x)</A></STRONG></PRE><H2>NAME</H2><PRE> <STRONG>getch</STRONG>, <STRONG>wgetch</STRONG>, <STRONG>mvgetch</STRONG>, <STRONG>mvwgetch</STRONG>, <STRONG>ungetch</STRONG>, <STRONG>has_key</STRONG> - get (or push back) characters from <STRONG>curses</STRONG> terminal keyboard</PRE><H2>SYNOPSIS</H2><PRE> <STRONG>#include</STRONG> <STRONG><curses.h></STRONG> <STRONG>int</STRONG> <STRONG>getch(void);</STRONG> <STRONG>int</STRONG> <STRONG>wgetch(WINDOW</STRONG> <STRONG>*win);</STRONG> <STRONG>int</STRONG> <STRONG>mvgetch(int</STRONG> <STRONG>y,</STRONG> <STRONG>int</STRONG> <STRONG>x);</STRONG> <STRONG>int</STRONG> <STRONG>mvwgetch(WINDOW</STRONG> <STRONG>*win,</STRONG> <STRONG>int</STRONG> <STRONG>y,</STRONG> <STRONG>int</STRONG> <STRONG>x);</STRONG> <STRONG>int</STRONG> <STRONG>ungetch(int</STRONG> <STRONG>ch);</STRONG> <STRONG>int</STRONG> <STRONG>has_key(int</STRONG> <STRONG>ch);</STRONG></PRE><H2>DESCRIPTION</H2><PRE> The <STRONG>getch</STRONG>, <STRONG>wgetch</STRONG>, <STRONG>mvgetch</STRONG> and <STRONG>mvwgetch</STRONG>, routines read a character from the window. In no-delay mode, if no input is waiting, the value <STRONG>ERR</STRONG> is returned. In delay mode, the program waits until the system passes text through to the program. Depending on the setting of <STRONG>cbreak</STRONG>, this is af- ter one character (cbreak mode), or after the first new- line (nocbreak mode). In half-delay mode, the program waits until a character is typed or the specified timeout has been reached. Unless <STRONG>noecho</STRONG> has been set, then the character will also be echoed into the designated window according to the fol- lowing rules: If the character is the current erase char- acter, left arrow, or backspace, the cursor is moved one space to the left and that screen position is erased as if <STRONG>delch</STRONG> had been called. If the character value is any oth- er <STRONG>KEY_</STRONG> define, the user is alerted with a <STRONG>beep</STRONG> call. Otherwise the character is simply output to the screen. If the window is not a pad, and it has been moved or modi- fied since the last call to <STRONG>wrefresh</STRONG>, <STRONG>wrefresh</STRONG> will be called before another character is read. If <STRONG>keypad</STRONG> is <STRONG>TRUE</STRONG>, and a function key is pressed, the to- ken for that function key is returned instead of the raw characters. Possible function keys are defined in <STRONG><curs-</STRONG> <STRONG>es.h></STRONG> as macros with values outside the range of 8-bit characters whose names begin with <STRONG>KEY_</STRONG>. Thus, a variable intended to hold the return value of a function key must be of short size or larger. When a character that could be the beginning of a function key is received (which, on modern terminals, means an es- cape character), <STRONG>curses</STRONG> sets a timer. If the remainder of the sequence does not come in within the designated time, the character is passed through; otherwise, the function key value is returned. For this reason, many terminals experience a delay between the time a user presses the es- cape key and the escape is returned to the program. The <STRONG>ungetch</STRONG> routine places <EM>ch</EM> back onto the input queue to be returned by the next call to <STRONG>wgetch</STRONG>. There is just one input queue for all windows. <STRONG>Function</STRONG> <STRONG>Keys</STRONG> The following function keys, defined in <STRONG><curses.h></STRONG>, might be returned by <STRONG>getch</STRONG> if <STRONG>keypad</STRONG> has been enabled. Note that not all of these are necessarily supported on any particular terminal. <EM>Name</EM> <EM>Key</EM> <EM>name</EM> KEY_BREAK Break key KEY_DOWN The four arrow keys ... KEY_UP KEY_LEFT KEY_RIGHT KEY_HOME Home key (upward+left arrow) KEY_BACKSPACE Backspace KEY_F0 Function keys; space for 64 keys is reserved. KEY_F(<EM>n</EM>) For 0 <= <EM>n</EM> <= 63 KEY_DL Delete line KEY_IL Insert line KEY_DC Delete character KEY_IC Insert char or enter insert mode KEY_EIC Exit insert char mode KEY_CLEAR Clear screen KEY_EOS Clear to end of screen KEY_EOL Clear to end of line KEY_SF Scroll 1 line forward KEY_SR Scroll 1 line backward (reverse) KEY_NPAGE Next page KEY_PPAGE Previous page KEY_STAB Set tab KEY_CTAB Clear tab KEY_CATAB Clear all tabs KEY_ENTER Enter or send KEY_SRESET Soft (partial) reset KEY_RESET Reset or hard reset KEY_PRINT Print or copy KEY_LL Home down or bottom (lower left) KEY_A1 Upper left of keypad KEY_A3 Upper right of keypad KEY_B2 Center of keypad KEY_C1 Lower left of keypad KEY_C3 Lower right of keypad KEY_BTAB Back tab key KEY_BEG Beg(inning) key KEY_CANCEL Cancel key KEY_CLOSE Close key KEY_COMMAND Cmd (command) key KEY_COPY Copy key KEY_CREATE Create key KEY_END End key KEY_EXIT Exit key KEY_FIND Find key KEY_HELP Help key KEY_MARK Mark key
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -