terminal

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: MIT, MIT Imports: 11 Imported by: 0

README

survey/terminal

This package started as a copy of kokuban/go-ansi but has since been modified to fit survey's specific needs.

Documentation

Index

Constants

View Source
const (
	EVENT_KEY = 0x0001

	// key codes for arrow keys
	// https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
	VK_DELETE = 0x2E
	VK_END    = 0x23
	VK_HOME   = 0x24
	VK_LEFT   = 0x25
	VK_UP     = 0x26
	VK_RIGHT  = 0x27
	VK_DOWN   = 0x28

	RIGHT_CTRL_PRESSED = 0x0004
	LEFT_CTRL_PRESSED  = 0x0008

	ENABLE_ECHO_INPUT      uint32 = 0x0004
	ENABLE_LINE_INPUT      uint32 = 0x0002
	ENABLE_PROCESSED_INPUT uint32 = 0x0001
)
View Source
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

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

Functions

func CursorBack

func CursorBack(n int)

func CursorDown

func CursorDown(n int)

func CursorForward

func CursorForward(n int)

func CursorHide

func CursorHide()

func CursorHorizontalAbsolute

func CursorHorizontalAbsolute(x int)

func CursorMoveNextLine added in v1.5.3

func CursorMoveNextLine(cur Coord, terminalSize *Coord)

for comparability purposes between windows in windows we don't have to print out a new line

func CursorNextLine

func CursorNextLine(n int)

func CursorPreviousLine

func CursorPreviousLine(n int)

func CursorRestore added in v1.5.2

func CursorRestore()

func CursorSave added in v1.5.2

func CursorSave()

save the cursor location

func CursorShow

func CursorShow()

func CursorUp

func CursorUp(n int)

func EraseLine added in v1.0.1

func EraseLine(mode EraseLineMode)

func NewAnsiStderr

func NewAnsiStderr() io.Writer

func NewAnsiStdout

func NewAnsiStdout() io.Writer

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 added in v1.2.0

type Coord struct {
	X Short
	Y Short
}

func CursorLocation added in v1.2.0

func CursorLocation() (Coord, error)

func Size added in v1.2.0

func Size() (*Coord, error)

func (Coord) CursorIsAtLineBegin added in v1.5.2

func (cur Coord) CursorIsAtLineBegin() bool

func (Coord) CursorIsAtLineEnd added in v1.5.2

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

type EraseLineMode added in v1.0.1

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

type RuneReader added in v1.1.1

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

func NewRuneReader added in v1.1.1

func NewRuneReader(input *os.File) *RuneReader

func (*RuneReader) ReadLine added in v1.1.1

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

func (*RuneReader) ReadRune added in v1.1.1

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

func (*RuneReader) RestoreTermMode added in v1.1.1

func (rr *RuneReader) RestoreTermMode() error

func (*RuneReader) SetTermMode added in v1.1.1

func (rr *RuneReader) SetTermMode() error

type Short added in v1.2.0

type Short int16
var COORDINATE_SYSTEM_BEGIN Short = 0

type Writer

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

func (*Writer) Write

func (w *Writer) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

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