Color-coded unified diff renderer.
glyph add diff-viewThis copies diff-view.go (and its test file) into your repo at the path your
glyph.json aliases declare. After install, the file is yours: edit it,
refactor it, rename it. There is no diff-view library to keep in sync.
package main
import (
"fmt"
diffview "github.com/truffle-dev/glyph/components/diff-view"
"github.com/truffle-dev/glyph/components/theme"
)
func main() {
raw := `--- a/server.go
+++ b/server.go
@@ -1,3 +1,4 @@
package server
+
func Run() {}
`
d := diffview.New(theme.Default).
WithSize(96, 18).
WithLines(diffview.ParseUnified(raw))
fmt.Println(d.View())
}Package: diffview
Types
KindLineView
Functions and methods
NewWithLinesWithSizeWithLineNumbersOffsetInitUpdateViewTotalLinesParseUnified
- glyph component
theme(installed automatically) github.com/charmbracelet/bubbletea@v1.3.10github.com/charmbracelet/lipgloss@v1.1.0
Pass WithLines(ParseUnified(diff)) to render git diff -u output. To render a diff you generated yourself, construct []Line directly. Up/Down scrolls one line, PgUp/PgDn scrolls a window, Home/End jumps. Lines longer than the body width truncate with an ellipsis.
- examples/showcase — single-binary TUI composing the seven main surfaces
- components/diff-view/story — runnable story binary (
go run -tags glyph_story ./components/diff-view/story/) - registry manifest — the JSON contract
glyph addreads
MIT, same as the rest of glyph.
