Skip to content

feat(render): reading column, coloured code blocks, definition lists, stronger headings - #173

Merged
backnotprop merged 2 commits into
mainfrom
feat/reading-look
Nov 20, 2026
Merged

backnotprop merged 2 commits into
mainfrom
feat/reading-look

Conversation

@backnotprop

@backnotprop backnotprop commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Makes the Markdown document screen easier to read.

Code blocks

  • The fences are no longer drawn. A quiet bar runs down the left, and the language shows at the top right when the first line leaves room.
  • Code is coloured by language with the syntect engine that diffs-rs uses (diffs-syntect and diffs-two-face). We depend on those crates directly because diffs-rs itself only builds on Unix. They are pure Rust, so colouring works on Windows too.
  • Colouring is lazy: it runs for the rows that are drawn, and the results are cached per block. The grammars of the first few languages compile on a background thread, so the first frame does not wait for them.
  • Unknown languages keep the one code colour they had before.
  • Colours come from new [colors] roles: code, code-keyword, code-string, code-number, code-function, code-type and code-comment. There are defaults for the dark and light palettes, and NO_COLOR is honoured through crossterm as before.
  • Every cell keeps its source byte. Selections and notes inside a code block map to the code, never to the fences. The bar, the padding and the label map to nothing.
  • A code line too long for the column continues on the next row instead of being cut off.
  • Fenced code inside a list item or a quote gets the same look: no fences, the bar inside the bullet indent or quote bars, colours. It has no language label and wraps like the text around it.
  • On the light palette, code stays readable on white: inline and plain code use a dark amber (new [colors] code role; dark keeps light yellow), and strings, numbers and types use darker 256-colour hues.

Reading column

  • The document text sits in a column centred in the space that the tree and the notes rail leave.
  • [ui] doc_width now defaults to 80 (it was 0). Setting it to 0 fills the pane as before.
  • < and > (new actions narrow-column and widen-column) narrow and widen the column by eight for the session.
  • The first frame is laid out at the column width, so opening a file does not need an extra reflow.
  • Fixes t, which misjudged whether the folder tree was showing once the column left spare space.

Definition lists render as the term, with each definition indented under it, instead of raw : lines.

Headings: H1 and H2 get a blank row above them. H1 gets a rule under it (╍) instead of an underline.

Tests cover:

  • known and unknown languages
  • code wrapping and the label in a narrow column
  • a selection across and inside a code block
  • a note on code at widths 60, 80, 120 and 200 (rail, header, footer and centring)
  • definition lists
  • section spacing
  • the column keys

Speed: built on #166's background layout. Code blocks the background thread lays out are coloured when drawn, like the first screen's, and <, > and resizes go through #166's reflow, so blocks that arrive late take the new width. --bench samples/big.md, 5 runs: first screens 3.8-5.0 ms (main 3.6-4.1 ms), rest in background 40-61 ms (main 40-50 ms). --snapshot samples/big.md 120 40 wall time, 21 runs: main min 85.6 / median 96.2 ms, this branch min 82.8 / median 96.0 ms. The machine was heavily loaded, so treat these as equal.

Overlap with other open work: keys.rs, app/input.rs and app/draw.rs (doc search), and cli.rs.

@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 20, 2026
… stronger headings

Fenced code drops its fences and sits beside a quiet bar, with its language at the top
right when there is room. Code with a bundled grammar is coloured by the syntect engine
diffs-rs uses (diffs-syntect and diffs-two-face, pure Rust, so Windows too), lazily, for the
rows drawn, through new [colors] code-* roles. Unknown languages keep one colour. Cells keep
their source bytes, so selections and notes inside code map to the code, never the fences.

The document text sits in a centred reading column, 80 columns by default ([ui] doc_width,
0 fills as before); < and > narrow and widen it by eight. Long code lines continue on the
next row instead of being clipped. Definition lists render as indented definitions, and
level one and two headings get more room, with a rule under level one.
…t code colours readable on white

Fenced code inside a list item or a quote drops its fences, sits beside the bar inside the
bullet indent or quote bars, and is coloured by language when drawn, read from the source
without the container syntax. Its cells keep their source bytes.

On the light palette, code no longer uses the pale ANSI hues: inline and plain code is a
dark amber (new [colors] code role, light yellow on dark as before), strings and types use
darker 256-colour greens and teals.

Code laid out by the background layout thread is coloured like the first screen's, and the
reading column's width changes reach blocks that arrive late.
@backnotprop
backnotprop added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 27ea5aa Nov 20, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/reading-look branch November 20, 2026 01:58
@backnotprop backnotprop mentioned this pull request Nov 23, 2026
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