editbox

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

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

Go to latest
Published: Jun 2, 2018 License: MIT Imports: 4 Imported by: 0

README

Editbox

Collection of input widgets to build TUI forms with termbox.

WIP. API will surely change. For now see examples.

Implemented Widgets

  • editbox.Label
  • editbox.Text
  • editbox.Input
  • editbox.Select
  • editbox.Textarea
  • editbox.Confirm

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(x, y int, fg, bg termbox.Attribute, msg string) (bool, termbox.Event)

Confirmation dialog

func Label

func Label(x, y, width int, fg, bg termbox.Attribute, text string)

Output line of text at x, y with specified width and fg/bg colors If width > 0 it will truncate text if it is longer than width or fill the rest of the width with spaces if text is shorter than width

func Text

func Text(x, y, width, height int, fg, bg termbox.Attribute, text string)

Output rectangular block of text at x, y with specified width, heigh and fg/bg colors. If width or height > 0 it will truncate text if it is longer/higher than width/height or fill the rest of the space width with spaces if text is shorter

Types

type Editbox

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

Base type for all editbox widgets except Select

func Input

func Input(x, y, width int, fg, bg termbox.Attribute) *Editbox

Create new Input widget. This DOES NOT call termbox.Flush().

func Textarea

func Textarea(
	x, y, width, height int,
	fg, bg termbox.Attribute,
	wrap bool,
) *Editbox

Create new Textarea widget. This DOES NOT call termbox.Flush().

func (*Editbox) AddExitKeys

func (ebox *Editbox) AddExitKeys(keys ...termbox.Key)

func (*Editbox) GetCursor

func (ebox *Editbox) GetCursor() (int, int)

Returns cursor position.

func (*Editbox) HandleEvent

func (ebox *Editbox) HandleEvent(ev termbox.Event)

Processes termbox events. Useful if you poll them by yourself.

func (*Editbox) Render

func (ebox *Editbox) Render()

Puts widget contents into termbox' cell buffer. This function DOES NOT call termbox.Flush().

func (*Editbox) SetCursor

func (ebox *Editbox) SetCursor(x, y int)

Set cursor position

func (*Editbox) SetText

func (ebox *Editbox) SetText(s string)

Set widget content

func (*Editbox) Text

func (ebox *Editbox) Text() string

Returns widget content.

func (*Editbox) WaitExit

func (ebox *Editbox) WaitExit() termbox.Event

Start listen for termbox events and edit text. Blocks until exit event. Returns event which made Editbox to exit.

type SelectBox

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

func Select

func Select(
	x, y, width, height int,
	fg, bg, sfg, sbg termbox.Attribute,
	items []string,
) *SelectBox

Create new Select widget. This DOES NOT call termbox.Flush().

func (*SelectBox) HandleEvent

func (sbox *SelectBox) HandleEvent(ev termbox.Event) bool

Processes termbox events. Useful if you poll them by yourself. Returns false on unknown event.

func (*SelectBox) Render

func (sbox *SelectBox) Render()

func (*SelectBox) SelectedIndex

func (sbox *SelectBox) SelectedIndex() int

func (*SelectBox) Text

func (sbox *SelectBox) Text() string

func (*SelectBox) WaitExit

func (sbox *SelectBox) WaitExit() termbox.Event

Make widget to listen for termbox events Blocks until exit event. Returns event which made SelectBox to exit, selected index, and selected value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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