logbar

package
Version: v0.0.0-...-d3fb95e Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package logbar implements a terminal UI component called a LogBar.

The top part, the "log", is a feed of newline-separated log messages.

The bottom part, the "bar", is a persistent status display that can be filled with any sorts of characters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	SetLine(index int, line string)
	Write(p []byte) (n int, err error)
}

Interface covers the common ground between a LogBar and a Manager.

type LogBar

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

LogBar is a terminal component. Set its persistent lines with SetLine(), write to it with fmt.Fprint, fmt.Fprintf, and fmt.Fprintln.

func New

func New(height int) *LogBar

New returns a new LogBar

func (*LogBar) BarHeight

func (lb *LogBar) BarHeight() int

BarHeight returns the height of the bar, in lines

func (*LogBar) Clean

func (lb *LogBar) Clean()

Clean marks this LogBar as clean, and remembers its height. Call this once you write the LogBar out to a writer

func (*LogBar) Render

func (lb *LogBar) Render() *bytes.Buffer

Render a Buffer that can be written to an io.Writer to render this component to a terminal.

func (*LogBar) SetLine

func (lb *LogBar) SetLine(row int, line string)

SetLine updates given line in the Bar.

func (*LogBar) Write

func (lb *LogBar) Write(p []byte) (n int, err error)

Write to the LogBar's log

func (*LogBar) WriteTo

func (lb *LogBar) WriteTo(wr io.Writer) (int64, error)

WriteTo writes this to a writer, and cleans it

type Manager

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

Manager manages writing a LogBar to an underlying io.Writer (ususally os.Stderr) at regular intervals, and also thread-safe updates to the LogBar.

If an error occurs when writing to the underlying writer, Manager panics.

func NewManager

func NewManager(lb *LogBar, writer io.Writer) *Manager

NewManager returns a new Manager

func (*Manager) SetLine

func (m *Manager) SetLine(idx int, line string)

SetLine sets a line in the bar

func (*Manager) Start

func (m *Manager) Start()

Start begins writing the log bar to the writer

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops writing the lob bar to the writer

func (*Manager) Write

func (m *Manager) Write(p []byte) (n int, err error)

Write to the log

Jump to

Keyboard shortcuts

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