chiark / gitweb /
Editor: support beginning/end of line.
authorSimon Tatham <anakin@pobox.com>
Tue, 2 Jan 2024 14:20:50 +0000 (14:20 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 2 Jan 2024 17:30:18 +0000 (17:30 +0000)
src/editor.rs

index f53da1d4825f767290422f713649c8b97d82f3cd..bbda7c36c501fa28d4bbf4e92f2187c5f3ecbcdf 100644 (file)
@@ -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();