editor

package
v0.0.0-...-8454ee1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const NullBufferPath = "/dev/null"

Variables

View Source
var (
	ErrQuitEditor     = errors.New("quit editor")
	ErrUnknownMode    = errors.New("unknown mode")
	ErrUnknownCommand = errors.New("unknown command")
	ErrUnkownMotion   = errors.New("unknown motion")
)
View Source
var ErrPromptCanceled = fmt.Errorf("user canceled the input prompt")

Functions

func Die

func Die(err error)

Types

type Editor

type Editor struct {
	Rows []*Row
	// contains filtered or unexported fields
}

func (*Editor) Close

func (e *Editor) Close() error

func (*Editor) CutRow

func (e *Editor) CutRow()

func (*Editor) DeleteChar

func (e *Editor) DeleteChar()

func (*Editor) DeleteRow

func (e *Editor) DeleteRow(at int)

func (*Editor) ExecuteCommand

func (e *Editor) ExecuteCommand() error

func (*Editor) ExecuteMotion

func (e *Editor) ExecuteMotion() error

func (*Editor) Find

func (e *Editor) Find() error

FIXME: Sometimes the patterm match will match the line above the rowOffset FIXME: Crashes sometimes in big files

func (*Editor) Init

func (e *Editor) Init(logger *log.Logger) error

func (*Editor) InsertChar

func (e *Editor) InsertChar(c rune)

func (*Editor) InsertNewline

func (e *Editor) InsertNewline()

func (*Editor) InsertRow

func (e *Editor) InsertRow(at int, chars string)

func (*Editor) JumpParagraph

func (e *Editor) JumpParagraph(k keys.Key)

func (*Editor) MoveCursor

func (e *Editor) MoveCursor(k keys.Key)

func (*Editor) MoveCursorByRepeat

func (e *Editor) MoveCursorByRepeat(k keys.Key, repeat int)

func (*Editor) OpenFile

func (e *Editor) OpenFile(filename string) error

OpenFile opens a file with the given filename. If a file does not exist, it returns os.ErrNotExist.

func (*Editor) PasteRow

func (e *Editor) PasteRow(at int)

func (*Editor) ProcessKey

func (e *Editor) ProcessKey() error

func (*Editor) ProcessKeyCommandMode

func (e *Editor) ProcessKeyCommandMode() error

func (*Editor) ProcessKeyInsertMode

func (e *Editor) ProcessKeyInsertMode() error

func (*Editor) ProcessKeyNormalMode

func (e *Editor) ProcessKeyNormalMode() error

func (*Editor) Prompt

func (e *Editor) Prompt(prompt string, cb func(query string, k keys.Key)) (string, error)

Prompt shows the given prompt in the command bar and get user input until to user presses the Enter key to confirm the input or until the user presses the Escape key to cancel the input. Returns the user input and nil if the user enters the input. Returns an empty string and ErrPromptCancel if the user cancels the input. It takes an optional callback function, which takes the query string and the last key pressed.

func (*Editor) Render

func (e *Editor) Render()

Render refreshes the screen.

func (*Editor) Save

func (e *Editor) Save(opts ...string) (int, error)

func (*Editor) SetMode

func (e *Editor) SetMode(mode modes.Mode)

func (*Editor) SetStatusMessage

func (e *Editor) SetStatusMessage(format string, a ...interface{})

func (*Editor) Undo

func (e *Editor) Undo()

FIXME: o and O doesn't push anything to the undo stack

func (*Editor) YankRow

func (e *Editor) YankRow()

FIXME: when cursor is at the end of the line, the yanking doesn't work

type Row

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

type UndoNode

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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