diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-21 03:30:35 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-21 03:30:35 +0200 |
| commit | b418c26050870b900ff56d5a47f32209795aaf4a (patch) | |
| tree | cdc181c63b2bbd3a3c1f608cbe0faf9a4e86877b | |
| parent | wm: F1 spawns a windowed shell — real shell, not a duplicate (diff) | |
| download | rs-dos-b418c26050870b900ff56d5a47f32209795aaf4a.tar.gz rs-dos-b418c26050870b900ff56d5a47f32209795aaf4a.zip | |
v0.5.11: fix terminal focus — toggle ACTIVE on Focus messages
- tty: read_line_from_queue() now takes &mut Terminal and handles
TaskMsg::Focus: Focus(true) sets ACTIVE to the terminal,
Focus(false) clears it. This fixes the bug where the console
shell's gop_print! output was redirected to the soft terminal
even after focus switched away from it.
- shell: run_windowed() passes the terminal through to read_line_from_queue.
- wm: remove noisy per-key debug logging from pump_main.
| -rw-r--r-- | Cargo.lock | 6 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | rsdos/src/main.rs | 2 | ||||
| -rw-r--r-- | rsnix/src/tty.rs | 16 | ||||
| -rw-r--r-- | rsnix/src/wm.rs | 8 | ||||
| -rw-r--r-- | shell/src/lib.rs | 4 |
6 files changed, 25 insertions, 13 deletions
| @@ -4,7 +4,7 @@ version = 4 | |||
| 4 | 4 | ||
| 5 | [[package]] | 5 | [[package]] |
| 6 | name = "rsdos" | 6 | name = "rsdos" |
| 7 | version = "0.5.10" | 7 | version = "0.5.11" |
| 8 | dependencies = [ | 8 | dependencies = [ |
| 9 | "rsnix", | 9 | "rsnix", |
| 10 | "shell", | 10 | "shell", |
| @@ -19,7 +19,7 @@ dependencies = [ | |||
| 19 | 19 | ||
| 20 | [[package]] | 20 | [[package]] |
| 21 | name = "rsnix" | 21 | name = "rsnix" |
| 22 | version = "0.5.10" | 22 | version = "0.5.11" |
| 23 | 23 | ||
| 24 | [[package]] | 24 | [[package]] |
| 25 | name = "rspaint" | 25 | name = "rspaint" |
| @@ -30,7 +30,7 @@ dependencies = [ | |||
| 30 | 30 | ||
| 31 | [[package]] | 31 | [[package]] |
| 32 | name = "shell" | 32 | name = "shell" |
| 33 | version = "0.5.10" | 33 | version = "0.5.11" |
| 34 | dependencies = [ | 34 | dependencies = [ |
| 35 | "rsdosedit", | 35 | "rsdosedit", |
| 36 | "rsnix", | 36 | "rsnix", |
| @@ -3,7 +3,7 @@ resolver = "2" | |||
| 3 | members = ["rsnix", "shell", "rsdos", "rsdosedit", "rspaint"] | 3 | members = ["rsnix", "shell", "rsdos", "rsdosedit", "rspaint"] |
| 4 | 4 | ||
| 5 | [workspace.package] | 5 | [workspace.package] |
| 6 | version = "0.5.10" | 6 | version = "0.5.11" |
| 7 | edition = "2024" | 7 | edition = "2024" |
| 8 | 8 | ||
| 9 | # no_std UEFI kernel: no unwinder available, so panic must abort. | 9 | # no_std UEFI kernel: no unwinder available, so panic must abort. |
diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index e5fb6dd..d1ed506 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs | |||
| @@ -483,7 +483,7 @@ fn terminal_entry() { | |||
| 483 | rsnix::vt::set_active(&mut term as *mut Terminal); | 483 | rsnix::vt::set_active(&mut term as *mut Terminal); |
| 484 | 484 | ||
| 485 | // Run the shell — it owns input, line editing, and command execution. | 485 | // Run the shell — it owns input, line editing, and command execution. |
| 486 | shell::run_windowed(); | 486 | shell::run_windowed(&mut term); |
| 487 | 487 | ||
| 488 | // Shell exited (^D or window close). Clean up. | 488 | // Shell exited (^D or window close). Clean up. |
| 489 | rsnix::serial_println!("term: shell exited, cleaning up"); | 489 | rsnix::serial_println!("term: shell exited, cleaning up"); |
diff --git a/rsnix/src/tty.rs b/rsnix/src/tty.rs index 918f6e0..c44dca8 100644 --- a/rsnix/src/tty.rs +++ b/rsnix/src/tty.rs | |||
| @@ -139,7 +139,14 @@ pub fn read_line() -> LineInput { | |||
| 139 | /// windowed shells). Same semantics as `read_line` but keys arrive as | 139 | /// windowed shells). Same semantics as `read_line` but keys arrive as |
| 140 | /// `TaskMsg::Key` instead of from the global PS/2 queue. Returns `None` | 140 | /// `TaskMsg::Key` instead of from the global PS/2 queue. Returns `None` |
| 141 | /// on `TaskMsg::Close` (window was closed). | 141 | /// on `TaskMsg::Close` (window was closed). |
| 142 | pub fn read_line_from_queue() -> Option<LineInput> { | 142 | /// Read one line in canonical mode from the task's message queue (for |
| 143 | /// windowed shells). Same semantics as `read_line` but keys arrive as | ||
| 144 | /// `TaskMsg::Key` instead of from the global PS/2 queue. Returns `None` | ||
| 145 | /// on `TaskMsg::Close` (window was closed). | ||
| 146 | /// | ||
| 147 | /// Handles `TaskMsg::Focus` to toggle the global `ACTIVE` redirect so | ||
| 148 | /// gop_print! goes to the right terminal buffer. | ||
| 149 | pub fn read_line_from_queue(term: &mut crate::vt::Terminal) -> Option<LineInput> { | ||
| 143 | crate::vt::sync_scroll(); | 150 | crate::vt::sync_scroll(); |
| 144 | let mut buf = strbuf::String::<LINE_BUF_SIZE>::new(); | 151 | let mut buf = strbuf::String::<LINE_BUF_SIZE>::new(); |
| 145 | loop { | 152 | loop { |
| @@ -191,6 +198,13 @@ pub fn read_line_from_queue() -> Option<LineInput> { | |||
| 191 | } | 198 | } |
| 192 | _ => {} | 199 | _ => {} |
| 193 | }, | 200 | }, |
| 201 | crate::sched::TaskMsg::Focus(gained) => { | ||
| 202 | if gained { | ||
| 203 | crate::vt::set_active(term as *mut crate::vt::Terminal); | ||
| 204 | } else { | ||
| 205 | crate::vt::set_active(core::ptr::null_mut()); | ||
| 206 | } | ||
| 207 | } | ||
| 194 | crate::sched::TaskMsg::Close => return None, | 208 | crate::sched::TaskMsg::Close => return None, |
| 195 | _ => {} | 209 | _ => {} |
| 196 | } | 210 | } |
diff --git a/rsnix/src/wm.rs b/rsnix/src/wm.rs index 05781e8..71c310f 100644 --- a/rsnix/src/wm.rs +++ b/rsnix/src/wm.rs | |||
| @@ -617,12 +617,10 @@ pub fn spawn_input_pump() -> Option<usize> { | |||
| 617 | 617 | ||
| 618 | fn pump_main() { | 618 | fn pump_main() { |
| 619 | loop { | 619 | loop { |
| 620 | if focused().is_some() { | 620 | if let Some(id) = focused() { |
| 621 | let o = owner(id).unwrap_or(0); | ||
| 621 | while let Some(ev) = crate::ps2::try_poll_key().or_else(crate::uhci::try_poll_key) { | 622 | while let Some(ev) = crate::ps2::try_poll_key().or_else(crate::uhci::try_poll_key) { |
| 622 | if !handle_key(ev) | 623 | if !handle_key(ev) { |
| 623 | && let Some(id) = focused() | ||
| 624 | && let Some(o) = owner(id) | ||
| 625 | { | ||
| 626 | let _ = crate::sched::send(o, TaskMsg::Key(ev)); | 624 | let _ = crate::sched::send(o, TaskMsg::Key(ev)); |
| 627 | } | 625 | } |
| 628 | } | 626 | } |
diff --git a/shell/src/lib.rs b/shell/src/lib.rs index 6077f35..f2a0e6e 100644 --- a/shell/src/lib.rs +++ b/shell/src/lib.rs | |||
| @@ -97,12 +97,12 @@ pub fn run() -> ! { | |||
| 97 | /// reads from the task's message queue (Fed by the WM input pump) and | 97 | /// reads from the task's message queue (Fed by the WM input pump) and |
| 98 | /// writes to the active terminal (set by the caller via `vt::set_active`). | 98 | /// writes to the active terminal (set by the caller via `vt::set_active`). |
| 99 | /// Returns when the window is closed (Close message or ^D on empty line). | 99 | /// Returns when the window is closed (Close message or ^D on empty line). |
| 100 | pub fn run_windowed() { | 100 | pub fn run_windowed(term: &mut rsnix::vt::Terminal) { |
| 101 | term_println(&alloc::format!("rs-dos v{}", env!("CARGO_PKG_VERSION"))); | 101 | term_println(&alloc::format!("rs-dos v{}", env!("CARGO_PKG_VERSION"))); |
| 102 | loop { | 102 | loop { |
| 103 | rsnix::vt::sync_scroll(); | 103 | rsnix::vt::sync_scroll(); |
| 104 | term_print("> "); | 104 | term_print("> "); |
| 105 | match tty::read_line_from_queue() { | 105 | match tty::read_line_from_queue(term) { |
| 106 | None => return, // window closed | 106 | None => return, // window closed |
| 107 | Some(LineInput::Interrupted) => continue, | 107 | Some(LineInput::Interrupted) => continue, |
| 108 | Some(LineInput::Eof) => return, // ^D in windowed mode = close | 108 | Some(LineInput::Eof) => return, // ^D in windowed mode = close |
