state

package
v1.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MenuStyleCommand = MenuStyle(iota)
	MenuStyleFilePath
	MenuStyleFileLocation
	MenuStyleChildDir
	MenuStyleParentDir
	MenuStyleInsertChoice
	MenuStyleWorkingDir
)
View Source
const (
	InputModeNormal = InputMode(iota)
	InputModeInsert
	InputModeMenu
	InputModeSearch
	InputModeVisual
	InputModeTask
	InputModeTextField
)
View Source
const (
	SearchDirectionForward = SearchDirection(iota)
	SearchDirectionBackward
)
View Source
const (
	StatusMsgStyleSuccess = StatusMsgStyle(iota)
	StatusMsgStyleError
)
View Source
const (
	ScrollDirectionForward = iota
	ScrollDirectionBackward
)
View Source
const DefaultUnsavedChangesAbortMsg = `Document has unsaved changes. Either save them ("force save") or discard them ("force reload") and try again`

Variables

This section is empty.

Functions

func AbortIfFileChanged

func AbortIfFileChanged(state *EditorState, f func(*EditorState))

AbortIfFileChanged aborts with an error message if the file has changed on disk. Specifically, abort if the file was moved/deleted or its content checksum has changed.

func AbortIfUnsavedChanges

func AbortIfUnsavedChanges(state *EditorState, abortMsg string, f func(*EditorState))

AbortIfUnsavedChanges executes a function only if the document does not have unsaved changes and shows an error status msg otherwise.

func AddToLastActionMacro added in v0.3.0

func AddToLastActionMacro(s *EditorState, action MacroAction)

AddToLastActionMacro adds an action to the "last action" macro.

func AddToRecordingUserMacro added in v0.3.0

func AddToRecordingUserMacro(s *EditorState, action MacroAction)

AddToRecordingUserMacro adds an action to the currently recording user macro, if any.

func AppendRuneToMenuSearch

func AppendRuneToMenuSearch(state *EditorState, r rune)

AppendMenuSearch appends a rune to the menu search query.

func AppendRuneToSearchQuery

func AppendRuneToSearchQuery(state *EditorState, r rune)

AppendRuneToSearchQuery appends a rune to the text search query.

func AppendRuneToTextField added in v1.3.0

func AppendRuneToTextField(state *EditorState, r rune)

func AutocompleteTextField added in v1.3.0

func AutocompleteTextField(state *EditorState)

AutocompleteTextField performs autocompletion on the text field input. If there are multiple matching suffixes, repeated invocations will cycle through the options (including the original input).

func BeginNewLineAbove

func BeginNewLineAbove(state *EditorState)

BeginNewLineAbove starts a new line above the current line, positioning the cursor at the end of the new line.

func BeginUndoEntry added in v1.0.0

func BeginUndoEntry(state *EditorState)

BeginUndoEntry begins a new undo entry. This should be called before tracking any undo operations.

func CancelTaskIfRunning added in v0.3.0

func CancelTaskIfRunning(state *EditorState)

CancelTaskIfRunning cancels the current task if one is running; otherwise, it does nothing.

func ClearAutoIndentWhitespaceLine added in v0.2.0

func ClearAutoIndentWhitespaceLine(state *EditorState, startOfLineLoc Locator)

ClearAutoIndentWhitespaceLine clears a line consisting of only whitespace characters when autoindent is enabled. This is used to remove whitespace introduced by autoindent (for example, when inserting consecutive newlines).

func ClearLastActionMacro added in v0.3.0

func ClearLastActionMacro(s *EditorState)

ClearLastActionMacro resets the "last action" macro.

func CommitUndoEntry added in v1.0.0

func CommitUndoEntry(state *EditorState)

CommitUndoEntry commits the current undo entry. This should be called after completing an action that can be undone.

func CompleteSearch

func CompleteSearch(state *EditorState, commit bool)

CompleteSearch terminates a text search and returns to normal mode. If commit is true, execute the complete search action. Otherwise, return to the original cursor position.

func CopyLine

func CopyLine(state *EditorState, page clipboard.PageId)

CopyLine copies the line under the cursor to the default page in the clipboard.

func CopyRange added in v0.7.0

func CopyRange(state *EditorState, page clipboard.PageId, loc RangeLocator)

CopyRange copies the characters in a range to the default page in the clipboard.

func CopySelection

func CopySelection(state *EditorState, page clipboard.PageId)

CopySelection copies the current selection to the clipboard.

