From b433f22592669eaa8238c0a6af40eeeb90216073 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 22 Oct 2022 09:41:17 -0600 Subject: [PATCH] Stubs for up/down --- src/buffer.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index b4b8250..1d9b62e 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -437,10 +437,20 @@ impl<'a> TextBuffer<'a> { } }, TextAction::Up => { - todo!("up"); + //TODO: make this move by layout lines and preserve X as best as possible! + if self.cursor.line.get() > 0 { + self.cursor.line = TextLineIndex::new(self.cursor.line.get() - 1); + self.cursor.index = 0; + self.redraw = true; + } }, TextAction::Down => { - todo!("down"); + //TODO: make this move by layout lines and preserve X as best as possible! + if self.cursor.line.get() + 1 < self.lines.len() { + self.cursor.line = TextLineIndex::new(self.cursor.line.get() + 1); + self.cursor.index = 0; + self.redraw = true; + } }, TextAction::Home => { todo!("home"); @@ -449,12 +459,14 @@ impl<'a> TextBuffer<'a> { todo!("end"); } TextAction::PageUp => { + //TODO: move cursor self.scroll -= self.lines(); self.redraw = true; self.shape_until_scroll(); }, TextAction::PageDown => { + //TODO: move cursor self.scroll += self.lines(); self.redraw = true;