tui

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: GPL-2.0, GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CitationDelete   = ":delete"
	CitationOpen     = ":open"
	CitationOpenUrl  = ":open-url"
	CitationOpenFile = ":open-file"
	CmdLineClose     = ":cmdl-close"
	CmdLineDelete    = ":cmdl-delete"
	CmdLineNext      = ":cmdl-next"
	CmdLineOpen      = ":cmdl-open"
	CmdLinePrev      = ":cmdl-prev"
	HelpNext         = ":help-down"
	HelpPrev         = ":help-up"
	HelpClose        = ":help-close"
	HelpShow         = ":help"
	ListEdit         = ":edit"
	ListExecute      = ":exec"
	ListFilter       = ":filter"
	ListGotoFirst    = ":goto-first"
	ListGotoLast     = ":goto-last"
	ListHalfDown     = ":down"
	ListHalfUp       = ":up"
	ListMarkDelete   = ":mark-delete"
	ListNext         = ":next"
	ListPrev         = ":prev"
	ListUnmark       = ":unmark"
	Quit             = ":quit"
)

Variables

View Source
var BLUE tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(129, 161, 193)).Background(tcell.ColorReset)

blue foreground

View Source
var DARK tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(28, 28, 28)).Background(tcell.ColorReset)

dark foreground (black)

View Source
var DIM tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(76, 86, 106)).Background(tcell.ColorReset)

dim foreground (grey)

View Source
var GREEN tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(163, 190, 140)).Background(tcell.ColorReset)

green foreground

View Source
var NORMAL tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(229, 233, 240)).Background(tcell.ColorReset)

white foreground

View Source
var ORANGE tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(208, 135, 112)).Background(tcell.ColorReset)

orange foreground

View Source
var PINK tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(180, 142, 173)).Background(tcell.ColorReset)

pink foreground

View Source
var RED tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(191, 97, 106)).Background(tcell.ColorReset)

red foreground

View Source
var YELLOW tcell.Style = tcell.StyleDefault.Foreground(tcell.NewRGBColor(235, 203, 139)).Background(tcell.ColorReset)

yellow foreground

Functions

func DrawBox

func DrawBox(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string)

draws a box (taken from tcell wiki)

func DrawHLine

func DrawHLine(s tcell.Screen, y, x1, x2 int, style tcell.Style)

draws horizontal line

func DrawText

func DrawText(s tcell.Screen, x1, y1, x2, y2 int, style tcell.Style, text string)

draws text (taken from tcell wiki)

func DrawVLine

func DrawVLine(s tcell.Screen, x, y1, y2 int, style tcell.Style)

draws vertical line with connecting start and end

func DrawVLineL

func DrawVLineL(s tcell.Screen, x, y1, y2 int, style tcell.Style)

draws left vertical line with corners

func DrawVLineR

func DrawVLineR(s tcell.Screen, x, y1, y2 int, style tcell.Style)

draws right vertical line with corners

func NewScreen

func NewScreen() tcell.Screen

returns a new screen

Types

type Box

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

ui border box with lines

func NewBox

func NewBox() Box

returns new widget

func (*Box) Draw

func (self *Box) Draw(screen tcell.Screen)

draws the widget

func (*Box) GetCoords

func (self *Box) GetCoords() (x1, y1, x2, y2 int)

returns coords

func (*Box) GetSizes

func (self *Box) GetSizes() (w, h int)

returns width and height

func (*Box) SetSizes

func (self *Box) SetSizes(x1, y1, x2, y2 int)

sets sizes for the widget

type Command

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

a command

type CommandLine

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

very basic commandline that handles commands

func NewCommandLine

func NewCommandLine() CommandLine

returns new widget

func (*CommandLine) Add

func (self *CommandLine) Add(char string)

append a character to the text

func (*CommandLine) Clear

func (self *CommandLine) Clear(s tcell.Screen)

clears commandline

func (*CommandLine) Del

func (self *CommandLine) Del()

pop last character from text

func (*CommandLine) Draw

func (self *CommandLine) Draw(screen tcell.Screen)

draws the widget

func (*CommandLine) GetCommand

func (self *CommandLine) GetCommand() Command

gets command at current index from history

func (*CommandLine) GetPromptResult

func (self *CommandLine) GetPromptResult() bool

returns a boolean value result for the prompt

func (*CommandLine) GetText

func (self *CommandLine) GetText() string

returns text

func (*CommandLine) HistoryAdd

func (self *CommandLine) HistoryAdd(str string)

add a command to history

func (*CommandLine) IsError

func (self *CommandLine) IsError() bool

checks whether commandline is in error mode

func (*CommandLine) IsPrompt