func DeleteLines

func DeleteLines(state *EditorState, targetLineLoc Locator, abortIfTargetIsCurrentLine bool, replaceWithEmptyLine bool, clipboardPage clipboard.PageId)

DeleteLines deletes lines from the cursor's current line to the line of a target cursor. It moves the cursor to the start of the line following the last deleted line.

func DeleteRange added in v0.7.0

func DeleteRange(state *EditorState, loc RangeLocator, clipboardPage clipboard.PageId) (uint64, uint64)

DeleteRange deletes all characters in a range (for example, a word or selection). This moves the cursor to the start position of the range.

func DeleteRuneFromMenuSearch

func DeleteRuneFromMenuSearch(state *EditorState)

DeleteMenuSearch deletes a rune from the menu search query.

func DeleteRuneFromSearchQuery

func DeleteRuneFromSearchQuery(state *EditorState)

DeleteRuneFromSearchQuery deletes the last rune from the text search query. A deletion in an empty query aborts the search and returns the editor to normal mode.

func DeleteRuneFromTextField added in v1.3.0

func DeleteRuneFromTextField(state *EditorState)

func DeleteToPos added in v0.7.0

func DeleteToPos(state *EditorState, loc Locator, clipboardPage clipboard.PageId)

DeleteToPos deletes characters from the cursor position up to (but not including) the position returned by the locator. It can delete either forwards or backwards from the cursor. The cursor position will be set to the start of the deleted region, which could be on a newline character or past the end of the text.

func EnterInsertMode added in v1.3.0

func EnterInsertMode(state *EditorState)

EnterInsertMode sets the editor to insert mode.

func EnterNormalMode added in v1.3.0

func EnterNormalMode(state *EditorState)

EnterNormalMode sets the editor to normal mode.

func ExecuteSelectedMenuItem

func ExecuteSelectedMenuItem(state *EditorState)

ExecuteSelectedMenuItem executes the action of the selected menu item and closes the menu.

func ExecuteTextFieldAction added in v1.3.0

func ExecuteTextFieldAction(state *EditorState)

func FindNextMatch

func FindNextMatch(state *EditorState, reverse bool)

FindNextMatch moves the cursor to the next position matching the search query.

func HideMenu

func HideMenu(state *EditorState)

HideMenu hides the menu.

func HideTextField added in v1.3.0

func HideTextField(state *EditorState)

func IndentLines added in v0.2.0

func IndentLines(state *EditorState, targetLineLoc Locator, count uint64)

IndentLines indents every line from the current cursor position to the position found by targetLineLoc.

func InsertNewline

func InsertNewline(state *EditorState)

InsertNewline inserts a newline at the current cursor position.

func InsertRune

func InsertRune(state *EditorState, r rune)

InsertRune inserts a single rune at the current cursor location.

func InsertTab

func InsertTab(state *EditorState)

InsertTab inserts a tab at the current cursor position.

func InsertText added in v1.0.0

func InsertText(state *EditorState, text string)

InsertText inserts multiple runes at the current cursor location.

func JoinLines

func JoinLines(state *EditorState)

JoinLines joins the next line with the current line. This matches vim's behavior, which has some subtle edge cases involving empty lines and indentation at the beginning of lines.

func LoadDocument

func LoadDocument(state *EditorState, path string, requireExists bool, cursorLoc Locator)

LoadDocument loads a file into the editor.

func LoadNextDocument

func LoadNextDocument(state *EditorState)

LoadNextDocument loads the next document from the timeline in the editor. The cursor is moved to the start of the line from when the document was last open.

func LoadPrevDocument

func LoadPrevDocument(state *EditorState)

LoadPrevDocument loads the previous document from the timeline in the editor. The cursor is moved to the start of the line from when the document was last open.

func MoveCursor

func MoveCursor(state *EditorState, loc Locator)

MoveCursor moves the cursor to the specified position in the document.

func MoveCursorToLineAbove

func MoveCursorToLineAbove(state *EditorState, count uint64)

MoveCursorToLineAbove moves the cursor up by the specified number of lines, preserving the offset within the line.

func MoveCursorToLineBelow

func MoveCursorToLineBelow(state *EditorState, count uint64)

MoveCursorToLineBelow moves the cursor down by the specified number of lines, preserving the offset within the line.

func MoveCursorToStartOfSelection added in v0.2.0

func MoveCursorToStartOfSelection(state *EditorState)

