Documentation ¶
Index ¶
- Constants
- func NewScrollPositionFromLineNumber(lineNumber linenumbers.LineNumber, name string) scrollPosition
- func TermcapToStyle(termcap string) (twin.Style, error)
- func ZOpen(filename string) (io.ReadCloser, string, error)
- type InputLines
- type Line
- type MatchRanges
- type Pager
- type PagerMode
- type PagerModeGotoLine
- type PagerModeJumpToMark
- type PagerModeMark
- type PagerModeNotFound
- type PagerModeSearch
- type PagerModeViewing
- type Reader
- func (reader *Reader) AwaitFirstByte()
- func (reader *Reader) GetLine(lineNumber linenumbers.LineNumber) *Line
- func (reader *Reader) GetLineCount() int
- func (reader *Reader) GetLines(firstLine linenumbers.LineNumber, wantedLineCount int) (*InputLines, overflowState)
- func (reader *Reader) PumpToStdout()
- func (reader *Reader) SetStyleForHighlighting(style chroma.Style)
- type ReaderOptions
- type StatusBarOption
Constants ¶
const MAX_HIGHLIGHT_SIZE int64 = 1024 * 1024
Files larger than this won't be highlighted
const NO_BREAK_SPACE = '\xa0'
Variables ¶
This section is empty.
Functions ¶
func NewScrollPositionFromLineNumber ¶ added in v1.22.0
func NewScrollPositionFromLineNumber(lineNumber linenumbers.LineNumber, name 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 (*Line) HighlightedTokens ¶ added in v1.7.0
func (line *Line) HighlightedTokens(plainTextStyle twin.Style, search *regexp.Regexp, lineNumber *linenumbers.LineNumber) textstyles.StyledRunesWithTrailer
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(lineNumber *linenumbers.LineNumber) 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 StatusBarStyle StatusBarOption ShowStatusBar bool UnprintableStyle textstyles.UnprintableStyleT WrapLongLines bool // Ref: https://github.com/walles/moar/issues/113 QuitIfOneScreen bool // Ref: https://github.com/walles/moar/issues/94 ScrollLeftHint twin.StyledRune ScrollRightHint twin.StyledRune SideScrollAmount int // Should be positive // If non-nil, scroll to this line number as soon as possible. Set this // value to LineNumberMax() to follow the end of the input (tail). TargetLineNumber *linenumbers.LineNumber // If true, pager will clear the screen on return. If false, pager will // clear the last line, and show the cursor. DeInit bool WithTerminalFg bool // If true, don't set linePrefix AfterExit func() error // contains filtered or unexported fields }
Pager is the main on-screen pager
func (*Pager) ReprintAfterExit ¶ added in v1.8.4
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, chromaStyle *chroma.Style, chromaFormatter *chroma.Formatter)
StartPaging brings up the pager on screen
type PagerMode ¶ added in v1.22.0
type PagerMode interface {
// contains filtered or unexported methods
}
type PagerModeGotoLine ¶ added in v1.22.0
type PagerModeGotoLine struct {
// contains filtered or unexported fields
}
type PagerModeJumpToMark ¶ added in v1.22.0
type PagerModeJumpToMark struct {
// contains filtered or unexported fields
}
type PagerModeMark ¶ added in v1.22.0
type PagerModeMark struct {
// contains filtered or unexported fields
}
type PagerModeNotFound ¶ added in v1.22.0
type PagerModeNotFound struct {
// contains filtered or unexported fields
}
type PagerModeSearch ¶ added in v1.22.0
type PagerModeSearch struct {
// contains filtered or unexported fields
}
type PagerModeViewing ¶ added in v1.22.0
type PagerModeViewing struct {
// contains filtered or unexported fields
}
type Reader ¶
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, formatter chroma.Formatter, options ReaderOptions) (*Reader, error)
NewReaderFromFilename creates a new file reader.
If options.Lexer is nil it will be determined from the input file name.
If options.Style is nil, you must call reader.SetStyleForHighlighting() later to get highlighting.
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, formatter chroma.Formatter, options ReaderOptions) *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.
Note that you must call reader.SetStyleForHighlighting() after this to get highlighting.
func NewReaderFromText ¶
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) AwaitFirstByte ¶ added in v1.23.8
func (reader *Reader) AwaitFirstByte()
Wait for the first line to be read.
Used for making sudo work: https://github.com/walles/moar/issues/199
func (*Reader) GetLine ¶
func (reader *Reader) GetLine(lineNumber linenumbers.LineNumber) *Line
GetLine gets a line. If the requested line number is out of bounds, nil is returned.
func (*Reader) GetLineCount ¶
GetLineCount returns the number of lines available for viewing
func (*Reader) GetLines ¶
func (reader *Reader) GetLines(firstLine linenumbers.LineNumber, wantedLineCount int) (*InputLines, overflowState)
GetLines gets the indicated lines from the input
Overflow state will be didFit if we returned all lines we currently have, or didOverflow otherwise.
func (*Reader) PumpToStdout ¶ added in v1.23.8
func (reader *Reader) PumpToStdout()
func (*Reader) SetStyleForHighlighting ¶ added in v1.23.8
func (reader *Reader) SetStyleForHighlighting(style chroma.Style)
type ReaderOptions ¶ added in v1.28.0
type ReaderOptions struct { // Format JSON input ShouldFormat bool // If this is nil, you must call reader.SetStyleForHighlighting() later if // you want highlighting. Style *chroma.Style // If this is set, it will be used as the lexer for highlighting Lexer chroma.Lexer }
type StatusBarOption ¶ added in v1.20.0
type StatusBarOption int
const ( //revive:disable-next-line:var-naming STATUSBAR_STYLE_INVERSE StatusBarOption = iota //revive:disable-next-line:var-naming STATUSBAR_STYLE_PLAIN //revive:disable-next-line:var-naming STATUSBAR_STYLE_BOLD )
Source Files ¶
- editor.go
- embed-api.go
- highlight.go
- inspection-reader.go
- line.go
- linewrapper.go
- matchRanges.go
- pager.go
- pagermode-go-to-line.go
- pagermode-jump-to-mark.go
- pagermode-mark.go
- pagermode-not-found.go
- pagermode-search.go
- pagermode-viewing.go
- panicHandler.go
- reader.go
- screenLines.go
- scrollPosition.go
- search.go
- styling.go
- zopen.go
Directories ¶
Path | Synopsis |
---|---|
This package handles styled strings.
|
This package handles styled strings. |