oviewer

package
v0.0.0-...-3186b04 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 49 Imported by: 1 module, 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 oviewer provides a pager for terminals.

oviewer displays the contents of the file or reader etc... on the current terminal screen. After running a Run, oviewer does not return until the user finishes running. So if you want to do something in concurrent, you need to use goroutine.

There is also a simple usage example below: https://github.com/noborus/mdviewer/

package main

import (
    "github.com/chapmanjacobd/ov/oviewer"
)

func main() {
    ov, err := oviewer.Open("main.go")
    if err != nil {
      panic(err)
    }
    if err := ov.Run(); err != nil {
      panic(err)
    }
}

Index

Examples

Constants

View Source
const (
	// Unspecified is the default alignment.
	Unspecified specifiedAlign = iota
	// RightAlign is the right alignment.
	RightAlign
	// LeftAlign is the left alignment.
	LeftAlign
)

Unspecified is the default value for the column alignment options below.

View Source
const (
	// Colors256 is the index of the 256 color. 8-bit colors. 0-255.
	Colors256 = 5
	// ColorsRGB is the index of the RGB color. 24-bit colors. r:0-255 g:0-255 b:0-255.
	ColorsRGB = 2
)

Colors256 and ColorsRGB identify SGR color formats.

View Source
const (
	DocNormal = iota
	DocHelp
	DocLog
	DocFilter
)

document type.

View Source
const (
	COLS = 80
	ROWS = 24
)

virtual terminal size.

View Source
const (
	// ScreenStateNotReady indicates that the screen is not ready.
	ScreenStateNotReady = iota
	// ScreenStateTransition indicates that the screen is transitioning.
	ScreenStateTransition
	// ScreenStateReady indicates that the screen is ready.
	ScreenStateReady
	// ScreenStateTerminated indicates that the screen is terminated.
	ScreenStateTerminated
)

ScreenStateNotReady and the following values identify screen lifecycle states.

View Source
const DefaultStatusLine = 1

DefaultStatusLine is the number of lines in the status line.

View Source
const DocumentCacheSize = 10000

DocumentCacheSize is the maximum number of lines to cache in the LRU cache for each document.

View Source
const EOFC string = "~"

EOFC is the EOF character.

View Source
const FormFeed = "\f"

FormFeed is the delimiter that separates the sections. The default delimiter that separates single output from watch.

View Source
const MaxWriteLog int = 10

MaxWriteLog is the maximum number of lines to output to the log when the debug flag is enabled.

View Source
const MinStartX = -10

MinStartX is the minimum start position of x.

View Source
const MouseFlags = tcell.MouseDragEvents

MouseFlags represents which events of the mouse should be captured. Set the mode to MouseDragEvents when the mouse is enabled in oviewer. Does not track mouse movements except when dragging.

View Source
const QuitSmallCountDown = 10

QuitSmallCountDown is the countdown to quit if the output fits on one screen. UpdateInterval(50 * time.Millisecond) * 10 = 500ms.

Variables

View Source
var (
	// ClickInterval is the threshold used for multi-click detection.
	ClickInterval = 500 * time.Millisecond
	// ClickDistance is the max movement allowed between clicks for multi-click detection.
	ClickDistance = 2
)
View Source
var (
	// MemoryLimit is a number that limits the chunks to load into memory.
	MemoryLimit int
	// MemoryLimitFile is a number that limits the chunks loading a file into memory.
	MemoryLimitFile int

	// OverStrikeStyle represents the overstrike style.
	OverStrikeStyle tcell.Style
	// OverLineStyle represents the overline underline style.
	OverLineStyle tcell.Style
	// SkipExtract is a flag to skip extracting compressed files.
	SkipExtract bool
)
View Source
var (
	// Redirect to standard output.
	//     echo "t" | ov> out
	STDOUTPIPE *os.File
	// Redirects the error output of ov --exec.
	//     ov --exec -- command 2> out
	STDERRPIPE *os.File
)

ov output destination.

View Source
var (
	// ErrOutOfRange indicates that value is out of range.
	ErrOutOfRange = errors.New("value out of range")
	// ErrNotInMemory indicates that value is not in memory.
	ErrNotInMemory = errors.New("value not in memory")
	// ErrFatalCache indicates that the cache value had a fatal error.
	ErrFatalCache = errors.New("fatal cache error")
	// ErrMissingFile indicates that the file does not exist.
	ErrMissingFile = errors.New("missing file")
	// ErrIsDirectory indicates that specify a directory instead of a file.
	ErrIsDirectory = errors.New("is a directory")
	// ErrNotFound indicates not found.
	ErrNotFound = errors.New("not found")
	// ErrNotTerminal indicates that it is not a terminal.
	ErrNotTerminal = errors.New("not a terminal")
	// ErrCancel indicates cancel.
	ErrCancel = errors.New("cancel")
	// ErrInvalidNumber indicates an invalid number.
	ErrInvalidNumber = errors.New("invalid number")
	// ErrFailedKeyBind indicates keybinding failed.
	ErrFailedKeyBind = errors.New("failed to set key bindings")
	// ErrSignalCatch indicates that the signal has been caught.
	ErrSignalCatch = errors.New("signal caught")
	// ErrAlreadyClose indicates that it is already closed.
	ErrAlreadyClose = errors.New("already closed")
	// ErrCannotClose indicates that it cannot be closed.
	ErrCannotClose = errors.New("cannot be closed")
	// ErrRequestClose indicates that the request is to close.
	ErrRequestClose = errors.New("close requested")
	// ErrNoColumn indicates that cursor specified a nonexistent column.
	ErrNoColumn = errors.New("column not found")
	// ErrNoDelimiter indicates that the line containing the delimiter could not be found.
	ErrNoDelimiter = errors.New("delimiter not found")
	// ErrNoMoreSection indicates that the section could not be found.
	ErrNoMoreSection = errors.New("no more sections")
	// ErrOverScreen indicates that the specified screen is out of range.
	ErrOverScreen = errors.New("screen position out of range")
	// ErrOutOfChunk indicates that the specified Chunk is out of range.
	ErrOutOfChunk = errors.New("chunk out of range")
	// ErrNotLoaded indicates that it cannot be loaded.
	ErrNotLoaded = errors.New("not loaded")
	// ErrEOFreached indicates that EOF has been reached.
	ErrEOFreached = errors.New("EOF reached")
	// ErrPreventReload indicates that reload is prevented.
	ErrPreventReload = errors.New("reload prevented")
	// ErrOverChunkLimit indicates that the chunk limit has been exceeded.
	ErrOverChunkLimit = errors.New("chunk limit exceeded")
	// ErrAlreadyLoaded indicates that the chunk already loaded.
	ErrAlreadyLoaded = errors.New("chunk already loaded")
	// ErrEvictedMemory indicates that it has been evicted from memory.
	ErrEvictedMemory = errors.New("evicted from memory")
	// ErrNotAlignMode indicates that it is not an align mode.
	ErrNotAlignMode = errors.New("not in align mode")
	// ErrNoColumnSelected indicates that no column is selected.
	ErrNoColumnSelected = errors.New("no column selected")
	// ErrInvalidSGR indicates that the SGR is invalid.
	ErrInvalidSGR = errors.New("invalid SGR")
	// ErrNotSupport indicates that it is not supported.
	ErrNotSupport = errors.New("not supported")
	// ErrInvalidDocumentNum indicates that the document number is invalid.
	ErrInvalidDocumentNum = errors.New("invalid document number")
	// ErrInvalidModeName indicates that the specified view mode was not found.
	ErrInvalidModeName = errors.New("view mode not found")
	// ErrInvalidRGBColor indicates that the RGB color is invalid.
	ErrInvalidRGBColor = errors.New("invalid RGB color")
	// ErrInvalidKey indicates that the key format is invalid.
	ErrInvalidKey = errors.New("invalid key format")
)
View Source
var ChunkSize = 10000

