display

package
v0.0.0-...-d046166 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package display provides advanced methods of logging to a terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

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

Display divides the screen into multiple independently-scrollable logging areas.

Output is separated into three areas:

+------------+
| Persistent |
| ...        |
+------------+
| Status     |
+------------+
| Verbose    |
| ...        |
+------------+

The persistent area contains important messages that should remain onscreen for as long as possible. New messages are logged at the bottom of the area, which grows upward until it reaches the top of the screen.

The status line is used to display the current progress and can be updated frequently.

The verbose area contains transient messages. It's assumed that only the last few verbose messages are still relevent. New messages are logged at the bottom of the area, which grows downward, but only to a fixed maximum height. If the area reaches the bottom of the screen before hitting its maximum height, all areas are pushed upward.

TODO(derat): Detect screen resize (with SIGWINCH?) and reinitialize everything.

func New

func New(tm Term, maxVerboseRows int) (*Display, error)

New returns a new Display backed by tm. The verbose area can grow to maxVerboseRows rows before scrolling.

func (*Display) AddPersistent

func (d *Display) AddPersistent(s string) error

AddPersistent adds s to the bottom of the persistent area. Long lines are truncated, and trailing empty lines are dropped.

func (*Display) AddVerbose

func (d *Display) AddVerbose(s string) error

AddVerbose adds s to the bottom of the persistent area. Long lines are truncated, and trailing empty lines are dropped.

func (*Display) Close

func (d *Display) Close() error

Close closes d. The status row and verbose area are cleared, and the cursor is left at the beginning of the status row's line.

func (*Display) SetStatus

func (d *Display) SetStatus(s string) error

SetStatus sets the status line to s.

type Term

type Term interface {
	// contains filtered or unexported methods
}

Term is used to control a terminal.

type VT100Term

type VT100Term struct{}

VT100Term controls a VT100 terminal. TODO(derat): Extract escape sequences from the system terminfo database instead of hardcoding them.

Jump to

Keyboard shortcuts

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