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. Expand ▾ Collapse ▴ Documentation ¶ Index ¶ type Hook func NewHook(port string, speed int, handleStdin bool, handler LineHandler) (*Hook, error) func (h *Hook) Close() error func (h *Hook) Run() error type LineHandler 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. Source Files ¶ View all Source files termhook.go Directories ¶ Show internal Expand all Path Synopsis cmds termhook Click to show internal directories. Click to hide internal directories.