aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJonas Maier <jonas@x77.dev>2026-03-06 21:18:01 +0100
committerJonas Maier <jonas@x77.dev>2026-03-06 21:18:01 +0100
commit98900bed263b696553581974f719b02855911637 (patch)
tree30cc8b4d837de2a2fafcded013d1712f5cf11b32 /src/main.rs
parent41dbb877cade868137360d2e676f4c2ad4594317 (diff)
downloadpish-98900bed263b696553581974f719b02855911637.tar.gz
Ctrl+A and Ctrl+E to move between the begin and end of line
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs23
1 files changed, 23 insertions, 0 deletions
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