Documentation
¶
Index ¶
- func RenderCount() int64
- type App
- type Backlinks
- type EditorResult
- type EditorView
- func (e *EditorView) Content() string
- func (e *EditorView) Focus() tea.Cmd
- func (e *EditorView) MarkSaved(content string)
- func (e *EditorView) SetError(msg string)
- func (e *EditorView) SetSize(w, h int)
- func (e *EditorView) Update(msg tea.KeyMsg) (EditorResult, tea.Cmd)
- func (e *EditorView) View() string
- type Help
- type Overlay
- type OverlayResult
- type PageView
- func (p *PageView) Cursor() int
- func (p *PageView) CycleLink(dir int)
- func (p *PageView) FocusLinkTo(name string)
- func (p *PageView) FollowCursor() string
- func (p *PageView) GotoBottom()
- func (p *PageView) GotoTop()
- func (p *PageView) HalfPageDown()
- func (p *PageView) HalfPageUp()
- func (p *PageView) LineDown()
- func (p *PageView) LineUp()
- func (p *PageView) Offset() int
- func (p *PageView) Page() string
- func (p *PageView) Restore(offset, cursor int)
- func (p *PageView) ScrollIndicator() string
- func (p *PageView) ScrollToTask(ordinal int)
- func (p *PageView) SetPage(name string)
- func (p *PageView) SetPageEmphasizing(name, term string)
- func (p *PageView) SetSize(w, h int)
- func (p *PageView) StatusLine() string
- func (p *PageView) View() string
- type Picker
- type SearchView
- func (s *SearchView) Apply(msg searchDoneMsg)
- func (s *SearchView) Query() string
- func (s *SearchView) SearchCmd(graphPath string) tea.Cmd
- func (s *SearchView) SetQuery(q string)
- func (b *SearchView) SetSize(w, h int)
- func (s *SearchView) Update(key string) OverlayResult
- func (s *SearchView) View() string
- type Todos
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderCount ¶
func RenderCount() int64
RenderCount returns the current value of the per-page render counter. Used by tests.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
type Backlinks ¶
type Backlinks struct {
// contains filtered or unexported fields
}
func NewBacklinks ¶
func NewBacklinks(idx *graph.Index, target string, unlinked []graph.UnlinkedRef, width, height int) *Backlinks
NewBacklinks builds the overlay for `target`, combining the in-memory linked backlinks with the supplied unlinked references (the App computes those via ripgrep on panel-open). Self-references are filtered from the linked list.
func (*Backlinks) SetLinkifyError ¶
SetLinkifyError records a failure to show in the panel and drops the confirm sub-state, so the user returns to the list rather than being stuck confirming a mention that is gone. Errors must render inside the overlay — a status-bar hint would be invisible behind it.
func (*Backlinks) SetSize ¶
func (b *Backlinks) SetSize(w, h int)
SetSize updates the cached terminal dimensions.
func (*Backlinks) Update ¶
func (b *Backlinks) Update(key string) OverlayResult
type EditorResult ¶
type EditorResult struct {
Save bool // App writes Content() to path
Exit bool // App tears down the editor and returns to the read view
}
EditorResult is what EditorView.Update reports to the App.
type EditorView ¶
type EditorView struct {
// contains filtered or unexported fields
}
EditorView is weft's in-app raw-markdown editor: a full-screen mode (not a centered overlay) that wraps bubbles/textarea. It owns the edit/save/exit state machine; the App performs the actual disk write so internal/edit stays the only writer.
func NewEditorView ¶
func NewEditorView(idx *graph.Index, name, path, content string, isNew bool, width, height int) *EditorView
NewEditorView builds an editor for page `name` targeting `path`, primed with `content` (empty for a not-yet-created page). isNew records whether the file existed at open time. idx is the graph index used for link completion; pass nil to disable completion (e.g. in tests that don't exercise it).
func (*EditorView) Content ¶
func (e *EditorView) Content() string
Content is the buffer normalized to end in exactly one newline.
func (*EditorView) Focus ¶
func (e *EditorView) Focus() tea.Cmd
Focus focuses the textarea and returns its (cursor-blink) command.
func (*EditorView) MarkSaved ¶
func (e *EditorView) MarkSaved(content string)
MarkSaved records a successful save: the given content becomes the new clean baseline and the file now exists.
func (*EditorView) SetError ¶
func (e *EditorView) SetError(msg string)
SetError records a message (e.g. a failed save) to show in the status line until the next successful save. Surfacing it here is load-bearing: while the editor is open, App.View renders EditorView.View(), not the app status bar, so a save error routed through the app hint is invisible.
func (*EditorView) SetSize ¶
func (e *EditorView) SetSize(w, h int)
SetSize resizes the textarea, reserving rows for the status line and the active completion strip.
func (*EditorView) Update ¶
func (e *EditorView) Update(msg tea.KeyMsg) (EditorResult, tea.Cmd)
Update handles one key and reports whether the App should save/exit. In editing mode every key except the intercepts (ctrl+s, esc/ctrl+c, pgup/pgdown) is forwarded to the textarea. The returned tea.Cmd is the textarea's own (cursor blink) command, which the App must propagate.
func (*EditorView) View ¶
func (e *EditorView) View() string
type Help ¶
type Help struct {
// contains filtered or unexported fields
}
Help is a stateless overlay listing the keymap. ? or esc toggles it off.
func NewHelp ¶
NewHelp builds the help overlay at the current terminal size. width clamps rendered lines and decides single- vs two-column layout; height caps the panel so it can never overflow the screen — body lines past the cap are dropped with a faint "resize" hint, while the title and close hint always stay visible. Passing width or height as 0 disables that dimension's constraint, yielding the natural content-sized panel (used by tests).
func (*Help) Update ¶
func (h *Help) Update(key string) OverlayResult
Update reports whether the overlay should close. There's no state to mutate.
type Overlay ¶
type Overlay interface {
Update(key string) OverlayResult
View() string
SetSize(w, h int)
}
Overlay is a modal view layered over the page. App routes keys to the active overlay and closes it when Update reports Accept or Cancel.
type OverlayResult ¶
type OverlayResult struct {
// Selected is the page to open when Accept is true. Empty means "accept
// but navigate nowhere" (e.g. a search hit whose file isn't indexed).
Selected string
// TaskOrdinal is the 0-based open-todo index on the selected page to
// scroll to, honoured only when DeepLink is true. Only the Todos overlay
// sets these; other overlays leave DeepLink false and the page opens at
// the top.
TaskOrdinal int
DeepLink bool
Accept bool // user chose Selected; App navigates (if non-empty) and closes
Cancel bool // user dismissed; App closes the overlay
// Create, when Accept is true, means "create the page named Selected"
// rather than open an existing one. Only the Picker sets it.
Create bool
// FocusLinkTo, when Accept is true and non-empty, asks the App to position
// the destination page's link cursor on the first link back to this page
// (so a backlink jump lands on — and highlights — the referencing link).
// Only the Backlinks overlay sets it, and only for linked refs.
FocusLinkTo string
// HighlightText, when Accept is true and non-empty, asks the App to navigate
// to Selected and highlight occurrences of this term on the destination
// (scrolling to the first). Only the Backlinks overlay sets it, for unlinked
// refs.
HighlightText string
// Linkify, when non-nil, asks the App to wrap LinkifyTarget as a [[link]]
// at this unlinked reference's location in its source file, then reindex
// and refresh the panel. Only the Backlinks overlay sets it.
Linkify *graph.UnlinkedRef
// LinkifyTarget is the page name to wrap, honoured only when Linkify is set.
LinkifyTarget string
Cmd tea.Cmd // optional async work to run (search launches rg here)
}
OverlayResult is what an overlay's Update reports back to the App.
type PageView ¶
type PageView struct {
// contains filtered or unexported fields
}
PageView renders a single page with a wiki-link cursor.
func (*PageView) CycleLink ¶
CycleLink moves the cursor to the next/previous wiki-link, scrolling the viewport so the new cursor target is visible. dir=+1 forwards, dir=-1 backwards.
func (*PageView) FocusLinkTo ¶
FocusLinkTo positions the link cursor on the first link whose target resolves to name and scrolls it into view. No-op when the page has no such link.
func (*PageView) FollowCursor ¶
FollowCursor returns the link target under the cursor, or "" if none.
func (*PageView) GotoBottom ¶
func (p *PageView) GotoBottom()
func (*PageView) HalfPageDown ¶
func (p *PageView) HalfPageDown()
func (*PageView) HalfPageUp ¶
func (p *PageView) HalfPageUp()
func (*PageView) LineDown ¶
func (p *PageView) LineDown()
LineDown/LineUp/HalfPage/Goto delegates to viewport.
func (*PageView) Restore ¶
Restore sets the viewport scroll offset and link cursor in one shot. The viewport's SetYOffset clamps offset against the current content height. Cursor is clamped to a valid link index; anything outside [0, len(Links)) falls back to -1 (no link selected). Use after SetPage to recover scroll/cursor state captured before a navigation.
func (*PageView) ScrollIndicator ¶
ScrollIndicator returns "" when the page fits the viewport (no scroll possible), otherwise "NN%" — 0% at the top, 100% at the bottom. viewport.ScrollPercent is already clamped to [0, 1] and returns exactly 0 at YOffset=0 and 1 at the max offset.
func (*PageView) ScrollToTask ¶
ScrollToTask centres the viewport on the open todo at the given 0-based ordinal (its position among the page's open todos in document order, as recorded in render.Result.Tasks). No-op when the ordinal is out of range. One-shot deep-link jump applied at SetPage time — not a property Restore rewinds into.
func (*PageView) SetPageEmphasizing ¶
SetPageEmphasizing switches to name and highlights whole-word occurrences of term (the page navigated from), scrolling to the first. The highlight is transient: a later SetPage or history Restore clears it.
func (*PageView) SetSize ¶
SetSize updates viewport size. The page body is only re-rendered when the width changes — height changes don't affect word-wrap, so we just resize the viewport and let it re-clip the existing styled content.
func (*PageView) StatusLine ¶
StatusLine returns the text to display on the left side of the App-level status bar: page name, plus a link count or cursor position when relevant.
type Picker ¶
type Picker struct {
// contains filtered or unexported fields
}
func (*Picker) SetSize ¶
func (b *Picker) SetSize(w, h int)
SetSize updates the cached terminal dimensions.
func (*Picker) Update ¶
func (p *Picker) Update(key string) OverlayResult
Update handles a key and reports the result to the App.
type SearchView ¶
type SearchView struct {
// contains filtered or unexported fields
}
func NewSearchView ¶
func NewSearchView(idx *graph.Index, width, height int) *SearchView
func (*SearchView) Apply ¶
func (s *SearchView) Apply(msg searchDoneMsg)
func (*SearchView) Query ¶
func (s *SearchView) Query() string
func (*SearchView) SearchCmd ¶
func (s *SearchView) SearchCmd(graphPath string) tea.Cmd
SearchCmd returns a tea.Cmd that runs rg and returns a searchDoneMsg.
func (*SearchView) SetQuery ¶
func (s *SearchView) SetQuery(q string)
func (*SearchView) SetSize ¶
func (b *SearchView) SetSize(w, h int)
SetSize updates the cached terminal dimensions.
func (*SearchView) Update ¶
func (s *SearchView) Update(key string) OverlayResult
Update handles a key and reports the result to the App.
func (*SearchView) View ¶
func (s *SearchView) View() string