ChunkSize is the unit of number of lines to split the file.

View Source
var DefaultContent = content{
	// contains filtered or unexported fields
}

DefaultContent is a default content. It is used for padding and empty cells.

View Source
var DefaultEditor string

DefaultEditor is the fallback editor to use if no other editor is specified.

View Source
var EOFContent = content{
	// contains filtered or unexported fields
}

EOFContent is EOFC only.

View Source
var Shrink string = "…"

Shrink is a character that represents a shrunk column.

View Source
var ShrinkContent = content{
	// contains filtered or unexported fields
}

ShrinkContent is a content that represents a shrunk column.

View Source
var SpaceContent = content{
	// contains filtered or unexported fields
}

SpaceContent is a space character.

View Source
var UpdateInterval = 50 * time.Millisecond

UpdateInterval is the update interval that calls eventUpdate().

Functions

func ContentsToStr

func ContentsToStr(lc contents) (string, widthPos)

ContentsToStr returns a converted string and byte position, as well as the content position conversion table.

func DuplicateKeyBind

func DuplicateKeyBind(k KeyBind) string

DuplicateKeyBind returns a string representing duplicate key bindings.

func KeyBindString

func KeyBindString(k KeyBind) string

KeyBindString returns keybind as a string for help.

func ListViewMode

func ListViewMode(config Config) []string

ListViewMode returns the list of view modes.

func NewChunk

func NewChunk(start int64) *chunk

NewChunk returns chunk.

func NewStore

func NewStore() *store

NewStore returns store.

func RangeStyle

func RangeStyle(lc contents, start int, end int, ovs OVStyle)

RangeStyle applies the style to the specified range. Apply style to contents.

func RawStrToContents

func RawStrToContents(str string, tabWidth int) contents

RawStrToContents converts a single-line string into a one line of contents. Does not interpret escape sequences. 1 Content matches the characters displayed on the screen.

func SetShrinkContent

func SetShrinkContent(shrink string)

SetShrinkContent sets the shrink character.

func SetTcellNewScreen

func SetTcellNewScreen(f func(opts ...tcell.TerminfoScreenOption) (tcell.Screen, error))

SetTcellNewScreen sets the function to create a new tcell screen. This is used for testing purposes to replace the tcell.NewScreen function. It allows for mocking the screen creation in tests.

func StrToContents

func StrToContents(str string, tabWidth int) contents

StrToContents converts a single-line string into a one line of contents. Parse escape sequences, etc. 1 Content matches the characters displayed on the screen.

func ToTcellStyle

func ToTcellStyle(s OVStyle) tcell.Style

ToTcellStyle convert from OVStyle to tcell style.

Types

type ClickState

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

ClickState holds the state for click detection.

type ClickType

type ClickType int

ClickType represents the type of mouse click.

const (
	// ClickSingle represents a single click.
	ClickSingle ClickType = iota
	// ClickDouble represents a double click.
	ClickDouble
	// ClickTriple represents a triple click.
	ClickTriple
	// ClickExpired indicates the click sequence timed out and state should reset.
	ClickExpired
)

ClickSingle and the following values identify mouse click events.

type Command

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

Command is the structure of the command.

func NewCommand

func NewCommand(args ...string) *Command

NewCommand returns a Command.

func (*Command) Exec

func (command *Command) Exec() (*Root, error)

Exec executes the command and returns an oviewer Root.

func (*Command) Reload

func (command *Command) Reload() *bufio.Reader

Reload restarts the command.

func (*Command) Wait

func (command *Command) Wait()

Wait waits for the command to exit. Wait does not block for process completion because waiting is handled in a goroutine.

type Compressed

type Compressed int

Compressed represents the type of compression.

const (
	// UNCOMPRESSED is an uncompressed format.
	UNCOMPRESSED Compressed = iota
	// GZIP is gzip compressed format.
	GZIP
	// BZIP2 is bzip2 compressed format.
	BZIP2
	// ZSTD is zstd compressed format.
	ZSTD
	// LZ4 is lz4 compressed format.
	LZ4
	// XZ is xz compressed format.
	XZ
)

UNCOMPRESSED and the following values identify supported compression formats.

func (Compressed) String

func (c Compressed) String() string

String returns the string representation of the compressed format.

type Config

type Config struct {
	// KeyBinding
	Keybind map[string][]string
	// Mode represents the operation of the customized mode.
	Mode map[string]General
	// ViewMode represents the view mode.
	// ViewMode sets several settings together and can be easily switched.
	ViewMode string
	// Default keybindings. Disabled if the default keybinding is "disable".
	DefaultKeyBind string

	// Prompt is the prompt setting.
	Prompt PromptConfig
	// MinStartX is the minimum value of the start position.
	MinStartX int
	// SidebarMode represents the sidebar mode.
	SidebarMode string
	// SidebarWidth is the width of the sidebar as a string (e.g., "30%", "10").
	SidebarWidth string
	// StyleOverStrike is a style that applies to overstrike.
	StyleOverStrike OVStyle
	// StyleOverLine is a style that applies to overstrike underlines.
	StyleOverLine OVStyle

	// GeneralConfig is the general setting.
	General General
	// helpConfig is the help setting.
	HelpDoc General
	// LogConfig is the log setting.
	LogDoc General
	// BeforeWriteOriginal specifies the number of lines before the current position.
	// 0 is the top of the current screen
	BeforeWriteOriginal int
	// AfterWriteOriginal specifies the number of lines after the current position.
	// 0 specifies the bottom of the screen.
	AfterWriteOriginal int
	// MemoryLimit is a number that limits chunk loading.
	MemoryLimit int
	// MemoryLimitFile is a number that limits the chunks loading a file into memory.
	MemoryLimitFile int
	// DisableMouse indicates whether mouse support is disabled.
	DisableMouse bool

	// IsWriteOnExit indicates whether to write the current screen on exit.
	IsWriteOnExit bool
	// IsWriteOriginal indicates whether the current screen should be written on quit.
	IsWriteOriginal bool
	// QuitSmall indicates whether to quit if the output fits on one screen.
	QuitSmall bool
	// QuitSmallFilter indicates whether to quit if the output fits on one screen and a filter is applied.
	QuitSmallFilter bool
	// CaseSensitive is case-sensitive if true.
	CaseSensitive bool
	// SmartCaseSensitive indicates whether lowercase search should ignore case.
	SmartCaseSensitive bool
	// RegexpSearch indicates whether to use regular expression search.
	RegexpSearch bool
	// Incsearch indicates whether to use incremental search.
	Incsearch bool
	// NotifyEOF specifies the number of times to notify EOF.
	NotifyEOF int

	// ReadWaitTime is the time to wait for reading before starting a search.
	ReadWaitTime time.Duration

	// ClipboardMethod specifies the method to use for copying to the clipboard.
	// Supported values:
	// - "auto" (default): Automatically selects between "OSC52" and "system" based on terminal support.
	// - "OSC52": Uses the OSC52 escape sequence for clipboard operations. This requires terminal support.
	// - "system": Uses the system's native clipboard method (e.g., xclip on Linux, pbcopy on macOS).
	ClipboardMethod string

	// Editor is the editor command to use for editing files.
	Editor string
	// ShrinkChar specifies the character to display when the column is shrunk.
	ShrinkChar string
	// DisableColumnCycle indicates whether to disable column cycling.
	DisableColumnCycle bool
	// DisableStickyFollow indicates whether to disable sticky follow mode.
	DisableStickyFollow bool
	// SetTerminalTitle indicates whether to set the terminal title to display filename.
	SetTerminalTitle bool
	// Debug indicates whether to enable debug output.
	Debug bool
	// contains filtered or unexported fields
}

