summaryrefslogtreecommitdiffstats
path: root/shell/src
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-08-27 17:23:34 +0200
committersalmonik <salmonik@tuta.io>2026-08-27 17:23:34 +0200
commitba304898b8e177d90afb58d201b4c3dd3c927c48 (patch)
tree3bcca98cb09ed8c035218039d9c86401d8ea0066 /shell/src
parenttool migration: v2 exports + 10 external CLI binaries (diff)
downloadrs-dos-ba304898b8e177d90afb58d201b4c3dd3c927c48.tar.gz
rs-dos-ba304898b8e177d90afb58d201b4c3dd3c927c48.zip
GUI: window/event exports, paint binary, event-loop gate
rsapi: WmEvent (kind=u8 enum: 0=key, 1=mouse, 2=focus, 3=close), WmKeyKind (Char/Enter/Backspace/F1-F4/…), WmMouseEvent (x/y/buttons), WindowInfo (ptr/w/h). Five new exports: wm_create, wm_buffer, wm_flush, wm_destroy, wm_recv (non-blocking TaskMsg dispatch → WmEvent). Shell: abi_wm_* wrappers bridge rsapi types to rsnix::wm and sched::recv(); wm_recv translates TaskMsg::Key/Mouse/Focus/Close into flat WmEvent union. bins/paint: gate binary — create_window + buffer + event loop with Bresenham line drawing, color select (1-8), clear (c), F4 close. All via wm_* ABI exports. Fully migrated: date, mem, pci, cat, ls, mkdir, touch, rm, klog, info, paint (11 external binaries in /bin/cli/ + 3 gate binaries).
Diffstat (limited to '')
-rw-r--r--shell/src/lib.rs97
1 files changed, 97 insertions, 0 deletions
diff --git a/shell/src/lib.rs b/shell/src/lib.rs
index 11f5786..6de056c 100644
--- a/shell/src/lib.rs
+++ b/shell/src/lib.rs
@@ -1126,6 +1126,98 @@ fn abi_kernel_version(out: &mut rsapi::KernelVersion) {
1126 out.patch = patch; 1126 out.patch = patch;
1127} 1127}
1128 1128
1129
1130/// ABI: create a window via the window manager.
1131fn abi_wm_create(title: rsapi::Line, w: u32, h: u32) -> i32 {
1132 let s = title.as_str();
1133 match rsnix::wm::create_window(s, w as usize, h as usize) {
1134 Some(id) => id as i32,
1135 None => -1,
1136 }
1137}
1138
1139/// ABI: get window pixel buffer info.
1140fn abi_wm_buffer(id: i32, out: &mut rsapi::WindowInfo) -> bool {
1141 match rsnix::wm::buffer(id as usize) {
1142 Some((ptr, w, h)) => {
1143 out.ptr = ptr;
1144 out.w = w as u32;
1145 out.h = h as u32;
1146 true
1147 }
1148 None => false,
1149 }
1150}
1151
1152/// ABI: composite window to screen.
1153fn abi_wm_flush(id: i32) {
1154 rsnix::wm::flush(id as usize);
1155}
1156
1157/// ABI: destroy a window.
1158fn abi_wm_destroy(id: i32) {
1159 rsnix::wm::destroy(id as usize);
1160}
1161
1162/// ABI: non-blocking receive of one WM event.
1163fn abi_wm_recv(out: &mut rsapi::WmEvent) -> bool {
1164 use rsnix::ps2::KeyEvent;
1165 match rsnix::sched::recv() {
1166 None => false,
1167 Some(msg) => {
1168 match msg {
1169 rsnix::sched::TaskMsg::Key(k) => {
1170 out.kind = 0;
1171 match k {
1172 KeyEvent::Char(c) => {
1173 out.key_kind = rsapi::WmKeyKind::Char;
1174 out.key_char = c as u8;
1175 }
1176 KeyEvent::Enter => { out.key_kind = rsapi::WmKeyKind::Enter; }
1177 KeyEvent::Backspace => { out.key_kind = rsapi::WmKeyKind::Backspace; }
1178 KeyEvent::Tab => { out.key_kind = rsapi::WmKeyKind::Tab; }
1179 KeyEvent::Escape => { out.key_kind = rsapi::WmKeyKind::Escape; }
1180 KeyEvent::Ctrl('c') => { out.key_kind = rsapi::WmKeyKind::CtrlC; }
1181 KeyEvent::ArrowUp => { out.key_kind = rsapi::WmKeyKind::ArrowUp; }
1182 KeyEvent::ArrowDown => { out.key_kind = rsapi::WmKeyKind::ArrowDown; }
1183 KeyEvent::ArrowLeft => { out.key_kind = rsapi::WmKeyKind::ArrowLeft; }
1184 KeyEvent::ArrowRight => { out.key_kind = rsapi::WmKeyKind::ArrowRight; }
1185 KeyEvent::Home => { out.key_kind = rsapi::WmKeyKind::Home; }
1186 KeyEvent::End => { out.key_kind = rsapi::WmKeyKind::End; }
1187 KeyEvent::PageUp => { out.key_kind = rsapi::WmKeyKind::PageUp; }
1188 KeyEvent::PageDown => { out.key_kind = rsapi::WmKeyKind::PageDown; }
1189 KeyEvent::Delete => { out.key_kind = rsapi::WmKeyKind::Delete; }
1190 KeyEvent::F(1) => { out.key_kind = rsapi::WmKeyKind::F1; }
1191 KeyEvent::F(2) => { out.key_kind = rsapi::WmKeyKind::F2; }
1192 KeyEvent::F(3) => { out.key_kind = rsapi::WmKeyKind::F3; }
1193 KeyEvent::F(4) => { out.key_kind = rsapi::WmKeyKind::F4; }
1194 _ => { out.key_kind = rsapi::WmKeyKind::Unknown; }
1195 }
1196 out.key_char = 0;
1197 true
1198 }
1199 rsnix::sched::TaskMsg::AppMouse(m) => {
1200 out.kind = 1;
1201 out.mouse.x = m.x;
1202 out.mouse.y = m.y;
1203 out.mouse.buttons = m.buttons;
1204 true
1205 }
1206 rsnix::sched::TaskMsg::Focus(f) => {
1207 out.kind = 2;
1208 out.focused = f;
1209 true
1210 }
1211 rsnix::sched::TaskMsg::Close => {
1212 out.kind = 3;
1213 true
1214 }
1215 _ => false,
1216 }
1217 }
1218 }
1219}
1220
1129/// Construct the Exports table for this invocation. v2 fields are 1221/// Construct the Exports table for this invocation. v2 fields are
1130/// populated at runtime (binary callbacks → shell → kernel). 1222/// populated at runtime (binary callbacks → shell → kernel).
1131fn build_exports() -> rsapi::Exports { 1223fn build_exports() -> rsapi::Exports {
@@ -1150,6 +1242,11 @@ fn build_exports() -> rsapi::Exports {
1150 pci_device: abi_pci_device, 1242 pci_device: abi_pci_device,
1151 klog_dump: abi_klog_dump, 1243 klog_dump: abi_klog_dump,
1152 kernel_version: abi_kernel_version, 1244 kernel_version: abi_kernel_version,
1245 wm_create: abi_wm_create,
1246 wm_buffer: abi_wm_buffer,
1247 wm_flush: abi_wm_flush,
1248 wm_destroy: abi_wm_destroy,
1249 wm_recv: abi_wm_recv,
1153 } 1250 }
1154} 1251}
1155 1252