action

package
Version: v2.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const TermEmuSupported = true

TermEmuSupported is a constant that marks if the terminal emulator is supported

Variables

View Source
var Binder = map[string]func(e Event, action string){
	"command":  InfoMapEvent,
	"buffer":   BufMapEvent,
	"terminal": TermMapEvent,
}
View Source
var BufKeyActions = map[string]BufKeyAction{}/* 109 elements not displayed */

BufKeyActions contains the list of all possible key actions the bufhandler could execute

View Source
var BufMouseActions = map[string]BufMouseAction{
	"MousePress":       (*BufPane).MousePress,
	"MouseMultiCursor": (*BufPane).MouseMultiCursor,
}

BufMouseActions contains the list of all possible mouse actions the bufhandler could execute

View Source
var InfoKeyActions = map[string]InfoKeyAction{
	"HistoryUp":       (*InfoPane).HistoryUp,
	"HistoryDown":     (*InfoPane).HistoryDown,
	"CommandComplete": (*InfoPane).CommandComplete,
	"ExecuteCommand":  (*InfoPane).ExecuteCommand,
	"AbortCommand":    (*InfoPane).AbortCommand,
}

InfoKeyActions contains the list of all possible key actions the infopane could execute

View Source
var MultiActions = map[string]bool{
	"CursorUp":                  true,
	"CursorDown":                true,
	"CursorPageUp":              true,
	"CursorPageDown":            true,
	"CursorLeft":                true,
	"CursorRight":               true,
	"CursorStart":               true,
	"CursorEnd":                 true,
	"SelectToStart":             true,
	"SelectToEnd":               true,
	"SelectUp":                  true,
	"SelectDown":                true,
	"SelectLeft":                true,
	"SelectRight":               true,
	"WordRight":                 true,
	"WordLeft":                  true,
	"SelectWordRight":           true,
	"SelectWordLeft":            true,
	"DeleteWordRight":           true,
	"DeleteWordLeft":            true,
	"SelectLine":                true,
	"SelectToStartOfLine":       true,
	"SelectToStartOfText":       true,
	"SelectToStartOfTextToggle": true,
	"SelectToEndOfLine":         true,
	"ParagraphPrevious":         true,
	"ParagraphNext":             true,
	"InsertNewline":             true,
	"Backspace":                 true,
	"Delete":                    true,
	"InsertTab":                 true,
	"FindNext":                  true,
	"FindPrevious":              true,
	"CopyLine":                  true,
	"Copy":                      true,
	"Cut":                       true,
	"CutLine":                   true,
	"DuplicateLine":             true,
	"DeleteLine":                true,
	"MoveLinesUp":               true,
	"MoveLinesDown":             true,
	"IndentSelection":           true,
	"OutdentSelection":          true,
	"OutdentLine":               true,
	"IndentLine":                true,
	"Paste":                     true,
	"PastePrimary":              true,
	"SelectPageUp":              true,
	"SelectPageDown":            true,
	"StartOfLine":               true,
	"StartOfText":               true,
	"StartOfTextToggle":         true,
	"EndOfLine":                 true,
	"JumpToMatchingBrace":       true,
}

MultiActions is a list of actions that should be executed multiple times if there are multiple cursors (one per cursor) Generally actions that modify global editor state like quitting or saving should not be included in this list

View Source
var PluginCmds = []string{"install", "remove", "update", "available", "list", "search"}
View Source
var TermKeyActions = map[string]TermKeyAction{
	"Exit":        (*TermPane).Exit,
	"CommandMode": (*TermPane).CommandMode,
	"NextSplit":   (*TermPane).NextSplit,
}

TermKeyActions contains the list of all possible key actions the termpane could execute

Functions

func BindKey

func BindKey(k, v string, bind func(e Event, a string))

func BufMapEvent added in v2.0.7

func BufMapEvent(k Event, action string)

BufMapKey maps an event to an action

func BufUnmap

func BufUnmap(k Event)

BufUnmap unmaps a key or mouse event from any action

func CommandComplete

func CommandComplete(b *buffer.Buffer) ([]string, []string)

CommandComplete autocompletes commands

func DefaultBindings

func DefaultBindings(pane string) map[string]string

DefaultBindings returns a map containing micro's default keybindings

func HelpComplete

func HelpComplete(b *buffer.Buffer) ([]string, []string)

HelpComplete autocompletes help topics

func InfoMapEvent added in v2.0.7

func InfoMapEvent(k Event, action string)

func InitBindings

func InitBindings()

InitBindings intializes the bindings map by reading from bindings.json

func InitCommands

func InitCommands()

func InitGlobals

func InitGlobals()

InitGlobals initializes the log buffer and the info bar

func InitTabs

func InitTabs(bufs []*buffer.Buffer)

func LuaAction

func LuaAction(fn string) func(*BufPane) bool

func MakeCommand

func MakeCommand(name string, action func(bp *BufPane, args []string), completer buffer.Completer)

MakeCommand is a function to easily create new commands This can be called by plugins in Lua so that plugins can define their own commands

func OptionComplete

func OptionComplete(b *buffer.Buffer) ([]string, []string)

OptionComplete autocompletes options

func OptionValueComplete

func OptionValueComplete(b *buffer.Buffer) ([]string, []string)

OptionValueComplete completes values for various options

func PluginCmdComplete

func PluginCmdComplete(b *buffer.Buffer) ([]string, []string)

PluginCmdComplete autocompletes the plugin command

func PluginComplete

func PluginComplete(b *buffer.Buffer) ([]string, []string)

PluginComplete completes values for the plugin command

func ReloadConfig

func ReloadConfig()

func RunTermEmulator

func RunTermEmulator(h *BufPane, input string, wait bool, getOutput bool, callback func(out string, userargs []interface{}), userargs []interface{}) error