MoveCursorToStartOfSelection moves the cursor to the start of the current selection. If nothing is selected, this does nothing.

func MoveMenuSelection

func MoveMenuSelection(state *EditorState, delta int)

MoveMenuSelection moves the menu selection up or down with wraparound.

func NewDocument added in v1.3.0

func NewDocument(state *EditorState, path string) error

NewDocument opens a new document at the given path. Returns an error if the file already exists or the directory doesn't exist. This won't create a new file on disk until the user saves it.

func OutdentLines added in v0.2.0

func OutdentLines(state *EditorState, targetLineLoc Locator, count uint64)

OutdentLines outdents every line from the current cursor position to the position found by targetLineLoc.

func PasteAfterCursor

func PasteAfterCursor(state *EditorState, page clipboard.PageId)

PasteAfterCursor inserts the text from the clipboard after the cursor position.

func PasteBeforeCursor

func PasteBeforeCursor(state *EditorState, page clipboard.PageId)

PasteBeforeCursor inserts the text from the clipboard before the cursor position.

func Quit

func Quit(state *EditorState)

Quit sets a flag that terminates the program.

func Redo

func Redo(state *EditorState)

Redo reverses the last undo operation.

func ReloadDocument

func ReloadDocument(state *EditorState)

ReloadDocument reloads the current document.

func RenameDocument added in v1.3.0

func RenameDocument(state *EditorState, newPath string) error

RenameDocument moves a document to a different file path. Returns an error if the file already exists or the directory doesn't exist.

func ReplaceChar

func ReplaceChar(state *EditorState, newChar rune)

ReplaceChar replaces the character under the cursor.

func ReplayLastActionMacro added in v0.3.0

func ReplayLastActionMacro(s *EditorState, count uint64)

ReplayLastActionMacro executes the actions recorded in the "last action" macro.

func ReplayRecordedUserMacro added in v0.3.0

func ReplayRecordedUserMacro(s *EditorState)

ReplayRecordedUserMacro replays the recorded user-defined macro. If no macro has been recorded, this shows an error status msg.

func ResizeView

func ResizeView(state *EditorState, width, height uint64)

ResizeView resizes the view to the specified width and height.

func RunShellCmd

func RunShellCmd(state *EditorState, shellCmd string, mode string)

RunShellCmd executes the command in a shell. Mode must be a valid command mode, as defined in config. All modes run as an asynchronous task that the user can cancel, except for CmdModeTerminal which takes over stdin/stdout.

func SaveDocument

func SaveDocument(state *EditorState)

SaveDocument saves the currently loaded document to disk.

func SaveDocumentIfUnsavedChanges added in v0.7.0

func SaveDocumentIfUnsavedChanges(state *EditorState)

SaveDocumentIfUnsavedChanges saves the document only if it has been edited or the file does not exist on disk.

func ScrollViewByNumLines

func ScrollViewByNumLines(state *EditorState, direction ScrollDirection, numLines uint64)

ScrollViewByNumLines moves the view origin up or down by the specified number of lines.

func ScrollViewToCursor

func ScrollViewToCursor(state *EditorState)

ScrollViewToCursor moves the view origin so that the cursor is visible.

func SearchCompleteMoveCursorToMatch added in v1.1.0

func SearchCompleteMoveCursorToMatch(state *EditorState, query string, direction SearchDirection, match SearchMatch)

SearchCompleteMoveCursorToMatch is a SearchCompleteAction that moves the cursor to the start of the search match.

func SearchWordUnderCursor added in v0.7.0

func SearchWordUnderCursor(state *EditorState, direction SearchDirection, completeAction SearchCompleteAction, targetCount uint64)

SearchWordUnderCursor starts a search for the word under the cursor.

func SelectRange added in v1.0.0

func SelectRange(state *EditorState, loc RangeLocator)

SelectRange selects a given range in charwise mode. This will clear any prior selection and move the cursor to the end of the new selection.

func SetLineNumberMode added in v1.1.0

func SetLineNumberMode(s *EditorState, mode config.LineNumberMode)

SetLineNumberMode sets the line number mode.

func SetSearchQueryToNextInHistory added in v1.0.0

func SetSearchQueryToNextInHistory(state *EditorState)

SetSearchQueryToNextInHistory sets the search query to the next search query in the history.

func SetSearchQueryToPrevInHistory added in v1.0.0

func SetSearchQueryToPrevInHistory(state *EditorState)

SetSearchQueryToPrevInHistory sets the search query to a previous search query in the history.

