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 FetchGitInfo(root, path string) tea.Cmd
- func FormatSize(bytes int64) string
- func NormalizeTabPath(path string) string
- func RenderInfo(d FileDetails, gitStatus, lastCommit string) string
- func Reveal(root, path string) tea.Cmd
- 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
- type FileDetails
- type GitInfoMsg
- type Info
- type Item
- type LoadedMsg
- type Model
- func (m *Model) ApplyLine(line int)
- func (m *Model) Arm(modelID int, relPath string, epoch uint64)
- func (m *Model) HandleKey(k tea.KeyMsg) 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) NeedsLoad() bool
- func (m *Model) Rendered() bool
- func (m *Model) Scroll(delta int)
- func (m *Model) ScrollOffset() int
- func (m *Model) SetPendingScroll(offset int)
- func (m *Model) SetRendered(rendered bool)
- func (m *Model) SetResult(msg LoadedMsg) bool
- func (m *Model) SetSize(width, height int)
- func (m *Model) SetWrap(wrap bool)
- func (m *Model) Title() string
- func (m *Model) ToggleRenderMode()
- func (m *Model) ToggleWrap()
- func (m *Model) View() string
- func (m *Model) Wrap() bool
- type RevealErrorMsg
- type TabHit
- type TabStrip
- type Tabs
Constants ¶
const TabMinBudget = 8
TabMinBudget is the floor for one tab's column share, chrome included.
Variables ¶
This section is empty.
Functions ¶
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 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 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 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 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.
type LoadedMsg ¶
type LoadedMsg struct {
ModelID int
RequestGeneration uint64
Epoch uint64
Path string
Result filepreview.PreviewResult
}
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 Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is one markdown document in one content box.
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) 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) NeedsLoad ¶ added in v0.99.0
NeedsLoad reports whether this model has never been asked to Load.
func (*Model) ScrollOffset ¶ added in v0.99.0
ScrollOffset is the current (or still-pending restore) viewport offset.
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) SetResult ¶
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) SetSize ¶
SetSize sets the content box dimensions. A width change invalidates rendered markdown because wrapping depends on it.
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.
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.
type TabStrip ¶ added in v0.99.1
TabStrip is the header row: only tabs, packed left to right.
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) 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.