RunTermEmulator starts a terminal emulator from a bufpane with the given input (command) if wait is true it will wait for the user to exit by pressing enter once the executable has terminated if getOutput is true it will redirect the stdout of the process to a pipe which will be passed to the callback which is a function that takes a string and a list of optional user arguments

func SetGlobalOption

func SetGlobalOption(option, value string) error

func SetGlobalOptionNative

func SetGlobalOptionNative(option string, nativeValue interface{}) error

func TermMapEvent added in v2.0.7

func TermMapEvent(k Event, action string)

func TryBindKey

func TryBindKey(k, v string, overwrite bool) (bool, error)

TryBindKey tries to bind a key by writing to config.ConfigDir/bindings.json Returns true if the keybinding already existed and a possible error

func UnbindKey

func UnbindKey(k string) error

UnbindKey removes the binding for a key from the bindings.json file

func WriteLog

func WriteLog(s string)

WriteLog writes a string to the log buffer

Types

type BufKeyAction

type BufKeyAction func(*BufPane) bool

func CommandAction

func CommandAction(cmd string) BufKeyAction

CommandAction returns a bindable function which executes the given command

func CommandEditAction

func CommandEditAction(prompt string) BufKeyAction

CommandEditAction returns a bindable function that opens a prompt with the given string and executes the command when the user presses enter

type BufMouseAction

type BufMouseAction func(*BufPane, *tcell.EventMouse) bool

type BufPane

type BufPane struct {
	display.BWindow

	// Buf is the buffer this BufPane views
	Buf *buffer.Buffer

	// Cursor is the currently active buffer cursor
	Cursor *buffer.Cursor
	// contains filtered or unexported fields
}

The BufPane connects the buffer and the window It provides a cursor (or multiple) and defines a set of actions that can be taken on the buffer The ActionHandler can access the window for necessary info about visual positions for mouse clicks and scrolling

var LogBufPane *BufPane

func NewBufPane

func NewBufPane(buf *buffer.Buffer, win display.BWindow, tab *Tab) *BufPane

func NewBufPaneFromBuf

func NewBufPaneFromBuf(buf *buffer.Buffer, tab *Tab) *BufPane

func (*BufPane) AddTab

func (h *BufPane) AddTab() bool

AddTab adds a new tab with an empty buffer

func (*BufPane) Autocomplete

func (h *BufPane) Autocomplete() bool

Autocomplete cycles the suggestions and performs autocompletion if there are suggestions

func (*BufPane) Backspace

func (h *BufPane) Backspace() bool

Backspace deletes the previous character

func (*BufPane) BindCmd

func (h *BufPane) BindCmd(args []string)

BindCmd creates a new keybinding

func (*BufPane) Bindings added in v2.0.7

func (h *BufPane) Bindings() *KeyTree

func (*BufPane) CdCmd

func (h *BufPane) CdCmd(args []string)

CdCmd changes the current working directory

func (*BufPane) Center

func (h *BufPane) Center() bool

Center centers the view on the cursor

func (*BufPane) ClearInfo added in v2.0.7

func (h *BufPane) ClearInfo() bool

ClearInfo clears the infobar

func (*BufPane) ClearStatus

func (h *BufPane) ClearStatus() bool

ClearStatus clears the messenger bar

func (*BufPane) Close

func (h *BufPane) Close()

func (*BufPane) CommandMode

func (h *BufPane) CommandMode() bool

CommandMode lets the user enter a command

func (*BufPane) Copy

func (h *BufPane) Copy() bool

Copy the selection to the system clipboard

func (*BufPane) CopyLine

func (h *BufPane) CopyLine() bool

Copy the current line to the clipboard

func (*BufPane) CursorDown

func (h *BufPane) CursorDown() bool

CursorDown moves the cursor down

func (*BufPane) CursorEnd

func (h *BufPane) CursorEnd() bool

CursorEnd moves the cursor to the end of the buffer

func (*BufPane) CursorLeft

func (h *BufPane) CursorLeft() bool

CursorLeft moves the cursor left

func (*BufPane) CursorPageDown

func (h *BufPane) CursorPageDown() bool

CursorPageDown places the cursor a page up

func (*BufPane) CursorPageUp

func (h *BufPane) CursorPageUp() bool

CursorPageUp places the cursor a page up

func (*BufPane) CursorRight

func (h *BufPane) CursorRight() bool

CursorRight moves the cursor right

func (*BufPane) CursorStart

func (h *BufPane) CursorStart() bool

CursorStart moves the cursor to the start of the buffer

func (*BufPane) CursorUp

func (h *BufPane) CursorUp() bool

CursorUp moves the cursor up

func (*BufPane) Cut

func (h *BufPane) Cut() bool

Cut the selection to the system clipboard

func (*BufPane) CutLine

func (h *BufPane) CutLine() bool

CutLine cuts the current line to the clipboard

func (*BufPane) CycleAutocompleteBack

func (h *BufPane) CycleAutocompleteBack() bool

CycleAutocompleteBack cycles back in the autocomplete suggestion list

func (*BufPane) Delete

func (h *BufPane) Delete() bool

Delete deletes the next character

func (*BufPane) DeleteLine

func (h *BufPane) DeleteLine() bool

DeleteLine deletes the current line

func (*BufPane) DeleteWordLeft

func (h *BufPane) DeleteWordLeft() bool

DeleteWordLeft deletes the word to the left of the cursor

func (*BufPane) DeleteWordRight

func (h *BufPane) DeleteWordRight() bool

DeleteWordRight deletes the word to the right of the cursor

func (*BufPane) Deselect added in v2.0.7

func (h *BufPane) Deselect() bool

