From cb17c57452ccd2ccca77e99098402d4b9f61c0a5 Mon Sep 17 00:00:00 2001 From: salmonik Date: Thu, 20 Aug 2026 13:47:10 +0200 Subject: wm: F1 spawns a windowed shell — real shell, not a duplicate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Architecture: - vt: ACTIVE terminal redirect — when set, all gop_print!/put_char/write_str go there instead of HOME. Terminal::from_buffer() renders into a WM-owned pixel buffer. - tty: read_line_from_queue() — canonical-mode line input from the task's own message queue (TaskMsg::Key). Returns None on Close. - shell: run_windowed() — same shell as the console but reads from the message queue. Returns on ^D or window close. - wm: F1 calls SPAWN_TERMINAL_CB (set by rsdos). No shell logic in the WM. - rsdos: terminal_task callback + terminal_entry task — creates a 640x400 chrome window, wires up Terminal::from_buffer, sets ACTIVE, runs shell::run_windowed(), cleans up on exit. - shell: 'term' debug command that invokes the callback directly and logs each step to serial. --- rsnix/src/wm.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'rsnix/src/wm.rs') diff --git a/rsnix/src/wm.rs b/rsnix/src/wm.rs index 2641b69..05781e8 100644 --- a/rsnix/src/wm.rs +++ b/rsnix/src/wm.rs @@ -394,8 +394,22 @@ pub fn handle_key(ev: KeyEvent) -> bool { } } +static TERM_COUNT: core::sync::atomic::AtomicUsize = core::sync::atomic::AtomicUsize::new(0); + +/// Callback set by rsdos to spawn a terminal task. Takes (title, w, h). +pub static mut SPAWN_TERMINAL_CB: Option = None; + fn spawn_terminal() { - crate::serial_println!("wm: F1 (spawn terminal) not implemented yet"); + let Some(cb) = (unsafe { SPAWN_TERMINAL_CB }) else { + crate::serial_println!("wm: SPAWN_TERMINAL_CB not set"); + return; + }; + let n = TERM_COUNT.fetch_add(1, Ordering::Relaxed) + 1; + let title = alloc::format!("term {}", n); + let (cw, ch) = gop::pixel_dims(); + let w = 640.min(cw); + let h = 400.min(ch); + cb(&title, w, h); } fn remove_from_zorder(id: usize) { -- cgit v1.2.3