survey.v1: gopkg.in/AlecAivazis/survey.v1/terminal Index | Files

package terminal

import "gopkg.in/AlecAivazis/survey.v1/terminal"

Index

Package Files

buffered_reader.go cursor.go display.go display_posix.go error.go output.go runereader.go runereader_linux.go runereader_posix.go sequences.go stdio.go terminal.go

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'
)

Variables

var (
    InterruptErr = errors.New("interrupt")
)

func EraseLine Uses

func EraseLine(out FileWriter, mode EraseLineMode)

func NewAnsiStderr Uses

func NewAnsiStderr(out FileWriter) io.Writer

NewAnsiStderr returns special stderr, which converts escape sequences to Windows API calls on Windows environment.

func NewAnsiStdout Uses

func NewAnsiStdout(out FileWriter) io.Writer

NewAnsiStdout returns special stdout, which converts escape sequences to Windows API calls on Windows environment.

type BufferedReader Uses

type BufferedReader struct {
    In     io.Reader
    Buffer *bytes.Buffer
}

func (*BufferedReader) Read Uses

func (br *BufferedReader) Read(p []byte) (int, error)

type Coord Uses

type Coord struct {
    X   Short
    Y   Short
}

func (Coord) CursorIsAtLineBegin Uses

func (cur Coord) CursorIsAtLineBegin() bool

func (Coord) CursorIsAtLineEnd Uses

func (cur Coord) CursorIsAtLineEnd(size *Coord) bool

type Cursor Uses

type Cursor struct {
    In  FileReader
    Out FileWriter
}

func (*Cursor) Back Uses

func (c *Cursor) Back(n int)

Back moves the cursor n cells to left.

func (*Cursor) Down Uses

func (c *Cursor) Down(n int)

Down moves the cursor n cells to down.

func (*Cursor) Forward Uses

func (c *Cursor) Forward(n int)

Forward moves the cursor n cells to right.

func (*Cursor) Hide Uses

func (c *Cursor) Hide()

Hide hide the cursor.

func (*Cursor) HorizontalAbsolute Uses

func (c *Cursor) HorizontalAbsolute(x int)

HorizontalAbsolute moves cursor horizontally to x.

func (*Cursor) Location Uses

func (c *Cursor) Location(buf *bytes.Buffer) (*Coord, error)

Location returns the current location of the cursor in the terminal

func (*Cursor) Move Uses

func (c *Cursor) Move(x int, y int)

Move moves the cursor to a specific x,y location.

func (*Cursor) MoveNextLine Uses

func (c *Cursor) MoveNextLine(cur *Coord, terminalSize *Coord)

for comparability purposes between windows in unix we need to print out a new line on some terminals

func (*Cursor) NextLine Uses

func (c *Cursor) NextLine(n int)

NextLine moves cursor to beginning of the line n lines down.

func (*Cursor) PreviousLine Uses

func (c *Cursor) PreviousLine(n int)

PreviousLine moves cursor to beginning of the line n lines up.

func (*Cursor) Restore Uses

func (c *Cursor) Restore()

Restore restores the saved position of the cursor

func (*Cursor) Save Uses

func (c *Cursor) Save()

Save saves the current position

func (*Cursor) Show Uses

func (c *Cursor) Show()

Show shows the cursor.

func (*Cursor) Size Uses

func (c *Cursor) Size(buf *bytes.Buffer) (*Coord, error)

Size returns the height and width of the terminal.

func (*Cursor) Up Uses

func (c *Cursor) Up(n int)

Up moves the cursor n cells to up.

type EraseLineMode Uses

type EraseLineMode int
const (
    ERASE_LINE_END EraseLineMode = iota
    ERASE_LINE_START
    ERASE_LINE_ALL
)

type FileReader Uses

type FileReader interface {
    io.Reader
    Fd() uintptr
}

FileReader provides a minimal interface for Stdout.

type FileWriter Uses

type FileWriter interface {
    io.Writer
    Fd() uintptr
}

FileWriter provides a minimal interface for Stdin.

type RuneReader Uses

type RuneReader struct {
    // contains filtered or unexported fields
}

func NewRuneReader Uses

func NewRuneReader(stdio Stdio) *RuneReader

func (*RuneReader) Buffer Uses

func (rr *RuneReader) Buffer() *bytes.Buffer

func (*RuneReader) ReadLine Uses

func (rr *RuneReader) ReadLine(mask rune) ([]rune, error)

func (*RuneReader) ReadRune Uses

func (rr *RuneReader) ReadRune() (rune, int, error)

func (*RuneReader) RestoreTermMode Uses

func (rr *RuneReader) RestoreTermMode() error

func (*RuneReader) SetTermMode Uses

func (rr *RuneReader) SetTermMode() error

For reading runes we just want to disable echo.

type Short Uses

type Short int16
var COORDINATE_SYSTEM_BEGIN Short = 1

type Stdio Uses

type Stdio struct {
    In  FileReader
    Out FileWriter
    Err io.Writer
}

Stdio is the standard input/output the terminal reads/writes with.

Package terminal imports 10 packages (graph) and is imported by 42 packages. Updated 2019-09-10. Refresh now. Tools for package owners.