func SetStatusMsg

func SetStatusMsg(state *EditorState, statusMsg StatusMsg)

SetStatusMsg sets the message displayed in the status bar.

func SetSyntax

func SetSyntax(state *EditorState, language syntax.Language)

SetSyntax sets the syntax language for the current document.

func SetWorkingDirectory added in v0.7.0

func SetWorkingDirectory(s *EditorState, dirPath string)

SetWorkingDirectory changes the working directory to the specified path.

func ShowChildDirsMenu added in v0.7.0

func ShowChildDirsMenu(s *EditorState, dirPatternsToHide []string)

ShowChildDirsMenu displays a menu for changing the working directory to a child directory.

func ShowFileMenu added in v0.3.0

func ShowFileMenu(s *EditorState, dirPatternsToHide []string)

ShowFileMenu displays a menu for finding and loading files in the current working directory. The files are loaded asynchronously as a task that the user can cancel.

func ShowMenu

func ShowMenu(state *EditorState, style MenuStyle, items []menu.Item)

ShowMenu displays the menu with the specified style and items.

func ShowParentDirsMenu added in v0.7.0

func ShowParentDirsMenu(s *EditorState)

ShowParentDirsMenu displays a menu for changing the working directory to a parent directory.

func ShowTextField added in v1.3.0

func ShowTextField(state *EditorState, promptText string, action TextFieldAction, autocompleteFunc TextFieldAutocompleteFunc)

func StartSearch

func StartSearch(state *EditorState, direction SearchDirection, completeAction SearchCompleteAction)

StartSearch initiates a new text search.

func StartTask added in v0.3.0

func StartTask(state *EditorState, task TaskFunc)

StartTask starts a task executing asynchronously in a separate goroutine. If the task completes, it will send an action to state.TaskResultChan() which the main event loop will receive and execute. This will also set the input mode to InputModeTask so that the user can press ESC to cancel the task.

func ToggleAutoIndent added in v0.2.0

func ToggleAutoIndent(s *EditorState)

ToggleAutoIndent enables or disables auto-indent.

func ToggleCaseAtCursor

func ToggleCaseAtCursor(state *EditorState)

ToggleCaseAtCursor changes the character under the cursor from upper-to-lowercase or vice-versa.

func ToggleCaseInSelection

func ToggleCaseInSelection(state *EditorState, selectionEndLoc Locator)

ToggleCaseInSelection toggles the case of all characters in the region from the cursor position to the position found by selectionEndLoc.

func ToggleLineNumberMode added in v1.1.0

func ToggleLineNumberMode(s *EditorState)

ToggleLineNumberMode toggles the line number mode between absolute and relative.

func ToggleShowLineNumbers

func ToggleShowLineNumbers(s *EditorState)

ToggleShowLineNumbers shows or hides line numbers in the left margin.

func ToggleShowSpaces added in v0.6.0

func ToggleShowSpaces(s *EditorState)

ToggleShowSpaces shows or hides space characters in the document.

func ToggleShowTabs added in v0.2.0

func ToggleShowTabs(s *EditorState)

ToggleShowTabs shows or hides tab characters in the document.

func ToggleTabExpand added in v0.3.0

func ToggleTabExpand(s *EditorState)

ToggleTabExpand toggles whether tabs should be expanded to spaces.

func ToggleUserMacroRecording added in v0.3.0

func ToggleUserMacroRecording(s *EditorState)

ToggleUserMacroRecording stops/starts recording a user-defined macro. If recording stops before any actions have been recorded, the previously-recorded macro will be preserved.

func ToggleVisualMode

func ToggleVisualMode(state *EditorState, selectionMode selection.Mode)

ToggleVisualMode transitions to/from visual selection mode.

func Undo

func Undo(state *EditorState)

Undo returns the document to its state at the last undo entry.

Types

type BufferState

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

BufferState represents the current state of a text buffer.

func (*BufferState) CursorPosition

func (s *BufferState) CursorPosition() uint64

func (*BufferState) LineNumMarginWidth

func (s *BufferState) LineNumMarginWidth() uint64

func (*BufferState) LineNumberMode added in v1.1.0

func (s *BufferState) LineNumberMode() config.LineNumberMode

func (*BufferState) LineWrapConfig added in v0.6.0

func (s *BufferState) LineWrapConfig() segment.LineWrapConfig

func (*BufferState) SearchMatch

func (s *BufferState) SearchMatch() *SearchMatch

