vidar: Index | Files

package input

import ""


Package Files

editor.go handler.go layers.go

type Edit Uses

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

Edit is a type containing details about edited text.

type Editor Uses

type Editor interface {
    Filepath() string
    Text() string
    Runes() []rune
    SyntaxLayers() []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 Uses

type Handler interface {
    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 Uses

type Span struct {
    Start, End int

type SyntaxLayer Uses

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

Package input imports 3 packages (graph) and is imported by 16 packages. Updated 2018-11-10. Refresh now. Tools for package owners.