From 995685a2841e17e0d72d3cd82b8b411f15f244a5 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 2 Jan 2024 14:20:50 +0000 Subject: [PATCH] Editor: support beginning/end of line. --- src/editor.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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(); -- 2.30.2