при использовании ncurses в голой консоли (не в xterm!) getch() не различает клавиши
Left и Shift+Left,Ctrl+Left и т.д. и т.п.
Но mc отлавливаеть сочетания клавиш с Shift/Ctrl.
Вопрос: в ncurses есть какой-то механизм для отслеживания нажатия Shift/Ctrl/Alt или mc работает с клавиатурой в обход ncurses?
ncurses getch()
Модератор: Модераторы разделов
-
lubyagin
- Сообщения: 1
- ОС: Debian GNU/Linux
Re: ncurses getch()
Чтобы разбирать scan-codes "вручную", необходимо вызвать keypad() со значением "1".
man 3ncurses keypad
int keypad(WINDOW *win, bool bf);
The keypad option enables the keypad of the user’s terminal. If enabled (bf is TRUE), the user can press a function
key (such as an arrow key) and wgetch returns a single value representing the function key, as in KEY_LEFT. If dis‐
abled (bf is FALSE), curses does not treat function keys specially and the program has to interpret the escape se‐
quences itself. If the keypad in the terminal can be turned on (made to transmit) and off (made to work locally),
turning on this option causes the terminal keypad to be turned on when wgetch is called. The default value for key‐
pad is false.
man 3ncurses wgetch
int getch(void);
int wgetch(WINDOW *win);
If keypad is TRUE, and a function key is pressed, the token for that function key is returned instead of the raw
characters. Possible function keys are defined in <curses.h> as macros with values outside the range of 8-bit char‐
acters whose names begin with KEY_. 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), curses 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 ex‐
perience a delay between the time a user presses the escape key and the escape is returned to the program.
Function Keys
The following function keys, defined in <curses.h>, might be returned by getch if keypad has been enabled. Note
that not all of these are necessarily supported on any particular terminal.
NOTES
Use of the escape key by a programmer for a single character function is discouraged, as it will cause a delay of up
to one second while the keypad code looks for a following function-key sequence.
Historically, the set of keypad macros was largely defined by the extremely function-key-rich keyboard of the AT&T
7300, aka 3B1, aka Safari 4. Modern personal computers usually have only a small subset of these. IBM PC-style
consoles typically support little more than KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_NPAGE,
KEY_PPAGE, and function keys 1 through 12. The Ins key is usually mapped to KEY_IC.
P.S. Scan-codes обычной клавиатуры можно посмотреть, например, во 2-ом томе БСП ("Библиотеки Системного Программиста") братьев Фроловых.
man 3ncurses keypad
int keypad(WINDOW *win, bool bf);
The keypad option enables the keypad of the user’s terminal. If enabled (bf is TRUE), the user can press a function
key (such as an arrow key) and wgetch returns a single value representing the function key, as in KEY_LEFT. If dis‐
abled (bf is FALSE), curses does not treat function keys specially and the program has to interpret the escape se‐
quences itself. If the keypad in the terminal can be turned on (made to transmit) and off (made to work locally),
turning on this option causes the terminal keypad to be turned on when wgetch is called. The default value for key‐
pad is false.
man 3ncurses wgetch
int getch(void);
int wgetch(WINDOW *win);
If keypad is TRUE, and a function key is pressed, the token for that function key is returned instead of the raw
characters. Possible function keys are defined in <curses.h> as macros with values outside the range of 8-bit char‐
acters whose names begin with KEY_. 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), curses 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 ex‐
perience a delay between the time a user presses the escape key and the escape is returned to the program.
Function Keys
The following function keys, defined in <curses.h>, might be returned by getch if keypad has been enabled. Note
that not all of these are necessarily supported on any particular terminal.
NOTES
Use of the escape key by a programmer for a single character function is discouraged, as it will cause a delay of up
to one second while the keypad code looks for a following function-key sequence.
Historically, the set of keypad macros was largely defined by the extremely function-key-rich keyboard of the AT&T
7300, aka 3B1, aka Safari 4. Modern personal computers usually have only a small subset of these. IBM PC-style
consoles typically support little more than KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_NPAGE,
KEY_PPAGE, and function keys 1 through 12. The Ins key is usually mapped to KEY_IC.
P.S. Scan-codes обычной клавиатуры можно посмотреть, например, во 2-ом томе БСП ("Библиотеки Системного Программиста") братьев Фроловых.
Alexander Lubyagin, http://lubyagin.discrete.ru/