terminal

package
v0.0.0-...-434faa1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TermAppAppleTerminal = "Apple_Terminal"
	TermAppITerm         = "iTerm.app"
	TermAppVscode        = "vscode"
)
View Source
const (
	EscClearScreen = "\x1b[2J"
	EscGotoTopLeft = "\x1b[0;0f"
	EscHideCursor  = "\x1b[?25l"
	EscShowCursor  = "\x1b[?25h"
)
View Source
const EnvTermApp = "TERM_PROGRAM"

Variables

This section is empty.

Functions

This section is empty.

Types

type TermApp

type TermApp string

type Terminal

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

func NewTerminal

func NewTerminal(stdout *os.File) *Terminal

NewTerminal returns a new terminal for the given file descriptor.

func (*Terminal) CaptureInput

func (t *Terminal) CaptureInput(ctx context.Context) (keys <-chan *input.Input, restore func(), err error)

func (*Terminal) Clear

func (t *Terminal) Clear()

Clear clears the screen and sets the cursor to 0,0.

func (*Terminal) ClearString

func (t *Terminal) ClearString() string

ClearString returns the ANSI codes for clearing the screen and setting the cursor to 0,0.

func (*Terminal) HideCursor

func (t *Terminal) HideCursor()

HideCursor sends ANSI escape code to hide the cursor.

func (*Terminal) Overpaint

func (t *Terminal) Overpaint() error

Overpaint clears the screen by printing w*h spaces.

func (*Terminal) Print

func (t *Terminal) Print(values ...interface{})

Print prints the values to the terminal's file descriptor.

func (*Terminal) Println

func (t *Terminal) Println(values ...interface{})

Println prints the values to the terminal's file descriptor ending with a new line and an additional carriage return "\r", to produce valid lines on raw terminals.

func (*Terminal) RunClearCommand

func (t *Terminal) RunClearCommand()

RunClearCommand runs a "clear" or similar command if supported by the OS. Panics if the OS does not support "clear".

func (*Terminal) ShowCursor

func (t *Terminal) ShowCursor()

ShowCursor sends ANSI escape code to show the cursor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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