Documentation
¶
Index ¶
- Constants
- func AlignHunkColors(rows []mekugi.ReviewRow, before, after []string)
- func CallerKey(caller string) string
- func DiffRows(source string) []mekugi.ReviewRow
- func Fade(line string, progress float64, canvas Canvas) string
- func Gutter(highlighted bool, theme Theme) string
- func Header(text string, width int, counts Counts, theme Theme) string
- func Safe(text string, colors bool) string
- func SourceLine(theme Theme, width int, numbers, fragment string, kind byte) string
- func WrapSource(text string, width int) []string
- type Canvas
- type Chunk
- type Counts
- type File
- type LineSource
- type OSC
- type Origin
- type Output
- type RGB
- type Render
- type Renderer
- func (r *Renderer) ColorDiff(ctx context.Context, theme Theme, source string) ([]string, error)
- func (r *Renderer) ColorDiffPath(ctx context.Context, theme Theme, path, source string) ([]string, error)
- func (r *Renderer) ColorDiffRows(ctx context.Context, theme Theme, path, source string) ([]mekugi.ReviewRow, error)
- func (r *Renderer) ColorHunk(ctx context.Context, theme Theme, review mekugi.ReviewFile, ...) ([]string, []string, error)
- func (r *Renderer) ColorSource(ctx context.Context, theme Theme, path, source string) ([]string, error)
- func (r *Renderer) Render(ctx context.Context, theme Theme, files []File, workspace string, width int) (Render, error)
- type Theme
- func (theme Theme) Accent() string
- func (theme Theme) Canvas() Canvas
- func (theme Theme) Foreground(kind chroma.TokenType) string
- func (theme Theme) RowBackground(kind byte) string
- func (theme Theme) SelectionBackground() string
- func (theme Theme) TextCanvas(kind byte, canvas Canvas) Canvas
- func (theme Theme) WordBackground(kind byte) string
- type View
- func (v *View) FilterCaller(caller string)
- func (v *View) FollowLatest()
- func (v *View) JumpTo(render Render, offset int)
- func (v *View) LatestChunk() Chunk
- func (v *View) Merge(files []File)
- func (v *View) Open(file int)
- func (v *View) Reflow(before, after Render)
- func (v *View) RefreshVisible()
- func (v *View) ScrollTo(render Render, offset int)
- func (v *View) Shows(chunk Chunk) bool
Constants ¶
const MaxSourceBytes = 64 << 20
const MaxSyntaxBytes = 256 << 10
Syntax is best-effort decoration. Bound lexer input independently of the display limit; huge hunks and unknown languages still display exact safe text.
const Subtle = "\x1b[2m"
Subtle marks secondary text; unsupported terminals receive a fixed-color fallback.
const SubtleReset = "\x1b[22m"
SubtleReset clears faint (SGR 22 also clears bold).
const UnknownCaller = "?"
UnknownCaller is the filter key for captures recorded without a caller, so filtering to them stays distinct from showing all.
Variables ¶
This section is empty.
Functions ¶
func AlignHunkColors ¶
AlignHunkColors replaces caller-owned row text with its before/after color, preserving hunk geometry without allocating another row slice.
func DiffRows ¶
DiffRows parses display-only unified output, including clipped and partial hunks. Metadata has no source-row kind; source rows omit their diff marker.
func Fade ¶
Fade renders SGR-colored text partway through appearing. Truecolor foregrounds blend from the fill beneath them, and default text takes the canvas foreground so it fades too. Fills, other attributes, and palette colors pass through. Progress 1 returns the text unchanged.
func Safe ¶
Only text and SGR colors may reach the viewport. In particular, captured source must not emit cursor controls, OSC clipboard writes, or terminal titles.
func SourceLine ¶
func WrapSource ¶ added in v0.2.0
WrapSource keeps both syntax foregrounds and word backgrounds on independently painted continuation rows. SourceLine keeps gutters and padding at the row fill.
Types ¶
type Canvas ¶
type Canvas struct{ Background, Foreground RGB }
Canvas is what a fading row emerges from. A terminal-reported background replaces the theme's assumed one; the foreground stands in for default text.
type File ¶
type File struct {
Path string
Chunks []Chunk
Highlighted bool
// Origins are the shown changes a visible file composes, in capture
// order. Baseline counts changes a caller filter folded into its base.
Origins []Origin
Baseline int
// contains filtered or unexported fields
}
Live views read immutable review projections, never workspace files or carriers.
func GroupCaptures ¶
type LineSource ¶
type LineSource struct {
// Change names the capture a row shows, or for a composed file the
// comma-separated changes it combines.
Change, Path string
Line int // Gutter coordinate: old for deletions, new otherwise.
Deleted bool // Line is an old-file coordinate.
Content int // Display column where the row's text starts, after gutters.
}
LineSource attributes a display row. Chrome rows have no Line.
type OSC ¶
Consume OSC replies separately from navigation. The payload is bounded even for malformed/unterminated replies, and an ST terminator may span input reads.
type Origin ¶
type Origin struct {
Change, Caller, Source string
}
Origin attributes a capture: its change ID, the canonical agent path that made it, and the tool or program that wrote it.
type RGB ¶
type RGB struct{ R, G, B uint8 }
RGB is a truecolor terminal color.
func BackgroundColor ¶
BackgroundColor is the reported background, for blending toward it.
func ForegroundColor ¶
ForegroundColor is the reported default text color (an OSC 10 reply).
type Render ¶
type Renderer ¶
type Renderer struct {
// LayoutOnly defers complete-hunk syntax decoration until PaintViewport.
LayoutOnly bool
// Caller presents a canonical agent path as a display name and an SGR
// color prefix. Without it, paths appear as recorded, uncolored.
Caller func(path string) (name, color string)
// contains filtered or unexported fields
}
Syntax is independent of wrapping, coordinates, and recency marks. Keep bounded caches in each viewer, never shared across sessions.
func (*Renderer) ColorDiff ¶
ColorDiff decorates unified output without changing its rows or metadata. Partial streaming hunks use the same source lexer as the diff pane.
func (*Renderer) ColorDiffPath ¶
func (r *Renderer) ColorDiffPath(ctx context.Context, theme Theme, path, source string) ([]string, error)
ColorDiffPath supplies the file identity for host hunks without unified headers. Explicit headers still select the language for each file.
func (*Renderer) ColorDiffRows ¶
func (r *Renderer) ColorDiffRows(ctx context.Context, theme Theme, path, source string) ([]mekugi.ReviewRow, error)
ColorDiffRows uses the same row geometry as DiffRows and the pane's source lexer. Callers can wrap and fill rows at their own viewport width.
func (*Renderer) ColorHunk ¶
func (r *Renderer) ColorHunk(ctx context.Context, theme Theme, review mekugi.ReviewFile, rows []mekugi.ReviewRow) ([]string, []string, error)
Tokenise the two sides separately so deleted text cannot change the syntax state of additions. Never read the workspace to fill uncaptured source gaps.
type Theme ¶
type Theme uint8
func BackgroundTheme ¶
OSC 11 uses X11 rgb: components of one to four hex digits. Do not treat malformed replies as evidence of a dark background.
func EnvironmentTheme ¶
COLORFGBG is a fallback for terminals that do not answer OSC 11. Its final field is the background's palette index; the optional middle field is ignored. Only neutral indices have a useful light/dark interpretation without a reply.
func (Theme) Foreground ¶
Chroma owns token inheritance; row backgrounds are applied separately.
func (Theme) RowBackground ¶
Changed rows use paired foregrounds and subtle fills, including before theme detection completes. Context and chrome retain the terminal background.
func (Theme) SelectionBackground ¶
SelectionBackground is a neutral fill that marks a selected row in place.
func (Theme) TextCanvas ¶
TextCanvas is what a changed row's text emerges from: the row's own fill, which stays put, and the default text color on that fill.
func (Theme) WordBackground ¶ added in v0.2.0
WordBackground emphasizes changed words without replacing syntax foregrounds.
type View ¶
type View struct {
Files []File
Selected int
Scroll map[string]int
Visible map[string]File
Following bool
Latest string
Initialized bool
UnseenUpdate bool
// Caller, when set, shows only captures whose CallerKey matches. Other
// callers' captures compose as baseline, so the net diff stays exact.
Caller string
}
func (*View) FilterCaller ¶
FilterCaller shows only one CallerKey's captures; an empty key shows all.
func (*View) FollowLatest ¶
func (v *View) FollowLatest()
Follow the latest newly observed capture, including edits received while paused. Capture ordering here drives navigation, not a claim about execution order.
func (*View) JumpTo ¶
JumpTo moves the viewport like ScrollTo, but a file it leaves keeps its position.
func (*View) LatestChunk ¶
func (*View) RefreshVisible ¶
func (v *View) RefreshVisible()
Rebuild the combined result from captures.