m

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: OSL-3.0 Imports: 22 Imported by: 0

README

Oviewer

Feature rich terminal pager

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeInit = true

If true, the Page function will clear the screen on return. If false, the Page function will clear the last line, and show the cursor.

Functions

func Page added in v1.0.2

func Page(reader *Reader) error

Page displays text in a pager.

The reader parameter can be constructed using one of: * NewReaderFromFilename() * NewReaderFromText() * NewReaderFromStream()

Or your could roll your own Reader based on the source code for any of those constructors.

func SetManPageFormatFromEnv added in v1.0.2

func SetManPageFormatFromEnv()

SetManPageFormatFromEnv parses LESS_TERMCAP_xx environment variables and adapts the moar output accordingly.

Types

type Line added in v1.0.2

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

A Line represents a line of text that can / will be paged

func NewLine added in v1.0.2

func NewLine(raw string) *Line

NewLine creates a new Line from a (potentially ANSI / man page formatted) string

func (*Line) Plain added in v1.0.2

func (line *Line) Plain() string

Plain returns a plain text representation of the initial string

func (*Line) Tokens added in v1.0.2

func (line *Line) Tokens() []Token

Tokens returns a representation of the string split into styled tokens

type Lines added in v1.0.2

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

Lines contains a number of lines from the reader, plus metadata

type MatchRanges added in v1.0.2

type MatchRanges struct {
	Matches [][2]int
}

MatchRanges collects match indices

func (*MatchRanges) InRange added in v1.0.2

func (mr *MatchRanges) InRange(index int) bool

InRange says true if the index is part of a regexp match

type Pager added in v1.0.2

type Pager struct {

	// NewPager shows lines by default, this field can hide them
	ShowLineNumbers bool
	// contains filtered or unexported fields
}

Pager is the main on-screen pager

func NewPager added in v1.0.2

func NewPager(r *Reader) *Pager

NewPager creates a new Pager

func (*Pager) Quit added in v1.0.2

func (p *Pager) Quit()

Quit leaves the help screen or quits the pager

func (*Pager) StartPaging added in v1.0.2

func (p *Pager) StartPaging(screen tcell.Screen)

StartPaging brings up the pager on screen

type Reader added in v1.0.2

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

Reader reads a file into an array of strings.

It does the reading in the background, and it returns parts of the read data upon request.

This package provides query methods for the struct, no peeking!!

func NewReaderFromFilename added in v1.0.2

func NewReaderFromFilename(filename string) (*Reader, error)

NewReaderFromFilename creates a new file reader.

The Reader will try to uncompress various compressed file format, and also apply highlighting to the file using Chroma: https://github.com/alecthomas/chroma

func NewReaderFromStream added in v1.0.2

func NewReaderFromStream(name string, reader io.Reader) *Reader

NewReaderFromStream creates a new stream reader

The name can be an empty string ("").

If non-empty, the name will be displayed by the pager in the bottom left corner to help the user keep track of what is being paged.

func NewReaderFromText added in v1.0.2

func NewReaderFromText(name string, text string) *Reader

NewReaderFromText creates a Reader from a block of text.

First parameter is the name of this Reader. This name will be displayed by Moar in the bottom left corner of the screen.

func (*Reader) GetLine added in v1.0.2

func (r *Reader) GetLine(lineNumberOneBased int) *Line

GetLine gets a line. If the requested line number is out of bounds, nil is returned.

func (*Reader) GetLineCount added in v1.0.2

func (r *Reader) GetLineCount() int

GetLineCount returns the number of lines available for viewing

func (*Reader) GetLines added in v1.0.2

func (r *Reader) GetLines(firstLineOneBased int, wantedLineCount int) *Lines

GetLines gets the indicated lines from the input

type Token added in v1.0.2

type Token struct {
	Rune  rune
	Style tcell.Style
}

Token is a rune with a style to be written to a cell on screen

Jump to

Keyboard shortcuts

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