func (*BufferState) SearchQueryAndDirection

func (s *BufferState) SearchQueryAndDirection() (string, SearchDirection)

func (*BufferState) SelectedRegion

func (s *BufferState) SelectedRegion() selection.Region

func (*BufferState) SelectionEndLocator added in v0.2.0

func (s *BufferState) SelectionEndLocator() Locator

func (*BufferState) SelectionMode added in v0.2.0

func (s *BufferState) SelectionMode() selection.Mode

func (*BufferState) SetViewSize

func (s *BufferState) SetViewSize(width, height uint64)

func (*BufferState) ShowSpaces added in v0.6.0

func (s *BufferState) ShowSpaces() bool

func (*BufferState) ShowTabs added in v0.2.0

func (s *BufferState) ShowTabs() bool

func (*BufferState) SyntaxTokensIntersectingRange added in v0.3.0

func (s *BufferState) SyntaxTokensIntersectingRange(startPos, endPos uint64) []parser.Token

func (*BufferState) TabSize

func (s *BufferState) TabSize() uint64

func (*BufferState) TextTree

func (s *BufferState) TextTree() *text.Tree

func (*BufferState) ViewOrigin

func (s *BufferState) ViewOrigin() (uint64, uint64)

func (*BufferState) ViewSize

func (s *BufferState) ViewSize() (uint64, uint64)

func (*BufferState) ViewTextOrigin

func (s *BufferState) ViewTextOrigin() uint64

type EditorState

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

EditorState represents the current state of the editor.

func NewEditorState

func NewEditorState(screenWidth, screenHeight uint64, configRuleSet config.RuleSet, suspendScreenFunc SuspendScreenFunc) *EditorState

func (*EditorState) DirPatternsToHide added in v0.2.0

func (s *EditorState) DirPatternsToHide() []string

func (*EditorState) DocumentBuffer

func (s *EditorState) DocumentBuffer() *BufferState

func (*EditorState) DocumentLoadCount added in v0.5.0

func (s *EditorState) DocumentLoadCount() int

func (*EditorState) FileWatcher

func (s *EditorState) FileWatcher() *file.Watcher

func (*EditorState) InputMode

func (s *EditorState) InputMode() InputMode

func (*EditorState) IsRecordingUserMacro added in v0.3.0

func (s *EditorState) IsRecordingUserMacro() bool

func (*EditorState) Menu

func (s *EditorState) Menu() *MenuState

func (*EditorState) QuitFlag

func (s *EditorState) QuitFlag() bool

func (*EditorState) ScreenSize

func (s *EditorState) ScreenSize() (uint64, uint64)

func (*EditorState) SetScreenSize

func (s *EditorState) SetScreenSize(width, height uint64)

func (*EditorState) StatusMsg

func (s *EditorState) StatusMsg() StatusMsg

func (*EditorState) Styles added in v0.2.0

func (s *EditorState) Styles() map[string]config.StyleConfig

func (*EditorState) TaskResultChan added in v0.3.0

func (s *EditorState) TaskResultChan() chan func(*EditorState)

func (*EditorState) TextField added in v1.3.0

func (s *EditorState) TextField() *TextFieldState

type InputMode

type InputMode int

InputMode controls how the editor interprets input events.

func (InputMode) String

func (im InputMode) String() string

type Locator

type Locator func(LocatorParams) uint64

Locator is a function that locates a position in the document.

func SelectionEndLocator added in v0.2.0

func SelectionEndLocator(textTree *text.Tree, cursorPos uint64, selector *selection.Selector) Locator

SelectionEndLocator returns a locator for the end of a selection. For example, suppose a user has selected the first two lines of a document. When the user repeats an action for this selection (by using the "." command), the command repeats for the two lines starting at the *new* cursor location. The selection end locator determines the end of the selection at the new cursor.

For linewise selections, it attempts to select the same number of lines. Example where cursor moves from line two to line three:

abcd        abcd
[efg   -->  efg
hij]        [hij
klm         klm]

For charwise selections it attempts to select down the same number of lines and over the same number of columns (grapheme clusters) on the final line of the selection. Example where the cursor moves from the second col in the first line to the third col in the second line:

ab[cd        abcd
ef]g    -->  ef[g
hij          hi]j
klm          klm

type LocatorParams

type LocatorParams struct {
	TextTree          *text.Tree
	SyntaxParser      *parser.P
	CursorPos         uint64
	AutoIndentEnabled bool
	TabSize           uint64
}

LocatorParams are inputs to a function that locates a position in the document.

type MacroAction added in v0.3.0

type MacroAction func(*EditorState)

MacroAction is a transformation of editor state that can be recorded and replayed.

type MacroState added in v0.3.0

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

MacroState stores recorded macros. The "last action" macro is used to repeat the last logical action (using the "." command in normal mode).

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

MenuState represents the menu for searching and selecting items.

func (m *MenuState) SearchQuery() string
func (m *MenuState) SearchResults() (results []menu.Item, selectedResultIdx int)
func (m *MenuState) Style() MenuStyle
type MenuStyle int
func (s MenuStyle) EmptyQueryShowAll() bool

EmptyQueryShowAll returns whether an empty query should show all items.

type RangeLocator added in v0.7.0

type RangeLocator func(LocatorParams) (uint64, uint64)

RangeLocator is a function that locates the start and end positions of a range in the document (for example, a word or selection). The (start, end] interval does NOT include the end position.

type ScrollDirection added in v0.3.0

type ScrollDirection int

Scroll direction represents the direction of the scroll (forward or backward).

type SearchCompleteAction added in v1.1.0

type SearchCompleteAction func(*EditorState, string, SearchDirection, SearchMatch)

SearchCompleteAction is the action to perform when a user completes a search.

func SearchCompleteChangeToMatch added in v1.1.0

func SearchCompleteChangeToMatch(clipboardPage clipboard.PageId) SearchCompleteAction

SearchCompleteChangeToMatch is a SearchCompleteAction that deletes to the search match, then enters insert mode.

func SearchCompleteCopyToMatch added in v1.1.0

func SearchCompleteCopyToMatch(clipboardPage clipboard.PageId) SearchCompleteAction

SearchCompleteCopyToMatch is a SearchCompleteAction that copies text from the cursor position to the search match.

func SearchCompleteDeleteToMatch added in v1.1.0

func SearchCompleteDeleteToMatch(clipboardPage clipboard.PageId) SearchCompleteAction

SearchCompleteDeleteToMatch is a SearchCompleteAction that deletes from the cursor position to the search match.

type SearchDirection added in v0.3.0

type SearchDirection int

SearchDirection represents the direction of the search (forward or backward).

func (SearchDirection) Reverse added in v0.3.0

func (d SearchDirection) Reverse() SearchDirection

Reverse returns the opposite direction.

type SearchMatch

type SearchMatch struct {
	StartPos uint64
	EndPos   uint64
}

SearchMatch represents the successful result of a text search.

func (*SearchMatch) ContainsPosition

func (sm *SearchMatch) ContainsPosition(pos uint64) bool

type StatusMsg

type StatusMsg struct {
	Style StatusMsgStyle
	Text  string
}

StatusMsg is a message displayed in the status bar.

type StatusMsgStyle

type StatusMsgStyle int

StatusMsgStyle controls how a status message will be displayed.

func (StatusMsgStyle) String

func (s StatusMsgStyle) String() string

type SuspendScreenFunc

type SuspendScreenFunc func(func() error) error

SuspendScreenFunc suspends the screen, executes a function, then resumes the screen. This allows the shell command to take control of the terminal.

type TaskFunc added in v0.3.0

type TaskFunc func(context.Context) func(*EditorState)

TaskFunc is a task that runs asynchronously. It accepts a context so that the user can cancel the task if it takes too long.

type TaskState added in v0.3.0

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

TaskState represents the state of the currently running task.

type TextFieldAction added in v1.3.0

type TextFieldAction func(*EditorState, string) error

TextFieldAction is the action to perform with the text input by the user.

type TextFieldAutocompleteFunc added in v1.3.0

type TextFieldAutocompleteFunc func(prefix string) ([]string, error)

TextFieldAutocompleteFunc retrieves autocomplete suffixes for a given prefix. It is acceptable to return an empty slice if there are no autocompletions, but every string in the slice must have non-zero length.

type TextFieldState added in v1.3.0

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

TextFieldState represents the state of the text field. This is used to enter text such as the file path when creating a new file from within the editor.

func (*TextFieldState) AutocompleteSuffix added in v1.3.0

func (s *TextFieldState) AutocompleteSuffix() string

func (*TextFieldState) InputText added in v1.3.0

func (s *TextFieldState) InputText() string

func (*TextFieldState) PromptText added in v1.3.0

func (s *TextFieldState) PromptText() string

Jump to

Keyboard shortcuts

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