docview

package
v1.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 34 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func EditExternal(root, path string, line int) tea.Cmd

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

func FetchGitInfo(root, path string) tea.Cmd

FetchGitInfo retrieves git status and last commit for a root-relative path.

func FormatSize added in v0.99.0

func FormatSize(bytes int64) string

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

func NormalizeTabPath(path string) string

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 Reveal added in v0.99.0

func Reveal(root, path string) tea.Cmd

Reveal opens path in the OS file manager. path is root-relative.

func SearchCommands added in v1.2.0

func SearchCommands(context string) []plugin.Command

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

func VisibleTabRange(widths []int, active, maxWidth int) (start, end int, showLeft, showRight bool)

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

func YankContents(root, path string) tea.Cmd

YankContents copies the file at root/path to the clipboard.

func YankPath added in v0.99.0

func YankPath(path string) tea.Cmd

YankPath copies the relative path to the clipboard.

func YankText added in v1.12.0

func YankText(text string) tea.Cmd

YankText copies text that is already in memory.

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

type GitInfoMsg struct {
	Path       string
	Status     string
	LastCommit string
}

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

func NewGutter(lineCount int) Gutter

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

func NewGutterForWidth(lineCount, totalWidth int) Gutter

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

func (g Gutter) Blank() string

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) Enabled added in v1.0.0

func (g Gutter) Enabled() bool

Enabled reports whether this gutter renders anything.

func (Gutter) Number added in v1.0.0

func (g Gutter) Number(line int) string

Number renders the cell for a 1-based source line number.

func (Gutter) Plain added in v1.0.0

func (g Gutter) Plain(line int) string

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

func (g Gutter) Width() int

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

func (g Gutter) WithSeparator(sep string) Gutter

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 OpenInfo added in v0.99.0

func OpenInfo(root, path string) (*Info, tea.Cmd)

OpenInfo starts the info modal and fetches git details.

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

func (i *Info) HandleKey(msg tea.KeyPressMsg) (closed bool, cmd tea.Cmd)

HandleKey routes modal keys. closed is true when the user dismissed it.

func (*Info) HandleMouse added in v0.99.0

func (i *Info) HandleMouse(msg tea.MouseMsg, handler *mouse.Handler) (closed bool)

HandleMouse routes modal mouse events. closed is true on dismiss.

func (*Info) Render added in v0.99.0

func (i *Info) Render(width, height int, handler *mouse.Handler) string

Render paints the modal and registers its hit regions.

func (*Info) WheelAtBoundary added in v1.0.0

func (i *Info) WheelAtBoundary(msg tea.MouseWheelMsg, handler *mouse.Handler) bool

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 Item added in v0.99.0

type Item struct {
	View *Model
}

Item is one open document.

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.

func (LoadedMsg) GetEpoch

func (m LoadedMsg) GetEpoch() uint64

GetEpoch allows callers to apply the normal plugin epoch checks if desired.

type Match added in v1.2.0

type Match struct {
	Line     int
	StartCol int
	EndCol   int
}

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 New

func New(renderer *markdown.Renderer) *Model

New creates an empty document viewer. A nil renderer uses the default markdown renderer.

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

func (m *Model) ApplyLine(line int)

ApplyLine jumps to line (1-based) and forces raw mode so the line is visible.

func (*Model) Arm added in v0.99.0

func (m *Model) Arm(modelID int, relPath string, epoch uint64)

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

func (m *Model) ContentLinkRect() mouse.Rect

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

func (m *Model) ContentLinksSafe() bool

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) HandleKey

func (m *Model) HandleKey(k tea.KeyMsg) bool

HandleKey applies document scrolling keys.

func (*Model) HandleSearchKey added in v1.2.0

func (m *Model) HandleSearchKey(msg tea.KeyMsg) (bool, tea.Cmd)

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

func (m *Model) HandleSearchPaste(msg tea.PasteMsg) (bool, tea.Cmd)

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

func (m *Model) HasScrollbar() bool

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

func (m *Model) HasSelection() bool

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

func (m *Model) Load(modelID int, rootDir, relPath string, line int, epoch uint64) tea.Cmd

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

func (m *Model) NeedsLoad() bool

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

func (m *Model) OffsetAtTrackRow(row int) int

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

func (m *Model) Refresh(suppressed bool) tea.Cmd

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

func (m *Model) RefreshFrom(load tea.Cmd) tea.Cmd

RefreshFrom is Refresh with an injected command instead of filepreview.LoadPreview.

func (*Model) RefreshPending added in v1.0.0

func (m *Model) RefreshPending() bool

RefreshPending reports whether a re-read is owed but has not started.

func (*Model) Reload added in v1.3.0

