edit: Add line deletion shortcut

This commit is contained in:
2026-06-09 18:16:37 +03:00
parent a7813a851c
commit 74af7639be

View File

@@ -191,6 +191,19 @@ impl Editor {
}
}
fn delete_line(&mut self) {
let (r, _) = self.cursor;
if self.buffer.len() == 1 {
self.buffer[0].clear();
self.cursor = (0, 0);
} else {
self.buffer.remove(r);
let new_r = r.min(self.buffer.len() - 1);
let new_col = self.cursor.1.min(self.buffer[new_r].len());
self.cursor = (new_r, new_col);
}
}
fn newline(&mut self) {
let (r, col) = self.cursor;
let col = col.min(self.buffer[r].len());
@@ -488,6 +501,7 @@ fn step(
// Editor focus inside Game: dispatch editing keys.
if *focus == Focus::Editor && matches!(screen, Screen::Game) {
match key.code {
KeyCode::Char('k') if ctrl => editor.delete_line(),
KeyCode::Char(c) if !ctrl => editor.insert_char(c),
KeyCode::Backspace => editor.backspace(),
KeyCode::Delete => editor.delete(),
@@ -707,6 +721,7 @@ fn help_widget<'a>() -> Paragraph<'a> {
\n\
[Tab] swap focus between log and editor\n\
[Ctrl-X] grade your YAML\n\
[Ctrl-K] delete current line (in editor)\n\
[Ctrl-H] open this help\n\
[Esc] close help · or focus log when editing\n\
[↑/↓] scroll the log (when log is focused)\n\