Deselect deselects on the current cursor

func (*BufPane) DoKeyEvent

func (h *BufPane) DoKeyEvent(e Event) bool

DoKeyEvent executes a key event by finding the action it is bound to and executing it (possibly multiple times for multiple cursors)

func (*BufPane) DoMouseEvent

func (h *BufPane) DoMouseEvent(e MouseEvent, te *tcell.EventMouse) bool

DoMouseEvent executes a mouse event by finding the action it is bound to and executing it

func (*BufPane) DoRuneInsert

func (h *BufPane) DoRuneInsert(r rune)

DoRuneInsert inserts a given rune into the current buffer (possibly multiple times for multiple cursors)

func (*BufPane) DuplicateLine

func (h *BufPane) DuplicateLine() bool

DuplicateLine duplicates the current line or selection

func (*BufPane) End

func (h *BufPane) End() bool

End moves the viewport to the end of the buffer

func (*BufPane) EndOfLine

func (h *BufPane) EndOfLine() bool

EndOfLine moves the cursor to the end of the line

func (*BufPane) Escape

func (h *BufPane) Escape() bool

Escape leaves current mode

func (*BufPane) EvalCmd

func (h *BufPane) EvalCmd(args []string)

EvalCmd evaluates a lua expression

func (*BufPane) Find

func (h *BufPane) Find() bool

Find opens a prompt and searches forward for the input

func (*BufPane) FindLiteral

func (h *BufPane) FindLiteral() bool

FindLiteral is the same as Find() but does not support regular expressions

func (*BufPane) FindNext

func (h *BufPane) FindNext() bool

FindNext searches forwards for the last used search term

func (*BufPane) FindPrevious

func (h *BufPane) FindPrevious() bool

FindPrevious searches backwards for the last used search term

func (*BufPane) ForceQuit added in v2.0.9

func (h *BufPane) ForceQuit() bool

ForceQuit closes the current tab or view even if there are unsaved changes (no prompt)

func (*BufPane) GotoCmd

func (h *BufPane) GotoCmd(args []string)

GotoCmd is a command that will send the cursor to a certain position in the buffer For example: `goto line`, or `goto line:col`

func (*BufPane) HSplitAction

func (h *BufPane) HSplitAction() bool

HSplitAction opens an empty horizontal split

func (*BufPane) HSplitBuf

func (h *BufPane) HSplitBuf(buf *buffer.Buffer) *BufPane

func (*BufPane) HSplitCmd

func (h *BufPane) HSplitCmd(args []string)

HSplitCmd opens a horizontal split with file given in the first argument If no file is given, it opens an empty buffer in a new split

func (*BufPane) HSplitIndex

func (h *BufPane) HSplitIndex(buf *buffer.Buffer, bottom bool) *BufPane

func (*BufPane) HalfPageDown

func (h *BufPane) HalfPageDown() bool

HalfPageDown scrolls the view down half a page

func (*BufPane) HalfPageUp

func (h *BufPane) HalfPageUp() bool

HalfPageUp scrolls the view up half a page

func (*BufPane) HandleCommand

func (h *BufPane) HandleCommand(input string)

HandleCommand handles input from the user

func (*BufPane) HandleEvent

func (h *BufPane) HandleEvent(event tcell.Event)

HandleEvent executes the tcell event properly

func (*BufPane) HasKeyEvent

func (h *BufPane) HasKeyEvent(e Event) bool

func (*BufPane) HelpCmd

func (h *BufPane) HelpCmd(args []string)

HelpCmd tries to open the given help page in a horizontal split

func (*BufPane) ID

func (h *BufPane) ID() uint64

func (*BufPane) IndentLine

func (h *BufPane) IndentLine() bool

IndentLine moves the current line forward one indentation

func (*BufPane) IndentSelection

func (h *BufPane) IndentSelection() bool

IndentSelection indents the current selection

func (*BufPane) InsertNewline

func (h *BufPane) InsertNewline() bool

InsertNewline inserts a newline plus possible some whitespace if autoindent is on

func (*BufPane) InsertTab

func (h *BufPane) InsertTab() bool

InsertTab inserts a tab or spaces

func (*BufPane) JumpLine

func (h *BufPane) JumpLine() bool

OpenFile opens a new file in the buffer

func (*BufPane) JumpToMatchingBrace

func (h *BufPane) JumpToMatchingBrace() bool

JumpToMatchingBrace moves the cursor to the matching brace if it is currently on a brace

func (*BufPane) MemUsageCmd

func (h *BufPane) MemUsageCmd(args []string)

MemUsageCmd prints micro's memory usage Alloc shows how many bytes are currently in use Sys shows how many bytes have been requested from the operating system NumGC shows how many times the GC has been run Note that Go commonly reserves more memory from the OS than is currently in-use/required Additionally, even if Go returns memory to the OS, the OS does not always claim it because there may be plenty of memory to spare

func (*BufPane) MouseMultiCursor

func (h *BufPane) MouseMultiCursor(e *tcell.EventMouse) bool

MouseMultiCursor is a mouse action which puts a new cursor at the mouse position

func (*BufPane) MousePress

func (h *BufPane) MousePress(e *tcell.EventMouse) bool

MousePress is the event that should happen when a normal click happens This is almost always bound to left click

func (*BufPane) MoveCursorDown added in v2.0.9

func (h *BufPane) MoveCursorDown(n int)

MoveCursorDown is not an action

func (*BufPane) MoveCursorUp added in v2.0.9

func (h *BufPane) MoveCursorUp(n int)

MoveCursorUp is not an action

func (*BufPane) MoveLinesDown

func (h *BufPane) MoveLinesDown() bool

MoveLinesDown moves down the current line or selected lines if any

func (*BufPane) MoveLinesUp