func (m *Model) Reload() tea.Cmd

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) Rendered

func (m *Model) Rendered() bool

Rendered reports whether markdown is shown rendered rather than raw.

func (*Model) ResultMatches added in v1.12.0

func (m *Model) ResultMatches(msg LoadedMsg) bool

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

func (m *Model) Root() string

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 (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) Scroll

func (m *Model) Scroll(delta int)

Scroll moves the viewport by delta rows and clamps it to the document.

func (*Model) ScrollAtBoundary added in v1.0.0

func (m *Model) ScrollAtBoundary(delta int) bool

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

func (m *Model) ScrollOffset() int

ScrollOffset is the current (or still-pending restore) viewport offset.

func (*Model) ScrollbarDragging added in v1.4.0

func (m *Model) ScrollbarDragging() bool

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

func (m *Model) ScrollbarRect() mouse.Rect

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

func (m *Model) SearchActive() bool

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

func (m *Model) SearchCommitted() bool

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

func (m *Model) SearchMatchIndex() int

SearchMatchIndex is the 0-based cursor into SearchMatches.

func (*Model) SearchMatches added in v1.2.0

func (m *Model) SearchMatches() []Match

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

func (m *Model) SearchQuery() string

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

func (m *Model) SelectionText() []string

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

func (m *Model) SetOrigin(x, y int)

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

func (m *Model) SetPendingScroll(offset int)

SetPendingScroll remembers an offset to apply after the next successful load.

func (*Model) SetRendered

func (m *Model) SetRendered(rendered bool)

SetRendered restores the persisted display mode.

func (*Model) SetResult

func (m *Model) SetResult(msg LoadedMsg) bool

func (*Model) SetRoot added in v1.0.0

func (m *Model) SetRoot(root string)

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

func (m *Model) SetSize(width, height int)

SetSize sets the content box dimensions. A width change invalidates rendered markdown because wrapping depends on it.

func (*Model) SetWrap added in v0.99.0

func (m *Model) SetWrap(wrap bool)

SetWrap restores the persisted wrap flag.

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) Title

func (m *Model) Title() string

Title returns the document's relative path.

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

func (m *Model) TopSourceLine() int

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

func (m *Model) View() string

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

func (m *Model) VisualRevision() uint64

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

func (m *Model) WatchTarget() livewatch.Target

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) Wrap added in v0.99.0

func (m *Model) Wrap() bool

Wrap reports whether long lines wrap instead of truncating.

func (*Model) YankSelectionOrContents added in v1.10.0

func (m *Model) YankSelectionOrContents() tea.Cmd

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

func (m *Model) YankSelectionOrLoaded() tea.Cmd

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

type NotModified struct {
	Path     string
	Epoch    uint64
	Revision string
}

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

type PreviewLoader func(root, path string, epoch uint64, ifRevision string) tea.Cmd

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

type TabHit = tabs.Hit

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

type TabStrip = tabs.Strip

TabStrip is the header row: only tabs, packed left to right.

func LayoutSearchTabStrip added in v1.2.0

func LayoutSearchTabStrip(group Tabs, label string, width int, focused bool) TabStrip

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

func LayoutTabStrip(group Tabs, width int, focused bool) TabStrip

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

type Tabs struct {
	Items  []Item
	Active int
}

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

func (t Tabs) ActiveView() *Model

ActiveView is the selected document, or nil.

func (*Tabs) Append added in v0.99.0

func (t *Tabs) Append(view *Model)

Append adds view and selects it.

func (Tabs) ClearSelectionsExcept added in v1.1.0

func (t Tabs) ClearSelectionsExcept(keep *Model)

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) CloseAt added in v1.3.0

func (t *Tabs) CloseAt(index int)

CloseAt removes the tab at index. Out of range is a no-op.

func (*Tabs) Cycle added in v0.99.0

func (t *Tabs) Cycle(delta int)

Cycle moves Active by delta, wrapping at the ends. A single tab is a no-op.

func (Tabs) IndexOf added in v0.99.0

func (t Tabs) IndexOf(path string) int

IndexOf returns the tab whose display path matches path, or -1. The key is the root-relative path, slash-normalized.

func (Tabs) Paths added in v1.15.0

func (t Tabs) Paths() []string

Paths lists the open documents' root-relative paths, the active one first, which is the order a file finder wants them in as recents.

func (*Tabs) Select added in v0.99.0

func (t *Tabs) Select(i int)

Select makes i the active tab.

func (Tabs) VisibleRange added in v0.99.0

func (t Tabs) VisibleRange(widths []int, maxWidth int) (start, end int, showLeft, showRight bool)

VisibleRange is the overflow window for this group: the inclusive [start, end] of tabs that fit in maxWidth, keeping Active on screen.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL