Documentation
¶
Overview ¶
Package docview is the shared file viewer: one document, wrap, and path actions (info, reveal, yank). Hosts own tabs and chrome.
Index ¶
- Constants
- func BeginResolutions(index *contentlink.ResolutionIndex, root string, frame PreparedFrame, ...)
- func ContentLinkKinds() contentlink.KindSet
- func EditExternal(root, path string, line int) tea.Cmd
- func FetchGitInfo(root, path string) tea.Cmd
- func FormatSize(bytes int64) string
- func InjectHighlights(row string, ranges []MatchRange, current int) string
- func NormalizeTabPath(path string) string
- func RenderInfo(d FileDetails, gitStatus, lastCommit string) string
- func Reveal(root, path string) tea.Cmd
- func SearchCommands(context string) []plugin.Command
- func VisibleTabRange(widths []int, active, maxWidth int) (start, end int, showLeft, showRight bool)
- func YankContents(root, path string) tea.Cmd
- func YankPath(path string) tea.Cmd
- func YankText(text string) tea.Cmd
- type ContentLinkFrame
- type ContentLinkHit
- type FileDetails
- type GitInfoMsg
- type Gutter
- type Info
- func (i *Info) ApplyGit(msg GitInfoMsg)
- func (i *Info) HandleKey(msg tea.KeyPressMsg) (closed bool, cmd tea.Cmd)
- func (i *Info) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) (closed bool)
- func (i *Info) Render(width, height int, handler *mouse.Handler) string
- func (i *Info) WheelAtBoundary(msg tea.MouseWheelMsg, handler *mouse.Handler) bool
- type Item
- type LoadedMsg
- type Match
- type MatchRange
- type Model
- func (m *Model) AbandonSelection() textselect.Result
- func (m *Model) ApplyLine(line int)
- func (m *Model) Arm(modelID int, relPath string, epoch uint64)
- func (m *Model) ClearSelection()
- func (m *Model) CloseSearch()
- func (m *Model) ContentLinkRect() mouse.Rect
- func (m *Model) ContentLinksSafe() bool
- func (m *Model) HandleKey(k tea.KeyMsg) bool
- func (m *Model) HandleSearchKey(msg tea.KeyMsg) (bool, tea.Cmd)
- func (m *Model) HandleSearchPaste(msg tea.PasteMsg) (bool, tea.Cmd)
- func (m *Model) HandleSelectionKey(msg tea.KeyMsg) textselect.Result
- func (m *Model) HandleSelectionMouse(action mouse.MouseAction) textselect.Result
- func (m *Model) HasScrollbar() bool
- func (m *Model) HasSelection() bool
- func (m *Model) Load(modelID int, rootDir, relPath string, line int, epoch uint64) tea.Cmd
- func (m *Model) LoadFile(modelID int, file *os.File, relPath string, line int, epoch uint64) tea.Cmd
- func (m *Model) LoadFrom(modelID int, rootDir, relPath string, line int, epoch uint64, load tea.Cmd) tea.Cmd
- func (m *Model) NeedsLoad() bool
- func (m *Model) Observe()
- func (m *Model) OffsetAtTrackRow(row int) int
- func (m *Model) PrepareFrame(opts PrepareOptions) PreparedFrame
- func (m *Model) PreparedFrame() PreparedFrame
- func (m *Model) Refresh(suppressed bool) tea.Cmd
- func (m *Model) RefreshFrom(load tea.Cmd) tea.Cmd
- func (m *Model) RefreshPending() bool
- func (m *Model) Reload() tea.Cmd
- func (m *Model) Rendered() bool
- func (m *Model) ResultMatches(msg LoadedMsg) bool
- func (m *Model) Root() string
- func (m *Model) ScanContentLinks(body string, opts contentlink.FrameOptions) ContentLinkFrame
- func (m *Model) Scroll(delta int)
- func (m *Model) ScrollAtBoundary(delta int) bool
- func (m *Model) ScrollOffset() int
- func (m *Model) ScrollbarDragging() bool
- func (m *Model) ScrollbarParams() ui.ScrollbarParams
- func (m *Model) ScrollbarRect() mouse.Rect
- func (m *Model) SearchActive() bool
- func (m *Model) SearchCommitted() bool
- func (m *Model) SearchMatchIndex() int
- func (m *Model) SearchMatches() []Match
- func (m *Model) SearchQuery() string
- func (m *Model) SelectionCopyCmd(result textselect.Result, wrap func(textselect.CopyNotice) tea.Msg) tea.Cmd
- func (m *Model) SelectionText() []string
- func (m *Model) SetLoader(loader PreviewLoader)
- func (m *Model) SetOrigin(x, y int)
- func (m *Model) SetPendingScroll(offset int)
- func (m *Model) SetRendered(rendered bool)
- func (m *Model) SetResult(msg LoadedMsg) bool
- func (m *Model) SetRoot(root string)
- func (m *Model) SetSelection(keys textselect.Keys, copyOnSelect bool)
- func (m *Model) SetSize(width, height int)
- func (m *Model) SetWrap(wrap bool)
- func (m *Model) StartSearch()
- func (m *Model) Title() string
- func (m *Model) ToggleRenderMode()
- func (m *Model) ToggleWrap()
- func (m *Model) TopSourceLine() int
- func (m *Model) View() string
- func (m *Model) VisualRevision() uint64
- func (m *Model) WatchTarget() livewatch.Target
- func (m *Model) Wrap() bool
- func (m *Model) YankSelectionOrContents() tea.Cmd
- func (m *Model) YankSelectionOrLoaded() tea.Cmd
- type NotModified
- type PrepareOptions
- type PreparedFrame
- func (f PreparedFrame) AppendHitsAt(dst []ContentLinkHit, originX, originY int) []ContentLinkHit
- func (f PreparedFrame) EachHitAt(originX, originY int, yield func(ContentLinkHit))
- func (f PreparedFrame) Output() string
- func (f PreparedFrame) Pending(yield func(contentlink.Pending))
- func (f PreparedFrame) Valid() bool
- type PreviewLoader
- type RevealErrorMsg
- type TabHit
- type TabStrip
- type Tabs
- func (t Tabs) ActiveView() *Model
- func (t *Tabs) Append(view *Model)
- func (t Tabs) ClearSelectionsExcept(keep *Model)
- func (t *Tabs) CloseActive()
- func (t *Tabs) CloseAt(index int)
- func (t *Tabs) Cycle(delta int)
- func (t Tabs) IndexOf(path string) int
- func (t *Tabs) Select(i int)
- func (t Tabs) VisibleRange(widths []int, maxWidth int) (start, end int, showLeft, showRight bool)
Constants ¶
const TabMinBudget = tabs.MinBudget
TabMinBudget is the floor for one tab's column share, chrome and the per-tab close control included.
Variables ¶
This section is empty.
Functions ¶
func BeginResolutions ¶ added in v1.12.0
func BeginResolutions(index *contentlink.ResolutionIndex, root string, frame PreparedFrame, yield func(contentlink.ResolutionRequest))
BeginResolutions passes this frame's unresolved candidates through the shared root-aware index and yields only newly accepted work. Re-reading a cached frame while work is in flight therefore schedules nothing.
func ContentLinkKinds ¶ added in v1.3.0
func ContentLinkKinds() contentlink.KindSet
ContentLinkKinds is the set the Files plugin advertises. Workspace and global document panes scan the same kinds so a token clickable in Files is clickable here.
func EditExternal ¶ added in v1.10.0
EditExternal opens a document through Sidecar's shared external-editor launcher. Hosts pass the viewer's root and title so the action remains tied to the focused document rather than to a primary file-browser selection.
func FetchGitInfo ¶ added in v0.99.0
FetchGitInfo retrieves git status and last commit for a root-relative path.
func FormatSize ¶ added in v0.99.0
FormatSize formats a byte count in human-readable form.
func InjectHighlights ¶ added in v1.2.0
func InjectHighlights(row string, ranges []MatchRange, current int) string
InjectHighlights walks an ANSI-styled row and opens/closes highlight sequences at the given plain-text byte offsets, leaving the row's own styling in place. Ranges must be sorted by Start; current is the index of the match that gets the "current match" styling.
func NormalizeTabPath ¶ added in v0.99.0
NormalizeTabPath is the dedup key: slash-normalized, cleaned display path.
func RenderInfo ¶ added in v0.99.0
func RenderInfo(d FileDetails, gitStatus, lastCommit string) string
RenderInfo paints the file-info field list.
func SearchCommands ¶ added in v1.2.0
SearchCommands is the footer vocabulary of a live in-file search, in one place so the project workspace and the global Workspaces browser cannot advertise different keys for the same bar. The caller supplies its own focus context; the IDs are what internal/keymap registers the bindings under, and they are the Files plugin's own so one feature has one vocabulary everywhere.
func VisibleTabRange ¶ added in v0.99.0
VisibleTabRange is the inclusive [start, end] window of tabs that fit in maxWidth given their rendered widths, keeping the active tab visible. showLeft and showRight are the overflow markers for tabs outside the window.
func YankContents ¶ added in v0.99.0
YankContents copies the file at root/path to the clipboard.
Types ¶
type ContentLinkFrame ¶ added in v1.3.0
type ContentLinkFrame struct {
Output string
Hits []ContentLinkHit
Pending []contentlink.Pending
}
ContentLinkFrame is ScanContentLinks' result: the body with recognized spans decorated, the hits those spans occupy, and any file/diff work the host still needs to resolve.
type ContentLinkHit ¶ added in v1.3.0
type ContentLinkHit struct {
Ref contentlink.Ref
Rect mouse.Rect
}
ContentLinkHit is one activatable span in the host's coordinate space.
type FileDetails ¶ added in v0.99.0
type FileDetails struct {
Path string
Name string
Kind string
Size string
Where string
Modified string
Permissions string
IsDir bool
Err error
}
FileDetails is stat + classification for a root-relative path.
func Inspect ¶ added in v0.99.0
func Inspect(root, path string) FileDetails
Inspect stats a root-relative path.
type GitInfoMsg ¶ added in v0.99.0
GitInfoMsg is git status and last commit for a path.
type Gutter ¶ added in v1.0.0
type Gutter struct {
// contains filtered or unexported fields
}
Gutter renders the line-number column beside a document's text. It is a value type with no state beyond its width, so callers can build one per render pass.
The zero Gutter is disabled: it has zero width and renders empty cells, so a caller that suppresses numbering (rendered markdown, placeholder text) can keep one code path.
func NewGutter ¶ added in v1.0.0
NewGutter returns a gutter wide enough to number a document of lineCount lines, never narrower than the historical four digits.
func NewGutterForWidth ¶ added in v1.0.0
NewGutterForWidth is NewGutter plus the "is there room?" decision: it returns a disabled gutter when numbering would leave less than minGutterContentWidth cells for the text itself.
func (Gutter) Blank ¶ added in v1.0.0
Blank renders an equal-width empty cell, for wrapped continuation rows and for lines that have no source line number of their own.
func (Gutter) Plain ¶ added in v1.0.0
Plain renders the cell for a 1-based source line number without styling, for callers that need the text to do their own column arithmetic on.
func (Gutter) Width ¶ added in v1.0.0
Width is the cell width of every cell this gutter renders, including the separator. It is 0 when the gutter is disabled.
func (Gutter) WithSeparator ¶ added in v1.0.0
WithSeparator returns a copy of g whose numbers are followed by sep instead of a single space, for callers that punctuate the column (" 12: text"). The separator counts towards Width, so a caller that budgets by Width never has to know which one it got.
type Info ¶ added in v0.99.0
type Info struct {
Root, Path string
GitStatus, LastCommit string
// contains filtered or unexported fields
}
Info is a file-info modal for a (root, path).
func (*Info) ApplyGit ¶ added in v0.99.0
func (i *Info) ApplyGit(msg GitInfoMsg)
ApplyGit records a fetch that belongs to this path.
func (*Info) HandleKey ¶ added in v0.99.0
HandleKey routes modal keys. closed is true when the user dismissed it.
func (*Info) HandleMouse ¶ added in v0.99.0
HandleMouse routes modal mouse events. closed is true on dismiss.
func (*Info) WheelAtBoundary ¶ added in v1.0.0
WheelAtBoundary reports whether this wheel event is certainly a no-op for the info modal, using the geometry of its most recent render. It never rebuilds or mutates content, and reports unknown (false) before the first render.
type LoadedMsg ¶
type LoadedMsg struct {
ModelID int
RequestGeneration uint64
Epoch uint64
Path string
Result filepreview.PreviewResult
// Refresh marks a result produced by Model.Refresh rather than Model.Load:
// an in-place re-read that preserves scroll and is discarded when the file
// came back unchanged. See live.go.
Refresh bool
// NotModified completes an in-flight refresh without replacing content.
NotModified bool
// Revision is the last adopted source revision, for a later conditional read.
Revision string
}
LoadedMsg is the result of a Model load. Its identity fields ensure a result can only be applied to the model, request, and plugin epoch that issued it.
type Match ¶ added in v1.2.0
Match is one hit, in the coordinate space described above: Line indexes the content lines of the current layout (banner rows included, because they are on screen and searchable), and Start/End are byte offsets into that line's joined plain text.
type MatchRange ¶ added in v1.2.0
type MatchRange struct {
Index int // position in the match list, so the current match can be told apart
Start int
End int
}
MatchRange is a highlight to inject, in plain-text byte offsets into one row. It is exported because hosts whose renderer is not a docview.Model — the files plugin's preview pane — paint their own rows through InjectHighlights rather than carrying a second copy of this logic.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is one markdown document in one content box.
func (*Model) AbandonSelection ¶ added in v1.1.0
func (m *Model) AbandonSelection() textselect.Result
AbandonSelection ends a gesture whose release never arrived — the pointer left the window, a modal opened, focus moved.
func (*Model) ApplyLine ¶ added in v0.99.0
ApplyLine jumps to line (1-based) and forces raw mode so the line is visible.
func (*Model) Arm ¶ added in v0.99.0
Arm shows the loading placeholder for a restored tab without issuing a load.
func (*Model) ClearSelection ¶ added in v1.1.0
func (m *Model) ClearSelection()
ClearSelection drops the selection and any gesture editing it.
func (*Model) CloseSearch ¶ added in v1.2.0
func (m *Model) CloseSearch()
CloseSearch ends the search and drops its matches.
func (*Model) ContentLinkRect ¶ added in v1.3.0
ContentLinkRect is the source-text rectangle in the origin the host last bound: past the gutter, above the in-file search bar, and excluding the scrollbar. It is the same box text selection uses, so a click on a line number cannot activate a SHA that happens to look like a line number.
func (*Model) ContentLinksSafe ¶ added in v1.3.0
ContentLinksSafe reports whether this viewer is showing source (or rendered) document rows that map onto the frame. Placeholders, empty loads, and unsized models opt out.
func (*Model) HandleSearchKey ¶ added in v1.2.0
HandleSearchKey answers a key while search owns the pane. It reports whether the key was consumed; a live search consumes every key it is offered, which is what makes esc the only way out and stops a query containing "n" from scrolling the document.
The returned command exists for hosts to batch: search itself has no side effects outside the model today.
func (*Model) HandleSearchPaste ¶ added in v1.14.0
HandleSearchPaste puts a bracketed paste into the query while it is being typed, and reports whether search took it. A committed search has no text input on screen, so a paste there belongs to whatever the host would give it to next.
func (*Model) HandleSelectionKey ¶ added in v1.1.0
func (m *Model) HandleSelectionKey(msg tea.KeyMsg) textselect.Result
HandleSelectionKey answers the chords that act on the selection: copy, select-all, and escape.
Escape belongs here rather than in each host: what it means to a live selection is the selection's business, and a host that wrote the rule itself would be a host the other surface has to remember to match.
func (*Model) HandleSelectionMouse ¶ added in v1.1.0
func (m *Model) HandleSelectionMouse(action mouse.MouseAction) textselect.Result
HandleSelectionMouse advances the selection gesture and reports what the host owes for it.
A drag that has run past an edge is scrolled here rather than by the host: the window it is asking for is this model's own, and a host that moved it would be the second place that knows how far a document can scroll. The rows it reveals are selected by the next motion event, as the engine's contract says. AutoScroll is reported back as the rows that were actually applied — a document already at its last row moves nothing — so a host that persists the offset saves exactly when a drag changed it.
func (*Model) HasScrollbar ¶ added in v1.4.0
HasScrollbar reports whether the model currently draws a bar (content overflows the viewport). When false, hosts must register no regions: the reserved column is an anti-jitter spacer, not a control.
func (*Model) HasSelection ¶ added in v1.1.0
HasSelection reports whether anything in this document is selected. It is asked by hosts outside a render — a key, a click elsewhere — so it settles the expiry itself rather than reporting a selection the next frame will drop.
func (*Model) Load ¶
Load retargets the model and returns a command that wraps the existing file browser loader. Only the docview-owned LoadedMsg is broadcast.
func (*Model) LoadFile ¶
func (m *Model) LoadFile(modelID int, file *os.File, relPath string, line int, epoch uint64) tea.Cmd
LoadFile retargets the model from an already-open file. The returned command owns and closes file after reading it.
func (*Model) LoadFrom ¶ added in v1.12.0
func (m *Model) LoadFrom(modelID int, rootDir, relPath string, line int, epoch uint64, load tea.Cmd) tea.Cmd
LoadFrom is Load with an injected command instead of filepreview.LoadPreview.
func (*Model) NeedsLoad ¶ added in v0.99.0
NeedsLoad reports whether this model has never been asked to Load.
func (*Model) Observe ¶ added in v1.0.0
func (m *Model) Observe()
Observe records that the document's file changed on disk.
A document that has never loaded declines to be owed a re-read: the host's own load path owns it, Model.Refresh refuses before it reaches the refresher, and a dirty flag nothing can clear reads to a host as a refresh owed forever.
func (*Model) OffsetAtTrackRow ¶ added in v1.4.0
OffsetAtTrackRow maps a track row (pointer Y minus the track top) onto the scroll offset whose thumb top anchors there — the shared core every other interactive scrollbar uses for track clicks and drags.
func (*Model) PrepareFrame ¶ added in v1.12.0
func (m *Model) PrepareFrame(opts PrepareOptions) PreparedFrame
PrepareFrame builds the visible document and link metadata once per visual identity. Pane origin is deliberately absent from the key; hits are replayed at the current origin by AppendHitsAt.
func (*Model) PreparedFrame ¶ added in v1.12.0
func (m *Model) PreparedFrame() PreparedFrame
PreparedFrame returns the most recently prepared visible frame. Pane hosts call PrepareFrame from their layout/SetSize path before consuming this in View.
func (*Model) Refresh ¶ added in v1.0.0
Refresh returns a command that re-reads the document in place, or nil when no re-read is owed.
Unlike Model.Load it preserves the scroll offset, the render mode and the wrap setting, and it leaves the current text on screen while the re-read runs rather than flashing a loading placeholder.
suppressed is the host's veto. A vetoed refresh stays owed and lands as soon as the veto lifts, so a host may safely block refreshes while something else owns the pane without losing the update.
func (*Model) RefreshFrom ¶ added in v1.12.0
RefreshFrom is Refresh with an injected command instead of filepreview.LoadPreview.
func (*Model) RefreshPending ¶ added in v1.0.0
RefreshPending reports whether a re-read is owed but has not started.
func (*Model) Reload ¶ added in v1.3.0
Reload force-rereads the current path, preserving scroll, wrap, and render mode. Unlike Refresh it runs even when nothing has observed a disk change, which is what a stuck loading placeholder needs.
func (*Model) ResultMatches ¶ added in v1.12.0
SetResult applies msg if it belongs to the current load. It returns false without changing the model for stale model, request, epoch, or path results.
func (*Model) Root ¶ added in v1.2.0
Root reports the directory the relative path is resolved against. It is what a host needs to hand the file to something outside docview — an editor, a reveal, a yank — without keeping a second copy of the pane's root.
func (*Model) ScanContentLinks ¶ added in v1.3.0
func (m *Model) ScanContentLinks(body string, opts contentlink.FrameOptions) ContentLinkFrame
ScanContentLinks recognizes tokens in an already-rendered View() body and optionally underlines them. Coordinates are visual columns of the source text, then offset by ContentLinkRect so a host can register them after chrome.
func (*Model) ScrollAtBoundary ¶ added in v1.0.0
ScrollAtBoundary reports whether delta would leave this document's current viewport unchanged. It is safe to ask before Update/View.
func (*Model) ScrollOffset ¶ added in v0.99.0
ScrollOffset is the current (or still-pending restore) viewport offset.
func (*Model) ScrollbarDragging ¶ added in v1.4.0
ScrollbarDragging reports whether a scrollbar gesture is live.
func (*Model) ScrollbarParams ¶ added in v1.4.0
func (m *Model) ScrollbarParams() ui.ScrollbarParams
ScrollbarParams reports the renderer inputs View draws the bar with: one row per laid-out display row, a viewport of contentHeight rows. Hosts feed these to ui.RenderScrollbarWithGeometry for region registration and to ui.OffsetAtRow/RowForOffset for press and drag mapping — no scrollbar math lives outside internal/ui.
func (*Model) ScrollbarRect ¶ added in v1.4.0
ScrollbarRect is the track column in the coordinate space mouse actions arrive in — the origin SetOrigin recorded — spanning the rows the track is drawn over. Zero when no interactive bar exists (nothing overflows, or the reserved column is the anti-jitter spacer); the zero rect contains no point.
func (*Model) SearchActive ¶ added in v1.2.0
SearchActive reports whether the search bar is on screen and owns the pane's keys. A host asks this to decide whether a keypress is search's before it is anyone else's.
func (*Model) SearchCommitted ¶ added in v1.2.0
SearchCommitted reports whether the query has been committed with enter, so n/N navigate rather than typing into the query.
func (*Model) SearchMatchIndex ¶ added in v1.2.0
SearchMatchIndex is the 0-based cursor into SearchMatches.
func (*Model) SearchMatches ¶ added in v1.2.0
SearchMatches is the current match set, recomputed first if the document or its layout moved underneath it.
func (*Model) SearchQuery ¶ added in v1.2.0
SearchQuery is the query as typed.
func (*Model) SelectionCopyCmd ¶ added in v1.1.0
func (m *Model) SelectionCopyCmd(result textselect.Result, wrap func(textselect.CopyNotice) tea.Msg) tea.Cmd
SelectionCopyCmd delivers the copy an engine result asked for, phrased by the shared pipeline and wrapped in whatever notification type the host uses. A result that asked for nothing produces no command, so a host can hand every result it gets straight here.
func (*Model) SelectionText ¶ added in v1.1.0
SelectionText is the selection as the user sees it: the visible rows, without the styling they were drawn with and without the gutter in front of them.
func (*Model) SetLoader ¶ added in v1.12.0
func (m *Model) SetLoader(loader PreviewLoader)
SetLoader replaces the default filepreview loader. Nil restores it.
func (*Model) SetOrigin ¶ added in v1.1.0
SetOrigin records where the host last drew this document's content box, in the coordinate space its mouse events arrive in. A pane that has not been drawn has no origin, so it hit-tests as empty rather than as the top-left corner of the screen.
func (*Model) SetPendingScroll ¶ added in v0.99.0
SetPendingScroll remembers an offset to apply after the next successful load.
func (*Model) SetRendered ¶
SetRendered restores the persisted display mode.
func (*Model) SetRoot ¶ added in v1.0.0
SetRoot records the directory that m.path is relative to.
Model.Load takes it as an argument, but Model.LoadFile is handed an already-open file and never learns where it came from. A host that loads by file descriptor must call this, or the pane cannot be refreshed — it has no path to re-read.
func (*Model) SetSelection ¶ added in v1.1.0
func (m *Model) SetSelection(keys textselect.Keys, copyOnSelect bool)
SetSelection binds the host's shared selection settings: the chords the pane answers, and whether finishing a drag copies without being asked.
func (*Model) SetSize ¶
SetSize sets the content box dimensions. A width change invalidates rendered markdown because wrapping depends on it.
func (*Model) StartSearch ¶ added in v1.2.0
func (m *Model) StartSearch()
StartSearch opens the search bar in its typing phase with an empty query.
func (*Model) ToggleRenderMode ¶
func (m *Model) ToggleRenderMode()
ToggleRenderMode switches between rendered markdown and raw highlighted source. Each mode keeps the current offset where possible.
func (*Model) ToggleWrap ¶ added in v0.99.0
func (m *Model) ToggleWrap()
ToggleWrap flips line wrapping.
func (*Model) TopSourceLine ¶ added in v1.2.0
TopSourceLine reports the 1-indexed source line at the top of the viewport, or 0 when the rows on screen do not map onto source lines (rendered markdown, a placeholder, an empty document). Hosts use it to open an editor where the reader was looking.
func (*Model) View ¶
View returns exactly the configured number of rows, each no wider than the configured width in terminal cells.
func (*Model) VisualRevision ¶ added in v1.12.0
VisualRevision is the cheap identity of everything Model owns that can change its visible document frame. Hosts combine it with their own root, resolution, matcher, geometry, and chrome identity.
func (*Model) WatchTarget ¶ added in v1.0.0
WatchTarget returns what to watch for changes to the document this model is showing, or an empty target when the model has no resolvable path.
It is the file itself, not its directory: a document pane is open on one document, and the surrounding directory can be enormous. livewatch still registers the parent with the kernel, because atomic writers replace a file rather than writing through it, but only events naming this exact path are reported.
func (*Model) YankSelectionOrContents ¶ added in v1.10.0
YankSelectionOrContents matches the Files preview's y behavior for every document host: copy the visible selection when one exists, otherwise copy the file itself. Keeping the choice here prevents each pane projection from quietly choosing a different source.
func (*Model) YankSelectionOrLoaded ¶ added in v1.12.0
YankSelectionOrLoaded copies the visible selection, or the already loaded body. It never opens a local path, so a remote document cannot yank this machine's twin file.
type NotModified ¶ added in v1.12.0
NotModified is returned by an injected loader when a refresh found no change.
type PrepareOptions ¶ added in v1.12.0
type PrepareOptions struct {
Root string
Resolution contentlink.ResolutionSnapshot
Matchers []contentlink.ResourceMatcher
MatcherGeneration uint64
AllowedKinds contentlink.KindSet
InternalNamespaces map[string]contentlink.URIOptions
// NamespaceGeneration must advance when a validator's behavior changes
// without changing its function identity (for example, a mutable closure).
NamespaceGeneration uint64
Decorate bool
Links bool
}
PrepareOptions names the host-owned inputs to a document frame. Root and Resolution are paired: the snapshot must have been obtained with ResolutionIndex.SnapshotForRoot for the same root.
type PreparedFrame ¶ added in v1.12.0
type PreparedFrame struct {
// contains filtered or unexported fields
}
PreparedFrame is an immutable visible document frame. Its hit rectangles are relative to the document body so moving a pane does not invalidate the expensive body or link scan.
func (PreparedFrame) AppendHitsAt ¶ added in v1.12.0
func (f PreparedFrame) AppendHitsAt(dst []ContentLinkHit, originX, originY int) []ContentLinkHit
AppendHitsAt replays relative hit descriptions at the body origin. dst is reused so hosts can rebuild mutable hit maps without allocating a second prepared hit list on every application View.
func (PreparedFrame) EachHitAt ¶ added in v1.12.0
func (f PreparedFrame) EachHitAt(originX, originY int, yield func(ContentLinkHit))
EachHitAt visits relative hit descriptions at the current body origin without allocating an intermediate replay slice.
func (PreparedFrame) Output ¶ added in v1.12.0
func (f PreparedFrame) Output() string
Output returns the already-rendered and, when enabled, decorated body.
func (PreparedFrame) Pending ¶ added in v1.12.0
func (f PreparedFrame) Pending(yield func(contentlink.Pending))
Pending visits the bounded set of newly discovered file and diff candidates. Callers must pass each candidate through ResolutionIndex.BeginClassified; cached frames may be read repeatedly while the first request is in flight.
func (PreparedFrame) Valid ¶ added in v1.12.0
func (f PreparedFrame) Valid() bool
Valid reports whether this value came from PrepareFrame.
type PreviewLoader ¶ added in v1.12.0
PreviewLoader produces a preview load command. IfRevision is the last adopted source revision and may be empty. The command should return filepreview.PreviewLoadedMsg, NotModified, or LoadedMsg.
type RevealErrorMsg ¶ added in v0.99.0
type RevealErrorMsg struct {
Err error
}
RevealErrorMsg is sent when reveal in the OS file manager fails.
type TabHit ¶ added in v0.99.1
TabHit is a drawn tab's click target. Col is relative to the strip's first column; Width is the rendered pill. CloseCol/CloseW are the × on the pill's right edge.
type TabStrip ¶ added in v0.99.1
TabStrip is the header row: only tabs, packed left to right.
func LayoutSearchTabStrip ¶ added in v1.2.0
LayoutSearchTabStrip is the same strip with the active tab renamed to a live search surface and its query, so a pane taking search keystrokes never reads as a pane showing a file. A pane opened straight into the finder has no tabs yet, and the label is the whole strip.
It lives here rather than in a host because both pane surfaces draw the same strip for the same surfaces.
func LayoutTabStrip ¶ added in v0.99.1
LayoutTabStrip is the document header: a left-truncated path tab strip and nothing else. Overflow lives on the tab group. Hosts draw this row and register hit regions from the same Tabs so a click cannot land on a tab that was never rendered.
type Tabs ¶ added in v0.99.0
Tabs is a document pane's open files. The pane tree points at this group, not at one model.
func (Tabs) ActiveView ¶ added in v0.99.0
ActiveView is the selected document, or nil.
func (Tabs) ClearSelectionsExcept ¶ added in v1.1.0
ClearSelectionsExcept drops every selection in this group but keep's, which is what makes one selection at a time the rule: starting one anywhere drops the one before it. A nil keep drops them all.
func (*Tabs) CloseActive ¶ added in v0.99.0
func (t *Tabs) CloseActive()
CloseActive removes the selected tab. The next tab (or the new last) is selected. An empty group leaves Active at 0.
func (*Tabs) Cycle ¶ added in v0.99.0
Cycle moves Active by delta, wrapping at the ends. A single tab is a no-op.