func (h *BufPane) MoveLinesUp() bool

MoveLinesUp moves up the current line or selected lines if any

func (*BufPane) Name

func (h *BufPane) Name() string

func (*BufPane) NewTabCmd

func (h *BufPane) NewTabCmd(args []string)

NewTabCmd opens the given file in a new tab

func (*BufPane) NextSplit

func (h *BufPane) NextSplit() bool

NextSplit changes the view to the next split

func (*BufPane) NextTab

func (h *BufPane) NextTab() bool

NextTab switches to the next tab in the tab list

func (*BufPane) None

func (h *BufPane) None() bool

None is an action that does nothing

func (*BufPane) OpenBuffer

func (h *BufPane) OpenBuffer(b *buffer.Buffer)

func (*BufPane) OpenCmd

func (h *BufPane) OpenCmd(args []string)

OpenCmd opens a new buffer with a given filename

func (*BufPane) OpenFile

func (h *BufPane) OpenFile() bool

OpenFile opens a new file in the buffer

func (*BufPane) OpenLogBuf

func (h *BufPane) OpenLogBuf()

OpenLogBuf opens the log buffer from the current bufpane If the current bufpane is a log buffer nothing happens, otherwise the log buffer is opened in a horizontal split

func (*BufPane) OutdentLine

func (h *BufPane) OutdentLine() bool

OutdentLine moves the current line back one indentation

func (*BufPane) OutdentSelection

func (h *BufPane) OutdentSelection() bool

OutdentSelection takes the current selection and moves it back one indent level

func (*BufPane) PageDown

func (h *BufPane) PageDown() bool

PageDown scrolls the view down a page

func (*BufPane) PageUp

func (h *BufPane) PageUp() bool

PageUp scrolls the view up a page

func (*BufPane) ParagraphNext

func (h *BufPane) ParagraphNext() bool

ParagraphNext moves the cursor to the next empty line, or end of the buffer if there's none

func (*BufPane) ParagraphPrevious

func (h *BufPane) ParagraphPrevious() bool

ParagraphPrevious moves the cursor to the previous empty line, or beginning of the buffer if there's none

func (*BufPane) Paste

func (h *BufPane) Paste() bool

Paste whatever is in the system clipboard into the buffer Delete and paste if the user has a selection

func (*BufPane) PastePrimary

func (h *BufPane) PastePrimary() bool

PastePrimary pastes from the primary clipboard (only use on linux)

func (*BufPane) PlayMacro

func (h *BufPane) PlayMacro() bool

PlayMacro plays back the most recently recorded macro

func (*BufPane) PluginCB

func (h *BufPane) PluginCB(cb string) bool

PluginCB calls all plugin callbacks with a certain name and displays an error if there is one and returns the aggregrate boolean response

func (*BufPane) PluginCBRune

func (h *BufPane) PluginCBRune(cb string, r rune) bool

PluginCBRune is the same as PluginCB but also passes a rune to the plugins

func (*BufPane) PluginCmd

func (h *BufPane) PluginCmd(args []string)

PluginCmd installs, removes, updates, lists, or searches for given plugins

func (*BufPane) PreviousSplit

func (h *BufPane) PreviousSplit() bool

PreviousSplit changes the view to the previous split

func (*BufPane) PreviousTab

func (h *BufPane) PreviousTab() bool

PreviousTab switches to the previous tab in the tab list

func (*BufPane) PwdCmd

func (h *BufPane) PwdCmd(args []string)

PwdCmd prints the current working directory

func (*BufPane) Quit

func (h *BufPane) Quit() bool

Quit this will close the current tab or view that is open

func (*BufPane) QuitAll

func (h *BufPane) QuitAll() bool

QuitAll quits the whole editor; all splits and tabs

func (*BufPane) QuitCmd

func (h *BufPane) QuitCmd(args []string)

QuitCmd closes the main view

func (*BufPane) RawCmd

func (h *BufPane) RawCmd(args []string)

RawCmd opens a new raw view which displays the escape sequences micro is receiving in real-time

func (*BufPane) Redo

func (h *BufPane) Redo() bool

Redo redoes the last action

func (*BufPane) ReloadCmd

func (h *BufPane) ReloadCmd(args []string)

ReloadCmd reloads all files (syntax files, colorschemes...)

func (*BufPane) RemoveAllMultiCursors

func (h *BufPane) RemoveAllMultiCursors() bool

RemoveAllMultiCursors removes all cursors except the base cursor

func (*BufPane) RemoveMultiCursor

func (h *BufPane) RemoveMultiCursor() bool

RemoveMultiCursor removes the latest multiple cursor

func (*BufPane) ReopenCmd

func (h *BufPane) ReopenCmd(args []string)

ReopenCmd reopens the buffer (reload from disk)

func (*BufPane) ReplaceAllCmd

func (h *BufPane) ReplaceAllCmd(args []string)

ReplaceAllCmd replaces search term all at once

func (*BufPane) ReplaceCmd

func (h *BufPane) ReplaceCmd(args []string)

ReplaceCmd runs search and replace

func (*BufPane) ResetCmd

func (h *BufPane) ResetCmd(args []string)

ResetCmd resets a setting to its default value

func (*BufPane) ResizePane

func (h *BufPane) ResizePane(size int)

func (*BufPane) Retab

func (h *BufPane) Retab() bool

Retab changes all tabs to spaces or all spaces to tabs depending on the user's settings

func (*BufPane) RetabCmd

func (h *BufPane) RetabCmd(args []string)

RetabCmd changes all spaces to tabs or all tabs to spaces depending on the user's settings

func (*BufPane) RunCmd

func (h *BufPane) RunCmd(args []string)

RunCmd runs a shell command in the background

func (*BufPane) Save

