refactor(md, term, cli): Move ANSI stream machinery into jp_term - #1139
Open
JeanMertz wants to merge 2 commits into
Open
refactor(md, term, cli): Move ANSI stream machinery into jp_term#1139JeanMertz wants to merge 2 commits into
jp_term#1139JeanMertz wants to merge 2 commits into
Conversation
JeanMertz
force-pushed
the
term/ansi-move
branch
from
September 8, 2026 21:43
88ff9fd to
4045f85
Compare
`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>
JeanMertz
force-pushed
the
term/ansi-move
branch
from
September 9, 2026 08:49
4045f85 to
8037b7e
Compare
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ansiandshademove fromjp_mdtojp_term, along with theregion-background types they interpret, which land in a new
jp_term::background. Nothing about what they do is markdown:segmentstokenizes an escape stream,
AnsiStatetracks what a stream left active,and
ShadedWriterkeeps a background showing across cursor rewrites andsplit escapes.
jp_mdgains ajp_termdependency and imports them likeany other consumer.
The move puts them where the printer can reach them.
jp_printerdependson
jp_termand deliberately not onjp_md, so shading a prompt meanteither pulling a markdown renderer into the output layer or writing the
state machine a second time.
DefaultBackground,BackgroundFill, andline_fillleavejp_md::formatforjp_term::background, so the types and the one placethat interprets them travel together.
AnsiState's methods widen frompub(crate)topubnow that its callers are in another crate.Signed-off-by: Jean Mertz git@jeanmertz.com