Documentation
¶
Index ¶
- Constants
- func CenterText(s string, width int) string
- func CutTextForWidth(width int, text string) string
- func FramedTextList(frameColor, header, postfix string, text []string) string
- func FramedTextMap(frameColor, header, postfix string, text map[string]string) string
- func FramedTextMapWithPadding(frameColor, header, postfix string, padding int, text map[string]string) string
- func GetTermWidth() int
- type DialogueFormat
- func (df *DialogueFormat) GetVariantByArrows(variants []string) (string, error)
- func (df *DialogueFormat) GetVariantByInput(variants []string) (string, error)
- func (df *DialogueFormat) Run(variants []string) (string, error)
- func (df *DialogueFormat) RunCheckVariant(variants []string, variant string) (bool, error)
- type DialogueType
- type Rewriter
Constants ¶
const FramedTextDefaultTermWidthPadding = 10
Variables ¶
This section is empty.
Functions ¶
func CenterText ¶
func CutTextForWidth ¶ added in v1.7.0
func FramedTextList ¶
func FramedTextMap ¶
func FramedTextMapWithPadding ¶ added in v1.7.0
Types ¶
type DialogueFormat ¶
type DialogueFormat struct {
Text string
Type DialogueType
}
DialogueFormat holds the prompt text and interaction mode for a dialogue.
func NewDialogue ¶
func NewDialogue(dtype DialogueType, prompt string) *DialogueFormat
NewDialogue creates a DialogueFormat with the given type and prompt text.
func (*DialogueFormat) GetVariantByArrows ¶
func (df *DialogueFormat) GetVariantByArrows(variants []string) (string, error)
GetVariantByArrows displays an arrow-navigable menu and returns the chosen item.
func (*DialogueFormat) GetVariantByInput ¶
func (df *DialogueFormat) GetVariantByInput(variants []string) (string, error)
GetVariantByInput reads a line from stdin and validates it against allowed variants.
func (*DialogueFormat) Run ¶
func (df *DialogueFormat) Run(variants []string) (string, error)
Run executes the dialogue and returns the selected variant.
func (*DialogueFormat) RunCheckVariant ¶
func (df *DialogueFormat) RunCheckVariant(variants []string, variant string) (bool, error)
RunCheckVariant runs the dialogue and reports whether the result matches the expected variant.
type DialogueType ¶
type DialogueType int
DialogueType represents the mode of user interaction.
const ( // ArrowsDialogueType enables keyboard arrow navigation. ArrowsDialogueType DialogueType = iota // InputDialogueType reads a typed string from stdin. InputDialogueType )
type Rewriter ¶
type Rewriter struct {
// contains filtered or unexported fields
}
Rewriter provides in-place terminal output rewriting using ANSI escape codes.
func NewRewriter ¶
func NewRewriter() *Rewriter