func (h *BufPane) Save() bool

Save the buffer to disk

func (*BufPane) SaveAll

func (h *BufPane) SaveAll() bool

SaveAll saves all open buffers

func (*BufPane) SaveAs

func (h *BufPane) SaveAs() bool

SaveAs saves the buffer to disk with the given name

func (*BufPane) SaveAsCB

func (h *BufPane) SaveAsCB(action string, callback func()) bool

SaveAsCB performs a save as and does a callback at the very end (after all prompts have been resolved) The callback is only called if the save was successful

func (*BufPane) SaveCB

func (h *BufPane) SaveCB(action string, callback func()) bool

SaveCB performs a save and does a callback at the very end (after all prompts have been resolved)

func (*BufPane) SaveCmd

func (h *BufPane) SaveCmd(args []string)

SaveCmd saves the buffer optionally with an argument file name

func (*BufPane) ScrollAdjust added in v2.0.9

func (h *BufPane) ScrollAdjust()

If the user has scrolled past the last line, ScrollAdjust can be used to shift the view so that the last line is at the bottom

func (*BufPane) ScrollDown

func (h *BufPane) ScrollDown(n int)

ScrollDown is not an action

func (*BufPane) ScrollDownAction

func (h *BufPane) ScrollDownAction() bool

ScrollDownAction scrolls the view up

func (*BufPane) ScrollUp

func (h *BufPane) ScrollUp(n int)

ScrollUp is not an action

func (*BufPane) ScrollUpAction

func (h *BufPane) ScrollUpAction() bool

ScrollUpAction scrolls the view up

func (*BufPane) Search added in v2.0.6

func (h *BufPane) Search(str string, useRegex bool, searchDown bool) error

Search searches for a given string/regex in the buffer and selects the next match if a match is found This function affects lastSearch and lastSearchRegex (saved searches) for use with FindNext and FindPrevious

func (*BufPane) SelectAll

func (h *BufPane) SelectAll() bool

SelectAll selects the entire buffer

func (*BufPane) SelectDown

func (h *BufPane) SelectDown() bool

SelectDown selects down one line

func (*BufPane) SelectLeft

func (h *BufPane) SelectLeft() bool

SelectLeft selects the character to the left of the cursor

func (*BufPane) SelectLine

func (h *BufPane) SelectLine() bool

SelectLine selects the entire current line

func (*BufPane) SelectPageDown

func (h *BufPane) SelectPageDown() bool

SelectPageDown selects down one page

func (*BufPane) SelectPageUp

func (h *BufPane) SelectPageUp() bool

SelectPageUp selects up one page

func (*BufPane) SelectRight

func (h *BufPane) SelectRight() bool

SelectRight selects the character to the right of the cursor

func (*BufPane) SelectToEnd

func (h *BufPane) SelectToEnd() bool

SelectToEnd selects the text from the cursor to the end of the buffer

func (*BufPane) SelectToEndOfLine

func (h *BufPane) SelectToEndOfLine() bool

SelectToEndOfLine selects to the end of the current line

func (*BufPane) SelectToStart

func (h *BufPane) SelectToStart() bool

SelectToStart selects the text from the cursor to the start of the buffer

func (*BufPane) SelectToStartOfLine

func (h *BufPane) SelectToStartOfLine() bool

SelectToStartOfLine selects to the start of the current line

func (*BufPane) SelectToStartOfText

func (h *BufPane) SelectToStartOfText() bool

SelectToStartOfText selects to the start of the text on the current line

func (*BufPane) SelectToStartOfTextToggle

func (h *BufPane) SelectToStartOfTextToggle() bool

SelectToStartOfTextToggle toggles the selection between the start of the text on the current line and the start of the line

func (*BufPane) SelectUp

func (h *BufPane) SelectUp() bool

SelectUp selects up one line

func (*BufPane) SelectWordLeft

func (h *BufPane) SelectWordLeft() bool

SelectWordLeft selects the word to the left of the cursor

func (*BufPane) SelectWordRight

func (h *BufPane) SelectWordRight() bool

SelectWordRight selects the word to the right of the cursor

func (*BufPane) SetActive

func (h *BufPane) SetActive(b bool)

func (*BufPane) SetCmd

func (h *BufPane) SetCmd(args []string)

SetCmd sets an option

func (*BufPane) SetID

func (h *BufPane) SetID(i uint64)

func (*BufPane) SetLocalCmd

func (h *BufPane) SetLocalCmd(args []string)

SetLocalCmd sets an option local to the buffer

func (*BufPane) SetTab

func (h *BufPane) SetTab(t *Tab)

func (*BufPane) ShellMode

func (h *BufPane) ShellMode() bool

ShellMode opens a terminal to run a shell command

func (*BufPane) ShowCmd

func (h *BufPane) ShowCmd(args []string)

ShowCmd shows the value of the given option

func (*BufPane) ShowKeyCmd

func (h *BufPane) ShowKeyCmd(args []string)

ShowKeyCmd displays the action that a key is bound to

func (*BufPane) SkipMultiCursor

func (h *BufPane) SkipMultiCursor() bool

SkipMultiCursor moves the current multiple cursor to the next available position

func (*BufPane) SpawnMultiCursor

func (h *BufPane) SpawnMultiCursor() bool

SpawnMultiCursor creates a new multiple cursor at the next occurrence of the current selection or current word

func (*BufPane) SpawnMultiCursorDown

func (h *BufPane) SpawnMultiCursorDown() bool

SpawnMultiCursorDown creates additional cursor, at the same X (if possible), one Y more.

func (*BufPane) SpawnMultiCursorSelect

func (h *BufPane) SpawnMultiCursorSelect() bool

SpawnMultiCursorSelect adds a cursor at the beginning of each line of a selection

