Documentation
¶
Index ¶
- Variables
- func CoordinatesHint(hint *Hint) int
- func DisplayHint(hint *Hint)
- type Hint
- func (h *Hint) ClearTransient()
- func (h *Hint) Len() int
- func (h *Hint) Persist(hint string)
- func (h *Hint) Reset()
- func (h *Hint) ResetPersist()
- func (h *Hint) Set(hint string)
- func (h *Hint) SetProvided(hint string)
- func (h *Hint) SetProvider(provider func(line []rune, cursor int) []rune)
- func (h *Hint) SetRefreshFunc(refresh func())
- func (h *Hint) SetTemporary(hint string)
- func (h *Hint) SetTransient(hint string)
- func (h *Hint) Text() string
- func (h *Hint) UpdateProvided(line []rune, cursor int)
- type Prompt
- func (p *Prompt) LastPrint()
- func (p *Prompt) LastUsed() int
- func (p *Prompt) MultilineColumnPrint()
- func (p *Prompt) Primary(prompt func() string)
- func (p *Prompt) PrimaryPrint()
- func (p *Prompt) PrimaryUsed() int
- func (p *Prompt) Refreshing() bool
- func (p *Prompt) Right(prompt func() string)
- func (p *Prompt) RightPrint(startColumn int, force bool)
- func (p *Prompt) Secondary(prompt func() string)
- func (p *Prompt) SecondaryPrint()
- func (p *Prompt) Tooltip(prompt func(word string) string)
- func (p *Prompt) Transient(prompt func() string)
- func (p *Prompt) TransientPrint()
- func (p *Prompt) UpperPrint()
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultSecondaryPrompt is the default prompt to use for secondary lines. DefaultSecondaryPrompt = color.FgBlackBright + "\U00002514 " + color.Reset // DefaultMultilineColumn is the default prompt to use for multiline columns. DefaultMultilineColumn = color.FgBlackBright + "\U00002502 " + color.Reset )
Functions ¶
func CoordinatesHint ¶
CoordinatesHint returns the number of terminal rows used by the hint.
Each non-empty lane occupies its own row (wrapping when wider than the terminal), matching exactly what DisplayHint prints (one NewlineReturn per lane). It is counted from the lanes directly rather than from the rendered string, so the inter-lane separators do not get miscounted as extra rows.
func DisplayHint ¶
func DisplayHint(hint *Hint)
DisplayHint prints the hint (persistent, provided, transient and/or completion) sections.
Types ¶
type Hint ¶
type Hint struct {
// contains filtered or unexported fields
}
Hint is in charge of printing the usage messages below the input line. Various other UI components have access to it so that they can feed specialized usage messages to it, like completions.
The hint area is composed of several independent lanes, rendered top to bottom in the following order:
- persistent: status set by internal commands (Vim registers, iterations).
- provided: passive hint computed from the current input line by a user-registered hint provider (see Shell.SetHintProvider).
- transient: one-shot status messages, typically pushed from an asynchronous producer (see Shell.SetTransientHint). These survive keystrokes that drive the completion/isearch lane.
- text: hints owned by the completion and incremental-search engines, plus temporary command messages.
Keeping these in distinct lanes lets passive hinting, async status reporting and completion hints coexist without clobbering one another.
All fields are guarded by mu: the transient lane in particular may be written from another goroutine while the main loop renders, so every accessor takes the lock.
func NewHint ¶ added in v1.2.0
NewHint creates a hint area wired to wake the render loop on asynchronous lane changes (such as SetTransient called from another goroutine), through the keys' input wake primitive.
func (*Hint) ClearTransient ¶ added in v1.2.0
func (h *Hint) ClearTransient()
ClearTransient drops the transient (async status) hint lane. It is safe to call from any goroutine, and wakes an idle render loop so the change is shown.
func (*Hint) Len ¶
Len returns the length of the current hint. This is generally used by consumers to know if there already is an active hint, in which case they might want to append to it instead of overwriting it altogether (like in isearch mode).
func (*Hint) Persist ¶
Persist adds a hint message to be persistently displayed until hint.ResetPersist() is called.
func (*Hint) Reset ¶
func (h *Hint) Reset()
Reset removes the hint message. It only clears the completion/command lane (text); the persistent, provider and transient lanes are left untouched, so async status and passive hints survive completion/isearch activity.
func (*Hint) ResetPersist ¶
func (h *Hint) ResetPersist()
ResetPersist drops the persistent hint section.
func (*Hint) Set ¶
Set sets the hint message to the given text. Generally, this hint message will persist until either a command or the completion system overwrites it, or if hint.Reset() is called.
func (*Hint) SetProvided ¶ added in v1.2.0
SetProvided sets the passive (provider) hint lane directly. It is normally recomputed from the current input line on every refresh (see SetProvider); an empty string clears the lane. This lane renders below the persistent lane and above the transient and completion lanes.
func (*Hint) SetProvider ¶ added in v1.2.0
SetProvider registers a function that computes the passive (provided) hint from the current input line and cursor position. It returns the hint text to show (return nil/empty for no hint). The provider is re-evaluated on every refresh, so the hint tracks the input as it changes.
This is the "passive/background hinting" lane: it renders above the transient (async status) lane and the completion hints. Pass nil to remove the provider.
func (*Hint) SetRefreshFunc ¶ added in v1.2.0
func (h *Hint) SetRefreshFunc(refresh func())
SetRefreshFunc registers a callback used to wake the render loop when an async hint lane changes (e.g. SetTransient from another goroutine). The shell wires this to the input wake primitive; integrators do not call it directly.
func (*Hint) SetTemporary ¶
SetTemporary sets a hint message that will be cleared at the next keypress or command being run, which generally coincides with the next redisplay.
func (*Hint) SetTransient ¶ added in v1.2.0
SetTransient sets the transient (async status) hint lane. It is safe to call from any goroutine, and wakes an idle render loop so the message appears immediately. The message persists until ClearTransient is called or it is replaced; crucially it is NOT cleared by the completion or incremental search engines. It renders above the completion lane and below the provider lane.
func (*Hint) UpdateProvided ¶ added in v1.2.0
UpdateProvided re-evaluates the registered provider (if any) against the given line and cursor and stores the result in the passive (provided) lane. It is called by the display engine on each refresh. The provider runs outside the lock so it may safely query shell state.
type Prompt ¶
type Prompt struct {
// contains filtered or unexported fields
}
Prompt stores all prompt rendering/generation functions and is in charge of displaying them, as well as computing their offsets.
func NewPrompt ¶
func NewPrompt(line *core.Line, cursor *core.Cursor, keymaps *keymap.Engine, opts *inputrc.Config) *Prompt
NewPrompt is a required constructor to initialize the prompt system.
func (*Prompt) LastPrint ¶
func (p *Prompt) LastPrint()
LastPrint prints the last line of the primary prompt, if the latter spans on several lines. If not, this function will actually print the entire primary prompt, and PrimaryPrint() will not print anything.
func (*Prompt) LastUsed ¶
LastUsed returns the number of terminal columns used by the last part of the primary prompt (of the entire string if not multiline). This, in effect, returns the X coordinate at which the input line should be printed, and indentation for subsequent lines if several.
func (*Prompt) MultilineColumnPrint ¶ added in v1.1.1
func (p *Prompt) MultilineColumnPrint()
MultilineColumnPrint prints the multiline editor column status indicator. It either prints a default, numbered or user-defined column.
func (*Prompt) PrimaryPrint ¶
func (p *Prompt) PrimaryPrint()
PrimaryPrint prints the primary prompt string, excluding the last line if the primary prompt spans on several lines.
func (*Prompt) PrimaryUsed ¶
PrimaryUsed returns the number of terminal rows on which the primary prompt string spans, excluding the last line if it contains newlines.
func (*Prompt) Refreshing ¶
Refreshing returns true if the prompt is currently redisplaying itself (at least the primary prompt), or false if not.
func (*Prompt) RightPrint ¶
RightPrint prints the right-sided prompt strings, which might be either a traditional RPROMPT string, or a tooltip prompt if any must be rendered. If force is true, whatever rprompt or tooltip exists will be printed. If false, only the rprompt, if it exists, will be printed.
func (*Prompt) Secondary ¶
Secondary uses a function returning the prompt to use as the secondary prompt.
func (*Prompt) SecondaryPrint ¶ added in v1.1.1
func (p *Prompt) SecondaryPrint()
SecondaryPrint prints the last cursor in secondary prompt mode, which is always activated when the current input line is a multiline one.
func (*Prompt) Transient ¶
Transient uses a function returning the prompt to use as a transient prompt.
func (*Prompt) TransientPrint ¶
func (p *Prompt) TransientPrint()
TransientPrint prints the transient prompt.
func (*Prompt) UpperPrint ¶ added in v1.2.0
func (p *Prompt) UpperPrint()
UpperPrint reprints every line of the primary prompt except the last one. It is used to keep a multi-line prompt's upper lines correct after the view has scrolled (e.g. when the prompt is rendered at the bottom of the window), since those lines are not otherwise repainted on a refresh.
The cursor must be positioned at the first prompt row, column 0. On return the cursor is at column 0 of the last prompt line's row (the upper lines each end with a newline).