aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.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/main.rs
parentda54c7c2c103c9b1c98f0c5179945b0122a1eef7 (diff)
downloadeditor-aee3a1f70072b5a35f4bf2a938b3722295d7efa9.tar.zst
Allow saving the file with CTRL-S.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index dd20c3f..d376c2d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -65,6 +65,11 @@ fn edit(file: &OsStr) -> Result<(), String> {
Key::CtrlQ => {
break;
}
+ Key::CtrlS => {
+ if let Err(err) = r.save(Path::new(file)) {
+ return Err(format!("write file {}: {}", file.to_string_lossy(), err));
+ }
+ }
Key::Up => {
if cursor_row == 0 {
continue;