Documentation
¶
Index ¶
- func Init(e *Engine, highlighter func([]rune) string)
- func WatchResize(eng *Engine) chan<- bool
- type Engine
- func (e *Engine) AcceptInline(line *core.Line, cursor *core.Cursor) bool
- func (e *Engine) AcceptInlineWord(line *core.Line, cursor *core.Cursor)
- func (e *Engine) AcceptLine()
- func (e *Engine) AvailableHelperLines() int
- func (e *Engine) ClearHelpers()
- func (e *Engine) ClearInlineSuggestion()
- func (e *Engine) CursorBelowLine()
- func (e *Engine) CursorToLineStart()
- func (e *Engine) GetInlineSuggestion() string
- func (e *Engine) PrintPrimaryPrompt()
- func (e *Engine) Refresh()
- func (e *Engine) RefreshTransient()
- func (e *Engine) ResetHelpers()
- func (e *Engine) SetInlineSuggestion(suggestion string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
Init computes some base coordinates needed before displaying the line and helpers. The shell syntax highlighter is also provided here, since any consumer library will have bound it after instantiating a new shell instance.
func WatchResize ¶
WatchResize redisplays the interface on terminal resize events.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine handles all display operations: it refreshes the terminal interface and stores the necessary offsets of each components.
func NewEngine ¶
func NewEngine(k *core.Keys, s *core.Selection, h *history.Sources, p *ui.Prompt, i *ui.Hint, c *completion.Engine, opts *inputrc.Config) *Engine
NewEngine is a required constructor for the display engine.
func (*Engine) AcceptInline ¶ added in v1.3.0
AcceptInline replaces the line buffer with the inline suggestion when one applies at the cursor, clears the suggestion, and reports whether it did so. Callers pass the line/cursor to accept onto, since the engine's own line may point at a minibuffer during completion or search.
func (*Engine) AcceptInlineWord ¶ added in v1.3.0
AcceptInlineWord accepts the next word of the inline suggestion, leaving the rest as a suggestion. It follows forward-word semantics: any leading whitespace plus the following run of non-whitespace runes are inserted.
func (*Engine) AcceptLine ¶
func (e *Engine) AcceptLine()
AcceptLine redraws the current UI when the line has been accepted and returned to the caller. After clearing various things such as hints, completions and some right prompts, the shell will put the display at the start of the line immediately following the line.
func (*Engine) AvailableHelperLines ¶
AvailableHelperLines returns the number of lines available below the hint section. It returns half the terminal space if we currently have less than 1/3rd of it below.
func (*Engine) ClearHelpers ¶
func (e *Engine) ClearHelpers()
ClearHelpers clears the hint and completion sections below the line.
func (*Engine) ClearInlineSuggestion ¶ added in v1.3.0
func (e *Engine) ClearInlineSuggestion()
ClearInlineSuggestion clears the current inline suggestion.
func (*Engine) CursorBelowLine ¶
func (e *Engine) CursorBelowLine()
CursorBelowLine moves the cursor to the leftmost column of the first row after the last line of input. This function should only be called when the cursor is on its "cursor" position on the input line.
func (*Engine) CursorToLineStart ¶
func (e *Engine) CursorToLineStart()
CursorToLineStart moves the cursor just after the primary prompt. This function should only be called when the cursor is on its "cursor" position on the input line.
func (*Engine) GetInlineSuggestion ¶ added in v1.3.0
GetInlineSuggestion returns the current inline suggestion.
func (*Engine) PrintPrimaryPrompt ¶
func (e *Engine) PrintPrimaryPrompt()
PrintPrimaryPrompt redraws the primary prompt. There are relatively few cases where you want to use this. It is currently only used when using clear-screen commands.
func (*Engine) Refresh ¶
func (e *Engine) Refresh()
Refresh recomputes and redisplays the entire readline interface, except the first lines of the primary prompt when the latter is a multiline one.
func (*Engine) RefreshTransient ¶
func (e *Engine) RefreshTransient()
RefreshTransient goes back to the first line of the input buffer and displays the transient prompt, then redisplays the input line.
func (*Engine) ResetHelpers ¶
func (e *Engine) ResetHelpers()
ResetHelpers cancels all active hints and completions.
func (*Engine) SetInlineSuggestion ¶ added in v1.3.0
SetInlineSuggestion sets a suggestion to display after the cursor.