mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-12 12:13:08 +00:00
Add some input support and updated readme
This commit is contained in:
parent
5e13f00121
commit
3a1e40ed49
27
Readme.md
27
Readme.md
@ -63,11 +63,28 @@ Also, Cursive currently expects every codepoint to be a one-column character, so
|
|||||||
|
|
||||||
### Input
|
### Input
|
||||||
|
|
||||||
The `key_codes` example can be a useful tool to see how the library reacts to various key presses.
|
* The `key_codes` example can be a useful tool to see how the library reacts to various key presses.
|
||||||
* **Basic set**: All simple key press (without shift, alt or ctrl pressed) should work in all terminals.
|
* Keep in mind that if the terminal has shortcuts registered, they probably won't be transmitted to the app.
|
||||||
* **Shift+keypress**: All characters keys (letters, numbers and punctuation) should work as expected.
|
* UTF-8 input should work fine in a unicode-enabled terminal emulator, but raw linux TTY may be more capricious.
|
||||||
* **UTF-8**: UTF-8 input should work fine in a unicode-enabled terminal emulator, but raw linux TTY may be more capricious.
|
|
||||||
* **Control codes**:
|
Here is the support table for input keys (All means Linux TTY and terminal emulators):
|
||||||
|
|
||||||
|
| | Key | Shift+Key | Ctrl+Key | Shift+Ctrl+Key |
|
||||||
|
|--------------------------|:----:|:----------------------:|:--------------------------:|:---------------:|
|
||||||
|
| Letters | All | All | All (except c,z,q,s,i,h,m) | None |
|
||||||
|
| Numbers | All | All | None (can crash the app) | None |
|
||||||
|
| Punctuation | All | All | None (can crash the app) | None |
|
||||||
|
| Enter, Esc | All | None | None | None |
|
||||||
|
| Left, Right arrow keys | All | VTE+Xterm | VTE+Xterm | VTE+Xterm |
|
||||||
|
| Up, Down arrow keys | All | Xterm | VTE+Xterm | Xterm |
|
||||||
|
| Ins | All | None (paste clipboard) | Xterm | None |
|
||||||
|
| Del | All | VTE+Xterm | VTE+Xterm | VTE+Xterm |
|
||||||
|
| Home, End | All | Xterm | Xterm | Xterm |
|
||||||
|
| PageUp, PageDown | All | None | Xterm | None |
|
||||||
|
| Fn keys: F1-F4 | All | None (WIP) | None (WIP) | None (WIP) |
|
||||||
|
| Fn keys: F5-F12 | All | VTE+Xterm (WIP) | VTE+Xterm (WIP) | VTE+Xterm (WIP) |
|
||||||
|
| PrtScn, ScrollLock | None | None | None | None |
|
||||||
|
| Window, Menu | None | None | None | None |
|
||||||
|
|
||||||
Contribute
|
Contribute
|
||||||
----------
|
----------
|
||||||
|
21
src/event.rs
21
src/event.rs
@ -35,13 +35,18 @@ pub enum Key {
|
|||||||
PageDown,
|
PageDown,
|
||||||
Backspace,
|
Backspace,
|
||||||
Home,
|
Home,
|
||||||
|
ShiftHome,
|
||||||
CtrlHome,
|
CtrlHome,
|
||||||
|
CtrlShiftHome,
|
||||||
End,
|
End,
|
||||||
|
ShiftEnd,
|
||||||
CtrlEnd,
|
CtrlEnd,
|
||||||
|
CtrlShiftEnd,
|
||||||
/// Delete key
|
/// Delete key
|
||||||
Del,
|
Del,
|
||||||
ShiftDel,
|
ShiftDel,
|
||||||
CtrlDel,
|
CtrlDel,
|
||||||
|
CtrlShiftDel,
|
||||||
/// Insert key
|
/// Insert key
|
||||||
Ins,
|
Ins,
|
||||||
CtrlIns,
|
CtrlIns,
|
||||||
@ -55,6 +60,8 @@ pub enum Key {
|
|||||||
ShiftRight,
|
ShiftRight,
|
||||||
CtrlShiftLeft,
|
CtrlShiftLeft,
|
||||||
CtrlShiftRight,
|
CtrlShiftRight,
|
||||||
|
CtrlShiftUp,
|
||||||
|
CtrlShiftDown,
|
||||||
CtrlLeft,
|
CtrlLeft,
|
||||||
CtrlRight,
|
CtrlRight,
|
||||||
CtrlUp,
|
CtrlUp,
|
||||||
@ -82,9 +89,13 @@ impl Key {
|
|||||||
127 | ncurses::KEY_BACKSPACE => Key::Backspace,
|
127 | ncurses::KEY_BACKSPACE => Key::Backspace,
|
||||||
// Those keys don't seem to be documented...
|
// Those keys don't seem to be documented...
|
||||||
515 => Key::CtrlDel,
|
515 => Key::CtrlDel,
|
||||||
|
516 => Key::CtrlShiftDel,
|
||||||
521 => Key::CtrlDown,
|
521 => Key::CtrlDown,
|
||||||
|
522 => Key::CtrlShiftDown,
|
||||||
526 => Key::CtrlEnd,
|
526 => Key::CtrlEnd,
|
||||||
|
527 => Key::CtrlShiftEnd,
|
||||||
531 => Key::CtrlHome,
|
531 => Key::CtrlHome,
|
||||||
|
532 => Key::CtrlShiftHome,
|
||||||
536 => Key::CtrlIns,
|
536 => Key::CtrlIns,
|
||||||
541 => Key::CtrlLeft,
|
541 => Key::CtrlLeft,
|
||||||
542 => Key::CtrlShiftLeft,
|
542 => Key::CtrlShiftLeft,
|
||||||
@ -93,6 +104,7 @@ impl Key {
|
|||||||
556 => Key::CtrlRight,
|
556 => Key::CtrlRight,
|
||||||
557 => Key::CtrlShiftRight,
|
557 => Key::CtrlShiftRight,
|
||||||
562 => Key::CtrlUp,
|
562 => Key::CtrlUp,
|
||||||
|
563 => Key::CtrlShiftUp,
|
||||||
ncurses::KEY_DC => Key::Del,
|
ncurses::KEY_DC => Key::Del,
|
||||||
ncurses::KEY_IC => Key::Ins,
|
ncurses::KEY_IC => Key::Ins,
|
||||||
ncurses::KEY_BTAB => Key::ShiftTab,
|
ncurses::KEY_BTAB => Key::ShiftTab,
|
||||||
@ -106,6 +118,8 @@ impl Key {
|
|||||||
ncurses::KEY_NPAGE => Key::PageDown,
|
ncurses::KEY_NPAGE => Key::PageDown,
|
||||||
ncurses::KEY_HOME => Key::Home,
|
ncurses::KEY_HOME => Key::Home,
|
||||||
ncurses::KEY_END => Key::End,
|
ncurses::KEY_END => Key::End,
|
||||||
|
ncurses::KEY_SHOME => Key::ShiftHome,
|
||||||
|
ncurses::KEY_SEND => Key::ShiftEnd,
|
||||||
ncurses::KEY_SDC => Key::ShiftDel,
|
ncurses::KEY_SDC => Key::ShiftDel,
|
||||||
// All Fn keys use the same enum with associated number
|
// All Fn keys use the same enum with associated number
|
||||||
f @ ncurses::KEY_F1 ... ncurses::KEY_F15 => Key::F((f - ncurses::KEY_F0) as u8),
|
f @ ncurses::KEY_F1 ... ncurses::KEY_F15 => Key::F((f - ncurses::KEY_F0) as u8),
|
||||||
@ -138,10 +152,13 @@ impl fmt::Display for Key {
|
|||||||
Key::Up => "Up",
|
Key::Up => "Up",
|
||||||
Key::CtrlShiftLeft => "Ctrl-Shift-Left",
|
Key::CtrlShiftLeft => "Ctrl-Shift-Left",
|
||||||
Key::CtrlShiftRight => "Ctrl-Shift-Right",
|
Key::CtrlShiftRight => "Ctrl-Shift-Right",
|
||||||
|
Key::CtrlShiftUp => "Ctrl-Shift-Up",
|
||||||
|
Key::CtrlShiftDown => "Ctrl-Shift-Down",
|
||||||
Key::ShiftLeft => "Shift-Left",
|
Key::ShiftLeft => "Shift-Left",
|
||||||
Key::ShiftRight => "Shift-Right",
|
Key::ShiftRight => "Shift-Right",
|
||||||
Key::ShiftDel => "Shift-Del",
|
Key::ShiftDel => "Shift-Del",
|
||||||
Key::CtrlDel => "Ctrl-Del",
|
Key::CtrlDel => "Ctrl-Del",
|
||||||
|
Key::CtrlShiftDel => "Ctrl-Shift-Del",
|
||||||
Key::CtrlLeft => "Ctrl-Left",
|
Key::CtrlLeft => "Ctrl-Left",
|
||||||
Key::CtrlRight => "Ctrl-Right",
|
Key::CtrlRight => "Ctrl-Right",
|
||||||
Key::CtrlUp => "Ctrl-Up",
|
Key::CtrlUp => "Ctrl-Up",
|
||||||
@ -151,9 +168,13 @@ impl fmt::Display for Key {
|
|||||||
Key::PageUp => "PageUp",
|
Key::PageUp => "PageUp",
|
||||||
Key::PageDown => "PageDown",
|
Key::PageDown => "PageDown",
|
||||||
Key::Home => "Home",
|
Key::Home => "Home",
|
||||||
|
Key::ShiftHome => "Shift-Home",
|
||||||
Key::CtrlHome => "Ctrl-Home",
|
Key::CtrlHome => "Ctrl-Home",
|
||||||
|
Key::CtrlShiftHome => "Ctrl-Shift-Home",
|
||||||
Key::End => "End",
|
Key::End => "End",
|
||||||
|
Key::ShiftEnd => "Shift-End",
|
||||||
Key::CtrlEnd => "Ctrl-End",
|
Key::CtrlEnd => "Ctrl-End",
|
||||||
|
Key::CtrlShiftEnd => "Ctrl-Shift-End",
|
||||||
Key::Backspace => "Backspace",
|
Key::Backspace => "Backspace",
|
||||||
Key::Del => "Del",
|
Key::Del => "Del",
|
||||||
Key::Enter => "Enter",
|
Key::Enter => "Enter",
|
||||||
|
Loading…
Reference in New Issue
Block a user