pager

package
v0.13.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChromaRenderer

type ChromaRenderer struct {
	// contains filtered or unexported fields
}

ChromaRenderer handles rendering content with chroma styling.

func NewChromaRenderer

func NewChromaRenderer(theme *themes.Theme, lineNumbersDisabled bool) *ChromaRenderer

NewChromaRenderer creates a new ChromaRenderer.

func (*ChromaRenderer) GetMatches

func (gr *ChromaRenderer) GetMatches() []MatchPosition

GetMatches returns the current search matches.

func (*ChromaRenderer) RenderContent

func (gr *ChromaRenderer) RenderContent(yaml string, width int) (string, error)

RenderContent renders YAML content with chroma styling.

func (*ChromaRenderer) SetFormatter

func (gr *ChromaRenderer) SetFormatter(name string)

SetFormatter sets the chroma formatter explicitly. This is primarily useful for testing.

func (*ChromaRenderer) SetSearchTerm

func (gr *ChromaRenderer) SetSearchTerm(term string)

SetSearchTerm sets the search term and clears existing matches.

type Config

type Config struct {
	CommonModel     *common.CommonModel
	KeyBinds        *KeyBinds
	ChromaRendering bool
	ShowLineNumbers bool
}

type ContentRenderedMsg

type ContentRenderedMsg string

type KeyBinds

type KeyBinds struct {
	Copy *keys.KeyBind

	// Navigation.
	Home         *keys.KeyBind `yaml:"home"`
	End          *keys.KeyBind `yaml:"end"`
	PageUp       *keys.KeyBind `yaml:"pageUp"`
	PageDown     *keys.KeyBind `yaml:"pageDown"`
	HalfPageUp   *keys.KeyBind `yaml:"halfPageUp"`
	HalfPageDown *keys.KeyBind `yaml:"halfPageDown"`

	// Search.
	Search    *keys.KeyBind `yaml:"search"`
	NextMatch *keys.KeyBind `yaml:"nextMatch"`
	PrevMatch *keys.KeyBind `yaml:"prevMatch"`
}

func (*KeyBinds) EnsureDefaults

func (kb *KeyBinds) EnsureDefaults()

func (*KeyBinds) GetKeyBinds

func (kb *KeyBinds) GetKeyBinds() []keys.KeyBind

type MatchPosition

type MatchPosition struct {
	Line   int // 0-based line number.
	Start  int // 0-based character position within the line.
	End    int // 0-based character position within the line (exclusive).
	Length int // Length of the match.
}

MatchPosition represents a search match position within the content.

type PagerModel

type PagerModel struct {

	// Current document being rendered, sans-chroma rendering. We cache
	// it here so we can re-render it on resize.
	CurrentDocument yamldoc.YAMLDocument

	ViewState ViewState
	ShowHelp  bool
	// contains filtered or unexported fields
}

func NewModel

func NewModel(c Config) PagerModel

func (*PagerModel) ExitSearch

func (m *PagerModel) ExitSearch()

ExitSearch exits search mode.

func (PagerModel) Render

func (m PagerModel) Render(yaml string) tea.Cmd

This is where the magic happens.

func (*PagerModel) SetSize

func (m *PagerModel) SetSize(w, h int)

func (*PagerModel) Unload

func (m *PagerModel) Unload()

func (PagerModel) Update

func (m PagerModel) Update(msg tea.Msg) (PagerModel, tea.Cmd)

func (PagerModel) View

func (m PagerModel) View() string

type ViewState

type ViewState int
const (
	StateReady ViewState = iota
	StateLoadingDocument
	StateShowingError
	StateShowingStatusMessage
	StateSearching
)

Jump to

Keyboard shortcuts

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