A simple CPU rendered GUI IDE experience.
-rw-r--r--src/edi/input_handlers.rs1
-rw-r--r--src/text.rs12
2 files changed, 13 insertions, 0 deletions
diff --git a/src/edi/input_handlers.rs b/src/edi/input_handlers.rs
index ac4ca4c..6457787 100644
--- a/src/edi/input_handlers.rs
+++ b/src/edi/input_handlers.rs
@@ -28,6 +28,7 @@ pub fn handle2<'a>(
Character("q") if alt() => text.home(),
Named(Home) => text.home(),
Named(End) => text.end(),
+ Named(Tab) if shift() => text.dedent().unwrap(),
Named(Tab) => text.tab(),
Named(Delete) => {
text.right();
diff --git a/src/text.rs b/src/text.rs
index a38ddb2..b5175fc 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -1156,6 +1156,18 @@ impl TextArea {
.context("couldnt apply one or more tedits")?;
Ok(())
}
+
+ pub(crate) fn dedent(&mut self) -> rootcause::Result<()> {
+ ceach!(self.cursor, |c| {
+ let s = self.rope.beginning_of_line(*c).context("couldnt get line of cursor")?;
+ if self.rope.slice(s..s + 4).chars().all(char::is_whitespace) {
+ self.remove(s..s + 4)?;
+ }
+ rootcause::Result::<()>::Ok(())
+ } => ?);
+
+ rootcause::Result::Ok(())
+ }
}
pub fn is_word(r: char) -> bool {