diff options
| author | salmonik <salmonik@tuta.io> | 2026-07-31 16:43:04 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-07-31 16:43:04 +0200 |
| commit | 43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2 (patch) | |
| tree | 3fe86cc049f154dc33202b6573e091d6cace7305 /rsnix/src/ps2.rs | |
| parent | vfs: everything is a file — dirs, ramfs, character devices (diff) | |
| download | rs-dos-43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2.tar.gz rs-dos-43c44ae6fe7dbfcf6af3e5e53c29f65bbf94c9c2.zip | |
shell: ^C cancels the line / aborts streams, ^D = EOF → poweroff
- ps2: Ctrl+C and Ctrl+D are now KeyEvents (ctrl modifier + c/d map);
other Ctrl+key combos are swallowed
- shell read_line: ^C clears the line and echoes '^C' (bash-style),
^D on an empty line echoes '^D' and shuts down (EOF), ^D with text
on the line is ignored
- cat/hexdump stream incrementally (was: build whole string then print)
and check for ^C between chunks, so a running dump can be aborted
- verified in QEMU: line cancel, standalone interrupt, ^C aborts an
infinite 'cat /dev/zero' stream, ^D powers off
Diffstat (limited to '')
| -rw-r--r-- | rsnix/src/ps2.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/rsnix/src/ps2.rs b/rsnix/src/ps2.rs index 477d146..1b10b3b 100644 --- a/rsnix/src/ps2.rs +++ b/rsnix/src/ps2.rs | |||
| @@ -22,6 +22,8 @@ pub enum KeyEvent { | |||
| 22 | Backspace, | 22 | Backspace, |
| 23 | Tab, | 23 | Tab, |
| 24 | Escape, | 24 | Escape, |
| 25 | CtrlC, | ||
| 26 | CtrlD, | ||
| 25 | ArrowUp, | 27 | ArrowUp, |
| 26 | ArrowDown, | 28 | ArrowDown, |
| 27 | ArrowLeft, | 29 | ArrowLeft, |
| @@ -304,6 +306,15 @@ fn process_byte(byte: u8) -> Option<KeyEvent> { | |||
| 304 | ch.to_ascii_uppercase() | 306 | ch.to_ascii_uppercase() |
| 305 | }; | 307 | }; |
| 306 | } | 308 | } |
| 309 | // Ctrl+letter — the shell uses ^C (interrupt) and ^D (EOF). | ||
| 310 | let ctrl = state.modifiers & (MOD_LCTRL | MOD_RCTRL) != 0; | ||
| 311 | if ctrl { | ||
| 312 | return match ch.to_ascii_lowercase() { | ||
| 313 | b'c' => Some(KeyEvent::CtrlC), | ||
| 314 | b'd' => Some(KeyEvent::CtrlD), | ||
| 315 | _ => None, // swallow other Ctrl+key combinations | ||
| 316 | }; | ||
| 317 | } | ||
| 307 | if ch != 0 { | 318 | if ch != 0 { |
| 308 | Some(KeyEvent::Char(ch as char)) | 319 | Some(KeyEvent::Char(ch as char)) |
| 309 | } else { | 320 | } else { |
