terminal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package terminal provides functionality for terminals.

Index

Constants

This section is empty.

Variables

View Source
var Stderr io.Writer
View Source
var Stdout io.Writer

Functions

func AnsiEscapeCode

func AnsiEscapeCode(code string) string

AnsiEscapeCode translates a named escape code to its ANSI equivalent.

func Escape

func Escape(s string, delims string, escape func(string) string) string

Escape replaces escape code instances within a string. Escape codes must be delimited using the delimiters in the delims parameter, which has the syntax "START END". For example, to use {{ and }} as delimiters specify "{{ }}".

For consistency with NewEscapeWriter, Escape will discard an unterminated escape code. For example, if delims is "{{ }}" and the string s is "hello {{world", the resulting string will be "hello ".

func GetSize

func GetSize(fd uintptr) (int, int, error)

GetSize gets the terminal size (cols x rows).

func IsAnsiTerminal

func IsAnsiTerminal(fd uintptr) bool

IsAnsiTerminal determines if the file descriptor describes a terminal that has ANSI capabilities.

func IsTerminal

func IsTerminal(fd uintptr) bool

IsTerminal determines if the file descriptor describes a terminal.

func NewEscapeWriter

func NewEscapeWriter(writer io.Writer, delims string, escape func(string) string) io.Writer

NewEscapeWriter replaces escape code instances within a string. Escape codes must be delimited using the delimiters in the delims parameter, which has the syntax "START END". For example, to use {{ and }} as delimiters specify "{{ }}".

Because NewEscapeWriter is an io.Writer it cannot know when the last Write will be received. For this reason it will discard an unterminated escape code. For example, if delims is "{{ }}" and the string s is "hello {{world", the resulting string will be "hello ".

func NewReader

func NewReader(r io.Reader) io.Reader

NewReader reads terminal input, including special keys.

func NullEscapeCode

func NullEscapeCode(code string) string

NullEscapeCode translates a named escape code to the empty string. It is used to eliminate escape codes.

func SetState

func SetState(fd uintptr, s State) error

Types

type State

type State *state

func GetState

func GetState(fd uintptr) (State, error)

func MakeRaw

func MakeRaw(fd uintptr) (State, error)

MakeRaw puts the terminal in "raw" mode. In this mode the terminal performs minimal processing. The fd should be the file descriptor of the terminal input.

Directories

Path Synopsis
Package editor provides simple readline functionality for Go programs.
Package editor provides simple readline functionality for Go programs.

Jump to

Keyboard shortcuts

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