Documentation ¶
Index ¶
- type Func
- type Prompt
- func (pr *Prompt) AddAction(ch rune, run Runner, mess string, args ...interface{}) bool
- func (pr *Prompt) Clear()
- func (pr *Prompt) Handle(k view.KeyEvent) (handled, canceled, required bool)
- func (pr Prompt) IsRoot() bool
- func (pr Prompt) Len() int
- func (pr Prompt) Pop() Prompt
- func (pr *Prompt) RemoveAction(ch rune, run Runner, mess string) bool
- func (pr *Prompt) Render(g view.Grid)
- func (pr *Prompt) RenderSize() (wanted, needed point.Point)
- func (pr Prompt) Run(i int) (next Prompt, required, handled bool)
- func (pr Prompt) RunPrompt(prior Prompt) (Prompt, bool)
- func (pr *Prompt) SetActionMess(ch rune, run Runner, mess string, args ...interface{}) bool
- func (pr *Prompt) SetAlign(align view.Align)
- func (pr *Prompt) SetMess(mess string, args ...interface{})
- func (pr Prompt) Sub(mess string, args ...interface{}) Prompt
- func (pr Prompt) Unwind() Prompt
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Prompt ¶
type Prompt struct {
// contains filtered or unexported fields
}
Prompt represents a set of actions that the user may select from. Each action has an associated key rune, message, and action. Prompts may be chained, i.e. the user is being shown a sub-prompt. Prompts may be left or right aligned when rendered.
func (*Prompt) AddAction ¶
AddAction adds a new action to the prompt with the given activation rune, display message, and action to run; if the rune conflicts with an already added action, then the addition fails and false is returned; otherwise true is returned.
func (*Prompt) Clear ¶
func (pr *Prompt) Clear()
Clear prompt state, by unwinding the prompt, clearing its mesage, and truncating its actions.
func (*Prompt) Handle ¶
Handle a key event, returning: whether the event was handled, if the prompt was canceled, and whether more user input is required (to take semantically take an action).
func (*Prompt) RemoveAction ¶
RemoveAction removes an action matching the given rune, runner, or message (in that order of precedence); zero values will not match. Returns true if an action was removed, false otherwise.
func (*Prompt) RenderSize ¶
RenderSize calculates how much space the prompt could use and how much it needs. TODO: not yet paginated.
func (Prompt) Run ¶
Run runs the i( >= 0 && <= Len())-th action, returning its next and required return values with handled=true if there is an ith-action; the current prompt, required=false and handled=false are retured if i is invalid.
func (Prompt) RunPrompt ¶
RunPrompt runs the prompt as a sub-prompt of another; causes Prompt to implement Runner, allowing prompts to be added as actions to other prompts.
func (*Prompt) SetActionMess ¶
SetActionMess updates the message on an existing action, matched by run or runner; it returns true only if an action was updated.
type Runner ¶
Runner represents an action invoked by a Prompt. RunPrompt is called when a Prompt action has been invoked by the user. It gets the prior Prompt value, and is expected to return a new Prompt value to display to the user. The `required` boolean argument indicates whether, semantically, an action was taken or whether further input is needed from the user (presumably underneath the returned `next` Prompt).