Config represents the settings of ov.

func NewConfig

func NewConfig() Config

NewConfig return the structure of Config with default values.

type Converter

type Converter interface {
	// contains filtered or unexported methods
}

Converter is an interface for converting escape sequences, etc.

type Document

type Document struct {

	// FileName is the file name to display.
	FileName string
	// Caption is an additional caption to display after the file name.
	Caption string

	// RunTimeSettings contains runtime configuration options for the document.
	RunTimeSettings

	// CFormat is a compressed format.
	CFormat Compressed

	// WatchMode indicates if watch mode is enabled.
	WatchMode bool

	// General is the General settings.
	General General
	// contains filtered or unexported fields
}

Document represents a document with various properties and methods for handling file operations, caching, synchronization, and display settings.

func NewDocument

func NewDocument() (*Document, error)

NewDocument creates and initializes a new Document with default settings. It returns a pointer to the Document and an error if the cache initialization fails.

func NewHelp

func NewHelp(k KeyBind) (*Document, error)

NewHelp generates a document for help.

func OpenDocument

func OpenDocument(fileName string) (*Document, error)

OpenDocument opens a file specified by fileName and returns a Document. If the fileName is "-", it reads from stdin. It returns an error if the file cannot be opened, is a directory, or if there are issues initializing the Document.

func STDINDocument

func STDINDocument() (*Document, error)

STDINDocument creates and returns a Document that reads from stdin. It returns a pointer to the Document and an error if the Document initialization fails.

func (*Document) BackSearch

func (m *Document) BackSearch(ctx context.Context, searcher Searcher, chunkNum int, line int) (int, error)

BackSearch searches backward from the specified line.

func (*Document) BackSearchChunk

func (m *Document) BackSearchChunk(ctx context.Context, searcher Searcher, chunkNum int, line int) (int, error)

BackSearchChunk searches backward from the specified line.

func (*Document) BackSearchChunkNonMatch

func (m *Document) BackSearchChunkNonMatch(ctx context.Context, searcher Searcher, chunkNum int, line int) (int, error)

BackSearchChunkNonMatch returns unmatched line number.

func (*Document) BackSearchLine

func (m *Document) BackSearchLine(ctx context.Context, searcher Searcher, lineNum int) (int, error)

BackSearchLine does a backward search on the document and returns a matching line number.

func (*Document) BufEOF

func (m *Document) BufEOF() bool

BufEOF checks if the end of the file (EOF) has been reached in the document buffer. Returns: - A boolean value: true if EOF is reached, false otherwise.

func (*Document) BufEndNum

func (m *Document) BufEndNum() int

BufEndNum returns the last line number.

func (*Document) BufStartNum

func (m *Document) BufStartNum() int

BufStartNum returns the starting line number of the buffer.

func (*Document) ClearCache

func (m *Document) ClearCache()

ClearCache clears the LRU cache of the document. It does not take any parameters and does not return any values.

func (*Document) ControlFile

func (m *Document) ControlFile(file *os.File) error

ControlFile controls file read and loads in chunks. ControlFile can be reloaded by file name.

func (*Document) ControlLog

func (m *Document) ControlLog() error

ControlLog controls log. ControlLog is only supported reload.

func (*Document) ControlReader

func (m *Document) ControlReader(r io.Reader, reload func() *bufio.Reader) error

ControlReader is the controller for io.Reader. Assuming call from Exec. reload executes the argument function.

func (*Document) CurrentLN

func (m *Document) CurrentLN() int

CurrentLN returns the currently displayed line number.

func (*Document) EnsureStylesLoaded

func (m *Document) EnsureStylesLoaded()

EnsureStylesLoaded scans up to the first min(BufEndNum(), DocumentCacheSize) lines to populate m.styles. This discovers styles that haven't yet been displayed so they can be toggled in the Styles sidebar. Styles beyond DocumentCacheSize may still be discovered later as lines are rendered/scanned.

func (*Document) Export

func (m *Document) Export(w io.Writer, start int, end int) error

Export exports the document in the specified range.

func (*Document) ExportPlain

func (m *Document) ExportPlain(w io.Writer, start int, end int) error

ExportPlain exports the document in the specified range without ANSI escape sequences.

func (*Document) GetLine deprecated

func (m *Document) GetLine(n int) string

GetLine returns one line from buffer.

Deprecated: Use Document.LineStr instead.

func (*Document) Line

func (m *Document) Line(n int) ([]byte, error)

Line returns one line from buffer.

func (*Document) LineStr

func (m *Document) LineStr(n int) (string, error)

LineStr returns one line from buffer.

func (*Document) LineString deprecated

func (m *Document) LineString(n int) string

LineString returns one line from the buffer as a string.

Deprecated: This method is deprecated because it does not return an error and may silently ignore failures. Please use Document.LineStr instead, which returns both the string and an error for better error handling.

func (*Document) NewCache

func (m *Document) NewCache() error

NewCache initializes a new LRU cache for the Document. It returns an error if the cache cannot be created.

func (*Document) Search

func (m *Document) Search(ctx context.Context, searcher Searcher, chunkNum int, lineNum int) (int, error)

Search searches for the search term and moves to the nearest matching line.

func (*Document) SearchChunk

func (m *Document) SearchChunk(ctx context.Context, searcher Searcher, chunkNum int, lineNum int) (int, error)

SearchChunk searches forward from the specified line.

func (*Document) SearchChunkNonMatch

func (m *Document) SearchChunkNonMatch(ctx context.Context, searcher Searcher, chunkNum int, lineNum int) (int, error)

SearchChunkNonMatch returns unmatched line number.

func (*Document) SearchLine

func (m *Document) SearchLine(ctx context.Context, searcher Searcher, lineNum int) (int, error)

SearchLine searches the document and returns the matching line number.

func (*Document) WaitEOF

func (m *Document) WaitEOF()

WaitEOF waits for EOF.

func (*Document) WaitEOFWithTimeout

func (m *Document) WaitEOFWithTimeout(timeout time.Duration)

WaitEOFWithTimeout waits for EOF with a timeout. Parameters: - timeout: the duration to wait before timing out.

type Eventer

