tui

package
v0.0.0-...-b061287 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2019 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorWriter

type ColorWriter interface {
	io.Writer
	// Define foreground and background color
	SetWriterColors(termbox.Attribute, termbox.Attribute)
}

ColorWriter defines an interface allowing to define color with an io.Writer interface

type ListWidget

type ListWidget struct {
	// ListWidget is a TextWidget
	*TextWidget
}

ListWidget represents a scrollable list

func NewListWidget

func NewListWidget() *ListWidget

NewListWidget creates new ListWidget, taken its size as parameter

func (*ListWidget) GetCursor

func (l *ListWidget) GetCursor() int

GetCursor gets the line where the viewing cursor is set

func (*ListWidget) SetCursor

func (l *ListWidget) SetCursor(y int)

SetCursor sets the cursor for viewing

func (*ListWidget) SetCursorDown

func (l *ListWidget) SetCursorDown()

SetCursorDown moves cursor down by one line

func (*ListWidget) SetCursorUp

func (l *ListWidget) SetCursorUp()

SetCursorUp moves cursor up by one line

type Style

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

Style is a struct that facilitates use of colors and style for terminal printing

func NewStyle

func NewStyle() Style

NewStyle createsa new Style with default colors

func (Style) Bg

func (s Style) Bg(bg termbox.Attribute) Style

Bg set Background color

func (Style) Bold

func (s Style) Bold() Style

Bold put foreground in Bold

func (Style) Fg

func (s Style) Fg(fg termbox.Attribute) Style

Fg set foreground color

func (Style) Fprint

func (s Style) Fprint(w ColorWriter, a ...interface{}) (n int, err error)

Fprint is a convenient wrapper that prints in color to a window that implements ColorWriter interface

func (Style) Fprintln

func (s Style) Fprintln(w ColorWriter, a ...interface{}) (n int, err error)

Fprintln is a convenient wrapper that print in color to a window that implements ColorWriter interface

func (Style) Reverse

func (s Style) Reverse() Style

Reverse reverse colors

type TerminalUI

type TerminalUI struct {
	W, H     int
	Widgets  []Widget
	UIEvents chan termbox.Event
}

func New

func New() (*TerminalUI, error)

func (*TerminalUI) AddWidget

func (t *TerminalUI) AddWidget(w Widget)

func (*TerminalUI) Close

func (t *TerminalUI) Close()

func (*TerminalUI) Draw

func (t *TerminalUI) Draw() error

func (*TerminalUI) Resize

func (t *TerminalUI) Resize()

func (*TerminalUI) Run

func (t *TerminalUI) Run() error

type TextWidget

type TextWidget struct {

	// TextWidget is a Window
	*Window
	// contains filtered or unexported fields
}

TextWidget represents a scrollable window that displays colored text TextWidget implements the io.Writer interface to facilitate entering content

func NewTextWidget

func NewTextWidget() *TextWidget

NewTextWidget creates new TextWidget

func (*TextWidget) Draw

func (txt *TextWidget) Draw()

Draw implements Widget interface to display the window content

func (*TextWidget) Reset

func (txt *TextWidget) Reset()

Reset empties the text to be displayed

func (*TextWidget) Scroll

func (txt *TextWidget) Scroll(x, y int)

Scroll modify the viewing position of the text horizontally and/or vertically

func (*TextWidget) SetWriterColors

func (txt *TextWidget) SetWriterColors(fg, bg termbox.Attribute)

SetWriterColors modifies the colors for writing

func (*TextWidget) Write

func (txt *TextWidget) Write(p []byte) (n int, err error)

Write corresponds to the implementataion of the io.Writer interface

type Widget

type Widget interface {
	// Draw widget content on screen
	Draw()
	// Set or reset Size of the Widget
	Resize(int, int, int, int)
}

Widget defines an interface for TerminalUI widgets

type Window

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

Window represents a window of the user interface

func NewWindow

func NewWindow() *Window

NewWindow creates new Window

func (*Window) Clear

func (win *Window) Clear()

Clear clears the window content

func (*Window) Resize

func (win *Window) Resize(x0, y0, w, h int)

Resize modify the size of the window

func (*Window) SetLine

func (win *Window) SetLine(y int, line []termbox.Cell)

SetLine prints a line in color using the normal colorscheme

func (*Window) SetLineHighlight

func (win *Window) SetLineHighlight(y int, line []termbox.Cell)

SetLineHighlight prints a line in color using the highlight colorscheme

func (*Window) SetStyle

func (win *Window) SetStyle(nStyle, hStyle Style)

SetStyle defines the window normal and highlight colorscheme

Jump to

Keyboard shortcuts

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