func (self *CommandLine) IsPrompt() bool

checks whether commandline is in prompt mode

func (*CommandLine) IsSelected

func (self *CommandLine) IsSelected() bool

whether widget is selected or not

func (*CommandLine) Next

func (self *CommandLine) Next()

goto next command in history

func (*CommandLine) Prev

func (self *CommandLine) Prev()

goto previous command in history

func (*CommandLine) Reset

func (self *CommandLine) Reset()

resets commandline to normal mode

func (*CommandLine) Sel

func (self *CommandLine) Sel()

selects widget

func (*CommandLine) SetText

func (self *CommandLine) SetText(text string)

sets text

func (*CommandLine) ShowError

func (self *CommandLine) ShowError(err string)

shows error

func (*CommandLine) ShowPrompt

func (self *CommandLine) ShowPrompt(prompt string)

shows prompt

func (*CommandLine) Unsel

func (self *CommandLine) Unsel()

unselects widget

type List

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

simple scrollable ui list

func NewList

func NewList(title string, entries []ListEntry, selected, border bool) List

returns a new widget

func (*List) Delete

func (self *List) Delete(i int)

deletes an entry from the list

func (*List) Draw

func (self *List) Draw(screen tcell.Screen)

draws the widget

func (*List) Filter

func (self *List) Filter(find string)

filters entries for a given find string

func (*List) FindMarks

func (self *List) FindMarks(mark rune) []int

returns ids of entries with a given mark

func (*List) GetCoords

func (self *List) GetCoords() (x1, y1, x2, y2 int)

returns coords

func (*List) GetId

func (self *List) GetId() int

returns currently selected entry id returns -1 if not found

func (*List) GetIndex

func (self *List) GetIndex() int

returns current index returns -1 if not found

func (*List) GetLen

func (self *List) GetLen() int

returns list length

func (*List) GetSizes

func (self *List) GetSizes() (w, h int)

returns width and height

func (*List) GotoFirst

func (self *List) GotoFirst()

moves cursor to first entry

func (*List) GotoLast

func (self *List) GotoLast()

moves cursor to last entry

func (*List) HalfDown

func (self *List) HalfDown()

do half down

func (*List) HalfUp

func (self *List) HalfUp()

do half up

func (*List) IsSelected

func (self *List) IsSelected() bool

whether widget is selected or not

func (*List) Next

func (self *List) Next()

select next entry

func (*List) Prev

func (self *List) Prev()

select previous entry

func (*List) Sel

func (self *List) Sel()

selects widget + index

func (*List) SetEntries

func (self *List) SetEntries(entries []ListEntry)

sets list entries

func (*List) SetEntry

func (self *List) SetEntry(entry ListEntry, index int)

sets list entry

func (*List) SetIndex

func (self *List) SetIndex(i int)

selects entry

func (*List) SetMark

func (self *List) SetMark(mark rune, style tcell.Style, index int)

sets mark to entry at index

func (*List) SetSizes

func (self *List) SetSizes(x1, y1, x2, y2 int)

sets sizes for the widget

func (*List) Unsel

func (self *List) Unsel()

unselects widget

type ListEntry

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

func NewListEntry

func NewListEntry(s string, style tcell.Style, id int) ListEntry

returns a new entry

func (*ListEntry) SetMark

func (self *ListEntry) SetMark(mark rune, style tcell.Style)

sets list entry mark

type Text

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

func NewText

func NewText(title string, content string, selected, border bool) Text

returns a new widget

func (*Text) Draw

func (self *Text) Draw(screen tcell.Screen)

draws widget

func (*Text) GetCoords

func (self *Text) GetCoords() (x1, y1, x2, y2 int)

returns coords

func (*Text) GetSizes

func (self *Text) GetSizes() (w, h int)

returns width and heigth

func (*Text) IsSelected

func (self *Text) IsSelected() bool

checks whether widget is selected

func (*Text) Next

func (self *Text) Next()

scroll down

func (*Text) Prev

func (self *Text) Prev()

scroll up

func (*Text) Sel

func (self *Text) Sel()

selects widget

func (*Text) SetSizes

func (self *Text) SetSizes(x1, y1, x2, y2 int)

sets sizes for the widget

func (*Text) SetText

func (self *Text) SetText(text string)

sets text

func (*Text) Unsel

func (self *Text) Unsel()

unselects widget

type UI

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

func (*UI) Init

func (self *UI) Init(data []citation.Citation, db *sql.DB)

initializes UI

func (*UI) Run

func (self *UI) Run()

runs UI loop

type UIData added in v0.0.4

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

Jump to

Keyboard shortcuts

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