From: Simon Tatham Date: Tue, 2 Jan 2024 14:20:50 +0000 (+0000) Subject: Editor: support beginning/end of line. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=995685a2841e17e0d72d3cd82b8b411f15f244a5;p=mastodonochrome.git Editor: support beginning/end of line. --- diff --git a/src/editor.rs b/src/editor.rs index f53da1d..bbda7c3 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -1046,6 +1046,16 @@ impl Composer { self.core.beginning_of_buffer(); } } + + fn beginning_of_line(&mut self) { + let (_x, y) = self.cursor_pos.expect("post_update should have run"); + self.goto_xy(0, y); + } + + fn end_of_line(&mut self) { + let (_x, y) = self.cursor_pos.expect("post_update should have run"); + self.goto_xy(usize::MAX, y); + } } #[test] @@ -1299,6 +1309,9 @@ impl ActivityState for Composer { (Start, Ctrl('V')) | (Start, PgDn) => self.page_down(), (Start, Ctrl('Z')) | (Start, PgUp) => self.page_up(), + (Start, Ctrl('A')) | (Start, Home) => self.beginning_of_line(), + (Start, Ctrl('E')) | (Start, End) => self.end_of_line(), + (Start, Return) => { self.core.insert("\n"); self.post_update();