From 98900bed263b696553581974f719b02855911637 Mon Sep 17 00:00:00 2001 From: Jonas Maier Date: Fri, 6 Mar 2026 21:18:01 +0100 Subject: Ctrl+A and Ctrl+E to move between the begin and end of line --- src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index aacdb56..e270acf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -165,6 +165,16 @@ impl Session { self.line.del_right(); self.line.display_post(b" "); } + + fn move_to_begin(&mut self) { + cursor::move_cursor(Direction::Left, self.line.all_left()); + io::stdout().flush().unwrap(); + } + + fn move_to_end(&mut self) { + cursor::move_cursor(Direction::Right, self.line.all_right()); + io::stdout().flush().unwrap(); + } } fn read1() -> u8 { @@ -203,10 +213,23 @@ fn event_loop() { }; match buf[0] { + // Ctrl+A + 1 => { + se.move_to_begin(); + continue; + } + + // Ctrl+E + 5 => { + se.move_to_end(); + continue; + } + // Ctrl+C 3 => { se.clear_prompt(); se.history_visit = 0; + continue; } // EOF -- cgit v1.2.3