Documentation
¶
Overview ¶
Package tty provides a tiny set of terminal cursor and screen manipulation functions.
Index ¶
- Constants
- Variables
- func ClearScreen() (err error)
- func CursorColumn(x int) (err error)
- func CursorDown(n int) (err error)
- func CursorEraseLine() (err error)
- func CursorHome() (err error)
- func CursorLeft(n int) (err error)
- func CursorMove(y, x int) (err error)
- func CursorRight(n int) (err error)
- func CursorUp(n int) (err error)
- func EnterAltScreen() (err error)
- func EraseLineFromCursor() (err error)
- func EraseLineToCursor() (err error)
- func LeaveAltScreen() (err error)
- func NotifyOnResize(ctx context.Context, done chan bool, handler func())
- func RestoreScreen() (err error)
- func SaveScreen() (err error)
- type MouseAction
- type MouseButton
- type MouseEvent
- type WindowSize
Constants ¶
View Source
const ( SaveSeq = "\x1b[?47h" RestoreSeq = "\x1b[?47l" ClearSeq = "\x1b[2J" EnterAltScreenSeq = "\x1b[?1049h" LeaveAltScreenSeq = "\x1b[?1049l" )
Screen
View Source
const ( CursorHomeSeq = "\x1b[H" CursorUpSeq = "\x1b[A" CursorDownSeq = "\x1b[B" CursorRightSeq = "\x1b[C" CursorLeftSeq = "\x1b[D" CursorSaveSeq = "\x1b[7" CursorRestoreSeq = "\x1b[8" CursorHideSeq = "\x1b[?25l" CursorShowSeq = "\x1b[?25h" CursorEraseLineSeq = "\x1b[2K" EraseLineToCurSeq = "\x1b[1K" EraseLineFromCurSeq = "\x1b[0K" )
Cursor
View Source
const ( CursorEraseNLines = "\x1b[2K" CursorMoveSeq = "\x1b[y;xH" CursorColumnSeq = "\x1b[xG" )
Requires Parameters
Variables ¶
View Source
var Output io.Writer = os.Stdout
Output is the output writer.
Functions ¶
func CursorColumn ¶
CursorColumn sets the cursor to the x-th column of the current line.
func CursorMove ¶
CursorMove moves the cursor to the y-th row and x-th column.
func CursorRight ¶
CursorRight moves the cursor right n columns.
func EraseLineFromCursor ¶
func EraseLineFromCursor() (err error)
EraseLineFromCursor erases the line from the cursor to the end of the line.
func EraseLineToCursor ¶
func EraseLineToCursor() (err error)
EraseLineToCursor erases from the start of the line to the cursor.
func NotifyOnResize ¶
NotifyOnResize listens for window size changes and runs the handler every time it does.
Types ¶
type MouseAction ¶
type MouseAction int
const ( MouseActionPress MouseAction = iota MouseActionRelease MouseActionMotion )
type MouseButton ¶
type MouseButton int
const ( MouseButtonNone MouseButton = iota MouseButtonLeft MouseButtonMiddle MouseButtonRight MouseButtonWheelUp MouseButtonWheelDown MouseButtonWheelLeft MouseButtonWheelRight MouseButtonBackward MouseButtonForward MouseButton10 MouseButton11 )
type MouseEvent ¶
type MouseEvent struct { X int Y int Shift bool Alt bool Ctrl bool Action MouseAction Button MouseButton }
func HandleMessage ¶
func HandleMessage(b []byte) (int, MouseEvent)
HandleMessage parses a single mouse event.
func (MouseEvent) IsWheel ¶
func (m MouseEvent) IsWheel() bool
type WindowSize ¶
type WindowSize struct {
Width, Height int
}
func TermSize ¶
func TermSize(fd uintptr) (*WindowSize, error)
Click to show internal directories.
Click to hide internal directories.