Versions in this module Expand all Collapse all v1 v1.0.1 May 31, 2023 v1.0.0 May 31, 2023 Changes in this version + var ASCIISequences = []*ASCIICode + var NewStandardOutputWriter = NewStdoutWriter + var SwitchKeyBindMode = OptionSwitchKeyBindMode + func Choose(prefix string, choices []string, opts ...Option) string + func DeleteBeforeChar(buf *Buffer) + func DeleteChar(buf *Buffer) + func DeleteWord(buf *Buffer) + func GoLeftChar(buf *Buffer) + func GoLeftWord(buf *Buffer) + func GoLineBeginning(buf *Buffer) + func GoLineEnd(buf *Buffer) + func GoRightChar(buf *Buffer) + func GoRightWord(buf *Buffer) + func Input(prefix string, completer Completer, opts ...Option) string + type ASCIICode struct + ASCIICode []byte + Key Key + type ASCIICodeBind struct + ASCIICode []byte + Fn KeyBindFunc + type Buffer struct + func NewBuffer() (b *Buffer) + func (b *Buffer) CursorDown(count int) + func (b *Buffer) CursorLeft(count int) + func (b *Buffer) CursorRight(count int) + func (b *Buffer) CursorUp(count int) + func (b *Buffer) Delete(count int) (deleted string) + func (b *Buffer) DeleteBeforeCursor(count int) (deleted string) + func (b *Buffer) DisplayCursorPosition() int + func (b *Buffer) Document() (d *Document) + func (b *Buffer) InsertText(v string, overwrite bool, moveCursor bool) + func (b *Buffer) JoinNextLine(separator string) + func (b *Buffer) NewLine(copyMargin bool) + func (b *Buffer) SwapCharactersBeforeCursor() + func (b *Buffer) Text() string + type Color int + const Black + const Blue + const Brown + const Cyan + const DarkBlue + const DarkGray + const DarkGreen + const DarkRed + const DefaultColor + const Fuchsia + const Green + const LightGray + const Purple + const Red + const Turquoise + const White + const Yellow + type Completer func(Document) []Suggest + type CompletionManager struct + func NewCompletionManager(completer Completer, max uint16) *CompletionManager + func (c *CompletionManager) Completing() bool + func (c *CompletionManager) GetSelectedSuggestion() (s Suggest, ok bool) + func (c *CompletionManager) GetSuggestions() []Suggest + func (c *CompletionManager) Next() + func (c *CompletionManager) Previous() + func (c *CompletionManager) Reset() + func (c *CompletionManager) Update(in Document) + type ConsoleParser interface + GetWinSize func() *WinSize + Read func() ([]byte, error) + Setup func() error + TearDown func() error + type ConsoleWriter interface + AskForCPR func() + ClearTitle func() + CursorBackward func(n int) + CursorDown func(n int) + CursorForward func(n int) + CursorGoTo func(row, col int) + CursorUp func(n int) + EraseDown func() + EraseEndOfLine func() + EraseLine func() + EraseScreen func() + EraseStartOfLine func() + EraseUp func() + Flush func() error + HideCursor func() + SaveCursor func() + ScrollDown func() + ScrollUp func() + SetColor func(fg, bg Color, bold bool) + SetTitle func(title string) + ShowCursor func() + UnSaveCursor func() + Write func(data []byte) + WriteRaw func(data []byte) + WriteRawStr func(data string) + WriteStr func(data string) + func NewStderrWriter() ConsoleWriter + func NewStdoutWriter() ConsoleWriter + type DisplayAttribute int + const DisplayBlink + const DisplayBold + const DisplayCrossedOut + const DisplayDefaultFont + const DisplayInvisible + const DisplayItalic + const DisplayLowIntensity + const DisplayRapidBlink + const DisplayReset + const DisplayReverse + const DisplayUnderline + type Document struct + Text string + func NewDocument() *Document + func (d *Document) CurrentLine() string + func (d *Document) CurrentLineAfterCursor() string + func (d *Document) CurrentLineBeforeCursor() string + func (d *Document) CursorPositionCol() (col int) + func (d *Document) CursorPositionRow() (row int) + func (d *Document) DisplayCursorPosition() int + func (d *Document) FindEndOfCurrentWord() int + func (d *Document) FindEndOfCurrentWordUntilSeparator(sep string) int + func (d *Document) FindEndOfCurrentWordUntilSeparatorIgnoreNextToCursor(sep string) int + func (d *Document) FindEndOfCurrentWordWithSpace() int + func (d *Document) FindStartOfPreviousWord() int + func (d *Document) FindStartOfPreviousWordUntilSeparator(sep string) int + func (d *Document) FindStartOfPreviousWordUntilSeparatorIgnoreNextToCursor(sep string) int + func (d *Document) FindStartOfPreviousWordWithSpace() int + func (d *Document) GetCharRelativeToCursor(offset int) (r rune) + func (d *Document) GetCursorDownPosition(count int, preferredColumn int) int + func (d *Document) GetCursorLeftPosition(count int) int + func (d *Document) GetCursorRightPosition(count int) int + func (d *Document) GetCursorUpPosition(count int, preferredColumn int) int + func (d *Document) GetEndOfLinePosition() int + func (d *Document) GetWordAfterCursor() string + func (d *Document) GetWordAfterCursorUntilSeparator(sep string) string + func (d *Document) GetWordAfterCursorUntilSeparatorIgnoreNextToCursor(sep string) string + func (d *Document) GetWordAfterCursorWithSpace() string + func (d *Document) GetWordBeforeCursor() string + func (d *Document) GetWordBeforeCursorUntilSeparator(sep string) string + func (d *Document) GetWordBeforeCursorUntilSeparatorIgnoreNextToCursor(sep string) string + func (d *Document) GetWordBeforeCursorWithSpace() string + func (d *Document) LastKeyStroke() Key + func (d *Document) LineCount() int + func (d *Document) Lines() []string + func (d *Document) OnLastLine() bool + func (d *Document) TextAfterCursor() string + func (d *Document) TextBeforeCursor() string + func (d *Document) TranslateIndexToPosition(index int) (row int, col int) + func (d *Document) TranslateRowColToIndex(row int, column int) (index int) + type Exec struct + type Executor func(string) + type ExitChecker func(in string, breakline bool) bool + type Filter func([]Suggest, string, bool) []Suggest + type History struct + func NewHistory() *History + func (h *History) Add(input string) + func (h *History) Clear() + func (h *History) Newer(buf *Buffer) (new *Buffer, changed bool) + func (h *History) Older(buf *Buffer) (new *Buffer, changed bool) + type Key int + const Any + const BackTab + const Backspace + const BracketedPaste + const CPRResponse + const ControlA + const ControlB + const ControlBackslash + const ControlC + const ControlCircumflex + const ControlD + const ControlDelete + const ControlDown + const ControlE + const ControlF + const ControlG + const ControlH + const ControlI + const ControlJ + const ControlK + const ControlL + const ControlLeft + const ControlM + const ControlN + const ControlO + const ControlP + const ControlQ + const ControlR + const ControlRight + const ControlS + const ControlSpace + const ControlSquareClose + const ControlT + const ControlU + const ControlUnderscore + const ControlUp + const ControlV + const ControlW + const ControlX + const ControlY + const ControlZ + const Delete + const Down + const End + const Enter + const Escape + const F1 + const F10 + const F11 + const F12 + const F13 + const F14 + const F15 + const F16 + const F17 + const F18 + const F19 + const F2 + const F20 + const F21 + const F22 + const F23 + const F24 + const F3 + const F4 + const F5 + const F6 + const F7 + const F8 + const F9 + const Home + const Ignore + const Insert + const Left + const NotDefined + const PageDown + const PageUp + const Right + const ShiftDelete + const ShiftDown + const ShiftLeft + const ShiftRight + const ShiftUp + const Tab + const Up + const Vt100MouseEvent + const WindowsMouseEvent + func GetKey(b []byte) Key + func (i Key) String() string + type KeyBind struct + Fn KeyBindFunc + Key Key + type KeyBindFunc func(*Buffer) + type KeyBindMode string + const CommonKeyBind + const EmacsKeyBind + type Option func(prompt *Prompt) error + func OptionAddASCIICodeBind(b ...ASCIICodeBind) Option + func OptionAddKeyBind(b ...KeyBind) Option + func OptionBreakLineCallback(fn func(*Document)) Option + func OptionCompletionOnDown() Option + func OptionCompletionWordSeparator(x string) Option + func OptionDescriptionBGColor(x Color) Option + func OptionDescriptionTextColor(x Color) Option + func OptionHistory(x []string) Option + func OptionInitialBufferText(x string) Option + func OptionInputBGColor(x Color) Option + func OptionInputTextColor(x Color) Option + func OptionLivePrefix(f func() (prefix string, useLivePrefix bool)) Option + func OptionMaxSuggestion(x uint16) Option + func OptionParser(x ConsoleParser) Option + func OptionPrefix(x string) Option + func OptionPrefixBackgroundColor(x Color) Option + func OptionPrefixTextColor(x Color) Option + func OptionPreviewSuggestionBGColor(x Color) Option + func OptionPreviewSuggestionTextColor(x Color) Option + func OptionScrollbarBGColor(x Color) Option + func OptionScrollbarThumbColor(x Color) Option + func OptionSelectedDescriptionBGColor(x Color) Option + func OptionSelectedDescriptionTextColor(x Color) Option + func OptionSelectedSuggestionBGColor(x Color) Option + func OptionSelectedSuggestionTextColor(x Color) Option + func OptionSetExitCheckerOnInput(fn ExitChecker) Option + func OptionShowCompletionAtStart() Option + func OptionSuggestionBGColor(x Color) Option + func OptionSuggestionTextColor(x Color) Option + func OptionSwitchKeyBindMode(m KeyBindMode) Option + func OptionTitle(x string) Option + func OptionWriter(x ConsoleWriter) Option + type PosixParser struct — darwin/amd64, js/wasm, linux/amd64 + func NewStandardInputParser() *PosixParser + func (t *PosixParser) GetWinSize() *WinSize + func (t *PosixParser) Read() ([]byte, error) + func (t *PosixParser) Setup() error + func (t *PosixParser) TearDown() error + type PosixWriter struct — darwin/amd64, js/wasm, linux/amd64 + func (w *PosixWriter) Flush() error + type Prompt struct + ASCIICodeBindings []ASCIICodeBind + func New(executor Executor, completer Completer, opts ...Option) *Prompt + func (p *Prompt) Input() string + func (p *Prompt) Run() + type Render struct + func (r *Render) BreakLine(buffer *Buffer) + func (r *Render) Render(buffer *Buffer, completion *CompletionManager) + func (r *Render) Setup() + func (r *Render) TearDown() + func (r *Render) UpdateWinSize(ws *WinSize) + type Suggest struct + Description string + Text string + func FilterContains(completions []Suggest, sub string, ignoreCase bool) []Suggest + func FilterFuzzy(completions []Suggest, sub string, ignoreCase bool) []Suggest + func FilterHasPrefix(completions []Suggest, sub string, ignoreCase bool) []Suggest + func FilterHasSuffix(completions []Suggest, sub string, ignoreCase bool) []Suggest + type VT100Writer struct + func (w *VT100Writer) AskForCPR() + func (w *VT100Writer) ClearTitle() + func (w *VT100Writer) CursorBackward(n int) + func (w *VT100Writer) CursorDown(n int) + func (w *VT100Writer) CursorForward(n int) + func (w *VT100Writer) CursorGoTo(row, col int) + func (w *VT100Writer) CursorUp(n int) + func (w *VT100Writer) EraseDown() + func (w *VT100Writer) EraseEndOfLine() + func (w *VT100Writer) EraseLine() + func (w *VT100Writer) EraseScreen() + func (w *VT100Writer) EraseStartOfLine() + func (w *VT100Writer) EraseUp() + func (w *VT100Writer) HideCursor() + func (w *VT100Writer) SaveCursor() + func (w *VT100Writer) ScrollDown() + func (w *VT100Writer) ScrollUp() + func (w *VT100Writer) SetColor(fg, bg Color, bold bool) + func (w *VT100Writer) SetDisplayAttributes(fg, bg Color, attrs ...DisplayAttribute) + func (w *VT100Writer) SetTitle(title string) + func (w *VT100Writer) ShowCursor() + func (w *VT100Writer) UnSaveCursor() + func (w *VT100Writer) Write(data []byte) + func (w *VT100Writer) WriteRaw(data []byte) + func (w *VT100Writer) WriteRawStr(data string) + func (w *VT100Writer) WriteStr(data string) + type WinSize struct + Col uint16 + Row uint16 + type WindowsParser struct — windows/amd64 + func NewStandardInputParser() *WindowsParser + func (p *WindowsParser) GetWinSize() *WinSize + func (p *WindowsParser) Read() ([]byte, error) + func (p *WindowsParser) Setup() error + func (p *WindowsParser) TearDown() error + type WindowsWriter struct — windows/amd64 + func (w *WindowsWriter) Flush() error