aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.rs
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2023-12-29 16:28:46 -0800
committerRose Hogenson <rosehogenson@posteo.net>2023-12-29 16:28:46 -0800
commitaee3a1f70072b5a35f4bf2a938b3722295d7efa9 (patch)
tree2af9b972768396d9eb717763bff0b57d3ea0b42b /src/term.rs
parentSupport inserting text. (diff)
downloadeditor-aee3a1f70072b5a35f4bf2a938b3722295d7efa9.tar.zst
Allow saving the file with CTRL-S.
Diffstat (limited to 'src/term.rs')
-rw-r--r--src/term.rs5
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]));
}