Documentation
¶
Overview ¶
Package docview provides a content-only markdown document viewer.
Index ¶
- type LoadedMsg
- type Model
- 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) Rendered() bool
- func (m *Model) Scroll(delta int)
- func (m *Model) SetRendered(rendered bool)
- func (m *Model) SetResult(msg LoadedMsg) bool
- func (m *Model) SetSize(width, height int)
- func (m *Model) Title() string
- func (m *Model) ToggleRenderMode()
- func (m *Model) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) 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) 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.