termhook

package module
v0.0.0-...-a267c97 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: BSD-2-Clause Imports: 10 Imported by: 2

README

termhook

termhook is a small library that attaches to a terminal, serial console or other similar device, and lets you attach your own hook on terminal output.

Example

See cmds/termhook/main.go for a simple terminal emulator built with the termhook library.

Warning: at the moment there is no way to exit the terminal without killing the running process, but will be implemented soon.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hook

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

Hook is the terminal hook type.

func NewHook

func NewHook(port string, speed int, handleStdin bool, handler LineHandler) (*Hook, error)

NewHook initializes and returns a new Hook object.

func (*Hook) Close

func (h *Hook) Close() error

Close closes the terminal hook.

func (*Hook) Run

func (h *Hook) Run() error

Run starts the terminal hook handler. This function is blocking.

type LineHandler

type LineHandler func(w io.Writer, line []byte) (bool, error)

LineHandler defines the function that is called at each line of output from the terminal. The boolean indicates whether the terminal reader should return.

Directories

Path Synopsis
cmds

Jump to

Keyboard shortcuts

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