Documentation ¶
Index ¶
- Constants
- type BoolAnswer
- type CursorMove
- type Editor
- func (e *Editor) Ask(question, answer string) (string, error)
- func (e *Editor) AskBool(question string) BoolAnswer
- func (e *Editor) BufferCount() int
- func (e *Editor) Close(i int)
- func (e *Editor) DeletePromptRune()
- func (e *Editor) Draw()
- func (e *Editor) DrawBuffer()
- func (e *Editor) DrawStatusBar()
- func (e *Editor) DrawTitleBar()
- func (e *Editor) FB() *buffer.Buffer
- func (e *Editor) HandleEvent(event termbox.Event)
- func (e *Editor) InsertPromptRune(c rune)
- func (e *Editor) JumpToLine()
- func (e *Editor) MoveCursor(move CursorMove)
- func (e *Editor) MovePromptCursor(move CursorMove)
- func (e *Editor) Open()
- func (e *Editor) Run(args []string)
- func (e *Editor) Save()
- func (e *Editor) ScrollView()
- func (e *Editor) SetStatusMessage(format string, args ...interface{})
- func (e *Editor) ShowHelp()
- func (e *Editor) Shutdown()
Constants ¶
const ( // BarForeground is the foreground color of title/status bars. BarForeground = termbox.ColorBlack // BarBackground is the background color of title/status bars. BarBackground = termbox.ColorWhite )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoolAnswer ¶
type BoolAnswer int
BoolAnswer represents a boolean answer choice.
const ( // BoolAnswerCancel represents a cancelled prompt. BoolAnswerCancel BoolAnswer = -1 // BoolAnswerNo represents a "No" answer. BoolAnswerNo BoolAnswer = 0 // BoolAnswerYes represents a "Yes" answer. BoolAnswerYes BoolAnswer = 1 )
type CursorMove ¶
type CursorMove int
CursorMove is a type of cursor movement.
const ( // CursorMoveUp moves the cursor up one row. CursorMoveUp CursorMove = 0 // CursorMoveDown moves the cursor down one row. CursorMoveDown CursorMove = 1 // CursorMoveLeft moves the cursor left one column. CursorMoveLeft CursorMove = 2 // CursorMoveRight moves the cursor right one column. CursorMoveRight CursorMove = 3 // CursorMoveLineStart moves the cursor to the first non-whitespace // character of the line, or the first character of the line if the cursor // is already on the first non-whitespace character. CursorMoveLineStart CursorMove = 4 // CursorMoveLineEnd moves the cursor to the end of the line. CursorMoveLineEnd CursorMove = 5 // CursorMovePageUp moves the cursor up by the height of the screen. CursorMovePageUp CursorMove = 6 // CursorMovePageDown moves the cursor down by the height of the screen. CursorMovePageDown CursorMove = 7 )
type Editor ¶
type Editor struct { // The editor's buffers and the index of the focused buffer. Buffers []buffer.Buffer FocusIndex int // The editor's height and width measured in rows and columns, respectively. Width int Height int // The current status message and the time it was set. StatusMessage string StatusMessageTime time.Time // The prompt question, answer, and whether it is active or not. PromptQuestion string PromptAnswer string PromptIsActive bool // The user's editor configuration. Config config.Config }
Editor is the editor instance and manages the UI.
func (*Editor) Ask ¶
Ask prompts the user to answer a question and assumes control over all input until the question is answered or the request is cancelled.
func (*Editor) AskBool ¶
func (e *Editor) AskBool(question string) BoolAnswer
AskBool asks a yes or no question with the choice of cancelling.
func (*Editor) BufferCount ¶
BufferCount is a shorthand for getting the number of open buffers.
func (*Editor) DeletePromptRune ¶
func (e *Editor) DeletePromptRune()
DeletePromptRune deletes a rune from the current prompt answer.
func (*Editor) Draw ¶
func (e *Editor) Draw()
Draw draws the entire editor - UI, buffer, etc. - to the screen & updates the cursor's position.
func (*Editor) DrawBuffer ¶
func (e *Editor) DrawBuffer()
DrawBuffer draws the editor's focused buffer.
func (*Editor) DrawStatusBar ¶
func (e *Editor) DrawStatusBar()
DrawStatusBar draws the editor's status bar on the bottom of the screen.
func (*Editor) DrawTitleBar ¶
func (e *Editor) DrawTitleBar()
DrawTitleBar draws the editor's title bar at the top of the screen.
func (*Editor) HandleEvent ¶
func (e *Editor) HandleEvent(event termbox.Event)
HandleEvent executes the appropriate code in response to an event.
func (*Editor) InsertPromptRune ¶
InsertPromptRune inserts a rune into the current prompt answer.
func (*Editor) JumpToLine ¶ added in v0.5.5
func (e *Editor) JumpToLine()
JumpToLine asks the user for a line number and attempts to jump to that line.
func (*Editor) MoveCursor ¶
func (e *Editor) MoveCursor(move CursorMove)
MoveCursor moves the cursor according to the operation provided.
func (*Editor) MovePromptCursor ¶
func (e *Editor) MovePromptCursor(move CursorMove)
MovePromptCursor moves the cursor inside of the current prompt.
func (*Editor) Open ¶
func (e *Editor) Open()
Open prompts the user for a path and creates a new buffer for it.
func (*Editor) Save ¶
func (e *Editor) Save()
Save writes the current buffer back to the file it was read from.
func (*Editor) ScrollView ¶
func (e *Editor) ScrollView()
ScrollView recalculates the offsets for the view window.
func (*Editor) SetStatusMessage ¶
SetStatusMessage sets the status message and the time it was set at.