func (*BufPane) SpawnMultiCursorUp

func (h *BufPane) SpawnMultiCursorUp() bool

SpawnMultiCursorUp creates additional cursor, at the same X (if possible), one Y less.

func (*BufPane) Start

func (h *BufPane) Start() bool

Start moves the viewport to the start of the buffer

func (*BufPane) StartOfLine

func (h *BufPane) StartOfLine() bool

StartOfLine moves the cursor to the start of the line

func (*BufPane) StartOfText

func (h *BufPane) StartOfText() bool

StartOfText moves the cursor to the start of the text of the line

func (*BufPane) StartOfTextToggle

func (h *BufPane) StartOfTextToggle() bool

StartOfTextToggle toggles the cursor between the start of the text of the line and the start of the line

func (*BufPane) Suspend

func (*BufPane) Suspend() bool

Suspend sends micro to the background. This is the same as pressing CtrlZ in most unix programs. This only works on linux and has no default binding. This code was adapted from the suspend code in nsf/godit

func (*BufPane) Tab

func (h *BufPane) Tab() *Tab

func (*BufPane) TabMoveCmd

func (h *BufPane) TabMoveCmd(args []string)

TabMoveCmd moves the current tab to a given index (starts at 1). The displaced tabs are moved up.

func (*BufPane) TabSwitchCmd

func (h *BufPane) TabSwitchCmd(args []string)

TabSwitchCmd switches to a given tab either by name or by number

func (*BufPane) TermCmd

func (h *BufPane) TermCmd(args []string)

TermCmd opens a terminal in the current view

func (*BufPane) TextFilterCmd

func (h *BufPane) TextFilterCmd(args []string)

TextFilterCmd filters the selection through the command. Selection goes to the command input. On successful run command output replaces the current selection.

func (*BufPane) ToggleDiffGutter

func (h *BufPane) ToggleDiffGutter() bool

ToggleDiffGutter turns the diff gutter off and on

func (*BufPane) ToggleHelp

func (h *BufPane) ToggleHelp() bool

ToggleHelp toggles the help screen

func (*BufPane) ToggleKeyMenu

func (h *BufPane) ToggleKeyMenu() bool

ToggleKeyMenu toggles the keymenu option and resizes all tabs

func (*BufPane) ToggleLogCmd

func (h *BufPane) ToggleLogCmd(args []string)

ToggleLogCmd toggles the log view

func (*BufPane) ToggleMacro

func (h *BufPane) ToggleMacro() bool

ToggleMacro toggles recording of a macro

func (*BufPane) ToggleOverwriteMode

func (h *BufPane) ToggleOverwriteMode() bool

ToggleOverwriteMode lets the user toggle the text overwrite mode

func (*BufPane) ToggleRuler

func (h *BufPane) ToggleRuler() bool

ToggleRuler turns line numbers off and on

func (*BufPane) UnbindCmd

func (h *BufPane) UnbindCmd(args []string)

UnbindCmd binds a key to its default action

func (*BufPane) Undo

func (h *BufPane) Undo() bool

Undo undoes the last action

func (*BufPane) Unsplit

func (h *BufPane) Unsplit() bool

Unsplit closes all splits in the current tab except the active one

func (*BufPane) VSplitAction

func (h *BufPane) VSplitAction() bool

VSplitAction opens an empty vertical split

func (*BufPane) VSplitBuf

func (h *BufPane) VSplitBuf(buf *buffer.Buffer) *BufPane

func (*BufPane) VSplitCmd

func (h *BufPane) VSplitCmd(args []string)

VSplitCmd opens a vertical split with file given in the first argument If no file is given, it opens an empty buffer in a new split

func (*BufPane) VSplitIndex

func (h *BufPane) VSplitIndex(buf *buffer.Buffer, right bool) *BufPane

func (*BufPane) WordLeft

func (h *BufPane) WordLeft() bool

WordLeft moves the cursor one word to the left

func (*BufPane) WordRight

func (h *BufPane) WordRight() bool

WordRight moves the cursor one word to the right

type Command

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

A Command contains information about how to execute a command It has the action for that command as well as a completer function

type Event

type Event interface {
	Name() string
}

func ConstructEvent added in v2.0.7

func ConstructEvent(event tcell.Event) (Event, error)

ConstructEvent takes a tcell event and returns a micro event. Note that tcell events can't express certain micro events such as key sequences. This function is mostly used for debugging/raw panes or constructing intermediate micro events while parsing a sequence.

type Handler

type Handler interface {
	HandleEvent(tcell.Event)
	HandleCommand(string)
}

A Handler will take a tcell event and execute it appropriately

type InfoKeyAction

type InfoKeyAction func(*InfoPane)

type InfoPane

type InfoPane struct {
	*BufPane
	*info.InfoBuf
}
var InfoBar *InfoPane

func GetInfoBar

func GetInfoBar() *InfoPane

GetInfoBar returns the infobar pane

func NewInfoBar

func NewInfoBar() *InfoPane

func NewInfoPane

func NewInfoPane(ib *info.InfoBuf, w display.BWindow, tab *Tab) *InfoPane

func (*InfoPane) AbortCommand added in v2.0.7

func (h *InfoPane) AbortCommand()

AbortCommand cancels the prompt

func (*InfoPane) Close

func (h *InfoPane) Close()

func (*InfoPane) CommandComplete added in v2.0.7

func (h *InfoPane) CommandComplete()

Autocomplete begins autocompletion

func (*InfoPane) DoKeyEvent

func (h *InfoPane) DoKeyEvent(e KeyEvent) bool

DoKeyEvent executes a key event for the command bar, doing any overridden actions

func (*InfoPane) ExecuteCommand added in v2.0.7

