text

package
v0.0.0-...-bbcbdef Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edit

type Edit struct {
	At  int
	Old []rune
	New []rune
}

Edit is a type containing details about edited text.

type Editor

type Editor interface {
	Filepath() string
	Text() string
	Runes() []rune
	SetText(string)
	SyntaxLayers() []SyntaxLayer
	SetSyntaxLayers([]SyntaxLayer)
}

Editor is the local set of methods that the Editor type passed to InputHandlers are guaranteed to have. Other methods may be accessed with type assertions, but we pass the Editor type instead of *editor.Editor in order to allow the more common methods to be accessed without needing to import the editor package.

Due to the oddities in dependency versions and plugins, this helps plugins avoid needing to be rebuilt every time the editor package changes.

type Handler

type Handler interface {
	bind.Bindable
	New() Handler
	Init(Editor, []rune)
	Bind(bind.Bindable) (Handler, error)
	Apply(focused Editor, edits ...Edit)
	HandleEvent(focused Editor, ev gxui.KeyboardEvent)
	HandleInput(focused Editor, stroke gxui.KeyStrokeEvent)
}

Handler handles key strokes from the keyboard. A Handler is essentially the text engine for the text editor. It takes each character entered by the user and processes it into text (or commands) to provide to the editor. If you want vidar to feel like vim, this is the type of command to implement.

It is the responsibility of the input handler to correctly deal with text input fast enough to keep up with a user. When implementing a Handler, it's important to use goroutines to run hooks and make sure that slow hooks are not slowing down the Handler or other hooks.

Since the Handler will replace vidar's default Handler, it should accept both commands.ChangeHook and commands.ContextChangeHook as hooks that can bind to it in order to support hooks that intend to bind to vidar's default Handler.

type Span

type Span struct {
	Start, End int
}

type SyntaxLayer

type SyntaxLayer struct {
	Spans     []Span
	Construct theme.LanguageConstruct
}

func (SyntaxLayer) Contains

func (l SyntaxLayer) Contains(pos int) bool

Jump to

Keyboard shortcuts

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