Documentation
¶
Overview ¶
Package diff renders unified diff text into styled lines, shared by the edit-result chat renderer and the permission prompt (doc 02 section 9). The input is the diff the core already computed and shipped in the event's consequence; this package never re-derives a change from raw tool input (D2, D15). It layers chroma syntax colors under the diff backgrounds, marks the intra-line spans that actually changed, and offers unified and side-by-side layouts.
Index ¶
- func Render(diffText string, width int, th theme.Theme, mode Mode) []string
- type Mode
- type Viewer
- func (v Viewer) Focus() int
- func (v Viewer) Hunks() int
- func (v Viewer) Mode() Mode
- func (v *Viewer) NextHunk()
- func (v *Viewer) PrevHunk()
- func (v *Viewer) ScrollLeft()
- func (v *Viewer) ScrollRight()
- func (v *Viewer) SetMode(m Mode)
- func (v *Viewer) SetSize(width, height int)
- func (v *Viewer) Toggle()
- func (v Viewer) View() []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Viewer ¶
type Viewer struct {
// contains filtered or unexported fields
}
Viewer is the stateful view over a single diff: the pure Render draws the cells, and the Viewer adds what a person needs on top of them, namely a live unified/split toggle, per-hunk navigation with a counter, and horizontal scroll for lines too wide to fit (doc 02 section 9, plan 02 slice 2). It holds no terminal state of its own beyond a size, a mode, a focused hunk, and a horizontal offset, so the same Viewer with the same fields yields the same frame, which is what the goldens pin.
func NewViewer ¶
NewViewer builds a viewer over diffText in Auto layout. Size defaults to something usable until SetSize arrives from the first resize.
func (*Viewer) NextHunk ¶
func (v *Viewer) NextHunk()
NextHunk and PrevHunk move the focus and reset horizontal scroll, so a jump always lands with the hunk's left edge in view.
func (*Viewer) ScrollLeft ¶
func (v *Viewer) ScrollLeft()
func (*Viewer) ScrollRight ¶
func (v *Viewer) ScrollRight()
ScrollRight and ScrollLeft pan a wide line horizontally rather than wrapping it into noise.
func (*Viewer) SetSize ¶
SetSize records the space the viewer draws into. Width feeds the Auto layout threshold; height bounds the visible window.