Versions in this module Expand all Collapse all v0 v0.5.2 Jul 15, 2024 Changes in this version + var FlagExecute bool = true v0.5.1 Jul 15, 2024 v0.4.0 Jul 7, 2024 v0.3.1 Jul 7, 2024 Changes in this version + const DefColCount + const DefRowCount + const DefaultIndentSize + const IndentUnit + const IndentUnitString + var ASCIISequences = []*ASCIICode + var NewStandardOutputWriter = NewStdoutWriter + func DefaultExecuteOnEnterCallback(p *Prompt, indentSize int) (int, bool) + func DefaultPrefixCallback() string + func DeleteBeforeChar(p *Prompt) bool + func DeleteChar(p *Prompt) bool + func DeleteWordBeforeCursor(p *Prompt) bool + func GoLeftChar(p *Prompt) bool + func GoLineBeginning(p *Prompt) bool + func GoLineEnd(p *Prompt) bool + func GoRightChar(p *Prompt) bool + func Input(opts ...Option) string + func NoopExecutor(in 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, columns istrings.Width, rows int) bool + func (b *Buffer) CursorLeft(count istrings.GraphemeNumber, columns istrings.Width, rows int) bool + func (b *Buffer) CursorLeftRunes(count istrings.RuneNumber, columns istrings.Width, rows int) bool + func (b *Buffer) CursorRight(count istrings.GraphemeNumber, columns istrings.Width, rows int) bool + func (b *Buffer) CursorRightRunes(count istrings.RuneNumber, columns istrings.Width, rows int) bool + func (b *Buffer) CursorUp(count int, columns istrings.Width, rows int) bool + func (b *Buffer) Delete(count istrings.GraphemeNumber, col istrings.Width, row int) string + func (b *Buffer) DeleteBeforeCursor(count istrings.GraphemeNumber, columns istrings.Width, rows int) string + func (b *Buffer) DeleteBeforeCursorRunes(count istrings.RuneNumber, columns istrings.Width, rows int) (deleted string) + func (b *Buffer) DeleteRunes(count istrings.RuneNumber, col istrings.Width, row int) string + func (b *Buffer) DisplayCursorPosition(columns istrings.Width) Position + func (b *Buffer) Document() (d *Document) + func (b *Buffer) InsertText(text string, overwrite bool) + func (b *Buffer) InsertTextMoveCursor(text string, columns istrings.Width, rows int, overwrite bool) + func (b *Buffer) JoinNextLine(separator string, col istrings.Width, row int) + func (b *Buffer) NewLine(columns istrings.Width, rows int, copyMargin bool) + func (b *Buffer) SwapCharactersBeforeCursor(col istrings.Width, row int) + 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) (suggestions []Suggest, startChar, endChar istrings.RuneNumber) + type CompletionManager struct + func NewCompletionManager(max uint16, opts ...CompletionManagerOption) *CompletionManager + func (c *CompletionManager) Completing() bool + func (c *CompletionManager) GetSelectedSuggestion() (s Suggest, ok bool) + func (c *CompletionManager) GetSuggestions() []Suggest + func (c *CompletionManager) Next() int + func (c *CompletionManager) Previous() + func (c *CompletionManager) Reset() + func (c *CompletionManager) Update(in Document) + type CompletionManagerOption func(*CompletionManager) + func CompletionManagerWithCompleter(completer Completer) CompletionManagerOption + 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) CurrentLineIndentLevel(indentSize int) int + func (d *Document) CurrentLineIndentSpaces() int + func (d *Document) CurrentRuneIndex() istrings.RuneNumber + func (d *Document) CursorPositionCol() (col istrings.Width) + func (d *Document) CursorPositionRow() (row istrings.RuneNumber) + func (d *Document) DisplayCursorPosition(columns istrings.Width) Position + func (d *Document) FindEndOfCurrentWord() istrings.ByteNumber + func (d *Document) FindEndOfCurrentWordUntilSeparator(sep string) istrings.ByteNumber + func (d *Document) FindEndOfCurrentWordUntilSeparatorIgnoreNextToCursor(sep string) istrings.ByteNumber + func (d *Document) FindEndOfCurrentWordWithSpace() istrings.ByteNumber + func (d *Document) FindRuneNumberUntilEndOfCurrentWord() istrings.RuneNumber + func (d *Document) FindRuneNumberUntilStartOfPreviousWord() istrings.RuneNumber + func (d *Document) FindStartOfFirstWordOfLine() istrings.RuneNumber + func (d *Document) FindStartOfPreviousWord() istrings.ByteNumber + func (d *Document) FindStartOfPreviousWordUntilSeparator(sep string) istrings.ByteNumber + func (d *Document) FindStartOfPreviousWordUntilSeparatorIgnoreNextToCursor(sep string) istrings.ByteNumber + func (d *Document) FindStartOfPreviousWordWithSpace() istrings.ByteNumber + func (d *Document) GetCharRelativeToCursor(offset istrings.RuneNumber) (r rune) + func (d *Document) GetCursorDownPosition(count int, preferredColumn istrings.Width) istrings.RuneNumber + func (d *Document) GetCursorLeftPosition(count istrings.GraphemeNumber) istrings.RuneNumber + func (d *Document) GetCursorLeftPositionRunes(count istrings.RuneNumber) istrings.RuneNumber + func (d *Document) GetCursorPosition(columns istrings.Width) Position + func (d *Document) GetCursorRightPosition(count istrings.GraphemeNumber) istrings.RuneNumber + func (d *Document) GetCursorRightPositionRunes(count istrings.RuneNumber) istrings.RuneNumber + func (d *Document) GetCursorUpPosition(count int, preferredColumn istrings.Width) istrings.RuneNumber + func (d *Document) GetEndOfLinePosition() istrings.RuneNumber + func (d *Document) GetEndOfTextPosition(columns istrings.Width) Position + func (d *Document) GetStartOfLinePosition() istrings.RuneNumber + 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) IndentLevel(input string, indentSize int) int + func (d *Document) IndentSpaces(input string) int + func (d *Document) LastKeyStroke() Key + func (d *Document) LastLineIndentLevel(indentSize int) int + func (d *Document) LastLineIndentSpaces() int + func (d *Document) LineCount() int + func (d *Document) Lines() []string + func (d *Document) OnLastLine() bool + func (d *Document) PreviousLine() (s string, ok bool) + func (d *Document) PreviousLineIndentLevel(indentSize int) int + func (d *Document) PreviousLineIndentSpaces() int + func (d *Document) TextAfterCursor() string + func (d *Document) TextBeforeCursor() string + func (d *Document) TextEndPositionRow() (row istrings.RuneNumber) + func (d *Document) TranslateIndexToPosition(index istrings.RuneNumber) (int, int) + func (d *Document) TranslateRowColToIndex(row int, column istrings.Width) (index istrings.RuneNumber) + type EagerLexer struct + func NewEagerLexer(fn LexerFunc) *EagerLexer + func (l *EagerLexer) Init(input string) + func (l *EagerLexer) Next() (Token, bool) + type ExecuteOnEnterCallback func(prompt *Prompt, indentSize int) (indent int, execute bool) + 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, columns istrings.Width, rows int) (new *Buffer, changed bool) + func (h *History) Older(buf *Buffer, columns istrings.Width, rows int) (new *Buffer, changed bool) + type Key int + const AltBackspace + const AltLeft + const AltRight + 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(p *Prompt) (rerender bool) + type KeyBindMode uint8 + const CommonKeyBind + const EmacsKeyBind + type Lexer interface + Init func(string) + Next func() (Token, bool) + type LexerFunc func(string) []Token + type Option func(prompt *Prompt) error + func WithASCIICodeBind(b ...ASCIICodeBind) Option + func WithBreakLineCallback(fn func(*Document)) Option + func WithCompleter(c Completer) Option + func WithCompletionOnDown() Option + func WithCompletionWordSeparator(sep string) Option + func WithDescriptionBGColor(x Color) Option + func WithDescriptionTextColor(x Color) Option + func WithExecuteOnEnterCallback(fn ExecuteOnEnterCallback) Option + func WithExitChecker(fn ExitChecker) Option + func WithHistory(x []string) Option + func WithIndentSize(i int) Option + func WithInitialText(text string) Option + func WithInputBGColor(x Color) Option + func WithInputTextColor(x Color) Option + func WithKeyBind(b ...KeyBind) Option + func WithKeyBindMode(m KeyBindMode) Option + func WithLexer(lex Lexer) Option + func WithMaxSuggestion(x uint16) Option + func WithPrefix(prefix string) Option + func WithPrefixBackgroundColor(x Color) Option + func WithPrefixCallback(f PrefixCallback) Option + func WithPrefixTextColor(x Color) Option + func WithReader(r Reader) Option + func WithScrollbarBGColor(x Color) Option + func WithScrollbarThumbColor(x Color) Option + func WithSelectedDescriptionBGColor(x Color) Option + func WithSelectedDescriptionTextColor(x Color) Option + func WithSelectedSuggestionBGColor(x Color) Option + func WithSelectedSuggestionTextColor(x Color) Option + func WithShowCompletionAtStart() Option + func WithSuggestionBGColor(x Color) Option + func WithSuggestionTextColor(x Color) Option + func WithTitle(t string) Option + func WithWriter(w Writer) Option + type Position struct + X istrings.Width + Y int + func (p Position) Add(other Position) Position + func (p Position) Join(other Position) Position + func (p Position) Subtract(other Position) Position + type PosixReader struct — darwin/amd64, js/wasm, linux/amd64 + func NewStdinReader() *PosixReader + func (t *PosixReader) Close() error + func (t *PosixReader) GetWinSize() *WinSize + func (t *PosixReader) Open() error + func (t *PosixReader) Read(buff []byte) (int, error) + type PosixWriter struct — darwin/amd64, js/wasm, linux/amd64 + func (w *PosixWriter) Flush() error + type PrefixCallback func() (prefix string) + type Prompt struct + ASCIICodeBindings []ASCIICodeBind + func New(executor Executor, opts ...Option) *Prompt + func (p *Prompt) Buffer() *Buffer + func (p *Prompt) Close() + func (p *Prompt) CursorDown(count int) bool + func (p *Prompt) CursorLeft(count istrings.GraphemeNumber) bool + func (p *Prompt) CursorLeftRunes(count istrings.RuneNumber) bool + func (p *Prompt) CursorRight(count istrings.GraphemeNumber) bool + func (p *Prompt) CursorRightRunes(count istrings.RuneNumber) bool + func (p *Prompt) CursorUp(count int) bool + func (p *Prompt) Delete(count istrings.GraphemeNumber) string + func (p *Prompt) DeleteBeforeCursor(count istrings.GraphemeNumber) string + func (p *Prompt) DeleteBeforeCursorRunes(count istrings.RuneNumber) string + func (p *Prompt) DeleteRunes(count istrings.RuneNumber) string + func (p *Prompt) IndentSize() int + func (p *Prompt) Input() string + func (p *Prompt) InsertText(text string, overwrite bool) + func (p *Prompt) InsertTextMoveCursor(text string, overwrite bool) + func (p *Prompt) Run() + func (p *Prompt) TerminalColumns() istrings.Width + func (p *Prompt) TerminalRows() int + func (p *Prompt) UserInputColumns() istrings.Width + type Reader interface + GetWinSize func() *WinSize + Open func() error + type Renderer struct + func NewRenderer() *Renderer + func (r *Renderer) BreakLine(buffer *Buffer, lexer Lexer) + func (r *Renderer) Close() + func (r *Renderer) Render(buffer *Buffer, completion *CompletionManager, lexer Lexer) + func (r *Renderer) Setup() + func (r *Renderer) UpdateWinSize(ws *WinSize) + func (r *Renderer) UserInputColumns() istrings.Width + type SimpleToken struct + func NewSimpleToken(firstIndex, lastIndex istrings.ByteNumber, opts ...SimpleTokenOption) *SimpleToken + func (t *SimpleToken) BackgroundColor() Color + func (t *SimpleToken) Color() Color + func (t *SimpleToken) DisplayAttributes() []DisplayAttribute + func (t *SimpleToken) FirstByteIndex() istrings.ByteNumber + func (t *SimpleToken) LastByteIndex() istrings.ByteNumber + type SimpleTokenOption func(*SimpleToken) + func SimpleTokenWithBackgroundColor(c Color) SimpleTokenOption + func SimpleTokenWithColor(c Color) SimpleTokenOption + func SimpleTokenWithDisplayAttributes(attrs ...DisplayAttribute) SimpleTokenOption + 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 + func NoopCompleter(_ Document) ([]Suggest, istrings.RuneNumber, istrings.RuneNumber) + type Token interface + BackgroundColor func() Color + Color func() Color + DisplayAttributes func() []DisplayAttribute + FirstByteIndex func() istrings.ByteNumber + LastByteIndex func() istrings.ByteNumber + type UserInput struct + 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) (int, error) + func (w *VT100Writer) WriteRaw(data []byte) + func (w *VT100Writer) WriteRawString(data string) + func (w *VT100Writer) WriteString(data string) (int, error) + type WinSize struct + Col uint16 + Row uint16 + type WindowsReader struct — windows/amd64 + func NewStdinReader() *WindowsReader + func (p *WindowsReader) Close() error + func (p *WindowsReader) GetWinSize() *WinSize + func (p *WindowsReader) Open() error + func (p *WindowsReader) Read(buff []byte) (int, error) + type WindowsWriter struct — windows/amd64 + func (w *WindowsWriter) Flush() error + type Writer 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) + SetDisplayAttributes func(fg, bg Color, attrs ...DisplayAttribute) + SetTitle func(title string) + ShowCursor func() + UnSaveCursor func() + WriteRaw func(data []byte) + WriteRawString func(data string) + func NewStderrWriter() Writer + func NewStdoutWriter() Writer