type Eventer interface {
	// Mode returns the input mode.
	Mode() InputMode
	// Prompt returns the prompt string in the input field.
	Prompt() string
	// Confirm returns the event when the input is confirmed.
	Confirm(i string) tcell.Event
	// Up returns strings when the up key is pressed during input.
	Up(i string) string
	// Down returns strings when the down key is pressed during input.
	Down(i string) string
}

Eventer is a generic interface for inputs.

type General

type General struct {
	// Converter is the converter name.
	Converter *string
	// Align is the alignment.
	Align *bool
	// Raw is the raw setting.
	Raw *bool
	// Wrap is the wrap mode setting ("char" or "word").
	Wrap *string
	// BreakIndent is the indentation width applied to subsequent wrapped lines.
	BreakIndent *string
	// Caption is an additional caption to display after the file name.
	Caption *string
	// ColumnDelimiter is a column delimiter.
	ColumnDelimiter *string
	// SectionDelimiter is a section delimiter.
	SectionDelimiter *string
	// JumpTarget is the configured jump target string.
	JumpTarget *string
	// MultiColorWords specifies words to color separated by spaces.
	MultiColorWords *[]string

	// TabWidth is the tab stop width.
	TabWidth *int
	// Header is the number of header lines to pin.
	Header *int
	// VerticalHeader is the number of vertical header lines.
	VerticalHeader *int
	// HeaderColumn is the number of columns from the left to be fixed.
	// If 0 is specified, no columns are fixed.
	HeaderColumn *int
	// SkipLines is the number of rows to skip.
	SkipLines *int
	// WatchInterval is the watch interval (seconds).
	WatchInterval *int
	// MarkStyleWidth is width to apply the style of the marked line.
	MarkStyleWidth *int
	// SectionStartPosition is a section start position.
	SectionStartPosition *int
	// SectionHeaderNum is the number of lines in the section header.
	SectionHeaderNum *int
	// HScrollWidth is the horizontal scroll width as a string (e.g., "80%", "40").
	HScrollWidth *string
	// HScrollWidthNum is the horizontal scroll width as an integer (number of columns).
	HScrollWidthNum *int
	// VScrollLines is the number of lines to scroll with the mouse wheel.
	VScrollLines *int
	// RulerType is the ruler type (0: none, 1: relative, 2: absolute).
	RulerType *RulerType
	// AlternateRows alternately style rows.
	AlternateRows *bool
	// ColumnMode is column mode.
	ColumnMode *bool
	// ColumnWidth is column width mode.
	ColumnWidth *bool
	// ColumnRainbow is column rainbow.
	ColumnRainbow *bool
	// LineNumMode displays line numbers.
	LineNumMode *bool
	// WrapMode indicates whether wrapping is enabled.
	WrapMode *bool
	// SignMode is a bitmask for display markers (1=break, 2=continue, 4=trunc).
	SignMode *int
	// BreakSign is the sign displayed at the start of wrapped lines.
	BreakSign *string
	// ContinueSign is the sign displayed at the end of lines that continue.
	ContinueSign *string
	// TruncSign is the sign used for truncated lines.
	TruncSign *string
	// FollowMode is the follow mode.
	FollowMode *bool
	// FollowAll is a follow mode for all documents.
	FollowAll *bool
	// FollowSection is a follow mode that uses section instead of line.
	FollowSection *bool
	// FollowName is the mode to follow files by name.
	FollowName *bool
	// PlainMode is whether to enable the original character decoration.
	PlainMode *bool
	// SectionHeader is whether to display the section header.
	SectionHeader *bool
	// HideOtherSection is whether to hide other sections.
	HideOtherSection *bool
	// StatusLine indicates whether to hide the status line.
	StatusLine *bool
	// PromptConfig holds settings related to the command prompt.
	Prompt PromptConfig
	// Style is the style setting for general appearance and formatting.
	Style StyleConfig
}

General is the general configuration.

func (*General) SetAlign

func (g *General) SetAlign(align bool)

SetAlign sets the alignment.

func (*General) SetAlternateRows

func (g *General) SetAlternateRows(alternate bool)

SetAlternateRows sets the alternate row style.

func (*General) SetBreakIndent

func (g *General) SetBreakIndent(indent string)

SetBreakIndent sets the indent width used for wrapped lines.

func (*General) SetCaption

func (g *General) SetCaption(caption string)

SetCaption sets the caption.

func (*General) SetColumnDelimiter

func (g *General) SetColumnDelimiter(delim string)

SetColumnDelimiter sets the column delimiter.

func (*General) SetColumnMode

func (g *General) SetColumnMode(mode bool)

SetColumnMode sets the column mode.

func (*General) SetColumnRainbow

func (g *General) SetColumnRainbow(rainbow bool)

SetColumnRainbow sets the column rainbow mode.

func (*General) SetColumnWidth

func (g *General) SetColumnWidth(width bool)

SetColumnWidth sets the column width mode.

func (*General) SetConverter

func (g *General) SetConverter(converter string)

SetConverter sets the converter name.

func (*General) SetFollowAll

func (g *General) SetFollowAll(followAll bool)

SetFollowAll sets the follow mode for all documents.

func (*General) SetFollowMode

func (g *General) SetFollowMode(follow bool)

SetFollowMode sets the follow mode.

func (*General) SetFollowName

func (g *General) SetFollowName(followName bool)

SetFollowName sets the follow mode by file name.

func (*General) SetFollowSection

func (g *General) SetFollowSection(followSection bool)

SetFollowSection sets the follow mode by section.

func (*General) SetHScrollWidth

func (g *General) SetHScrollWidth(width string)

SetHScrollWidth sets the horizontal scroll width as a string.

func (*General) SetHScrollWidthNum

func (g *General) SetHScrollWidthNum(num int)

SetHScrollWidthNum sets the horizontal scroll width as an integer.

func (*General) SetHeader

func (g *General) SetHeader(header int)

SetHeader sets the number of header lines to be fixed.

func (*General) SetHeaderColumn

func (g *General) SetHeaderColumn(headerColumn int)

SetHeaderColumn sets the number of header columns to be fixed.

func (*General) SetHideOtherSection

func (g *General) SetHideOtherSection(hide bool)

SetHideOtherSection sets whether to hide other sections.

func (*General) SetJumpTarget

func (g *General) SetJumpTarget(target string)

SetJumpTarget sets the jump target string.

func (*General) SetLineNumMode

func (g *General) SetLineNumMode(lineNum bool)

SetLineNumMode sets the line number display mode.

func (*General) SetMarkStyleWidth

func (g *General) SetMarkStyleWidth(width int)

SetMarkStyleWidth sets the width for the marked line style.

func (*General) SetMultiColorWords

func (g *General) SetMultiColorWords(words []string)

SetMultiColorWords sets the multi-color words.

func (*General) SetPlainMode

func (g *General) SetPlainMode(plain bool)

SetPlainMode sets the plain mode for character decoration.

func (*General) SetRaw

func (g *General) SetRaw(raw bool)

SetRaw sets the raw mode.

func (*General) SetRulerType

func (g *General) SetRulerType(rtype RulerType)

SetRulerType sets the ruler type.

func (*General) SetSectionDelimiter

func (g *General) SetSectionDelimiter(delim string)

SetSectionDelimiter sets the section delimiter.

func (*General) SetSectionHeader

func (g *General) SetSectionHeader(sectionHeader bool)

