Skip to main content

Component · Data

Diff View

A vertically scrollable, syntax-neutral presentation of projected diff lines.

Kind
widget
Input
interactive
Canvas
120×40

Live preview

Loading terminal preview.

Static terminal poster. Choose Run live to start the Rust demo.

Ghosttydiff/basic
Loading terminal poster…
○ loading posterNo input — rendered state only
Diff View · exact mounted Rust story

01 · Purpose

What it is for

A vertically scrollable, syntax-neutral presentation of projected diff lines.

Best fit: Data · data · widget

02 · Behavior

What the mounted story proves

  1. 01

    DiffView

    Representative 120×40 terminal state.

  2. 02

    Passive paint

    No keyboard or pointer action is claimed by this representative story.

  3. 03

    Evidence stays explicit

    1 covered · 9 partial · 5 missing axes.

03 · Implement

Install, then start from exact code

Install

cargo add termrock --git https://github.com/tailrocks/termrock.git --rev 5283c2acf9154d0cfcd37b1ffe821c00faf90ea2

Add TermRock once. Keep domain effects in the host application.

Minimal implementation

Exact Rust setup used by diff/basic.

Open to load code.

04 · Adapt

Variants and composition

Variants

Use the preview Variant menu when alternate registered stories exist. Each selection mounts a fresh configuration.

Composition

Data · data · widget

05 · Reference

API, tokens, accessibility

API

DiffViewOpen source ↗

Tokens

DesignSystemInspect exact story code for roles and capability projection.

Accessibility

Input contract mountedNo input claim in the representative story.

Contract

Evidence in progress1/23 axes covered

06 · Go deeper

Advanced guidance

Authored implementation guidance

O(visible) paint over a consumer-owned line projection. TermRock owns mode resolution, scroll, search, fold, cursor/hunk chrome, line numbers, word-level spans, and no-color prefixes — not git, staging, or multi-file loading.

When to use / when not

Use DiffViewPrefer
Read-only patch viewing (delta/GitUI-class)—
Interactive hunk activate/stageDiffReview veneer
Structured eventsEventStream
Plain logsLogStream

Outcomes

  • Scrolled · CursorMoved · HunkCursorMoved · HunkActivated
  • ModeChanged · SearchChanged · FoldToggled · FileNavigated · Cancelled · Ignored

Modes

PreferenceEffective
Auto (default)Split when width ≥ 56; else unified
SplitPrefer split; collapses under narrow
UnifiedAlways single column

Non-color

  • Prefixes: + / - / (always painted)
  • Active gutter: › / >; inactive hunk · / .
  • Whitespace marker: · / ~
  • Empty: ∅ / [ ]
  • Colorless: strong add/remove + bold word spans

Keys

KeyAction
n/pHunk step
j/k page Home/EndScroll / first-last hunk
sCycle mode
/Search
zFold hunk
l · w · .Line nos · word-diff · whitespace
EnterActivate hunk
Ownership boundary

TermRock owns reusable terminal rendering and interaction state. The host owns domain data, policy, persistence, authorization, and side effects.

Evidence status

1 covered, 9 partial, and 5 missing contract axes. Missing evidence is not a behavior claim.