FABRIC.md items 4.4v/4.4r/4.4ab: keyboard bridge, and simplify to a
full-screen vt100 terminal 4.4v -- keyboard-to-REPL bridge, real and tested: Refactored KEY-EVENT's per-arch translation logic (keyboard_words.c) into a shared C function, sk_key_event_poll(), so the REPL bridge reuses item 4.3.5f's already-converged Linux-keycode-namespace event stream instead of building separate amd64/aarch64/riscv64 tables. repl.c's sk_kbd_getc() decodes the standard US-QWERTY printable range plus Enter/Backspace/Shift against that stream; sk_readline() polls it as a second source alongside console_getc(). Verified via QEMU monitor sendkey injection, and by Captain Bob typing directly into the live QEMU window over real emulated PS/2 hardware mid-session (1 1 + . -> 2 ok, then a clean BYE shutdown). 4.4ab -- simplify to a full-screen terminal: Captain Bob's call, reverting the 640x480 CANVAS box + independent REPL strip (4.4o/4.4t/4.4x/4.4z) in favor of the simplest shape: the entire framebuffer is one vt100 terminal, g_vt.cols/rows = fb_width()/fb_height() divided by cell size, no origin offset, no box, no strip, no border drawing. The REPL prompt is just the terminal's last scrolling line. Scrollback, TTF rendering, and SGR color are all box-agnostic and keep working unmodified. 4.4r -- reframed as a text/graphics mode toggle: "Hide/show the scroll box" stopped meaning anything once the box was removed; the underlying need survives as a whole-screen mode switch. vt100_toggle_graphics() is a two-state machine (VISIBLE/HIDDEN) -- hidden mode stops the terminal from touching the framebuffer while its logical state keeps advancing, so direct framebuffer/TTF-TEXT drawing can use the whole screen; showing again wipes and reuses scrollback_redraw() to restore the terminal exactly. Reachable two ways, one transition function: physically via Alt+TAB (4.4y revised from Ctrl+TAB) and programmatically via the new ALT+TAB FORTH word. Verified: three-arch clean QEMU boot + logs; amd64 screendump confirms full-width text with no box/strip artifacts. Punch list §25 items 4.4v/4.4r/4.4ab complete; 4.4y revised. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b21aa50a14
commit
af20efaa15
@@ -50,9 +50,29 @@
|
||||
* -- see the implementation's own doc comment), pressed is 1 or 0. This is
|
||||
* the word the later REPL keyboard-input work (M8) is expected to build
|
||||
* on; KBD-SCAN/VKBD-EVENT remain as lower-level per-device diagnostics.
|
||||
*
|
||||
* @par ALT+TAB ( -- )
|
||||
* FABRIC.md item 4.4y-revised. Programmatic equivalent of the physical
|
||||
* Alt+TAB graphics/text toggle -- calls the same state-machine transition
|
||||
* (console_fb_toggle_graphics() / vt100_toggle_graphics()) the keyboard
|
||||
* interception in repl.c uses, so there is exactly one place the toggle
|
||||
* actually happens.
|
||||
* @}
|
||||
*/
|
||||
|
||||
void register_keyboard_words(VM *vm);
|
||||
|
||||
/**
|
||||
* FABRIC.md item 4.4v: shared C-level poll, one converged event stream
|
||||
* (Linux input keycode namespace, all three architectures) -- see
|
||||
* KEY-EVENT's doc comment above for the full per-arch translation
|
||||
* rationale. Used by both kbw_key_event() (the FORTH word) and the REPL
|
||||
* keyboard bridge (repl.c), so there is exactly one implementation.
|
||||
*
|
||||
* @param keycode Written with the Linux input keycode on success.
|
||||
* @param pressed Written with 1 (press/repeat) or 0 (release) on success.
|
||||
* @return 1 if an event was available, 0 otherwise.
|
||||
*/
|
||||
int sk_key_event_poll(uint16_t *keycode, int *pressed);
|
||||
|
||||
#endif /* KEYBOARD_WORDS_H */
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "starkernel/virtio_input.h"
|
||||
#endif
|
||||
|
||||
#if defined(__STARKERNEL__)
|
||||
#include "starkernel/console.h"
|
||||
#endif
|
||||
|
||||
/* KBD-SCAN ( -- c -1 | 0 ) */
|
||||
static void kbw_scan(VM *vm)
|
||||
{
|
||||
@@ -117,29 +121,60 @@ static void kbw_vdebug(VM *vm)
|
||||
* field already lives in the same Linux keycode namespace; `value` is
|
||||
* mapped 1:1 except autorepeat (value=2), folded into "still pressed"
|
||||
* here since this checkpoint's shape only distinguishes press/release. */
|
||||
static void kbw_key_event(VM *vm)
|
||||
/* FABRIC.md item 4.4v: shared C-level implementation, so the REPL
|
||||
* keyboard bridge (repl.c) and the KEY-EVENT FORTH word below poll the
|
||||
* exact same converged event stream rather than each re-deriving the
|
||||
* per-arch translation kbw_key_event's own doc comment already explains
|
||||
* (XT Set-1 make code == Linux keycode for the non-extended range; break
|
||||
* codes set bit 7 instead of carrying a separate field). */
|
||||
int sk_key_event_poll(uint16_t *keycode, int *pressed)
|
||||
{
|
||||
#if defined(__STARKERNEL__) && defined(ARCH_AMD64)
|
||||
uint8_t sc;
|
||||
if (i8042_pop_scancode(&sc)) {
|
||||
vm_push(vm, (cell_t)(sc & 0x7Fu));
|
||||
vm_push(vm, (cell_t)((sc & 0x80u) ? 0 : 1));
|
||||
vm_push(vm, -1);
|
||||
} else {
|
||||
vm_push(vm, 0);
|
||||
*keycode = (uint16_t)(sc & 0x7Fu);
|
||||
*pressed = (sc & 0x80u) ? 0 : 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#elif defined(__STARKERNEL__) && (defined(ARCH_RISCV64) || defined(ARCH_AARCH64))
|
||||
uint16_t code;
|
||||
uint32_t value;
|
||||
if (virtio_input_pop_event(&code, &value)) {
|
||||
vm_push(vm, (cell_t)code);
|
||||
vm_push(vm, (cell_t)(value == 0u ? 0 : 1));
|
||||
*keycode = code;
|
||||
*pressed = (value == 0u) ? 0 : 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
(void)keycode; (void)pressed;
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void kbw_key_event(VM *vm)
|
||||
{
|
||||
uint16_t keycode;
|
||||
int pressed;
|
||||
|
||||
if (sk_key_event_poll(&keycode, &pressed)) {
|
||||
vm_push(vm, (cell_t)keycode);
|
||||
vm_push(vm, (cell_t)pressed);
|
||||
vm_push(vm, -1);
|
||||
} else {
|
||||
vm_push(vm, 0);
|
||||
}
|
||||
#else
|
||||
vm_push(vm, 0);
|
||||
}
|
||||
|
||||
/* ALT+TAB ( -- ): FABRIC.md item 4.4y-revised. Programmatic equivalent of
|
||||
* the physical Alt+TAB interception (repl.c's sk_kbd_getc()) -- both call
|
||||
* console_fb_toggle_graphics(), so there is exactly one state-machine
|
||||
* transition, invoked two ways. */
|
||||
static void kbw_alt_tab(VM *vm)
|
||||
{
|
||||
(void)vm;
|
||||
#if defined(__STARKERNEL__)
|
||||
console_fb_toggle_graphics();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -150,4 +185,5 @@ void register_keyboard_words(VM *vm)
|
||||
register_word(vm, "VKBD-EVENT", kbw_vevent);
|
||||
register_word(vm, "VKBD-DEBUG", kbw_vdebug);
|
||||
register_word(vm, "KEY-EVENT", kbw_key_event);
|
||||
register_word(vm, "ALT+TAB", kbw_alt_tab);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user