Documentation
¶
Index ¶
- func Diff(oldText, newText string) string
- func HighlightJSON(line string) string
- type DiffView
- type Editor
- type Viewer
- func (v *Viewer) MatchCount() int
- func (v *Viewer) MatchIndex() int
- func (v *Viewer) MatchLine() int
- func (v *Viewer) NextMatch()
- func (v *Viewer) PrevMatch()
- func (v *Viewer) Search(query string)
- func (v *Viewer) Searching() bool
- func (v *Viewer) SetContent(content string)
- func (v *Viewer) SetDimensions(width, height int)
- func (v *Viewer) SetHighlight(on bool)
- func (v *Viewer) ToggleWrap()
- func (v *Viewer) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (v *Viewer) View() string
- func (v *Viewer) Wrapped() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff renders a unified line-by-line diff of oldText vs newText. Context lines are prefixed with a space, deletions with `-` (error color) and additions with `+` (success color).
func HighlightJSON ¶
HighlightJSON applies syntax highlighting to a single line of (already pretty-printed) JSON. It is line-based so it composes with soft-wrapping and line numbering. Non-JSON input is returned styled as plain text.
Types ¶
type DiffView ¶
type DiffView struct {
core.BaseComponent
// contains filtered or unexported fields
}
DiffView is a scrollable component wrapping a rendered unified diff.
func NewDiffView ¶
NewDiffView creates a diff view for oldText vs newText.
func (*DiffView) SetContent ¶
SetContent recomputes the diff for new inputs.
func (*DiffView) SetDimensions ¶
SetDimensions sizes the diff view.
type Editor ¶
type Editor struct {
core.BaseComponent
// contains filtered or unexported fields
}
Editor is an editable text component (schema/config/query text) built on bubbles/textarea.
func (*Editor) SetDimensions ¶
SetDimensions sizes the underlying textarea.
type Viewer ¶
type Viewer struct {
core.BaseComponent
// contains filtered or unexported fields
}
Viewer is a read-only content viewer with line numbers, a soft-wrap toggle and in-content `/` search with n/N match navigation. It generalizes the older JSONContentView: pass Highlight to colorize JSON content.
func (*Viewer) MatchCount ¶
MatchCount returns the number of lines matching the current query.
func (*Viewer) MatchIndex ¶
MatchIndex returns the index of the active match, or -1 if there is none.
func (*Viewer) NextMatch ¶
func (v *Viewer) NextMatch()
NextMatch advances to the next search match (wraps around).
func (*Viewer) PrevMatch ¶
func (v *Viewer) PrevMatch()
PrevMatch moves to the previous search match (wraps around).
func (*Viewer) Search ¶
Search sets the active query, computes matching lines and jumps to the first match. An empty query clears the search.
func (*Viewer) Searching ¶
Searching reports whether the in-content `/` search prompt is currently open. Callers that add their own single-key hotkeys should defer to the viewer while this is true so keystrokes reach the search field unmodified.
func (*Viewer) SetContent ¶
SetContent replaces the viewed content and resets search state.
func (*Viewer) SetDimensions ¶
SetDimensions sets the viewer size.
func (*Viewer) SetHighlight ¶
SetHighlight enables or disables JSON syntax highlighting.
func (*Viewer) ToggleWrap ¶
func (v *Viewer) ToggleWrap()
ToggleWrap flips soft-wrapping of long lines.
func (*Viewer) Update ¶
Update handles key input: `/` opens search, enter runs it, esc cancels, n/N navigate matches, w toggles wrap. Other keys scroll the viewport.