terminal

package
v1.8.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyArrowLeft       = '\x02'
	KeyArrowRight      = '\x06'
	KeyArrowUp         = '\x10'
	KeyArrowDown       = '\x0e'
	KeySpace           = ' '
	KeyEnter           = '\r'
	KeyBackspace       = '\b'
	KeyDelete          = '\x7f'
	KeyInterrupt       = '\x03'
	KeyEndTransmission = '\x04'
)

Variables

View Source
var (
	InterruptErr = errors.New("interrupt")
)
View Source
var (
	Stdout = NewAnsiStdout()
)

Functions

func CursorBack

func CursorBack(n int)

CursorBack moves the cursor n cells to left.

func CursorDown

func CursorDown(n int)

CursorDown moves the cursor n cells to down.

func CursorForward

func CursorForward(n int)

CursorForward moves the cursor n cells to right.

func CursorHide

func CursorHide()

CursorHide hide the cursor.

func CursorHorizontalAbsolute

func CursorHorizontalAbsolute(x int)

CursorHorizontalAbsolute moves cursor horizontally to x.

func CursorMove

func CursorMove(x int, y int)

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

func CursorNextLine

func CursorNextLine(n int)

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

func CursorPreviousLine

func CursorPreviousLine(n int)

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

func CursorShow

func CursorShow()

CursorShow shows the cursor.

func CursorUp

func CursorUp(n int)

CursorUp moves the cursor n cells to up.

func EraseLine

func EraseLine(mode EraseLineMode)

func NewAnsiStderr

func NewAnsiStderr() io.Writer

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

func NewAnsiStdout

func NewAnsiStdout() io.Writer

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

func Print

func Print(a ...interface{}) (n int, err error)

Print prints given arguments with escape sequence conversion for windows.

func Printf

func Printf(format string, a ...interface{}) (n int, err error)

Printf prints a given format with escape sequence conversion for windows.

func Println

func Println(a ...interface{}) (n int, err error)

Println prints given arguments with newline and escape sequence conversion for windows.

Types

type Coord

type Coord struct {
	X Short
	Y Short
}

func CursorLocation

func CursorLocation() (*Coord, error)

CursorLocation returns the current location of the cursor in the terminal

func Size

func Size() (*Coord, error)

Size returns the height and width of the terminal.

type EraseLineMode

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

type RuneReader

type RuneReader struct {
	Input *os.File
	// contains filtered or unexported fields
}

func NewRuneReader

func NewRuneReader(input *os.File) *RuneReader

func (*RuneReader) ReadLine

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

func (*RuneReader) ReadRune

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL