Skip to content

refactor(md, term, cli): Move ANSI stream machinery into jp_term - #1139

Open
JeanMertz wants to merge 2 commits into
mainfrom
term/ansi-move
Open

refactor(md, term, cli): Move ANSI stream machinery into jp_term#1139
JeanMertz wants to merge 2 commits into
mainfrom
term/ansi-move

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

ansi and shade move from jp_md to jp_term, along with the
region-background types they interpret, which land in a new
jp_term::background. Nothing about what they do is markdown: segments
tokenizes an escape stream, AnsiState tracks what a stream left active,
and ShadedWriter keeps a background showing across cursor rewrites and
split escapes. jp_md gains a jp_term dependency and imports them like
any other consumer.

The move puts them where the printer can reach them. jp_printer depends
on jp_term and deliberately not on jp_md, so shading a prompt meant
either pulling a markdown renderer into the output layer or writing the
state machine a second time.

DefaultBackground, BackgroundFill, and line_fill leave
jp_md::format for jp_term::background, so the types and the one place
that interprets them travel together. AnsiState's methods widen from
pub(crate) to pub now that its callers are in another crate.

Signed-off-by: Jean Mertz git@jeanmertz.com

Base automatically changed from prompt/hold-output to main September 9, 2026 08:40
`ansi` and `shade` move from `jp_md` to `jp_term`, along with the
region-background types they interpret, which land in a new
`jp_term::background`. Nothing about what they do is markdown: `segments`
tokenizes an escape stream, `AnsiState` tracks what a stream left active,
and `ShadedWriter` keeps a background showing across cursor rewrites and
split escapes. `jp_md` gains a `jp_term` dependency and imports them like
any other consumer.

The move puts them where the printer can reach them. `jp_printer` depends
on `jp_term` and deliberately not on `jp_md`, so shading a prompt meant
either pulling a markdown renderer into the output layer or writing the
state machine a second time.

`DefaultBackground`, `BackgroundFill`, and `line_fill` leave
`jp_md::format` for `jp_term::background`, so the types and the one place
that interprets them travel together. `AnsiState`'s methods widen from
`pub(crate)` to `pub` now that its callers are in another crate.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
The module summary said `visual_width` and `advance_column` both advance
a tab to its stop. Only the second does: `visual_width` is a column
count, and its own doc comment says a tab counts as one column.

Each now gets its own sentence, with the numbers the tab test pins, so a
caller padding to a fixed column is pointed at `advance_column` instead
of reaching for the width and overshooting.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant