Documentation ¶
Overview ¶
Package terminal exposes the terminal as a matrix of characters and a collections of events.
package main import ( "github.com/guillermo/terminal" "github.com/guillermo/terminal/char" "github.com/guillermo/terminal/events" ) func main() { // An empty Terminal is a valid one term := &terminal.Terminal{} err := term.Open() if err != nil { panic(err) } // Always restore the terminal to the previous state defer term.Close() // Get the size of the terminal rows, cols := term.Size() // Rows and Cols start with 1 term.Set(1, 1, char.C("H")) term.Set(rows, cols, char.C("i")) term.Sync() for { // Listen for events e := term.NextEvent() if ke, ok := e.(events.KeyboardEvent); ok { if ke.Key == "q" { // EXIT break } } } }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶ added in v0.0.2
type File interface {
Fd() uintptr
}
File is the interface used for getting the Fd() of the Output device. For example os.Stdout.Fd() returns the file descriptor needed to ask the OS for the terminal size.
type Terminal ¶
type Terminal struct { Input io.Reader Output io.Writer DefaultChar char.Charer // contains filtered or unexported fields }
Terminal holds the state of the current terminal
func (*Terminal) NextEvent ¶
NextEvent return the next events.Event. If there are no events available it will block.
func (*Terminal) Open ¶
Open opens a terminal.
If Output is a File it will try to open the terminal as a tty.
If Output is nil, os.Stdout will be used.
If Input is nil, os.Stdin will be used.
If DefaultChar is present, it will clear the screen with the background Color of the DefaultChar
Directories ¶
Path | Synopsis |
---|---|
Package ansi converts a given area into a stream of ansi sequences to be dump into a terminal
|
Package ansi converts a given area into a stream of ansi sequences to be dump into a terminal |
Package area implements a matrix of Characters
|
Package area implements a matrix of Characters |
Package char represent a Char in a terminal
|
Package char represent a Char in a terminal |
cmd
|
|
sequencegenerator
sequencegenerator Generates a sequences.go file containing most possible terminal input.
|
sequencegenerator Generates a sequences.go file containing most possible terminal input. |
Package events contains the basic primitives of the input and output events
|
Package events contains the basic primitives of the input and output events |
Package framebuffer stores the current terminal state and return the ansi sequences require to transform the current state to the new one
|
Package framebuffer stores the current terminal state and return the ansi sequences require to transform the current state to the new one |
Package input converts a io.Reader (normally a tty) into a sequence of events.
|
Package input converts a io.Reader (normally a tty) into a sequence of events. |
Package tty implements the os part of the terminal
|
Package tty implements the os part of the terminal |