SetSectionHeader sets whether to display the section header.

func (*General) SetSectionHeaderNum

func (g *General) SetSectionHeaderNum(num int)

SetSectionHeaderNum sets the number of lines in the section header.

func (*General) SetSectionStartPosition

func (g *General) SetSectionStartPosition(pos int)

SetSectionStartPosition sets the section start position.

func (*General) SetSignMode

func (g *General) SetSignMode(mode int)

SetSignMode sets the display marker bitmask.

func (*General) SetSkipLines

func (g *General) SetSkipLines(skipLines int)

SetSkipLines sets the number of lines to skip.

func (*General) SetStatusLine

func (g *General) SetStatusLine(status bool)

SetStatusLine sets the status line visibility.

func (*General) SetTabWidth

func (g *General) SetTabWidth(tabWidth int)

SetTabWidth sets the tab stop number.

func (*General) SetVScrollLines

func (g *General) SetVScrollLines(num int)

SetVScrollLines sets the number of lines to scroll with the mouse wheel.

func (*General) SetVerticalHeader

func (g *General) SetVerticalHeader(verticalHeader int)

SetVerticalHeader sets the number of vertical header lines.

func (*General) SetWatchInterval

func (g *General) SetWatchInterval(interval int)

SetWatchInterval sets the watch interval in seconds.

func (*General) SetWrap

func (g *General) SetWrap(wrap string)

SetWrap sets the wrap mode ("char" or "word").

func (*General) SetWrapMode

func (g *General) SetWrapMode(wrap bool)

SetWrapMode sets the wrap mode.

type Group

type Group int

Group represents a category of key binding actions.

const (
	// GroupAll includes all key binding groups.
	GroupAll Group = -1
	// GroupGeneral contains general actions such as exit and help.
	GroupGeneral Group = iota
	// GroupMoving contains cursor and scroll movement actions.
	GroupMoving
	// GroupSidebar contains sidebar toggle and navigation actions.
	GroupSidebar
	// GroupDocList contains document list navigation actions.
	GroupDocList
	// GroupMark contains mark set and jump actions.
	GroupMark
	// GroupSearch contains search and search navigation actions.
	GroupSearch
	// GroupChange contains display option toggle actions.
	GroupChange
	// GroupChangeInput contains display option changes that require input.
	GroupChangeInput
	// GroupColumn contains column-related operations.
	GroupColumn
	// GroupSection contains section-related operations.
	GroupSection
	// GroupClose contains close and reload actions.
	GroupClose
	// GroupTyping contains key bindings used while typing in input mode.
	GroupTyping
)

GroupAll and the following values identify key binding action groups.

func (Group) String

func (g Group) String() string

type Input

type Input struct {
	Event Eventer

	// Candidate is prepared when the history is used as an input candidate.
	// Header and SkipLines use numbers up and down instead of candidate.
	Candidate map[InputMode]*candidate
	// contains filtered or unexported fields
}

Input represents the status of various inputs. Retain each input list to save the input history.

func NewInput

func NewInput() *Input

NewInput returns all the various inputs.

type InputMode

type InputMode int

InputMode represents the state of the input.

const (
	// Normal is the default mode where no special input handling is active.
	Normal InputMode = iota
	// ViewMode is for view selection.
	ViewMode
	// Search is for searching.
	Search
	// Backsearch is for backward searching.
	Backsearch
	// Filter is for filtering.
	Filter
	// MarkByPattern is for marking by pattern.
	MarkByPattern
	// Goline is for moving to a specific line.
	Goline
	// Header is for setting the number of headers.
	Header
	// Delimiter is for setting the delimiter.
	Delimiter
	// TabWidth is for setting the tab width.
	TabWidth
	// BreakIndentInput is for setting the wrapped-line indent.
	BreakIndentInput
	// SignModeInput is for setting the display marker bitmask.
	SignModeInput
	// Watch is for setting the watch interval.
	Watch
	// SkipLines is for setting the number of lines to skip.
	SkipLines
	// WriteBA is for setting the number of ranges to write at quit.
	WriteBA
	// SectionDelimiter is for setting the section delimiter.
	SectionDelimiter
	// SectionStart is for setting the section start position.
	SectionStart
	// MultiColor is for multi-word coloring.
	MultiColor
	// JumpTarget is for setting the position to display the search results.
	JumpTarget
	// SaveBuffer is for saving the buffer.
	SaveBuffer
	// SectionNum is for setting the section number.
	SectionNum
	// ConvertType is for setting the convert type.
	ConvertType
	// VerticalHeader is for setting the number of vertical headers.
	VerticalHeader
	// HeaderColumn is for setting the number of vertical header columns.
	HeaderColumn
	// MarkNum is for setting the mark number.
	MarkNum
	// StyleToggle is for toggling style highlight suppression.
	StyleToggle
)

Normal is the default input mode; the following values define other modes.

type KeyBind

type KeyBind map[string][]string

KeyBind represents a mapping from action names to their associated key sequences.

func DefaultKeyBinds

func DefaultKeyBinds() KeyBind

DefaultKeyBinds are the default keybindings.

func GetKeyBinds

func GetKeyBinds(config Config) KeyBind

GetKeyBinds returns the current key mapping based on the provided configuration. If the default key bindings are not disabled in the configuration, it initializes the key bindings with the default values and then overwrites them with any custom key bindings specified in the configuration file.

Parameters:

  • config: The configuration object that contains the key binding settings.

Returns:

  • KeyBind: A map where the keys are action names and the values are slices of strings representing the keys assigned to those actions.

func LessKeyBinds

func LessKeyBinds() KeyBind

LessKeyBinds are keybindings preset for less-like operations.

func (KeyBind) GetKeyBindDescriptions

func (k KeyBind) GetKeyBindDescriptions(group Group) [][]string

GetKeyBindDescriptions returns a slice of key binding descriptions for the specified group.

func (KeyBind) String

func (k KeyBind) String() string

String returns keybind as a string for help.

type KeyBindDescription

type KeyBindDescription struct {
	Group       Group
	Action      string
	Description string
}

KeyBindDescription describes one key binding action and its group.

type LineC

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

LineC is one line of information. Contains content, string, location information.

type LineNumber

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

LineNumber is Number of logical lines and number of wrapping lines on the screen.

type LogDocument

type LogDocument struct {
	*Document
	// contains filtered or unexported fields
}

LogDocument is a document for log.

func NewLogDoc

func NewLogDoc() (*LogDocument, error)

NewLogDoc generates a document for log. NewLogDoc makes LogDoc the output destination of go's standard logger.

func (*LogDocument) Write

func (logDoc *LogDocument) Write(p []byte) (int, error)

Write matches the interface of io.Writer(so package log is possible). Therefore, the log.Print output is displayed by logDoc.

type MatchedLine

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

MatchedLine represents a line that matches a search or filter criteria, containing the line number and the line content.

type MatchedLineList

type MatchedLineList []MatchedLine

MatchedLineList is a slice of MatchedLine, representing a list of matched lines.

type MouseSelectState

type MouseSelectState int

MouseSelectState represents the state of mouse selection.

const (
	// SelectNone means there is no active selection.
	SelectNone MouseSelectState = iota
	// SelectActive means selection is currently in progress.
	SelectActive
	// SelectCopied means the last selection has been copied.
	SelectCopied
)

