Cursor indicator + HB-ON/HB-OFF runtime DoE instrumentation toggle
Cursor (Captain Bob: "the only thing we need is a cursor"): vt100_draw_cursor() draws a solid block at the terminal's current position, called from repl.c after the prompt prints and after every keystroke/backspace. vt100_erase_cursor() cleans up the one gap a static cursor has -- Enter/newline moves away from the cursor cell without a character draw ever overwriting it, which left a stray block behind until this fix. HB-ON/HB-OFF (Captain Bob: run a program with or without instrumentation without rebuilding): Converted per-tick DoE logging from a build-time flag (HEARTBEAT_DOE_LOG) to a runtime one. doe_log_tick_row() now self-gates on g_doe_log_enabled (default 1, matching the old default) instead of being compiled out entirely; the call site in vm_runtime.c is unconditional. Two new FORTH words, HB-ON and HB-OFF, flip the flag live. Removed the now-dead HEARTBEAT_DOE_LOG plumbing: the Kconfig symbol, and the -D forwarding in both LOADER_CFLAGS and KERNEL_CFLAGS. Verified: three-arch clean QEMU boot + logs; dictionary word count 466 (463 baseline + ALT+TAB + HB-ON + HB-OFF, exactly the three words added across this session); amd64 screendump confirms the cursor renders correctly after real interactive typing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
af20efaa15
commit
59458a0a16
@@ -57,6 +57,9 @@
|
||||
#include "starkernel/capsule_birth.h"
|
||||
#include "starkernel/capsule_vm_physics.h"
|
||||
#include "freestanding/stdio.h"
|
||||
#include "word_registry.h"
|
||||
|
||||
int g_doe_log_enabled = 1;
|
||||
|
||||
#define DOE_PREFIX "\x1b[36m[HADES][DOE ]\x1b[0m "
|
||||
#define DOE_BUF_SIZE 512
|
||||
@@ -81,6 +84,8 @@ static uint64_t doe_log_heat_by_name(const char *name)
|
||||
|
||||
void doe_log_tick_row(VM *vm, const HeartbeatTickSnapshot *snap)
|
||||
{
|
||||
if (!g_doe_log_enabled)
|
||||
return;
|
||||
if (!snap)
|
||||
return;
|
||||
|
||||
@@ -141,3 +146,23 @@ void doe_log_tick_row(VM *vm, const HeartbeatTickSnapshot *snap)
|
||||
console_puts(buf);
|
||||
console_puts("\r\n");
|
||||
}
|
||||
|
||||
/* HB-ON ( -- ): enable per-tick DoE instrumentation (g_doe_log_enabled=1). */
|
||||
static void doe_word_hb_on(VM *vm)
|
||||
{
|
||||
(void)vm;
|
||||
g_doe_log_enabled = 1;
|
||||
}
|
||||
|
||||
/* HB-OFF ( -- ): disable per-tick DoE instrumentation (g_doe_log_enabled=0). */
|
||||
static void doe_word_hb_off(VM *vm)
|
||||
{
|
||||
(void)vm;
|
||||
g_doe_log_enabled = 0;
|
||||
}
|
||||
|
||||
void register_doe_log_words(VM *vm)
|
||||
{
|
||||
register_word(vm, "HB-ON", doe_word_hb_on);
|
||||
register_word(vm, "HB-OFF", doe_word_hb_off);
|
||||
}
|
||||
|
||||
@@ -324,6 +324,20 @@ void console_fb_toggle_graphics(void)
|
||||
}
|
||||
}
|
||||
|
||||
void console_fb_draw_cursor(void)
|
||||
{
|
||||
if (fb_is_available()) {
|
||||
vt100_draw_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
void console_fb_erase_cursor(void)
|
||||
{
|
||||
if (fb_is_available()) {
|
||||
vt100_erase_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a single character from serial console (non-blocking)
|
||||
* Returns -1 if no character available
|
||||
|
||||
@@ -313,6 +313,33 @@ static void draw_cursor_glyph(uint8_t ch)
|
||||
}
|
||||
}
|
||||
|
||||
/* Solid block cursor at the current position (g_vt.cx, g_vt.cy). Not
|
||||
* blinking -- a static indicator, simplest thing that actually shows
|
||||
* where typed input lands, callable as often as the caller likes since
|
||||
* it is idempotent (always draws the same thing at the current position).
|
||||
* A character typed at this position naturally overwrites it --
|
||||
* draw_cursor_glyph() always fills the whole cell with bg before drawing
|
||||
* a glyph -- but *leaving* this position without drawing a character
|
||||
* (Enter/newline) does not, which is what vt100_erase_cursor() below is
|
||||
* for. No-op outside TTF mode or graphics mode (4.4ab's
|
||||
* g_terminal_visible), matching every other draw call in this file. */
|
||||
void vt100_draw_cursor(void)
|
||||
{
|
||||
if (!g_terminal_visible || g_glyph_mode != VT_GLYPH_TTF) return;
|
||||
fb_fill_rect(px_of(g_vt.cx), py_of(g_vt.cy), cell_w(), cell_h(), eff_fg());
|
||||
}
|
||||
|
||||
/* Erases whatever vt100_draw_cursor() last drew at the current position,
|
||||
* restoring it to plain background -- call this before moving away from
|
||||
* a cursor-drawn cell without also drawing a character there (the
|
||||
* newline case in sk_readline: Enter moves to a new line, and nothing
|
||||
* else would ever overwrite the stray block left behind). */
|
||||
void vt100_erase_cursor(void)
|
||||
{
|
||||
if (!g_terminal_visible || g_glyph_mode != VT_GLYPH_TTF) return;
|
||||
fb_fill_rect(px_of(g_vt.cx), py_of(g_vt.cy), cell_w(), cell_h(), eff_bg());
|
||||
}
|
||||
|
||||
static void reset_attrs(void)
|
||||
{
|
||||
g_vt.fg = g_vt.def_fg;
|
||||
|
||||
@@ -190,6 +190,7 @@ static int sk_readline(char *buf, int size)
|
||||
int n = 0;
|
||||
|
||||
buf[0] = '\0';
|
||||
console_fb_draw_cursor(); /* show the cursor at the bare prompt, before any input */
|
||||
|
||||
for (;;) {
|
||||
int c = console_getc(); /* non-blocking poll */
|
||||
@@ -223,6 +224,7 @@ static int sk_readline(char *buf, int size)
|
||||
}
|
||||
|
||||
if (c == '\r' || c == '\n') {
|
||||
console_fb_erase_cursor(); /* leaving this cell without drawing a char over it */
|
||||
console_putc('\n');
|
||||
break;
|
||||
}
|
||||
@@ -235,6 +237,7 @@ static int sk_readline(char *buf, int size)
|
||||
console_putc('\b');
|
||||
console_putc(' ');
|
||||
console_putc('\b');
|
||||
console_fb_draw_cursor();
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -244,6 +247,7 @@ static int sk_readline(char *buf, int size)
|
||||
buf[n++] = (char)c;
|
||||
buf[n] = '\0';
|
||||
console_putc((char)c); /* echo */
|
||||
console_fb_draw_cursor();
|
||||
}
|
||||
|
||||
buf[n] = '\0';
|
||||
|
||||
@@ -47,9 +47,7 @@
|
||||
#include "../include/inference_engine.h"
|
||||
#include "../include/physics_metadata.h"
|
||||
#include "../include/physics_hotwords_cache.h"
|
||||
#if defined(HEARTBEAT_DOE_LOG) && HEARTBEAT_DOE_LOG
|
||||
#include "starkernel/doe_log.h"
|
||||
#endif
|
||||
#include "../include/ssm_jacquard.h"
|
||||
#include "vm_internal.h"
|
||||
#include "starkernel/capsule_vm_physics.h"
|
||||
@@ -516,9 +514,9 @@ void vm_heartbeat_run_cycle(VM *vm)
|
||||
#if defined(HEARTBEAT_CSV_ENABLED) && HEARTBEAT_CSV_ENABLED
|
||||
heartbeat_emit_tick_row(vm, &tick_snapshot);
|
||||
#endif
|
||||
#if defined(HEARTBEAT_DOE_LOG) && HEARTBEAT_DOE_LOG
|
||||
/* Always compiled in; g_doe_log_enabled (default 1) is the runtime
|
||||
* gate now, toggled live by HB-ON/HB-OFF -- see doe_log.h. */
|
||||
doe_log_tick_row(vm, &tick_snapshot);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HEARTBEAT_THREAD_ENABLED
|
||||
|
||||
Reference in New Issue
Block a user