Documentation ¶
Overview ¶
Package term is influenced by https://github.com/AlecAivazis/survey and https://github.com/manifoldco/promptui it might contain some code snippets from those A little copying is better than a little dependency. - Go proverbs.
Index ¶
- Constants
- func Close() error
- func DisableColor()
- func Init(r Reader, w Writer) error
- type BufferedReader
- type BufferedWriter
- func (b *BufferedWriter) ClearScreen() error
- func (b *BufferedWriter) Flush() error
- func (b *BufferedWriter) HideCursor()
- func (b *BufferedWriter) Reset()
- func (b *BufferedWriter) ShowCursor()
- func (b *BufferedWriter) Write(bites []byte) (int, error)
- func (b *BufferedWriter) WriteCells(cs []Cell) (int, error)
- type Cell
- type Key
- type Reader
- type RuneReader
- type Writer
Constants ¶
const ( ArrowLeft = rune(KeyCtrlB) ArrowRight = rune(KeyCtrlF) ArrowUp = rune(KeyCtrlP) ArrowDown = rune(KeyCtrlN) Space = ' ' Enter = '\r' NewLine = '\n' Backspace = rune(KeyCtrlH) Backspace2 = rune(KeyDEL) )
These are the key that aliases
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BufferedReader ¶
BufferedReader fullfills the io.Reader interface
type BufferedWriter ¶
type BufferedWriter struct {
// contains filtered or unexported fields
}
BufferedWriter creates, clears and, moves up or down lines as needed to write the output to the terminal using ANSI escape codes.
func NewBufferedWriter ¶
func NewBufferedWriter(w io.Writer) *BufferedWriter
NewBufferedWriter creates and initializes a new BufferedWriter.
func (*BufferedWriter) ClearScreen ¶
func (b *BufferedWriter) ClearScreen() error
ClearScreen solves problems (R) and use it after Reset()
func (*BufferedWriter) Flush ¶
func (b *BufferedWriter) Flush() error
Flush writes any buffered data to the underlying io.Writer, ensuring that any pending data is displayed.
func (*BufferedWriter) HideCursor ¶
func (b *BufferedWriter) HideCursor()
HideCursor writes to os.Stdout that to hide cursor
func (*BufferedWriter) Reset ¶
func (b *BufferedWriter) Reset()
Reset truncates the underlining buffer and marks all its previous lines to be cleared during the next Write.
func (*BufferedWriter) ShowCursor ¶
func (b *BufferedWriter) ShowCursor()
ShowCursor writes to os.Stdout that to show cursor
func (*BufferedWriter) Write ¶
func (b *BufferedWriter) Write(bites []byte) (int, error)
Write writes a single line to the underlining buffer.
func (*BufferedWriter) WriteCells ¶
func (b *BufferedWriter) WriteCells(cs []Cell) (int, error)
WriteCells add colored text to the inner buffer
type Key ¶
type Key int16
Key is the ascii codes of a keys
const ( KeyCtrlSpace Key = iota KeyCtrlA // KeySOH KeyCtrlB // KeySTX KeyCtrlC // KeyETX KeyCtrlD // KeyEOT KeyCtrlE // KeyENQ KeyCtrlF // KeyACK KeyCtrlG // KeyBEL KeyCtrlH // KeyBS KeyCtrlI // KeyTAB KeyCtrlJ // KeyLF KeyCtrlK // KeyVT KeyCtrlL // KeyFF KeyCtrlM // KeyCR KeyCtrlN // KeySO KeyCtrlO // KeySI KeyCtrlP // KeyDLE KeyCtrlQ // KeyDC1 KeyCtrlR // KeyDC2 KeyCtrlS // KeyDC3 KeyCtrlT // KeyDC4 KeyCtrlU // KeyNAK KeyCtrlV // KeySYN KeyCtrlW // KeyETB KeyCtrlX // KeyCAN KeyCtrlY // KeyEM KeyCtrlZ // KeySUB KeyESC // KeyESC KeyCtrlBackslash // KeyFS KeyCtrlRightSq // KeyGS KeyCtrlCarat // KeyRS KeyCtrlUnderscore // KeyUS KeyDEL = 0x7F )
These are the control keys. Note that they overlap with other keys.
type RuneReader ¶
type RuneReader struct {
// contains filtered or unexported fields
}
RuneReader reads from an io.Reader interface
func NewRuneReader ¶
func NewRuneReader(reader Reader) *RuneReader
NewRuneReader creates a new instance of RuneReader