focus

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binder

type Binder interface {
	Push(...bind.Bindable)
	Pop() []bind.Bindable
	Execute(bind.Bindable)
}

A Binder is a type which can bind bindables

type EditorOpener

type EditorOpener interface {
	Open(string) (editor text.Editor, existed bool)
	CurrentEditor() text.Editor
}

EditorOpener represents a type that can open a file, returning an editor.

type FileBinder

type FileBinder interface {
	// FileBindables returns the bindables that should be registered
	// for the given file.
	FileBindables(path string) []bind.Bindable
}

A FileBinder is a type that registers a list of commands on file open.

type FileChanger

type FileChanger interface {
	// FileChanged will be called when the currently focused
	// file changes.
	FileChanged(oldPath, newPath string)
}

A FileChanger is a type that just needs to be called when the open file changes.

type LineStarter

type LineStarter interface {
	LineStart(int) int
}

LineStarter represents a type that knows which position lines start at.

type Location

type Location struct {
	status.General
	// contains filtered or unexported fields
}

Location is a bind.MultiOp that knows how to focus locations in the code.

func NewLocation

func NewLocation(driver gxui.Driver) *Location

NewLocation returns a *Location bound to the passed in driver.

func (*Location) Bind

func (l *Location) Bind(h bind.Bindable) (bind.HookedMultiOp, error)

Bind binds hooks to l.

func (*Location) Exec

func (l *Location) Exec() error

Exec executes l against the values it has stored, returning an error if it encounters any problems.

func (*Location) For

func (l *Location) For(opts ...Opt) bind.Bindable

For makes a clone of l, then applies opts to the copy before returning it.

func (*Location) Name

func (l *Location) Name() string

Name returns l's name.

func (*Location) Reset

func (l *Location) Reset()

Reset resets l's execution state.

func (*Location) Store

func (l *Location) Store(elem interface{}) bind.Status

Store checks elem for an types that l needs to store in order to execute.

type Mover

type Mover interface {
	To(...int) bind.Bindable
}

Mover represents a type that can move carets.

type Opener

type Opener interface {
	Open(string)
}

Opener represents a type that can open a file, but doesn't return anything.

This is legacy code from before hooks existed and should be removed when all places that currently use it are converted to using hooks.

type Opt

type Opt func(*Location) error

Opt is an option function that will apply to *Location types.

func Column

func Column(col int) Opt

Column takes a column number and returns an Opt that will modify a *Location to move carets to that column. Compatible with Line.

func Line

func Line(line int) Opt

Line takes a line number and returns an Opt that will modify a *Location to move carets to that line. Compatible with Column.

func Offset

func Offset(offset int) Opt

Offset takes a character offset and returns an Opt that will modify a *Location to move carets to that offset.

func Path

func Path(path string) Opt

Path takes a file path and returns an Opt that will modify a *Location to focus that file.

func SkipUnbind

func SkipUnbind() Opt

SkipUnbind returns an Opt that modifies a *Location to skip the process of unbinding previously-bound commands. This is currently used to work around an issue that would leave the editor with *no* commands bound to it, as the final entry got popped ofl.

Jump to

Keyboard shortcuts

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