Versions in this module Expand all Collapse all v1 v1.5.0 Oct 5, 2020 Changes in this version + const COLOR_BBLUE — windows/amd64 + const COLOR_BGREEN — windows/amd64 + const COLOR_BINTENSITY — windows/amd64 + const COLOR_BRED — windows/amd64 + const COLOR_FBLUE — windows/amd64 + const COLOR_FGREEN — windows/amd64 + const COLOR_FINTENSITY — windows/amd64 + const COLOR_FRED — windows/amd64 + const COMMON_LVB_BOLD — windows/amd64 + const COMMON_LVB_UNDERSCORE — windows/amd64 + const CharBackspace + const CharBackward + const CharBckSearch + const CharBell + const CharCtrlH + const CharCtrlJ + const CharCtrlL + const CharCtrlU + const CharCtrlW + const CharCtrlY + const CharCtrlZ + const CharDelete + const CharEnter + const CharEsc + const CharEscapeEx + const CharForward + const CharFwdSearch + const CharInterrupt + const CharKill + const CharLineEnd + const CharLineStart + const CharNext + const CharPrev + const CharTab + const CharTranspose + const EVENT_FOCUS — windows/amd64 + const EVENT_KEY — windows/amd64 + const EVENT_MENU — windows/amd64 + const EVENT_MOUSE — windows/amd64 + const EVENT_WINDOW_BUFFER_SIZE — windows/amd64 + const MetaBackspace + const MetaBackward + const MetaDelete + const MetaForward + const MetaTranspose + const S_DIR_BCK + const S_DIR_FWD + const S_STATE_FAILING + const S_STATE_FOUND + const T_DATA + const T_EOF + const T_ERAW + const T_ISTTY_REPORT + const T_RAW + const T_WIDTH + const T_WIDTH_REPORT + const VIM_INSERT + const VIM_NORMAL + const VIM_VISUAL + const VK_BACK — windows/amd64 + const VK_CANCEL — windows/amd64 + const VK_CONTROL — windows/amd64 + const VK_DELETE — windows/amd64 + const VK_DOWN — windows/amd64 + const VK_ESCAPE — windows/amd64 + const VK_LCONTROL — windows/amd64 + const VK_LEFT — windows/amd64 + const VK_LSHIFT — windows/amd64 + const VK_MENU — windows/amd64 + const VK_RCONTROL — windows/amd64 + const VK_RETURN — windows/amd64 + const VK_RIGHT — windows/amd64 + const VK_RSHIFT — windows/amd64 + const VK_SHIFT — windows/amd64 + const VK_TAB — windows/amd64 + const VK_UP — windows/amd64 + var ColorTableBg = []word — windows/amd64 + var ColorTableFg = []word — windows/amd64 + var ErrInterrupt = errors.New("Interrupt") + var Stderr io.WriteCloser = os.Stderr + var Stdin io.ReadCloser = os.Stdin + var Stdout io.WriteCloser = os.Stdout + var TabWidth = 4 + func AddHistory(content string) error + func ClearScreen(_ io.Writer) error — windows/amd64 + func ClearScreen(w io.Writer) (int, error) — darwin/amd64, linux/amd64 + func Debug(o ...interface{}) + func DefaultIsTerminal() bool — darwin/amd64, linux/amd64, windows/amd64 + func DefaultOnWidthChanged(f func()) — darwin/amd64, linux/amd64 + func DefaultOnWidthChanged(func()) — windows/amd64 + func DialRemote(n, addr string) error + func Do(p PrefixCompleterInterface, line []rune, pos int) (newLine [][]rune, offset int) + func GetConsoleCursorInfo() (*_CONSOLE_CURSOR_INFO, error) — windows/amd64 + func GetConsoleScreenBufferInfo() (*_CONSOLE_SCREEN_BUFFER_INFO, error) — windows/amd64 + func GetInt(s []string, def int) int + func GetScreenWidth() int — darwin/amd64, linux/amd64, windows/amd64 + func GetSize(fd int) (int, int, error) — darwin/amd64, linux/amd64 + func GetSize(fd int) (width, height int, err error) — windows/amd64 + func GetStdin() int — darwin/amd64, linux/amd64, windows/amd64 + func IsPrintable(key rune) bool + func IsTerminal(fd int) bool — darwin/amd64, linux/amd64, windows/amd64 + func IsWordBreak(i rune) bool + func Line(prompt string) (string, error) + func LineCount(screenWidth, w int) int + func ListenRemote(n, addr string, cfg *Config, h func(*Instance), ...) error + func NewFillableStdin(stdin io.Reader) (io.ReadCloser, io.Writer) + func Password(prompt string) ([]byte, error) + func Print(p PrefixCompleterInterface, prefix string, level int, buf *bytes.Buffer) + func ReadPassword(fd int) ([]byte, error) — darwin/amd64, linux/amd64, windows/amd64 + func Restore(fd int, state *State) error + func RetSegment(segments [][]rune, cands [][]rune, idx int) ([][]rune, int) + func SetAutoComplete(completer AutoCompleter) + func SetConsoleCursorPosition(c *_COORD) error — windows/amd64 + func SetHistoryPath(fp string) + func SplitByLine(start, screenWidth int, rs []rune) []string + func SplitSegment(line []rune, pos int) ([][]rune, int) + func SuspendMe() — darwin/amd64, linux/amd64, windows/amd64 + func WaitForResume() chan struct + type ANSIWriter struct — windows/amd64 + func NewANSIWriter(w io.Writer) *ANSIWriter + func (a *ANSIWriter) Close() error + func (a *ANSIWriter) Write(b []byte) (int, error) + type ANSIWriterCtx struct — windows/amd64 + func NewANSIWriterCtx(target io.Writer) *ANSIWriterCtx + func (a *ANSIWriterCtx) Flush() + type AutoCompleter interface + Do func(line []rune, pos int) (newLine [][]rune, length int) + func SegmentFunc(f func([][]rune, int) [][]rune) AutoCompleter + type CallFunc func(u ...uintptr) error — windows/amd64 + type CancelableStdin struct + func NewCancelableStdin(r io.Reader) *CancelableStdin + func (c *CancelableStdin) Close() error + func (c *CancelableStdin) Read(b []byte) (n int, err error) + type Config struct + AutoComplete AutoCompleter + DisableAutoSaveHistory bool + EOFPrompt string + EnableMask bool + ForceUseInteractive bool + FuncExitRaw func() error + FuncFilterInputRune func(rune) (rune, bool) + FuncGetWidth func() int + FuncIsTerminal func() bool + FuncMakeRaw func() error + FuncOnWidthChanged func(func()) + HistoryFile string + HistoryLimit int + HistorySearchFold bool + InterruptPrompt string + Listener Listener + MaskRune rune + Painter Painter + Prompt string + Stderr io.Writer + Stdin io.ReadCloser + StdinWriter io.Writer + Stdout io.Writer + UniqueEditLine bool + VimMode bool + func (c *Config) Init() error + func (c *Config) SetListener(f func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool)) + func (c *Config) SetPainter(p Painter) + func (c Config) Clone() *Config + type DumpListener struct + func (d *DumpListener) OnChange(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) + type DynamicCompleteFunc func(string) []string + type DynamicPrefixCompleterInterface interface + GetDynamicNames func(line []rune) [][]rune + IsDynamic func() bool + type FillableStdin struct + func (s *FillableStdin) Close() error + func (s *FillableStdin) Read(p []byte) (n int, err error) + type Instance struct + Config *Config + Operation *Operation + Terminal *Terminal + func HandleConn(cfg Config, conn net.Conn) (*Instance, error) + func New(prompt string) (*Instance, error) + func NewEx(cfg *Config) (*Instance, error) + func (i *Instance) Clean() + func (i *Instance) Close() error + func (i *Instance) GenPasswordConfig() *Config + func (i *Instance) HistoryDisable() + func (i *Instance) HistoryEnable() + func (i *Instance) IsVimMode() bool + func (i *Instance) Line() *Result + func (i *Instance) ReadPassword(prompt string) ([]byte, error) + func (i *Instance) ReadPasswordEx(prompt string, l Listener) ([]byte, error) + func (i *Instance) ReadPasswordWithConfig(cfg *Config) ([]byte, error) + func (i *Instance) ReadSlice() ([]byte, error) + func (i *Instance) Readline() (string, error) + func (i *Instance) ReadlineWithDefault(what string) (string, error) + func (i *Instance) Refresh() + func (i *Instance) ResetHistory() + func (i *Instance) SaveHistory(content string) error + func (i *Instance) SetConfig(cfg *Config) *Config + func (i *Instance) SetHistoryPath(p string) + func (i *Instance) SetMaskRune(r rune) + func (i *Instance) SetPrompt(s string) + func (i *Instance) SetVimMode(on bool) + func (i *Instance) Stderr() io.Writer + func (i *Instance) Stdout() io.Writer + func (i *Instance) Write(b []byte) (int, error) + func (i *Instance) WriteStdin(val []byte) (int, error) + type InterruptError struct + Line []rune + func (*InterruptError) Error() string + type Kernel struct — windows/amd64 + FillConsoleOutputAttribute CallFunc + FillConsoleOutputCharacterW CallFunc + GetConsoleCursorInfo CallFunc + GetConsoleScreenBufferInfo CallFunc + GetStdHandle CallFunc + ReadConsoleInputW CallFunc + SetConsoleCursorPosition CallFunc + SetConsoleTextAttribute CallFunc + func NewKernel() *Kernel + func (k *Kernel) Wrap(p *syscall.LazyProc) CallFunc + type Listener interface + OnChange func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool) + func FuncListener(f func(line []rune, pos int, key rune) (newLine []rune, newPos int, ok bool)) Listener + type Message struct + Data []byte + Type MsgType + func NewMessage(t MsgType, data []byte) *Message + func ReadMessage(r io.Reader) (*Message, error) + func (m *Message) WriteTo(w io.Writer) (int, error) + type MsgType int16 + type Operation struct + func NewOperation(t *Terminal, cfg *Config) *Operation + func (o *Operation) Clean() + func (o *Operation) Close() + func (o *Operation) GenPasswordConfig() *Config + func (o *Operation) GetConfig() *Config + func (o *Operation) IsNormalMode() bool + func (o *Operation) Password(prompt string) ([]byte, error) + func (o *Operation) PasswordEx(prompt string, l Listener) ([]byte, error) + func (o *Operation) PasswordWithConfig(cfg *Config) ([]byte, error) + func (o *Operation) Refresh() + func (o *Operation) ResetHistory() + func (o *Operation) Runes() ([]rune, error) + func (o *Operation) SaveHistory(content string) error + func (o *Operation) SetBuffer(what string) + func (o *Operation) SetHistoryPath(path string) + func (o *Operation) SetMaskRune(r rune) + func (o *Operation) SetPrompt(s string) + func (o *Operation) SetTitle(t string) + func (o *Operation) Slice() ([]byte, error) + func (o *Operation) Stderr() io.Writer + func (o *Operation) Stdout() io.Writer + func (o *Operation) String() (string, error) + func (o Operation) CompleteRefresh() + func (o Operation) EnterCompleteMode(offset int, candidate [][]rune) + func (o Operation) EnterCompleteSelectMode() + func (o Operation) EnterPasswordMode(cfg *Config) (err error) + func (o Operation) EnterVimInsertMode() + func (o Operation) ExitCompleteMode(revent bool) + func (o Operation) ExitCompleteSelectMode() + func (o Operation) ExitPasswordMode() + func (o Operation) ExitSearchMode(revert bool) + func (o Operation) ExitVimInsertMode() + func (o Operation) ExitVimMode() + func (o Operation) HandleCompleteSelect(r rune) bool + func (o Operation) HandleVim(r rune, readNext func() rune) rune + func (o Operation) HandleVimNormal(r rune, readNext func() rune) (t rune) + func (o Operation) IsEnableVimMode() bool + func (o Operation) IsInCompleteMode() bool + func (o Operation) IsInCompleteSelectMode() bool + func (o Operation) IsSearchMode() bool + func (o Operation) OnComplete() bool + func (o Operation) PasswordConfig() *Config + func (o Operation) SearchBackspace() + func (o Operation) SearchChar(r rune) + func (o Operation) SearchMode(dir int) bool + func (o Operation) SearchRefresh(x int) + func (o Operation) SetVimMode(on bool) + func (op *Operation) SetConfig(cfg *Config) (*Config, error) + type Painter interface + Paint func(line []rune, pos int) []rune + type PrefixCompleter struct + Callback DynamicCompleteFunc + Children []PrefixCompleterInterface + Dynamic bool + Name []rune + func NewPrefixCompleter(pc ...PrefixCompleterInterface) *PrefixCompleter + func PcItem(name string, pc ...PrefixCompleterInterface) *PrefixCompleter + func PcItemDynamic(callback DynamicCompleteFunc, pc ...PrefixCompleterInterface) *PrefixCompleter + func (p *PrefixCompleter) Do(line []rune, pos int) (newLine [][]rune, offset int) + func (p *PrefixCompleter) GetChildren() []PrefixCompleterInterface + func (p *PrefixCompleter) GetDynamicNames(line []rune) [][]rune + func (p *PrefixCompleter) GetName() []rune + func (p *PrefixCompleter) IsDynamic() bool + func (p *PrefixCompleter) Print(prefix string, level int, buf *bytes.Buffer) + func (p *PrefixCompleter) SetChildren(children []PrefixCompleterInterface) + func (p *PrefixCompleter) Tree(prefix string) string + type PrefixCompleterInterface interface + Do func(line []rune, pos int) (newLine [][]rune, length int) + GetChildren func() []PrefixCompleterInterface + GetName func() []rune + Print func(prefix string, level int, buf *bytes.Buffer) + SetChildren func(children []PrefixCompleterInterface) + type RawMode struct + func (r *RawMode) Enter() (err error) + func (r *RawMode) Exit() error + type RawReader struct — windows/amd64 + func NewRawReader() *RawReader + func (r *RawReader) Close() error + func (r *RawReader) Read(buf []byte) (int, error) + type RemoteCli struct + func NewRemoteCli(conn net.Conn) (*RemoteCli, error) + func (r *RemoteCli) Close() + func (r *RemoteCli) MarkIsTerminal(is bool) + func (r *RemoteCli) Serve() error + func (r *RemoteCli) ServeBy(source io.Reader) error + func (r *RemoteCli) Write(b []byte) (int, error) + type RemoteSvr struct + func NewRemoteSvr(conn net.Conn) (*RemoteSvr, error) + func (r *RemoteSvr) Close() error + func (r *RemoteSvr) EnterRawMode() error + func (r *RemoteSvr) ExitRawMode() error + func (r *RemoteSvr) GetWidth() int + func (r *RemoteSvr) GotIsTerminal(data []byte) + func (r *RemoteSvr) GotReportWidth(data []byte) + func (r *RemoteSvr) HandleConfig(cfg *Config) + func (r *RemoteSvr) IsTerminal() bool + func (r *RemoteSvr) Read(b []byte) (int, error) + func (r *RemoteSvr) Write(b []byte) (int, error) + type Result struct + Error error + Line string + func (l *Result) CanBreak() bool + func (l *Result) CanContinue() bool + type RuneBuffer struct + func NewRuneBuffer(w io.Writer, prompt string, cfg *Config, width int) *RuneBuffer + func (r *RuneBuffer) BackEscapeWord() + func (r *RuneBuffer) Backspace() + func (r *RuneBuffer) Backup() + func (r *RuneBuffer) Clean() + func (r *RuneBuffer) CurrentWidth(x int) int + func (r *RuneBuffer) CursorLineCount() int + func (r *RuneBuffer) Delete() (success bool) + func (r *RuneBuffer) DeleteWord() + func (r *RuneBuffer) Erase() + func (r *RuneBuffer) IdxLine(width int) int + func (r *RuneBuffer) IsCursorInEnd() bool + func (r *RuneBuffer) Kill() + func (r *RuneBuffer) KillFront() + func (r *RuneBuffer) Len() int + func (r *RuneBuffer) LineCount(width int) int + func (r *RuneBuffer) MoveBackward() + func (r *RuneBuffer) MoveForward() + func (r *RuneBuffer) MoveTo(ch rune, prevChar, reverse bool) (success bool) + func (r *RuneBuffer) MoveToEndWord() + func (r *RuneBuffer) MoveToLineEnd() + func (r *RuneBuffer) MoveToLineStart() + func (r *RuneBuffer) MoveToNextWord() + func (r *RuneBuffer) MoveToPrevWord() (success bool) + func (r *RuneBuffer) OnWidthChange(newWidth int) + func (r *RuneBuffer) Pos() int + func (r *RuneBuffer) PromptLen() int + func (r *RuneBuffer) Refresh(f func()) + func (r *RuneBuffer) Replace(ch rune) + func (r *RuneBuffer) Reset() []rune + func (r *RuneBuffer) Restore() + func (r *RuneBuffer) RuneSlice(i int) []rune + func (r *RuneBuffer) Runes() []rune + func (r *RuneBuffer) Set(buf []rune) + func (r *RuneBuffer) SetConfig(cfg *Config) + func (r *RuneBuffer) SetMask(m rune) + func (r *RuneBuffer) SetOffset(offset string) + func (r *RuneBuffer) SetPrompt(prompt string) + func (r *RuneBuffer) SetStyle(start, end int, style string) + func (r *RuneBuffer) SetWithIdx(idx int, buf []rune) + func (r *RuneBuffer) Transpose() + func (r *RuneBuffer) WriteRune(s rune) + func (r *RuneBuffer) WriteRunes(s []rune) + func (r *RuneBuffer) WriteString(s string) + func (r *RuneBuffer) Yank() + type Runes struct + func (Runes) Aggregate(candicate [][]rune) (same []rune, size int) + func (Runes) Backspace(r []rune) []byte + func (Runes) ColorFilter(r []rune) []rune + func (Runes) Copy(r []rune) []rune + func (Runes) Equal(a, b []rune) bool + func (Runes) EqualRune(a, b rune, fold bool) bool + func (Runes) HasPrefix(r, prefix []rune) bool + func (Runes) HasPrefixFold(r, prefix []rune) bool + func (Runes) Index(r rune, rs []rune) int + func (Runes) TrimSpaceLeft(in []rune) []rune + func (Runes) Width(r rune) int + func (Runes) WidthAll(r []rune) (length int) + func (r Runes) EqualFold(a, b []rune) bool + func (r Runes) EqualRuneFold(a, b rune) bool + func (rs Runes) IndexAll(r, sub []rune) int + func (rs Runes) IndexAllBck(r, sub []rune) int + func (rs Runes) IndexAllBckEx(r, sub []rune, fold bool) int + func (rs Runes) IndexAllEx(r, sub []rune, fold bool) int + type SegmentComplete struct + func SegmentAutoComplete(completer SegmentCompleter) *SegmentComplete + func (c *SegmentComplete) Do(line []rune, pos int) (newLine [][]rune, offset int) + type SegmentCompleter interface + DoSegment func([][]rune, int) [][]rune + type State struct — darwin/amd64, linux/amd64, windows/amd64 + func GetState(fd int) (*State, error) + func MakeRaw(fd int) (*State, error) + type TabCompleter struct + func (t *TabCompleter) Do([]rune, int) ([][]rune, int) + type Terminal struct + func NewTerminal(cfg *Config) (*Terminal, error) + func (t *Terminal) Bell() + func (t *Terminal) Close() error + func (t *Terminal) EnterRawMode() (err error) + func (t *Terminal) ExitRawMode() (err error) + func (t *Terminal) GetConfig() *Config + func (t *Terminal) GetOffset(f func(offset string)) + func (t *Terminal) IsReading() bool + func (t *Terminal) KickRead() + func (t *Terminal) Print(s string) + func (t *Terminal) PrintRune(r rune) + func (t *Terminal) ReadRune() rune + func (t *Terminal) Readline() *Operation + func (t *Terminal) SetConfig(c *Config) error + func (t *Terminal) SleepToResume() + func (t *Terminal) Write(b []byte) (int, error) + func (t *Terminal) WriteStdin(b []byte) (int, error) + type Termios syscall.Termios — darwin/amd64, linux/amd64