summaryrefslogtreecommitdiffstats
path: root/rsapi
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 /rsapi
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--rsapi/src/lib.rs72
1 files changed, 72 insertions, 0 deletions
diff --git a/rsapi/src/lib.rs b/rsapi/src/lib.rs
index dfe75d6..e5f2119 100644
--- a/rsapi/src/lib.rs
+++ b/rsapi/src/lib.rs
@@ -105,6 +105,66 @@ pub struct PciDevice {
105 pub device_id: u16, 105 pub device_id: u16,
106} 106}
107 107
108// ---- GUI types (v2 window/event) ----
109
110/// Window buffer info returned by wm_buffer.
111#[repr(C)]
112#[derive(Clone, Copy)]
113pub struct WindowInfo {
114 pub ptr: *mut u32,
115 pub w: u32,
116 pub h: u32,
117}
118
119/// Key event kind (flattened for ABI stability).
120#[repr(u8)]
121#[derive(Clone, Copy, PartialEq, Eq)]
122pub enum WmKeyKind {
123 Char = 0,
124 Enter = 1,
125 Backspace = 2,
126 Tab = 3,
127 Escape = 4,
128 CtrlC = 5,
129 ArrowUp = 10,
130 ArrowDown = 11,
131 ArrowLeft = 12,
132 ArrowRight = 13,
133 Home = 14,
134 End = 15,
135 PageUp = 16,
136 PageDown = 17,
137 Delete = 18,
138 F1 = 20,
139 F2 = 21,
140 F3 = 22,
141 F4 = 23,
142 Unknown = 255,
143}
144
145/// Mouse button state.
146#[repr(C)]
147#[derive(Clone, Copy)]
148pub struct WmMouseEvent {
149 pub x: i32,
150 pub y: i32,
151 pub buttons: u8,
152}
153
154/// One window manager event delivered to a GUI binary.
155#[repr(C)]
156#[derive(Clone, Copy)]
157pub struct WmEvent {
158 pub kind: u8, // 0=key, 1=mouse, 2=focus, 3=close
159 pub key_kind: WmKeyKind,
160 pub key_char: u8,
161 pub mouse: WmMouseEvent,
162 pub focused: bool,
163 pub _pad: [u8; 4],
164}
165
166
167
108/// Kernel version information. 168/// Kernel version information.
109#[derive(Clone, Copy)] 169#[derive(Clone, Copy)]
110pub struct KernelVersion { 170pub struct KernelVersion {
@@ -167,4 +227,16 @@ pub struct Exports {
167 pub klog_dump: fn(buf: *mut u8, cap: u64) -> u64, 227 pub klog_dump: fn(buf: *mut u8, cap: u64) -> u64,
168 /// Fill `out` with kernel version info. 228 /// Fill `out` with kernel version info.
169 pub kernel_version: fn(out: &mut KernelVersion), 229 pub kernel_version: fn(out: &mut KernelVersion),
230
231 // ---- window/events (v2 GUI) ----
232 /// Create a window; returns window id or -1.
233 pub wm_create: fn(title: Line, w: u32, h: u32) -> i32,
234 /// Get the window's pixel buffer info.
235 pub wm_buffer: fn(id: i32, out: &mut WindowInfo) -> bool,
236 /// Composite the window to screen.
237 pub wm_flush: fn(id: i32),
238 /// Destroy a window.
239 pub wm_destroy: fn(id: i32),
240 /// Non-blocking: receive one event. Returns true if an event was delivered.
241 pub wm_recv: fn(out: &mut WmEvent) -> bool,
170} 242}