syntax

package
v0.0.0-...-0f375d1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Unlicense Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeKeyword = Type(iota)
	TypeString
	TypeRune
	TypeInt
	TypeComment
	TypeTrailingSpaces
)

Variables

View Source
var DefaultTheme = Theme{
	TypeKeyword:        Attr{Fg: tcell.ColorYellow, Bg: tcell.ColorReset},
	TypeString:         Attr{Fg: tcell.ColorRed, Bg: tcell.ColorReset},
	TypeRune:           Attr{Fg: tcell.ColorYellow, Bg: tcell.ColorReset},
	TypeInt:            Attr{Fg: tcell.ColorReset, Bg: tcell.ColorReset},
	TypeComment:        Attr{Fg: tcell.ColorPurple, Bg: tcell.ColorReset},
	TypeTrailingSpaces: Attr{Fg: tcell.ColorReset, Bg: tcell.ColorYellow},
}

Functions

This section is empty.

Types

type Attr

type Attr struct {
	Fg tcell.Color
	Bg tcell.Color
}

type Byter

type Byter interface {
	Bytes() []byte
}

Byter could converted to []bytes.

type Cursor

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

func NewCursor

func NewCursor(text []byte) *Cursor

func (*Cursor) Advance

func (c *Cursor) Advance() bool

func (*Cursor) Pos

func (c *Cursor) Pos() cell.Pt

func (*Cursor) Remain

func (c *Cursor) Remain() []byte

func (*Cursor) Skip

func (c *Cursor) Skip(b int)

type Language

type Language struct {
	TabToSpace bool
	TabWidth   int
	// contains filtered or unexported fields
}

Language is a set of tab configurations and syntaxes.

func NewLanguage

func NewLanguage(ext string) *Language

NewLanguage finds a language from given extension. It will return "unknown" language if it didn't find language for the extension.

func (*Language) AddSyntax

func (l *Language) AddSyntax(s Syntax)

AddSyntax adds a syntax to the language. It will become more useful when we really split syntax for languages into their own configuration files.

type Match

type Match struct {
	Name  string
	Type  Type
	Range cell.Range
}

type Parser

type Parser struct {
	Matches []Match
	// contains filtered or unexported fields
}

Parser is syntax parser.

func NewParser

func NewParser(text Byter, ext string) *Parser

NewParser creates a new Parser.

func (*Parser) ClearFrom

func (p *Parser) ClearFrom(pt cell.Pt)

ClearFrom clears it's match from pt. If there is an overwrap with a match, it will clear that match too.

func (*Parser) ParseTo

func (p *Parser) ParseTo(pt cell.Pt)

ParseTo calculates it's matches to pt. If a match started but not ended when reached to pt, it will continue parsing to the match's end.

func (*Parser) SetText

func (p *Parser) SetText(text Byter)

SetText set it's text. After done this, first ParseTo will clear current matches and calculate matches from start.

type Syntax

type Syntax struct {
	Name string
	Type Type
	Re   *regexp.Regexp
}

func (Syntax) NewMatch

func (s Syntax) NewMatch(start, end cell.Pt) Match

type Theme

type Theme map[Type]Attr

type Type

type Type int

Jump to

Keyboard shortcuts

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