tableview

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 6 Imported by: 4

Documentation

Overview

Package tableview provides a way to display a table widget in a terminal, using all the width and height and being able to scroll vertically or horizontally, search, filter, sort and adding additional funcionality

Index

Constants

View Source
const (
	AlignLeft   = tview.AlignLeft
	AlignCenter = tview.AlignCenter
	AlignRight  = tview.AlignRight
)

Text alignment in each column.

Variables

View Source
var DefaultApplication = NewApplication()

Functions

This section is empty.

Types

type Application added in v0.1.2

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

func NewApplication added in v0.1.2

func NewApplication() *Application

func (*Application) NewTable added in v0.1.2

func (a *Application) NewTable() *TableView

func (*Application) Run added in v0.1.2

func (a *Application) Run()

func (*Application) SetActiveTable added in v0.1.2

func (a *Application) SetActiveTable(t *TableView)

type TableView

type TableView struct {
	ID int // index of this table in parent Application's "tables"
	// contains filtered or unexported fields
}

TableView holds a description of one table to be displayed

func NewTableView

func NewTableView() *TableView

NewTableView returns an empty TableView

func (*TableView) FillTable

func (t *TableView) FillTable(columns []string, data [][]string)

FillTable populates a TableView with the given data

func (*TableView) JoinRows added in v0.1.3

func (t *TableView) JoinRows(startRow int, endRow int) error

JoinRows marks several rows to be always together, and with the same visibility. This affects the behaviour of t.search(), t.filterData() and t.sort()

func (*TableView) NewCommand

func (t *TableView) NewCommand(ch rune, text string, action func(row int))

NewCommand sets the function to be executed when a given key is pressed. The selected row is passed to the function as an argument.

func (*TableView) Run

func (t *TableView) Run()

Run draws the table and starts a loop, waiting for keystrokes and redrawing the screen. It exits when ^C or "q" is pressed.

func (*TableView) SetAlign

func (t *TableView) SetAlign(column int, align int)

SetAlign sets the alignment in this column. This must be either AlignLeft, AlignCenter, or AlignRight.

func (*TableView) SetCell

func (t *TableView) SetCell(row int, column int, content string)

SetCell sets the content of a cell in the specified position.

func (*TableView) SetExpansion

func (t *TableView) SetExpansion(column int, expansion int)

SetExpansion sets the value by which the column expands if the available width for the table is more than the table width.

func (*TableView) SetSelectedFunc

func (t *TableView) SetSelectedFunc(action func(row int))

SetSelectedFunc sets the function to be executed when the user presses ENTER. The selecred row is passed to the function as an argument.

func (*TableView) Suspend added in v0.1.3

func (t *TableView) Suspend(f func())

Suspend temporarily suspends the application by exiting terminal UI mode and invoking the provided function "f". When "f" returns, terminal UI mode is entered again and the application resumes.

Jump to

Keyboard shortcuts

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