m

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 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 ConsumeLessTermcapEnvs added in v1.11.3

func ConsumeLessTermcapEnvs()

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

func NewScrollPositionFromLineNumberOneBased added in v1.9.3

func NewScrollPositionFromLineNumberOneBased(lineNumberOneBased int, source string) scrollPosition

Create a new position, scrolled to the given line number

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

Returns a representation of the string split into styled tokens. Any regexp matches are highlighted. 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 {
	Following bool

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

	StatusBarStyle StatusBarStyle
	ShowStatusBar  bool

	UnprintableStyle UnprintableStyle

	WrapLongLines bool

	// Ref: https://github.com/walles/moar/issues/94
	ScrollLeftHint  twin.Cell
	ScrollRightHint twin.Cell

	SideScrollAmount int // Should be positive

	// 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 with default settings

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) ReprintAfterExit added in v1.8.4

func (p *Pager) ReprintAfterExit() error

After the pager has exited and the normal screen has been restored, you can call this method to print the pager contents to screen again, faking "leaving" pager contents on screen after exit.

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.

Calling _wait() on this Reader will always return immediately, no asynchronous ops will be performed.

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 StatusBarStyle added in v1.8.5

type StatusBarStyle int
const (
	STATUSBAR_STYLE_INVERSE StatusBarStyle = iota
	STATUSBAR_STYLE_PLAIN
	STATUSBAR_STYLE_BOLD
)

type UnprintableStyle added in v1.8.6

type UnprintableStyle int

How do we render unprintable characters?

const (
	UNPRINTABLE_STYLE_HIGHLIGHT UnprintableStyle = iota
	UNPRINTABLE_STYLE_WHITESPACE
)

Jump to

Keyboard shortcuts

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