diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2023-12-29 16:28:46 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2023-12-29 16:28:46 -0800 |
| commit | aee3a1f70072b5a35f4bf2a938b3722295d7efa9 (patch) | |
| tree | 2af9b972768396d9eb717763bff0b57d3ea0b42b /src/term.rs | |
| parent | Support inserting text. (diff) | |
| download | editor-aee3a1f70072b5a35f4bf2a938b3722295d7efa9.tar.zst | |
Allow saving the file with CTRL-S.
Diffstat (limited to 'src/term.rs')
| -rw-r--r-- | src/term.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/term.rs b/src/term.rs index 2303fa2..c4319b4 100644 --- a/src/term.rs +++ b/src/term.rs @@ -63,6 +63,7 @@ pub fn raw() -> Option<RawHandle> { pub enum Key { CtrlQ, + CtrlS, Up, Down, Left, @@ -72,6 +73,7 @@ pub enum Key { pub fn read_key(stdin: &mut Stdin) -> Result<Key, String> { const CTRL_Q: u8 = 17; + const CTRL_S: u8 = 19; const ESC: u8 = 27; loop { @@ -82,6 +84,9 @@ pub fn read_key(stdin: &mut Stdin) -> Result<Key, String> { if buf[0] == CTRL_Q { return Ok(Key::CtrlQ); } + if buf[0] == CTRL_S { + return Ok(Key::CtrlS); + } if buf[0] != ESC { return Ok(Key::Char(buf[0])); } |