SelectNone and the following values identify mouse selection states.

type OVPromptConfig

type OVPromptConfig struct {
	// Normal is the normal prompt setting.
	Normal OVPromptConfigNormal
	Input  OVPromptConfigInput
}

OVPromptConfig is the prompt setting.

func NewOVPromptConfig

func NewOVPromptConfig() OVPromptConfig

NewOVPromptConfig returns the structure of OVPromptConfig with default values.

type OVPromptConfigInput

type OVPromptConfigInput struct {
	CursorType int
}

OVPromptConfigInput is the input prompt setting.

type OVPromptConfigNormal

type OVPromptConfigNormal struct {
	// ShowFilename controls whether to display filename.
	ShowFilename bool
	// InvertColor controls whether the text is colored and inverted.
	InvertColor bool
	// ProcessOfCount controls whether to display the progress of the count.
	ProcessOfCount bool
	// CursorType controls the type of cursor to display.
	CursorType int
}

OVPromptConfigNormal is the normal prompt setting.

type OVStyle

type OVStyle struct {
	// Background is a color name string.
	Background string
	// Foreground is a color name string.
	Foreground string
	// UnderlineColor is an underline color name string.
	UnderlineColor string
	// UnderlineStyle is an underline style.
	UnderlineStyle string
	// VerticalAlignType is a vertical align type.
	VerticalAlignType int
	// If true, add blink.
	Blink bool
	// If true, add bold.
	Bold bool
	// If true, add dim.
	Dim bool
	// If true, add italic.
	Italic bool
	// If true, add reverse.
	Reverse bool
	// If true, add underline.
	Underline bool
	// If true, add strike through.
	StrikeThrough bool
	// If true, add overline (not yet supported).
	OverLine bool
	// If true, sub blink.
	UnBlink bool
	// If true, sub bold.
	UnBold bool
	// If true, sub dim.
	UnDim bool
	// If true, sub italic.
	UnItalic bool
	// If true, sub reverse.
	UnReverse bool
	// If true, sub underline.
	UnUnderline bool
	// If true, sub strike through.
	UnStrikeThrough bool
	// if true, sub overline (not yet supported).
	UnOverLine bool
	// If true, reset all styles.
	Reset bool
}

OVStyle represents a style in addition to the original style.

type PromptConfig

type PromptConfig struct {
	// Normal is the normal prompt setting.
	Normal PromptConfigNormal
	Input  PromptConfigInput
}

PromptConfig is the prompt setting.

type PromptConfigInput

type PromptConfigInput struct {
	CursorType *int
}

PromptConfigInput is the input prompt setting.

type PromptConfigNormal

type PromptConfigNormal struct {
	// ShowFilename controls whether to display filename.
	ShowFilename *bool
	// InvertColor controls whether the text is colored and inverted.
	InvertColor *bool
	// ProcessOfCount controls whether to display the progress of the count.
	ProcessOfCount *bool
	// CursorType controls the type of cursor to display.
	CursorType *int
}

PromptConfigNormal is the normal prompt setting.

type Root

type Root struct {
	// tcell.Screen is the root screen.
	Screen tcell.Screen

	// Doc is the current document.
	Doc *Document

	// Pattern is the search pattern.
	Pattern string
	// OnExit stores lines to output on exit.
	OnExit []string

	// OriginStr stores the original search string.
	OriginStr string

	// DocList is the list of documents.
	DocList []*Document

	// Config is the runtime configuration for ov.
	Config Config
	// OriginPos is the position at the start of search.
	OriginPos int

	// CurrentDoc is the index of the current document.
	CurrentDoc int

	// FollowAll is a follow mode for all documents.
	FollowAll bool

	// SidebarItems is the items to display in the sidebar.
	SidebarItems []SidebarItem
	// SidebarHelpItems is the help items to display in the sidebar.
	SidebarHelpItems []SidebarItem
	// contains filtered or unexported fields
}

Root is the root structure of the oviewer.

func ExecCommand deprecated

func ExecCommand(cmd *exec.Cmd) (*Root, error)

ExecCommand return the structure of oviewer. ExecCommand executes the command and opens stdout/stderr as document.

Deprecated: use NewCommand and [Exec] instead.

Example
package main

import (
	"os/exec"

	"github.com/chapmanjacobd/ov/oviewer"
)

func main() {
	command := exec.Command("ls", "-alF")
	ov, err := oviewer.ExecCommand(command)
	if err != nil {
		panic(err)
	}
	if err := ov.Run(); err != nil {
		panic(err)
	}
}

func NewOviewer

func NewOviewer(docs ...*Document) (*Root, error)

NewOviewer return the structure of oviewer. NewOviewer requires one or more documents.

Example
package main

import (
	"bytes"

	"github.com/chapmanjacobd/ov/oviewer"
)

func main() {
	doc, err := oviewer.NewDocument()
	if err != nil {
		panic(err)
	}
	s := "Hello, World!"
	if err := doc.ControlReader(bytes.NewBufferString(s), nil); err != nil {
		panic(err)
	}

	ov, err := oviewer.NewOviewer(doc)
	if err != nil {
		panic(err)
	}
	if err := ov.Run(); err != nil {
		panic(err)
	}
}

func NewRoot

func NewRoot(r io.Reader) (*Root, error)

NewRoot returns the structure of the oviewer. NewRoot is a simplified version that can be used externally.

Example
package main

import (
	"strings"

	"github.com/chapmanjacobd/ov/oviewer"
)

func main() {
	r := strings.NewReader(strings.Repeat("north\n", 99))
	ov, err := oviewer.NewRoot(r)
	if err != nil {
		panic(err)
	}
	if err := ov.Run(); err != nil {
		panic(err)
	}
}

func Open

func Open(fileNames ...string) (*Root, error)

Open reads the file named of the argument and return the structure of oviewer. If there is no file name, create Root from standard input. If there is only one file name, create Root from that file, but return an error if the open is an error. If there is more than one file name, create Root from multiple files.

Example
package main

import (
	"github.com/chapmanjacobd/ov/oviewer"
)

func main() {
	ov, err := oviewer.Open("example_test.go")
	if err != nil {
		panic(err)
	}
	if err := ov.Run(); err != nil {
		panic(err)
	}
}

func (*Root) AddDocument

func (root *Root) AddDocument(m *Document)

AddDocument fires the eventAddDocument event.

func (*Root) BackSearch

func (root *Root) BackSearch(str string)

BackSearch fires a backward search event. This is for calling Search from the outside. Normally, the event is executed from Confirm.

func (*Root) Cancel

func (root *Root) Cancel(context.Context)

Cancel follow mode and follow all mode.

func (*Root) Close

func (root *Root) Close()

Close closes the oviewer.

func (*Root) CloseAllFilter

func (root *Root) CloseAllFilter()

CloseAllFilter fires the eventCloseAllFilter event.

func (*Root) CloseDocument

func (root *Root) CloseDocument(_ *Document)

CloseDocument fires the eventCloseDocument event.

func (*Root) CopySelect

func (root *Root) CopySelect(context.Context)

CopySelect fires the eventCopySelect event.

func (*Root) DocumentLen

func (root *Root) DocumentLen() int

DocumentLen returns the number of Docs.