func (h *InfoPane) ExecuteCommand()

ExecuteCommand completes the prompt

func (*InfoPane) HandleEvent

func (h *InfoPane) HandleEvent(event tcell.Event)

func (*InfoPane) HistoryDown added in v2.0.7

func (h *InfoPane) HistoryDown()

HistoryDown cycles history down

func (*InfoPane) HistoryUp added in v2.0.7

func (h *InfoPane) HistoryUp()

HistoryUp cycles history up

type KeyEvent

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

KeyEvent is a key event containing a key code, some possible modifiers (alt, ctrl, etc...) and a rune if it was simply a character press Note: to be compatible with tcell events, for ctrl keys r=code

func (KeyEvent) Name added in v2.0.7

func (k KeyEvent) Name() string

type KeySequenceEvent added in v2.0.7

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

A KeySequence defines a list of consecutive events. All events in the sequence must be KeyEvents or MouseEvents.

func (KeySequenceEvent) Name added in v2.0.7

func (k KeySequenceEvent) Name() string

type KeyTree added in v2.0.7

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

A KeyTree is a data structure for storing keybindings. It maps key events to actions, and maintains a set of currently enabled modes, which affects the action that is returned for a key event. The tree acts like a Trie for Events to handle sequence events.

var BufBindings *KeyTree
var InfoBindings *KeyTree
var InfoBufBindings *KeyTree
var TermBindings *KeyTree

func NewKeyTree added in v2.0.7

func NewKeyTree() *KeyTree

NewKeyTree allocates and returns an empty key tree

func (*KeyTree) DeleteAllBindings added in v2.0.7

func (k *KeyTree) DeleteAllBindings(e Event)

DeleteAllBindings removes all actions associated with the given event, regardless of whether they are active or not.

func (*KeyTree) DeleteBinding added in v2.0.7

func (k *KeyTree) DeleteBinding(e Event)

DeleteBinding removes any currently active actions associated with the given event.

func (*KeyTree) HasMode added in v2.0.7

func (k *KeyTree) HasMode(mode string) bool

HasMode returns if the given mode is currently active

func (*KeyTree) NextEvent added in v2.0.7

func (k *KeyTree) NextEvent(e Event, mouse *tcell.EventMouse) (PaneKeyAction, bool)

NextEvent returns the action for the current sequence where e is the next event. Even if the action was registered as a PaneKeyAnyAction or PaneMouseAction, it will be returned as a PaneKeyAction closure where the appropriate arguments have been provided. If no action is associated with the given Event, or mode constraints are not met for that action, nil is returned. A boolean is returned to indicate if there is a conflict with this action. A conflict occurs when there is an active action for this event but there are bindings associated with further sequences starting with this event. The calling function can decide what to do about the conflict (e.g. use a timeout).

func (*KeyTree) RecordedEventsStr added in v2.0.7

func (k *KeyTree) RecordedEventsStr() string

CurrentEventsStr returns the list of recorded events as a string

func (*KeyTree) RegisterKeyAnyBinding added in v2.0.7

func (k *KeyTree) RegisterKeyAnyBinding(e Event, a PaneKeyAnyAction)

RegisterKeyAnyBinding registers a PaneKeyAnyAction with an Event. The event should contain an "any" event.

func (*KeyTree) RegisterKeyBinding added in v2.0.7

func (k *KeyTree) RegisterKeyBinding(e Event, a PaneKeyAction)

RegisterKeyBinding registers a PaneKeyAction with an Event.

func (*KeyTree) RegisterMouseBinding added in v2.0.7

func (k *KeyTree) RegisterMouseBinding(e Event, a PaneMouseAction)

RegisterMouseBinding registers a PaneMouseAction with an Event. The event should contain a mouse event.

func (*KeyTree) ResetEvents added in v2.0.7

func (k *KeyTree) ResetEvents()

ResetEvents sets the current sequence back to the initial value.

func (*KeyTree) SetMode added in v2.0.7

func (k *KeyTree) SetMode(mode string, en bool)

SetMode enables or disabled a given mode

type KeyTreeCursor added in v2.0.7

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

A KeyTreeCursor keeps track of the current location within the tree, and stores any information from previous events that may be needed to execute the action (values of wildcard events or mouse events)

func (*KeyTreeCursor) MakeClosure added in v2.0.7

func (k *KeyTreeCursor) MakeClosure(a TreeAction) PaneKeyAction

MakeClosure uses the information stored in a key tree cursor to construct a PaneKeyAction from a TreeAction (which may have a PaneKeyAction, PaneMouseAction, or AnyAction)

type KeyTreeNode added in v2.0.7

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

A KeyTreeNode stores a single node in the KeyTree (trie). The children are stored as a map, and any node may store a list of actions (the list will be nil if no actions correspond to a certain node)

func NewKeyTreeNode added in v2.0.7

func NewKeyTreeNode() *KeyTreeNode

type ModeConstraint added in v2.0.7

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

A ModeConstraint specifies that an action can only be executed while a certain mode is enabled or disabled.

type MouseEvent

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

MouseEvent is a mouse event with a mouse button and any possible key modifiers

func (MouseEvent) Name added in v2.0.7

func (m MouseEvent) Name() string

type Pane

type Pane interface {
	Handler
	display.Window
	ID() uint64
	SetID(i uint64)
	Name() string
	Close()
	SetTab(t *Tab)
	Tab() *Tab
}

type PaneKeyAction added in v2.0.7

type PaneKeyAction func(Pane) bool

func BufKeyActionGeneral added in v2.0.7

func BufKeyActionGeneral(a BufKeyAction) PaneKeyAction

func InfoKeyActionGeneral added in v2.0.7

func InfoKeyActionGeneral(a InfoKeyAction) PaneKeyAction

