m

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: BSD-2-Clause-Views Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BACKSPACE = '\b'
View Source
const MAX_HIGHLIGHT_SIZE int64 = 1024 * 1024

Files larger than this won't be highlighted

View Source
const NO_BREAK_SPACE = '\xa0'

From: https://www.compart.com/en/unicode/U+00A0

Variables

This section is empty.

Functions

func SetManPageFormatFromEnv

func SetManPageFormatFromEnv()

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

Types

type InputLines added in v1.8.0

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

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

type Line

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

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

func NewLine

func NewLine(raw string) *Line

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

func (*Line) HighlightedTokens added in v1.7.0

func (line *Line) HighlightedTokens(search *regexp.Regexp) []twin.Cell

Returns a representation of the string split into styled tokens. Any regexp matches are highlighted in inverse video. A nil regexp means no highlighting.

func (*Line) Plain

func (line *Line) Plain() string

Plain returns a plain text representation of the initial string

type MatchRanges

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

MatchRanges collects match indices

func (*MatchRanges) InRange

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

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

type Pager

type Pager struct {

	// NewPager shows lines by default, this field can hide them
	ShowLineNumbers bool

	WrapLongLines bool

	// If true, pager will clear the screen on return. If false, pager will
	// clear the last line, and show the cursor.
	DeInit bool
	// contains filtered or unexported fields
}

Pager is the main on-screen pager

func NewPager

func NewPager(r *Reader) *Pager

NewPager creates a new Pager

func (*Pager) Page

func (p *Pager) Page() error

Page displays text in a pager.

func (*Pager) Quit

func (p *Pager) Quit()

Quit leaves the help screen or quits the pager

func (*Pager) StartPaging

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

StartPaging brings up the pager on screen

type Reader

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

func NewReaderFromFilename(filename string, style chroma.Style, formatter chroma.Formatter) (*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

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

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

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

func (r *Reader) GetLineCount() int

GetLineCount returns the number of lines available for viewing

func (*Reader) GetLines

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

GetLines gets the indicated lines from the input

type RenderedLine added in v1.8.0

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

type ScreenLines added in v1.8.0

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

Jump to

Keyboard shortcuts

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