func (*Root) ExpandColumn

func (root *Root) ExpandColumn(_ context.Context, cursor int) error

ExpandColumn expands the specified column.

func (*Root) Filter

func (root *Root) Filter(str string, nonMatch bool)

Filter fires the filter event.

func (*Root) MarkByPattern

func (root *Root) MarkByPattern(str string)

MarkByPattern marks lines matching the pattern.

func (*Root) MoveBottom

func (root *Root) MoveBottom()

MoveBottom fires the event of moving to bottom.

func (*Root) MoveLine

func (root *Root) MoveLine(num int)

MoveLine fires an eventGoto event that moves to the specified line.

func (*Root) MoveTop

func (root *Root) MoveTop()

MoveTop fires the event of moving to top.

func (*Root) OutputOnExit

func (root *Root) OutputOnExit()

OutputOnExit outputs to the terminal when exiting.

func (*Root) Paste

func (root *Root) Paste(context.Context)

Paste fires the eventPaste event.

func (*Root) Quit

func (root *Root) Quit(context.Context)

Quit fires the eventAppQuit event.

func (*Root) Reload

func (root *Root) Reload(context.Context)

Reload fires the eventReload event.

func (*Root) Run

func (root *Root) Run() error

Run starts the terminal pager.

func (*Root) ScreenContent

func (root *Root) ScreenContent() []string

ScreenContent returns the screen content.

func (*Root) Search

func (root *Root) Search(str string)

Search fires a forward search event. This is for calling Search from the outside. Normally, the event is executed from Confirm.

func (*Root) SetConfig

func (root *Root) SetConfig(config Config)

SetConfig sets config.

func (*Root) SetDocument

func (root *Root) SetDocument(docNum int) error

SetDocument fires the eventDocument event.

func (*Root) SetKeyHandler

func (root *Root) SetKeyHandler(ctx context.Context, name string, keys []string, handler func(context.Context)) error

SetKeyHandler assigns a new key handler.

func (*Root) SetWatcher

func (root *Root) SetWatcher(watcher *fsnotify.Watcher)

SetWatcher sets file monitoring.

func (*Root) ShrinkColumn

func (root *Root) ShrinkColumn(_ context.Context, cursor int) error

ShrinkColumn shrinks the specified column.

func (*Root) StrLeftStatus

func (root *Root) StrLeftStatus(numVisible bool) string

StrLeftStatus returns the left status string.

func (*Root) Suspend

func (root *Root) Suspend()

Suspend fires the eventAppSuspend event.

func (*Root) TailSync

func (root *Root) TailSync(ctx context.Context)

TailSync move to tail and sync.

func (*Root) ViewSync

func (root *Root) ViewSync(context.Context)

ViewSync redraws the whole thing.

func (*Root) WriteCurrentScreen

func (root *Root) WriteCurrentScreen()

WriteCurrentScreen writes to the current screen.

func (*Root) WriteLog

func (root *Root) WriteLog()

WriteLog write to the log terminal.

func (*Root) WriteOriginal

func (root *Root) WriteOriginal()

WriteOriginal writes to the original terminal.

func (*Root) WriteQuit

func (root *Root) WriteQuit(ctx context.Context)

WriteQuit sets the write flag and executes a quit event.

type RulerType

type RulerType int

RulerType is the type of ruler.

const (
	// RulerNone is no ruler.
	RulerNone RulerType = iota
	// RulerRelative is a relative ruler.
	RulerRelative
	// RulerAbsolute is an absolute ruler.
	RulerAbsolute
)

RulerNone and the following values identify ruler display modes.

func (RulerType) String

func (r RulerType) String() string

String returns the string representation of the ruler type.

type RunTimeSettings

type RunTimeSettings struct {
	// Name is the name of the view mode.
	Name string
	// Converter is the converter name.
	Converter string
	// Caption is an additional caption to display after the file name.
	Caption string
	// ColumnDelimiterReg is a compiled regular expression of ColumnDelimiter.
	ColumnDelimiterReg *regexp.Regexp
	// ColumnDelimiter is a column delimiter.
	ColumnDelimiter string
	// SectionDelimiterReg is a section delimiter.
	SectionDelimiterReg *regexp.Regexp
	// SectionDelimiter is a section delimiter.
	SectionDelimiter string
	// Specified string for jumpTarget.
	JumpTarget string
	// MultiColorWords specifies words to color separated by spaces.
	MultiColorWords []string

	// TabWidth is tab stop num.
	TabWidth int
	// Header is number of header lines to be fixed.
	Header int
	// VerticalHeader is the number of vertical header lines.
	VerticalHeader int
	// HeaderColumn is the number of columns from the left to be fixed.
	// If 0 is specified, no columns are fixed.
	HeaderColumn int
	// SkipLines is the rows to skip.
	SkipLines int
	// WatchInterval is the watch interval (seconds).
	WatchInterval int
	// MarkStyleWidth is width to apply the style of the marked line.
	MarkStyleWidth int
	// SectionStartPosition is a section start position.
	SectionStartPosition int
	// SectionHeaderNum is the number of lines in the section header.
	SectionHeaderNum int
	// HScrollWidth is the horizontal scroll width.
	HScrollWidth string
	// HScrollWidthNum is the horizontal scroll width.
	HScrollWidthNum int
	// VScrollLines is the number of lines to scroll with the mouse wheel.
	VScrollLines int
	// RulerType is the ruler type (0: none, 1: relative, 2: absolute).
	RulerType RulerType
	// AlternateRows alternately style rows.
	AlternateRows bool
	// ColumnMode is column mode.
	ColumnMode bool
	// ColumnWidth is column width mode.
	ColumnWidth bool
	// ColumnRainbow is column rainbow.
	ColumnRainbow bool
	// LineNumMode displays line numbers.
	LineNumMode bool
	// WrapMode is wrap mode.
	WrapMode bool
	// SignMode is a bitmask for display markers (1=break, 2=continue, 4=trunc).
	SignMode int
	// BreakSign is the sign displayed at the start of wrapped lines.
	BreakSign string
	// ContinueSign is the sign displayed at the end of lines that continue.
	ContinueSign string
	// TruncSign is the sign used for truncated lines.
	TruncSign string

	// BreakIndent is the indentation width applied to subsequent wrapped lines.
	BreakIndent string
	// FollowMode is the follow mode.
	FollowMode bool
	// FollowAll is a follow mode for all documents.
	FollowAll bool
	// FollowSection is a follow mode that uses section instead of line.
	FollowSection bool
	// FollowName is the mode to follow files by name.
	FollowName bool
	// PlainMode is whether to enable the original character decoration.
	PlainMode bool
	// SectionHeader is whether to display the section header.
	SectionHeader bool
	// HideOtherSection is whether to hide other sections.
	HideOtherSection bool
	// StatusLine is whether to display the status line.
	StatusLine bool

	// PromptConfig is the prompt configuration.
	OVPromptConfig
	// Style is the style of the document.
	Style Style
}

RunTimeSettings structure contains the RunTimeSettings of the display. RunTimeSettings contains values that determine the behavior of each document.

func NewRunTimeSettings

func NewRunTimeSettings() RunTimeSettings

NewRunTimeSettings returns the structure of RunTimeSettings with default values.

type SCR

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

