docview

package
v0.98.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 8 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 provides a content-only markdown document viewer.

Index

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.

func (LoadedMsg) GetEpoch

func (m LoadedMsg) GetEpoch() uint64

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

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

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

HandleKey applies document scrolling keys.

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

func (m *Model) Rendered() bool

Rendered reports whether markdown is shown rendered rather than raw.

func (*Model) Scroll

func (m *Model) Scroll(delta int)

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

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

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

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

func (m *Model) View() string

View returns exactly the configured number of rows, each no wider than the configured width in terminal cells.

Jump to

Keyboard shortcuts

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