termboxui

package module
v0.0.0-...-85bc0af Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2015 License: MIT Imports: 7 Imported by: 0

README

termboxui-go

A minimalistic package to add functionality to termbox-go. This package is intended to be used alongside termbox and does not fully encapsulate nor wrap all of termbox's methods.

Some features that termboxui adds:

  • Windows
    • Label: Displays text and automatically wraps text and scrolling
  • Containers
    • Split: Allows splitting the screen into two sections and automatically tiles two windows

Install

go get github.com/xenoryt/termboxui-go

Documentation

Overview

termboxui adds extra functionality to the termbox package by nsf. This package is intended to be used with termbox and does not completely encapsulate and wrap all of its functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawBox

func DrawBox(x, y, w, h int)

Draws a box along the perimeter of the rectangular area

func DrawHorzLine

func DrawHorzLine(x, y int, w int)

Draw a horizontal line starting at point (x, y) with length w

func DrawVertLine

func DrawVertLine(x, y int, h int)

Draw a vertical line starting at point (x, y) with length h

func Fill

func Fill(x, y, w, h int, cell termbox.Cell)

Fill fills a rectangular area with the given cell

func FillView

func FillView(view *View, x, y, w, h int, cell termbox.Cell)

FillView fills a rectangular area in a View with the given cell

func WrapText

func WrapText(text string, lim int) []string

Wraps the text into multiple lines at most lim chars long. Returns a list of all the lines. Supports unicode.

Types

type Container

type Container interface {
	Draw()
	Place(Window) error
	Remove(Window)
	Move(x, y int)
	Resize(width, height int)
}

Container represents anything that can store and display Windows. Generally containers are used to tile the Windows as well as handling resizing the Windows

type Frame

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

func NewFrame

func NewFrame() *Frame

func (*Frame) Draw

func (f *Frame) Draw()

func (*Frame) Move

func (f *Frame) Move(x, y int)

func (*Frame) Place

func (f *Frame) Place(win Window)

func (*Frame) Resize

func (f *Frame) Resize(w, h int)

type HSplit

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

HSplit creates a vertical divider and tiles windows next to the split.

func (*HSplit) Draw

func (s *HSplit) Draw()

Draw draws the split and its children

func (*HSplit) GetSplitLoc

func (s *HSplit) GetSplitLoc() int

Gets the location of the split relative to the entire screen.

func (*HSplit) Move

func (s *HSplit) Move(x, y int)

func (*HSplit) Place

func (s *HSplit) Place(win Window) error

Place places the window either to the left or right of the split. If both spaces are empty, it will be placed to the left. If both spaces have been taken, this will return an error.

func (*HSplit) Remove

func (s *HSplit) Remove(win Window)

Remove removes the window and makes its occupied space available again.

func (*HSplit) RemoveFirst

func (s *HSplit) RemoveFirst()

RemoveFirst removes the window to the left

func (*HSplit) RemoveLast

func (s *HSplit) RemoveLast()

RemoveLast removes the window to the right

func (*HSplit) Resize

func (s *HSplit) Resize(w, h int)

type Label

type Label struct {
	Title string
	// contains filtered or unexported fields
}

Label creates an area that displays text

func NewLabel

func NewLabel() *Label

NewLabel creates a new label

func (*Label) Clear

func (lbl *Label) Clear()

func (*Label) Draw

func (lbl *Label) Draw()

Draw writes the buffered text onto the screen

func (*Label) Move

func (lbl *Label) Move(x, y int)

func (*Label) NextPage

func (lbl *Label) NextPage() error

func (Label) Origin

func (lbl Label) Origin() (x, y int)

func (Label) Overwrite

func (lbl Label) Overwrite()

Redraw clears any previous text in the label and then perform a Draw

func (*Label) PrevPage

func (lbl *Label) PrevPage() error

func (*Label) Resize

func (lbl *Label) Resize(width, height int)

func (*Label) Scroll

func (lbl *Label) Scroll(amt int) error

func (*Label) SetBG

func (lbl *Label) SetBG(attr termbox.Attribute)

func (*Label) SetBorders

func (lbl *Label) SetBorders(borders bool)

func (*Label) SetFG

func (lbl *Label) SetFG(attr termbox.Attribute)

func (Label) Size

func (lbl Label) Size() (width, height int)

func (*Label) Write

func (lbl *Label) Write(p []byte) (n int, err error)

Write content to the label

type Split

type Split interface {
	Draw()
	Place(Window) error
	Remove(Window)
	RemoveFirst()
	RemoveLast()
	Move(x, y int)
	Resize(w, h int)
}

func NewSplit

func NewSplit(location float32, sType SplitType) Split

NewSplit creates a new horizontal split. If the location is positive then it is based starting from the left/top. If the location is negative then it starts from the right/bottom. If location is on the interval (0, 1), then it is treated as a percentage and the split will appear that percent down the screen. If location is >= 1 then it is truncated and will appear on the location'th row. The split will take up the entire screen by default. A VSplit.Move and VSplit.Resize is necessary to place it in the correct position if that is not the behaviour you want.

type SplitType

type SplitType int
const (
	SplitHorizontal SplitType = iota
	SplitVertical
)

type VSplit

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

VSplit creates a vertical divider and tiles windows next to the split.

func (*VSplit) Draw

func (s *VSplit) Draw()

Draw draws the split and its children

func (*VSplit) GetSplitLoc

func (s *VSplit) GetSplitLoc() int

Gets the location of the split relative to the entire screen.

func (*VSplit) Move

func (s *VSplit) Move(x, y int)

func (*VSplit) Place

func (s *VSplit) Place(win Window) error

Place places the window either to the left or right of the split. If both spaces are empty, it will be placed to the left. If both spaces have been taken, this will return an error.

func (*VSplit) Remove

func (s *VSplit) Remove(win Window)

Remove removes the window and makes its occupied space available again.

func (*VSplit) RemoveFirst

func (s *VSplit) RemoveFirst()

RemoveFirst removes the window to the left

func (*VSplit) RemoveLast

func (s *VSplit) RemoveLast()

RemoveLast removes the window to the right

func (*VSplit) Resize

func (s *VSplit) Resize(w, h int)

type View

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

View imitates another termbox session. Can "pre-render" cells here and display them later on

func NewView

func NewView() *View

Creates a new View with the specified buffer size REQ: bufw and bufh must be greater than 0

func (*View) Clear

func (v *View) Clear(fg, bg termbox.Attribute)

func (*View) ClearDefault

func (v *View) ClearDefault()

func (*View) Move

func (v *View) Move(xOffset, yOffset int)

Move moves the location of the view by the specified offset. It does not move the content that has already been rendered but all future content will be rendered at the new location.

func (*View) MoveTo

func (v *View) MoveTo(x, y int)

MoveTo moves the view to the specified location. It does not move the content that has already been rendered but all future content will be rendered at the new location.

func (*View) Origin

func (v *View) Origin() (x, y int)

func (*View) Resize

func (v *View) Resize(w, h int)

func (*View) SetCell

func (v *View) SetCell(x, y int, ch rune, fg, bg termbox.Attribute)

func (*View) Size

func (v *View) Size() (width, height int)

type Window

type Window interface {
	Draw()
	Move(x, y int)
	Resize(width, height int)
}

Window represents any UI element

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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