SCR contains the screen information.

type Searcher

type Searcher interface {
	// Match searches for bytes.
	Match(target []byte) bool
	// MatchString searches for strings.
	MatchString(target string) bool
	// FindAll searches for strings and returns the index of the match.
	FindAll(target string) [][]int
	// String returns the search word.
	String() string
}

Searcher interface provides a match method that determines if the search word matches the argument string.

func NewSearcher

func NewSearcher(word string, searchReg *regexp.Regexp, caseSensitive bool, regexpSearch bool) Searcher

NewSearcher returns the Searcher interface suitable for the search term.

type SidebarItem

type SidebarItem struct {
	Label     string   // Always-visible label (e.g., index, description)
	Contents  contents // Contents to display
	IsCurrent bool
}

SidebarItem represents an item to display in the sidebar.

type SidebarMode

type SidebarMode int

SidebarMode represents the display mode of the sidebar.

const (
	// SidebarModeNone is no sidebar.
	SidebarModeNone SidebarMode = iota
	// SidebarModeHelp is the help sidebar.
	SidebarModeHelp
	// SidebarModeMarks is the mark list sidebar.
	SidebarModeMarks
	// SidebarModeDocList is the document list sidebar.
	SidebarModeDocList
	// SidebarModeSections is the section list sidebar.
	SidebarModeSections
	// SidebarModeViewMode is the view mode list sidebar.
	SidebarModeViewMode
	// SidebarModeStyles is the style list sidebar.
	SidebarModeStyles

	// SidebarModeEnd marks the end of sidebar modes.
	SidebarModeEnd
)

SidebarMode values.

func (SidebarMode) String

func (s SidebarMode) String() string

String returns the string representation of the SidebarMode.

type SignMode

type SignMode int

SignMode represents the mode of the sign indicator (break, continue, truncation).

const (
	SignBreak SignMode = 1 << iota
	SignContinue
	SignTrunc
)

SignBreak, SignContinue, and SignTrunc are flags for line indicators.

type Style

type Style struct {
	// ColumnRainbow is the style that applies to the column rainbow color highlight.
	ColumnRainbow []OVStyle
	// MultiColorHighlight is the style that applies to the multi color highlight.
	MultiColorHighlight []OVStyle
	// Header is the style that applies to the header.
	Header OVStyle
	// Body is the style that applies to the body.
	Body OVStyle
	// LineNumber is a style that applies line number.
	LineNumber OVStyle
	// SearchHighlight is the style that applies to the search highlight.
	SearchHighlight OVStyle
	// ColumnHighlight is the style that applies to the column highlight.
	ColumnHighlight OVStyle
	// MarkLine is a style that marked line.
	MarkLine OVStyle
	// SectionLine is a style that section delimiter line.
	SectionLine OVStyle
	// VerticalHeader is a style that applies to the vertical header.
	VerticalHeader OVStyle
	// JumpTargetLine is the line that displays the search results.
	JumpTargetLine OVStyle
	// Alternate is a style that applies line by line.
	Alternate OVStyle
	// Ruler is a style that applies to the ruler.
	Ruler OVStyle
	// HeaderBorder is the style that applies to the boundary line of the header.
	// The boundary line of the header refers to the visual separator between the header and the rest of the content.
	HeaderBorder OVStyle
	// SectionHeaderBorder is the style that applies to the boundary line of the section header.
	// The boundary line of the section header is the line that separates different sections in the header.
	SectionHeaderBorder OVStyle
	// VerticalHeaderBorder is the style that applies to the boundary character of the vertical header.
	// The boundary character of the vertical header refers to the visual separator that delineates the vertical header from the rest of the content.
	VerticalHeaderBorder OVStyle
	// LeftStatus is the style that applies to the left status line.
	LeftStatus OVStyle
	// RightStatus is the style that applies to the right status line.
	RightStatus OVStyle
	// SelectActive is the style that applies to the text being selected (during mouse drag).
	SelectActive OVStyle
	// SelectCopied is the style that applies to the text that has been copied to clipboard.
	SelectCopied OVStyle
	// PauseLine is the style that applies to the line where follow mode is paused.
	PauseLine OVStyle
	// BreakSign is the style that applies to the break sign.
	BreakSign OVStyle
	// ContinueSign is the style that applies to the continuation sign.
	ContinueSign OVStyle
	// TruncSign is the style that applies to the truncation sign.
	TruncSign OVStyle
}

Style structure contains the style settings of the display.

func NewHelpStyle

func NewHelpStyle() Style

NewHelpStyle returns a Style for the help document.

func NewLogStyle

func NewLogStyle() Style

NewLogStyle generates a style for log documents.

func NewStyle

func NewStyle() Style

NewStyle returns the structure of Style with default values.

type StyleConfig

type StyleConfig struct {
	// ColumnRainbow is the style that applies to the column rainbow color highlight.
	ColumnRainbow *[]OVStyle
	// MultiColorHighlight is the style that applies to the multi color highlight.
	MultiColorHighlight *[]OVStyle
	// Header is the style that applies to the header.
	Header *OVStyle
	// Body is the style that applies to the body.
	Body *OVStyle
	// LineNumber is a style that applies line number.
	LineNumber *OVStyle
	// SearchHighlight is the style that applies to the search highlight.
	SearchHighlight *OVStyle
	// ColumnHighlight is the style that applies to the column highlight.
	ColumnHighlight *OVStyle
	// MarkLine is a style that marked line.
	MarkLine *OVStyle
	// SectionLine is a style that section delimiter line.
	SectionLine *OVStyle
	// VerticalHeader is a style that applies to the vertical header.
	VerticalHeader *OVStyle
	// JumpTargetLine is the line that displays the search results.
	JumpTargetLine *OVStyle
	// Alternate is a style that applies line by line.
	Alternate *OVStyle
	// Ruler is a style that applies to the ruler.
	Ruler *OVStyle
	// HeaderBorder is the style that applies to the boundary line of the header.
	// The boundary line of the header refers to the visual separator between the header and the rest of the content.
	HeaderBorder *OVStyle
	// SectionHeaderBorder is the style that applies to the boundary line of the section header.
	// The boundary line of the section header is the line that separates different sections in the header.
	SectionHeaderBorder *OVStyle
	// VerticalHeaderBorder is the style that applies to the boundary character of the vertical header.
	// The boundary character of the vertical header refers to the visual separator that delineates the vertical header from the rest of the content.
	VerticalHeaderBorder *OVStyle
	// LeftStatus is the style that applies to the left side of the status line.
	LeftStatus *OVStyle
	// RightStatus is the style that applies to the right side of the status line.
	RightStatus *OVStyle
	// SelectActive is the style that applies to the text being selected (during mouse drag).
	SelectActive *OVStyle
	// SelectCopied is the style that applies to the text that has been copied to clipboard.
	SelectCopied *OVStyle
	// PauseLine is the style that applies to the line where follow mode is paused.
	PauseLine *OVStyle
	// BreakSign is the style that applies to the break sign.
	BreakSign *OVStyle
	// ContinueSign is the style that applies to the continuation sign.
	ContinueSign *OVStyle
	// TruncSign is the style that applies to the trunc sign.
	TruncSign *OVStyle
}

StyleConfig is the style setting.

Jump to

Keyboard shortcuts

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