package terminal
import "github.com/AlecAivazis/survey/v2/terminal"
Index ¶
- Constants
- Variables
- func EraseLine(out FileWriter, mode EraseLineMode) error
- func NewAnsiStderr(out FileWriter) io.Writer
- func NewAnsiStdout(out FileWriter) io.Writer
- func StringWidth(str string) int
- type BufferedReader
- type Coord
- type Cursor
- func (c *Cursor) Back(n int) error
- func (c *Cursor) Down(n int) error
- func (c *Cursor) Forward(n int) error
- func (c *Cursor) Hide() error
- func (c *Cursor) HorizontalAbsolute(x int) error
- func (c *Cursor) Location(buf *bytes.Buffer) (*Coord, error)
- func (c *Cursor) MoveNextLine(cur *Coord, terminalSize *Coord) error
- func (c *Cursor) NextLine(n int) error
- func (c *Cursor) PreviousLine(n int) error
- func (c *Cursor) Restore() error
- func (c *Cursor) Save() error
- func (c *Cursor) Show() error
- func (c *Cursor) Size(buf *bytes.Buffer) (*Coord, error)
- func (c *Cursor) Up(n int) error
- type EraseLineMode
- type FileReader
- type FileWriter
- type OnRuneFn
- type RuneReader
- func NewRuneReader(stdio Stdio) *RuneReader
- func (rr *RuneReader) Buffer() *bytes.Buffer
- func (rr *RuneReader) ReadLine(mask rune, onRunes ...OnRuneFn) ([]rune, error)
- func (rr *RuneReader) ReadLineWithDefault(mask rune, d []rune, onRunes ...OnRuneFn) ([]rune, error)
- func (rr *RuneReader) ReadRune() (rune, int, error)
- func (rr *RuneReader) RestoreTermMode() error
- func (rr *RuneReader) SetTermMode() error
- type Short
- type Stdio
Constants ¶
const ( KeyArrowLeft = '\x02' KeyArrowRight = '\x06' KeyArrowUp = '\x10' KeyArrowDown = '\x0e' KeySpace = ' ' KeyEnter = '\r' KeyBackspace = '\b' KeyDelete = '\x7f' KeyInterrupt = '\x03' KeyEndTransmission = '\x04' KeyEscape = '\x1b' KeyDeleteWord = '\x17' // Ctrl+W KeyDeleteLine = '\x18' // Ctrl+X SpecialKeyHome = '\x01' SpecialKeyEnd = '\x11' SpecialKeyDelete = '\x12' IgnoreKey = '\000' KeyTab = '\t' )
Variables ¶
var ( //lint:ignore ST1012 keeping old name for backwards compatibility InterruptErr = errors.New("interrupt") )
Functions ¶
func EraseLine ¶
func EraseLine(out FileWriter, mode EraseLineMode) error
func NewAnsiStderr ¶
func NewAnsiStderr(out FileWriter) io.Writer
NewAnsiStderr returns special stderr, which converts escape sequences to Windows API calls on Windows environment.
func NewAnsiStdout ¶
func NewAnsiStdout(out FileWriter) io.Writer
NewAnsiStdout returns special stdout, which converts escape sequences to Windows API calls on Windows environment.
func StringWidth ¶
StringWidth returns the visible width of a string when printed to the terminal
Types ¶
type BufferedReader ¶
func (*BufferedReader) Read ¶
func (br *BufferedReader) Read(p []byte) (int, error)
type Coord ¶
func (Coord) CursorIsAtLineBegin ¶
func (Coord) CursorIsAtLineEnd ¶
type Cursor ¶
type Cursor struct { In FileReader Out FileWriter }
func (*Cursor) Back ¶
Back moves the cursor n cells to left.
func (*Cursor) Down ¶
Down moves the cursor n cells to down.
func (*Cursor) Forward ¶
Forward moves the cursor n cells to right.
func (*Cursor) Hide ¶
Hide hide the cursor.
func (*Cursor) HorizontalAbsolute ¶
HorizontalAbsolute moves cursor horizontally to x.
func (*Cursor) Location ¶
Location returns the current location of the cursor in the terminal
func (*Cursor) MoveNextLine ¶
for comparability purposes between windows in unix we need to print out a new line on some terminals
func (*Cursor) NextLine ¶
NextLine moves cursor to beginning of the line n lines down.
func (*Cursor) PreviousLine ¶
PreviousLine moves cursor to beginning of the line n lines up.
func (*Cursor) Restore ¶
Restore restores the saved position of the cursor
func (*Cursor) Save ¶
Save saves the current position
func (*Cursor) Show ¶
Show shows the cursor.
func (*Cursor) Size ¶
Size returns the height and width of the terminal.
func (*Cursor) Up ¶
Up moves the cursor n cells to up.
type EraseLineMode ¶
type EraseLineMode int
const ( ERASE_LINE_END EraseLineMode = iota ERASE_LINE_START ERASE_LINE_ALL )
type FileReader ¶
FileReader provides a minimal interface for Stdout.
type FileWriter ¶
FileWriter provides a minimal interface for Stdin.
type OnRuneFn ¶
type RuneReader ¶
type RuneReader struct {
// contains filtered or unexported fields
}
func NewRuneReader ¶
func NewRuneReader(stdio Stdio) *RuneReader
func (*RuneReader) Buffer ¶
func (rr *RuneReader) Buffer() *bytes.Buffer
func (*RuneReader) ReadLine ¶
func (rr *RuneReader) ReadLine(mask rune, onRunes ...OnRuneFn) ([]rune, error)
func (*RuneReader) ReadLineWithDefault ¶
func (*RuneReader) ReadRune ¶
func (rr *RuneReader) ReadRune() (rune, int, error)
ReadRune Parse escape sequences such as ESC [ A for arrow keys. See https://vt100.net/docs/vt102-ug/appendixc.html
func (*RuneReader) RestoreTermMode ¶
func (rr *RuneReader) RestoreTermMode() error
func (*RuneReader) SetTermMode ¶
func (rr *RuneReader) SetTermMode() error
For reading runes we just want to disable echo.
type Short ¶
type Short int16
var COORDINATE_SYSTEM_BEGIN Short = 1
type Stdio ¶
type Stdio struct { In FileReader Out FileWriter Err io.Writer }
Stdio is the standard input/output the terminal reads/writes with.
Source Files ¶
buffered_reader.go cursor.go display.go display_posix.go error.go output.go runereader.go runereader_posix.go sequences.go stdio.go terminal.go
- Version
- v2.3.7 (latest)
- Published
- Dec 8, 2022
- Platform
- js/wasm
- Imports
- 11 packages
- Last checked
- 20 hours ago –
Tools for package owners.