termgow

package module
v0.0.0-...-7430742 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2015 License: MIT Imports: 4 Imported by: 0

README

termgo-widgets [in progress]

Build Status

WIdgets to help cross-platform terminal UI development

Using termbox-go as a base library

Documentation

Overview

@author Axel Anceau - 2014 Package termgow allows to creates console apps faster

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic interface {
	Size() (int, int)
	GetForeground() termbox.Attribute
	GetBackground() termbox.Attribute
}

Basic interface contains all methods that every basic element must implements

type Container

type Container struct {
	Element
	// contains filtered or unexported fields
}

A container is a visual basic element

func (*Container) RemoveBorder

func (c *Container) RemoveBorder()

RemoveBorder removes the border from the container (if any)

func (*Container) SetAlignment

func (c *Container) SetAlignment(vertical styles.Alignment, horizontal styles.Alignment)

SetAlignment sets the alignment of the container

func (*Container) SetBorder

func (c *Container) SetBorder(style *styles.BorderStyle)

SetBorder sets the border style of the container

func (*Container) SetMargin

func (c *Container) SetMargin(s *Spacing)

SetMargin sets the margin (in terms of chars) for every bounds of the window

Note : If an element has a specified x/y pos, the margin will not be considered

func (*Container) SetPadding

func (c *Container) SetPadding(s *Spacing)

SetPadding sets the padding (in terms of chars) for every bounds of the window

type Element

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

Most basic type. Everything is an element

func (*Element) GetBackground

func (e *Element) GetBackground() termbox.Attribute

GetBackground gets background's color

func (*Element) GetForeground

func (e *Element) GetForeground() termbox.Attribute

GetForeground gets foreground (chars) color

func (*Element) SetBackground

func (e *Element) SetBackground(color termbox.Attribute)

SetBackground changes background's color

func (*Element) SetForeground

func (e *Element) SetForeground(color termbox.Attribute)

SetForeground sets foreground's color (characters)

func (*Element) SetSize

func (e *Element) SetSize(width, height int)

SetSize changes windows's width & height value

func (*Element) Size

func (e *Element) Size() (int, int)

Size returns width & height of the current element

type Layout

type Layout interface {
	AddWidget(widget *Widget) error
	RemoveWidget(widget *Widget) error
}

Layout interface contains methods that a layout must implement to be able to manage a set of widgets

type Program

type Program struct {
	Element
	IsRunning bool // If the program is currently running or not
	// contains filtered or unexported fields
}

General informations about the program

func NewProgram

func NewProgram() (*Program, error)

NewProgram creates a new Program (only one program is allowed)

func (*Program) AddWindow

func (p *Program) AddWindow(win *Window) error

AddWindow adds a new window to the set of window to print An error is returned if the window already exists

func (*Program) Close

func (p *Program) Close()

Close the program. Must be called when the program is not needed anymore

func (*Program) RemoveWindow

func (p *Program) RemoveWindow(win *Window) error

RemoveWindow removes a window from the program An error is returned if the window does not exists

func (*Program) Run

func (p *Program) Run()

Run the given program (until ctrl + c has been pressed)

type Spacing

type Spacing struct {
	Left   int
	Top    int
	Right  int
	Bottom int
}

Spacing type contains spacing values for each side of a rect

type Widget

type Widget interface {
	Hide() error
	Show() error
}

Widget interface manages widget's different states

type Window

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

Window is the base of a view with termgow

func NewWindow

func NewWindow() *Window

NewWindow returns a new Window with terminal's size

func (*Window) Hide

func (w *Window) Hide() error

Hide the window from the program

If the program has not been created, an error will be returned

func (*Window) Show

func (w *Window) Show() error

Show the window in the program. If the window is already showed, it will be displayed in foreground

If the program has not been created or the window is not in its list, an error will be returned

Notes

Bugs

  • deleting win.priority from p.showed hides all other windows when .show() is called back delete(p.showed, win.priority)

Directories

Path Synopsis
@author Axel Anceau - 2014 Package colors contains foreground and background colors available
@author Axel Anceau - 2014 Package colors contains foreground and background colors available

Jump to

Keyboard shortcuts

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