func TermKeyActionGeneral added in v2.0.7

func TermKeyActionGeneral(a TermKeyAction) PaneKeyAction

type PaneKeyAnyAction added in v2.0.7

type PaneKeyAnyAction func(Pane, []KeyEvent) bool

type PaneMouseAction added in v2.0.7

type PaneMouseAction func(Pane, *tcell.EventMouse) bool

func BufMouseActionGeneral added in v2.0.7

func BufMouseActionGeneral(a BufMouseAction) PaneMouseAction

type RawEvent

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

RawEvent is simply an escape code We allow users to directly bind escape codes to get around some of a limitations of terminals

func (RawEvent) Name added in v2.0.7

func (r RawEvent) Name() string

type RawPane

type RawPane struct {
	*BufPane
}

func NewRawPane

func NewRawPane(tab *Tab) *RawPane

func NewRawPaneFromWin

func NewRawPaneFromWin(b *buffer.Buffer, win display.BWindow, tab *Tab) *RawPane

func (*RawPane) HandleEvent

func (h *RawPane) HandleEvent(event tcell.Event)

type Tab

type Tab struct {
	*views.Node
	*display.UIWindow
	Panes []Pane
	// contains filtered or unexported fields
}

A Tab represents a single tab It consists of a list of edit panes (the open buffers), a split tree (stored as just the root node), and a uiwindow to display the UI elements like the borders between splits

func MainTab

func MainTab() *Tab

func NewTabFromBuffer

func NewTabFromBuffer(x, y, width, height int, b *buffer.Buffer) *Tab

NewTabFromBuffer creates a new tab from the given buffer

func NewTabFromPane

func NewTabFromPane(x, y, width, height int, pane Pane) *Tab

func (*Tab) CurPane

func (t *Tab) CurPane() *BufPane

CurPane returns the currently active pane

func (*Tab) GetPane

func (t *Tab) GetPane(splitid uint64) int

GetPane returns the pane with the given split index

func (*Tab) HandleEvent

func (t *Tab) HandleEvent(event tcell.Event)

HandleEvent takes a tcell event and usually dispatches it to the current active pane. However if the event is a resize or a mouse event where the user is interacting with the UI (resizing splits) then the event is consumed here If the event is a mouse event in a pane, that pane will become active and get the event

func (*Tab) RemovePane

func (t *Tab) RemovePane(i int)

Remove pane removes the pane with the given index

func (*Tab) Resize

func (t *Tab) Resize()

Resize resizes all panes according to their corresponding split nodes

func (*Tab) SetActive

func (t *Tab) SetActive(i int)

SetActive changes the currently active pane to the specified index

type TabList

type TabList struct {
	*display.TabWindow
	List []*Tab
}

The TabList is a list of tabs and a window to display the tab bar at the top of the screen

var Tabs *TabList

Tabs is the global tab list

func NewTabList

func NewTabList(bufs []*buffer.Buffer) *TabList

NewTabList creates a TabList from a list of buffers by creating a Tab for each buffer

func (*TabList) AddTab

func (t *TabList) AddTab(p *Tab)

AddTab adds a new tab to this TabList

func (*TabList) Display

func (t *TabList) Display()

Display updates the names and then displays the tab bar

func (*TabList) HandleEvent

func (t *TabList) HandleEvent(event tcell.Event)

HandleEvent checks for a resize event or a mouse event on the tab bar otherwise it will forward the event to the currently active tab

func (*TabList) RemoveTab

func (t *TabList) RemoveTab(id uint64)

RemoveTab removes a tab with the given id from the TabList

func (*TabList) Resize

func (t *TabList) Resize()

Resize resizes all elements within the tab list One thing to note is that when there is only 1 tab the tab bar should not be drawn so resizing must take that into account

func (*TabList) UpdateNames

func (t *TabList) UpdateNames()

UpdateNames makes sure that the list of names the tab window has access to is correct

type TermKeyAction added in v2.0.7

type TermKeyAction func(*TermPane)

type TermPane

type TermPane struct {
	*shell.Terminal
	display.Window
	// contains filtered or unexported fields
}

func NewTermPane

func NewTermPane(x, y, w, h int, t *shell.Terminal, id uint64, tab *Tab) (*TermPane, error)

func (*TermPane) Close

func (t *TermPane) Close()

func (*TermPane) CommandMode added in v2.0.7

func (t *TermPane) CommandMode()

CommandMode opens the termpane's command mode

func (*TermPane) Exit added in v2.0.7

func (t *TermPane) Exit()

Exit closes the termpane

func (*TermPane) HandleCommand

func (t *TermPane) HandleCommand(input string)

HandleCommand handles a command for the term pane

func (*TermPane) HandleEvent

func (t *TermPane) HandleEvent(event tcell.Event)

HandleEvent handles a tcell event by forwarding it to the terminal emulator If the event is a mouse event and the program running in the emulator does not have mouse support, the emulator will support selections and copy-paste

func (*TermPane) ID

func (t *TermPane) ID() uint64

func (*TermPane) NextSplit added in v2.0.7

func (t *TermPane) NextSplit()

NextSplit moves to the next split

func (*TermPane) Quit

func (t *TermPane) Quit()

Quit closes this termpane

func (*TermPane) SetID

func (t *TermPane) SetID(i uint64)

func (*TermPane) SetTab

func (t *TermPane) SetTab(tab *Tab)

func (*TermPane) Tab

func (t *TermPane) Tab() *Tab

func (*TermPane) Unsplit

func (t *TermPane) Unsplit()

Unsplit removes this split

type TreeAction added in v2.0.7

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

A TreeAction stores an action, and a set of mode constraints for the action to be active.

Jump to

Keyboard shortcuts

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