update: tuiの文字入力のCtrlブロックを追加

This commit is contained in:
2026-05-03 00:44:38 +09:00
parent 261c682e5e
commit 2c86e64f19
5 changed files with 71 additions and 59 deletions
+12
View File
@@ -345,6 +345,10 @@ impl InputBuffer {
}
}
pub fn move_start(&mut self) {
self.cursor = 0;
}
pub fn move_home(&mut self) {
while self.cursor > 0 {
if matches!(self.atoms[self.cursor - 1], Atom::Char('\n')) {
@@ -921,6 +925,14 @@ mod word_motion_tests {
assert_eq!(cursor(&buf), 0);
}
#[test]
fn move_start_lands_at_beginning_of_buffer() {
let mut buf = buf_from("foo\nbar");
assert_eq!(cursor(&buf), 7);
buf.move_start();
assert_eq!(cursor(&buf), 0);
}
#[test]
fn forward_from_start_lands_after_first_word() {
let mut buf = buf_from("foo bar baz");