ADR-0022 stage 3/8: simple-mode echo lines highlighted

Lift `dsl::ECHO_PREFIX = "running: "` as a public const,
with a unit test asserting `t!("dsl.running", input = "")`
matches it. The catalog template is now contracted to equal
`format!("{ECHO_PREFIX}{input}")` — a translator changing
the prefix breaks the test.

Add `input_render::lex_to_runs(input, theme)` — a
cursor-less variant of `render_input_runs` for use cases
(echo lines, future hint panel) that need token-class
colouring without an inverted cursor.

ui::render_output_line: when the line is an Echo submitted
in Simple mode, peel the prefix and re-tokenise the rest
through lex_to_runs, rendering each token at its class
colour. Advanced-mode echoes and any echo whose body
unexpectedly lacks the prefix fall through to the plain
rendering.

Tests: 683 passing, 0 failing, 1 ignored (682 baseline →
+1 echo_prefix_matches_catalog_template). Clippy clean
(uses let-chain to keep the if condition flat).

Stage 4 adds render-time parse + error overlay so the
failing token in mid-typed input lights up in the error
colour.
This commit is contained in:
claude@clouddev1
2026-05-10 17:32:11 +00:00
parent cafc455c8a
commit 39da399add
3 changed files with 70 additions and 6 deletions
+10 -1
View File
@@ -55,11 +55,20 @@ impl StyledRun {
/// the cursor at `cursor_byte` (clamped to `input.len()`).
#[must_use]
pub fn render_input_runs(input: &str, cursor_byte: usize, theme: &Theme) -> Vec<StyledRun> {
let mut runs = base_runs(input, theme);
let mut runs = lex_to_runs(input, theme);
inject_cursor(&mut runs, input, cursor_byte, theme);
runs
}
/// Cursor-less variant: tokenises `input` into styled runs
/// covering the full byte range, with no inverted cursor.
/// Used by the echo-line renderer (ADR-0022 §5) where there's
/// no cursor to show.
#[must_use]
pub fn lex_to_runs(input: &str, theme: &Theme) -> Vec<StyledRun> {
base_runs(input, theme)
}
fn base_runs(input: &str, theme: &Theme) -> Vec<StyledRun> {
let tokens = lex(input);
let mut runs = Vec::with_capacity(tokens.len() * 2);