highlighter

package
v0.0.0-...-041bb18 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const InitialState = "INIT"

Variables

This section is empty.

Functions

This section is empty.

Types

type FileRule

type FileRule struct {
	Pattern string `toml:"pattern"`
	When    string `toml:"when"`

	Colors     string `toml:"color"`
	LineColors string `toml:"line_color"`

	PreLine        string `toml:"pre_line"`
	PreLineColors  string `toml:"pre_line_color"`
	PostLine       string `toml:"post_line"`
	PostLineColors string `toml:"post_line_color"`

	Show bool `toml:"show"`
	Hide bool `toml:"hide"`
	Stop bool `toml:"stop"`

	NextState string   `toml:"next_state"`
	States    []string `toml:"states"`

	After  int `toml:"after"`
	Before int `toml:"before"`
}

type Highlighter

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

Highlighter defines a highlighter specification. Use NewHighlighter() or NewHighlighterWithTerm() to create a new instance.

func NewHighlighter

func NewHighlighter() *Highlighter

NewHighlighter creates a new Highlighter instance with the auto-detected Term.

func NewHighlighterWithTerm

func NewHighlighterWithTerm(t term.Term) *Highlighter

NewHighlighter creates a new Highlighter instance with a given Term.

func (*Highlighter) AddSimpleRangeRules

func (h *Highlighter) AddSimpleRangeRules(patternStart, colorsStart, patternEnd, colorsEnd string) error

func (*Highlighter) AddSimpleRule

func (h *Highlighter) AddSimpleRule(pattern, colorsStr string) error

func (*Highlighter) DefaultAfter

func (h *Highlighter) DefaultAfter() int

func (*Highlighter) DefaultBefore

func (h *Highlighter) DefaultBefore() int

func (*Highlighter) DefaultHide

func (h *Highlighter) DefaultHide() bool

func (*Highlighter) IgnoreCase

func (h *Highlighter) IgnoreCase() bool

func (*Highlighter) LoadToml

func (h *Highlighter) LoadToml(ruleFile string) error

func (*Highlighter) MatcherFlags

func (h *Highlighter) MatcherFlags() matcher.Flags

func (*Highlighter) MustAddSimpleRangeRules

func (h *Highlighter) MustAddSimpleRangeRules(patternStart, colorsStart, patternEnd, colorsEnd string)

func (*Highlighter) MustAddSimpleRule

func (h *Highlighter) MustAddSimpleRule(pattern, colorsStr string)

func (*Highlighter) NewRule

func (h *Highlighter) NewRule() *Rule

func (*Highlighter) NewRuntime

func (h *Highlighter) NewRuntime(wr io.Writer) *Runtime

NewRuntime creates a new Runtime. Output will be written to wr.

func (*Highlighter) NoSkipMarker

func (h *Highlighter) NoSkipMarker() bool

func (*Highlighter) SetDefaultAfter

func (h *Highlighter) SetDefaultAfter(defaultAfter int)

func (*Highlighter) SetDefaultBefore

func (h *Highlighter) SetDefaultBefore(defaultBefore int)

func (*Highlighter) SetDefaultHide

func (h *Highlighter) SetDefaultHide(defaultHide bool)

func (*Highlighter) SetIgnoreCase

func (h *Highlighter) SetIgnoreCase(ignoreCase bool)

func (*Highlighter) SetNoSkipMarker

func (h *Highlighter) SetNoSkipMarker(noSkipMarker bool)

func (*Highlighter) Term

func (h *Highlighter) Term() term.Term

type Rule

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

func (*Rule) MustSetLineColorsString

func (r *Rule) MustSetLineColorsString(colorsStr string)

func (*Rule) MustSetMatchColorsString

func (r *Rule) MustSetMatchColorsString(colorsStr string)

func (*Rule) MustSetMatcherString

func (r *Rule) MustSetMatcherString(pattern string)

func (*Rule) MustSetPostLineString

func (r *Rule) MustSetPostLineString(marker, colorsStr string)

func (*Rule) MustSetPreLineString

func (r *Rule) MustSetPreLineString(marker, colorsStr string)

func (*Rule) MustSetPreMatcherString

func (r *Rule) MustSetPreMatcherString(pattern string)

func (*Rule) SetAfter

func (r *Rule) SetAfter(n int)

func (*Rule) SetBefore

func (r *Rule) SetBefore(n int)

func (*Rule) SetHide

func (r *Rule) SetHide(v bool)

func (*Rule) SetLineColorsString

func (r *Rule) SetLineColorsString(colorsStr string) error

func (*Rule) SetMatchColorsString

func (r *Rule) SetMatchColorsString(colorsStr string) error

func (*Rule) SetMatcherString

func (r *Rule) SetMatcherString(pattern string) error

func (*Rule) SetNextState

func (r *Rule) SetNextState(s string)

func (*Rule) SetPostLineString

func (r *Rule) SetPostLineString(marker, colorsStr string) error

func (*Rule) SetPreLineString

func (r *Rule) SetPreLineString(marker, colorsStr string) error

func (*Rule) SetPreMatcherString

func (r *Rule) SetPreMatcherString(pattern string) error

func (*Rule) SetShow

func (r *Rule) SetShow(v bool)

func (*Rule) SetStates

func (r *Rule) SetStates(states []string)

func (*Rule) SetStop

func (r *Rule) SetStop(v bool)

type RuleFile

type RuleFile struct {
	Rules []FileRule `toml:"rule"`
}

type Runtime

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

Runtime defines a Highlighter execution highlighter. Multiple Runtime's can be created for the same Highlighter instance.

func (*Runtime) ColorBytes

func (r *Runtime) ColorBytes(b []byte) error

ColorBytes applies filter on a given byte array and write to wr.

func (*Runtime) ColorReader

func (r *Runtime) ColorReader(rd io.Reader, callFinish bool) error

ColorReader reads from rd and applies filter on the output.

func (*Runtime) Finish

func (r *Runtime) Finish() error

Finish finalizes the output.

Jump to

Keyboard shortcuts

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