Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generic ¶
type Generic struct { Scopes []Scope Wrapped []Wrapped StaticWords map[string]theme.LanguageConstruct DynamicWords []Word }
Generic understands and parses a general map of a language syntax.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is a representation of the mapped syntax of a file. It knows about scopes and various language constructs.
func (Map) Layers ¶
func (m Map) Layers() []text.SyntaxLayer
Layers returns all syntax layers from all nested scopes.
type Scope ¶
type Scope struct { // Open is the string that opens a scope. For example, { is a // common way to open a scope. Open string // Close is the string that closes a scope. For example, } is // a common way to close a scope. Close string }
Scope represents an opening and closing scope. These will always use the theme.ScopePair language construct.
type Syntax ¶
type Syntax struct {
// contains filtered or unexported fields
}
Syntax is a type that reads Go source code to provide information on it.
func (*Syntax) Layers ¶
func (s *Syntax) Layers() []text.SyntaxLayer
Layers returns a gxui.CodeSyntaxLayer for each construct used from s.Theme when s.Parse was called. The corresponding gxui.CodeSyntaxLayer will have its foreground and background constructs set, and all positions that should be highlighted that construct will be stored.
type Word ¶
type Word struct { // Before is the word (without spaces) that prefixes this // construct. Do not list separators (e.g. } or )). Before string // After is the word (without spaces) that suffixes this // construct. Do not list separators (e.g. { or (). After string // Construct is the language construct that this word detects. Construct theme.LanguageConstruct }
Word represents a word surrounded by defining characteristics which should be a certain type of language construct.
A simple example: a go function can be detected with:
syntax.Word{Before: []rune("func"), Construct: theme.Func}
TODO: for many languages, using words before and after is not sufficient; but for now, because we don't want to mess with the problems of multiple spaces, we're just going to leave it.
type Wrapped ¶
type Wrapped struct { // Open is the string that opens a the wrapped type, e.g. " or '. Open string // Close is the string that closes the wrapped type. Can be the // same as Open. Close string // Escapes is any way that one could escape a Close. Escapes []string // Construct is the language construct that this wrapped type // detects. Construct theme.LanguageConstruct // Nested tells us whether or not this type can nest itself Nested bool }
Wrapped represents a wrapped type, like a string or comment block.