widgets

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateColumnsList

func CreateColumnsList(unchanged, added, removed []string) *tview.TextView

Types

type CellsPool added in v0.8.0

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

func NewCellsPool added in v0.8.0

func NewCellsPool(t *VirtualTable) *CellsPool

func (*CellsPool) Get added in v0.8.0

func (p *CellsPool) Get(row, column, ncells int) (cells []*TableCell, found bool)

type DataTable

type DataTable struct {
	*SelectableTable
	// contains filtered or unexported fields
}

DataTable add following behaviors on top of SelectableTable: - Add row number column to the left corner - Hoist primary key columns to the left right next to row number column - Make row number and primary key columns fixed in place - Make column names (first row) fixed in place - Apply default styling to the fixed columns and rows

func NewDataTable

func NewDataTable() *DataTable

func (*DataTable) GetShape

func (t *DataTable) GetShape() (rowCount, columnCount int)

GetShape get number of rows and number of columns

func (*DataTable) SetColumnStatuses

func (t *DataTable) SetColumnStatuses(cells []*TableCell) *DataTable

func (*DataTable) SetGetCellsFunc

func (t *DataTable) SetGetCellsFunc(getCells func(row, column int) []*TableCell) *DataTable

SetGetCellsFunc set function to get table cell at a position

func (*DataTable) SetPrimaryKeyIndices

func (t *DataTable) SetPrimaryKeyIndices(pk []uint32) *DataTable

SetPrimaryKeyIndices records primary key columns and hoist them to the beginning

func (*DataTable) SetShape

func (t *DataTable) SetShape(rowCount, columnCount int) *DataTable

SetShape sets total number of rows and columns

type DiffTable

type DiffTable struct {
	*DataTable
	// contains filtered or unexported fields
}

func NewDiffTable

func NewDiffTable(reader *diff.RowChangeReader) *DiffTable

func (*DiffTable) UpdateRowCount

func (t *DiffTable) UpdateRowCount()

type MergeApp

type MergeApp struct {
	RemovedCols map[int]struct{}

	Table *MergeTable
	Flex  *tview.Flex

	Finished bool
	// contains filtered or unexported fields
}

func NewMergeApp

func NewMergeApp(buf *diff.BlockBuffer, merger *merge.Merger, app *tview.Application, commitNames []string, commitSums [][]byte, baseSum []byte) *MergeApp

func (*MergeApp) BeforeDraw

func (a *MergeApp) BeforeDraw(screen tcell.Screen)

func (*MergeApp) InitializeTable

func (a *MergeApp) InitializeTable(cd *diff.ColDiff, merges []*merge.Merge)

type MergeRow

type MergeRow struct {
	Cells [][]*TableCell
	// contains filtered or unexported fields
}

func NewMergeRow

func NewMergeRow(buf *diff.BlockBuffer, cd *diff.ColDiff, names []string) *MergeRow

func (*MergeRow) DisplayMerge

func (c *MergeRow) DisplayMerge(m *merge.Merge) error

func (*MergeRow) SetCell

func (c *MergeRow) SetCell(col int, s string, unresolved bool)

type MergeRowPool

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

func NewMergeRowPool

func NewMergeRowPool(blkBuf *diff.BlockBuffer, cd *diff.ColDiff, names []string, merges []*merge.Merge) *MergeRowPool

func (*MergeRowPool) GetCell

func (p *MergeRowPool) GetCell(row, col, subrow int) *TableCell

func (*MergeRowPool) IsTextAtCellDifferentFromBase

func (p *MergeRowPool) IsTextAtCellDifferentFromBase(row, col, layer int) bool

func (*MergeRowPool) RefreshRow

func (p *MergeRowPool) RefreshRow(row int)

func (*MergeRowPool) SetCell

func (p *MergeRowPool) SetCell(row, col int, s string, unresolved bool)

type MergeTable

type MergeTable struct {
	*SelectableTable
	// contains filtered or unexported fields
}

func NewMergeTable

func NewMergeTable(buf *diff.BlockBuffer, commitNames []string, commitSums [][]byte, cd *diff.ColDiff, merges []*merge.Merge, removedCols map[int]struct{}, removedRows map[int]struct{}) *MergeTable

func (*MergeTable) GetCellText

func (t *MergeTable) GetCellText(row, column, subrow int) string

func (*MergeTable) GetSelection

func (t *MergeTable) GetSelection() (row, subRow, column int)

func (*MergeTable) InputHandler

func (t *MergeTable) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

func (*MergeTable) RefreshRow

func (t *MergeTable) RefreshRow(row int) *MergeTable

func (*MergeTable) Select

func (t *MergeTable) Select(row, column int)

func (*MergeTable) SetAbortHandler

func (t *MergeTable) SetAbortHandler(f func()) *MergeTable

func (*MergeTable) SetCell

func (t *MergeTable) SetCell(row, column int, val string, unresolved bool)

func (*MergeTable) SetDeleteColumnHandler

func (t *MergeTable) SetDeleteColumnHandler(f func(column int)) *MergeTable

func (*MergeTable) SetDeleteRowHandler

func (t *MergeTable) SetDeleteRowHandler(f func(row int)) *MergeTable

func (*MergeTable) SetFinishHandler

func (t *MergeTable) SetFinishHandler(f func()) *MergeTable

func (*MergeTable) SetRedoHandler

func (t *MergeTable) SetRedoHandler(f func()) *MergeTable

func (*MergeTable) SetResolveHandler

func (t *MergeTable) SetResolveHandler(f func(row int)) *MergeTable

func (*MergeTable) SetSelectNextConflict

func (t *MergeTable) SetSelectNextConflict(f func()) *MergeTable

func (*MergeTable) SetSetCellHandler

func (t *MergeTable) SetSetCellHandler(f func(row, column, layer int)) *MergeTable

func (*MergeTable) SetShowInputHandler

func (t *MergeTable) SetShowInputHandler(f func(row, column int)) *MergeTable

func (*MergeTable) SetUndoHandler

func (t *MergeTable) SetUndoHandler(f func()) *MergeTable

func (*MergeTable) SetUnresolveHandler

func (t *MergeTable) SetUnresolveHandler(f func(row int)) *MergeTable

type PaginatedTextView

type PaginatedTextView struct {
	*tview.TextView
	// contains filtered or unexported fields
}

func NewPaginatedTextView

func NewPaginatedTextView() *PaginatedTextView

func (*PaginatedTextView) PullText

func (v *PaginatedTextView) PullText() error

func (*PaginatedTextView) SetChangedFunc

func (v *PaginatedTextView) SetChangedFunc(handler func()) *PaginatedTextView

func (*PaginatedTextView) SetDynamicColors

func (v *PaginatedTextView) SetDynamicColors(dynamic bool) *PaginatedTextView

func (*PaginatedTextView) SetPullText

func (v *PaginatedTextView) SetPullText(f func() ([]byte, error)) *PaginatedTextView

func (*PaginatedTextView) Write

func (v *PaginatedTextView) Write(p []byte) (n int, err error)

type PreviewTable

type PreviewTable struct {
	*DataTable
	// contains filtered or unexported fields
}

func NewPreviewTable

func NewPreviewTable(rowReader diff.RowReader, rowCount int, columns []string, primaryKeyIndices []uint32) *PreviewTable

func (*PreviewTable) SetRowCount

func (t *PreviewTable) SetRowCount(num int) *PreviewTable

type ProgressBar

type ProgressBar struct {
	*tview.TextView
	// contains filtered or unexported fields
}

func NewProgressBar

func NewProgressBar(desc string) *ProgressBar

func (*ProgressBar) Draw

func (b *ProgressBar) Draw(screen tcell.Screen)

func (*ProgressBar) SetCurrent

func (b *ProgressBar) SetCurrent(num int64) *ProgressBar

func (*ProgressBar) SetTotal

func (b *ProgressBar) SetTotal(num int64) *ProgressBar

type SelectableTable

type SelectableTable struct {
	*VirtualTable
	// contains filtered or unexported fields
}

SelectableTable add following behaviors on top of VirtualTable: - Allow selecting cell and row (by selecting row number cell) - Define default selected style

func NewSelectableTable

func NewSelectableTable() *SelectableTable

func (*SelectableTable) Draw

func (t *SelectableTable) Draw(screen tcell.Screen)

func (*SelectableTable) GetSelection

func (t *SelectableTable) GetSelection() (row int, column int, subColumn int)

func (*SelectableTable) InputHandler

func (t *SelectableTable) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

func (*SelectableTable) MouseHandler

func (t *SelectableTable) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*SelectableTable) Select

func (t *SelectableTable) Select(row, column, subCol int) *SelectableTable

Select sets the selected cell. Depending on the selection settings specified via SetSelectable(), this may be an entire row or column, or even ignored completely. The "selection changed" event is fired if such a callback is available (even if the selection ends up being the same as before and even if cells are not selectable).

func (*SelectableTable) SetGetCellsFunc

func (t *SelectableTable) SetGetCellsFunc(getCells func(row, column int) []*TableCell) *SelectableTable

SetGetCellsFunc set function to get table cell at a position

func (*SelectableTable) SetMinSelection

func (t *SelectableTable) SetMinSelection(row, column int) *SelectableTable

SetMinSelection tells table to prevent selection from going below certain index

func (*SelectableTable) SetSelectedFunc

func (t *SelectableTable) SetSelectedFunc(handler func(row, column, subColumn int)) *SelectableTable

SetSelectedFunc sets a handler which is called whenever the user presses the Enter key on a selected cell/row/column. The handler receives the position of the selection and its cell contents. If entire rows are selected, the column index is undefined. Likewise for entire columns.

func (*SelectableTable) SetSelectionChangedFunc

func (t *SelectableTable) SetSelectionChangedFunc(handler func()) *SelectableTable

func (*SelectableTable) WrapInputHandler

func (t *SelectableTable) WrapInputHandler(f func(event *tcell.EventKey, setFocus func(p tview.Primitive)) bool) func(event *tcell.EventKey, setFocus func(p tview.Primitive))

type TabPages

type TabPages struct {
	*tview.Flex
	// contains filtered or unexported fields
}

func NewTabPages

func NewTabPages(app *tview.Application) *TabPages

func (*TabPages) AddTab

func (p *TabPages) AddTab(label string, item tview.Primitive) *TabPages

func (*TabPages) Draw

func (p *TabPages) Draw(screen tcell.Screen)

func (*TabPages) LastTab

func (p *TabPages) LastTab() tview.Primitive

func (*TabPages) ProcessInput

func (p *TabPages) ProcessInput(event *tcell.EventKey) *tcell.EventKey

func (*TabPages) SetLabel

func (p *TabPages) SetLabel(item tview.Primitive, label string) error

type TableCell

type TableCell struct {
	// The text to be displayed in the table cell.
	Text string

	// The alignment of the cell text. One of AlignLeft (default), AlignCenter,
	// or AlignRight.
	Align int

	// The maximum width of the cell in screen space. This is used to give a
	// column a maximum width. Any cell text whose screen width exceeds this width
	// is cut off. Set to 0 if there is no maximum width.
	MaxWidth int

	// If the total table width is less than the available width, this value is
	// used to add extra width to a column. See SetExpansion() for details.
	Expansion int

	// If set to true, the BackgroundColor is not used and the cell will have
	// the background color of the table.
	Transparent bool

	// The style attributes of the cell.
	Attributes tcell.AttrMask

	// An optional handler for mouse clicks.
	Clicked func() bool
	// contains filtered or unexported fields
}

TableCell represents one cell inside a Table.

func NewTableCell

func NewTableCell(text string) *TableCell

func (*TableCell) BackgroundColor

func (c *TableCell) BackgroundColor() tcell.Color

func (*TableCell) Color

func (c *TableCell) Color() tcell.Color

func (*TableCell) DisableTransparency

func (c *TableCell) DisableTransparency(disable bool) *TableCell

func (*TableCell) FlipStyle

func (c *TableCell) FlipStyle() *TableCell

func (*TableCell) GetPosition

func (c *TableCell) GetPosition() (x, y, width int)

GetPosition returns the position of the table cell on screen. If the cell is not on screen, the return values are

func (*TableCell) Reset added in v0.8.0

func (c *TableCell) Reset()

func (*TableCell) SetAlign

func (c *TableCell) SetAlign(align int) *TableCell

SetAlign sets the cell's text alignment, one of AlignLeft, AlignCenter, or AlignRight.

func (*TableCell) SetAttributes

func (c *TableCell) SetAttributes(attr tcell.AttrMask) *TableCell

SetAttributes sets the cell's text attributes. You can combine different attributes using bitmask operations:

cell.SetAttributes(tcell.AttrUnderline | tcell.AttrBold)

func (*TableCell) SetBackgroundColor

func (c *TableCell) SetBackgroundColor(color tcell.Color) *TableCell

SetBackgroundColor sets the cell's background color. This will also cause the cell's Transparent flag to be set to "false".

func (*TableCell) SetClickedFunc

func (c *TableCell) SetClickedFunc(clicked func() bool) *TableCell

SetClickedFunc sets a handler which fires when this cell is clicked.

func (*TableCell) SetExpansion

func (c *TableCell) SetExpansion(expansion int) *TableCell

SetExpansion sets the value by which the column of this cell expands if the available width for the table is more than the table width (prior to applying this expansion value). This is a proportional value. The amount of unused horizontal space is divided into widths to be added to each column. How much extra width a column receives depends on the expansion value: A value of 0 (the default) will not cause the column to increase in width. Other values are proportional, e.g. a value of 2 will cause a column to grow by twice the amount of a column with a value of 1.

Since this value affects an entire column, the maximum over all visible cells in that column is used.

This function panics if a negative value is provided.

func (*TableCell) SetFlipped

func (c *TableCell) SetFlipped(s bool) *TableCell

SetFlipped sets the flipped state of cell. When a cell is in flipped state, it returns cell.color as background color and vice versa.

func (*TableCell) SetMaxWidth

func (c *TableCell) SetMaxWidth(maxWidth int) *TableCell

SetMaxWidth sets maximum width of the cell in screen space. This is used to give a column a maximum width. Any cell text whose screen width exceeds this width is cut off. Set to 0 if there is no maximum width.

func (*TableCell) SetPosition

func (c *TableCell) SetPosition(x, y, width int) *TableCell

SetPosition sets position on screen for table cell.

func (*TableCell) SetStyle

func (c *TableCell) SetStyle(style tcell.Style) *TableCell

SetStyle sets the cell's style (foreground color, background color, and attributes) all at once.

func (*TableCell) SetText

func (c *TableCell) SetText(text string) *TableCell

SetText sets the cell's text.

func (*TableCell) SetTextColor

func (c *TableCell) SetTextColor(color tcell.Color) *TableCell

SetTextColor sets the cell's text color.

func (*TableCell) SetTransparency

func (c *TableCell) SetTransparency(transparent bool) *TableCell

SetTransparency sets the background transparency of this cell. A value of "true" will cause the cell to use the table's background color. A value of "false" will cause it to use its own background color.

type UsageBar

type UsageBar struct {
	*tview.TextView
	// contains filtered or unexported fields
}

func DataTableUsage

func DataTableUsage() *UsageBar

func NewUsageBar

func NewUsageBar(entries [][2]string, margin int) *UsageBar

func (*UsageBar) BeforeDraw

func (b *UsageBar) BeforeDraw(screen tcell.Screen, flex *tview.Flex)

type VirtualTable

type VirtualTable struct {
	*tview.Box
	// contains filtered or unexported fields
}

func NewVirtualTable

func NewVirtualTable() *VirtualTable

func (*VirtualTable) Draw

func (t *VirtualTable) Draw(screen tcell.Screen)

Draw draws this primitive onto the screen.

func (*VirtualTable) GetOffset

func (t *VirtualTable) GetOffset() (row, column int)

GetOffset returns the current row and column offset. This indicates how many rows and columns the table is scrolled down and to the right.

func (*VirtualTable) GetShape

func (t *VirtualTable) GetShape() (rowCount, columnCount int)

GetShape get number of rows and number of columns

func (*VirtualTable) InputHandler

func (t *VirtualTable) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive))

InputHandler returns the handler for this primitive.

func (*VirtualTable) KeepColumnInView

func (t *VirtualTable) KeepColumnInView(column int) *VirtualTable

func (*VirtualTable) MouseHandler

func (t *VirtualTable) MouseHandler() func(action tview.MouseAction, event *tcell.EventMouse, setFocus func(p tview.Primitive)) (consumed bool, capture tview.Primitive)

MouseHandler returns the mouse handler for this primitive.

func (*VirtualTable) ScrollToBeginning

func (t *VirtualTable) ScrollToBeginning() *VirtualTable

ScrollToBeginning scrolls the table to the beginning to that the top left corner of the table is shown.

func (*VirtualTable) ScrollToEnd

func (t *VirtualTable) ScrollToEnd() *VirtualTable

ScrollToEnd scrolls the table to the beginning to that the bottom left corner of the table is shown. Adding more rows to the table will cause it to automatically scroll with the new data.

func (*VirtualTable) SetBorders

func (t *VirtualTable) SetBorders(show bool) *VirtualTable

SetBorders sets whether or not each cell in the table is surrounded by a border.

func (*VirtualTable) SetBordersColor

func (t *VirtualTable) SetBordersColor(color tcell.Color) *VirtualTable

SetBordersColor sets the color of the cell borders.

func (*VirtualTable) SetDoneFunc

func (t *VirtualTable) SetDoneFunc(handler func(key tcell.Key)) *VirtualTable

SetDoneFunc sets a handler which is called whenever the user presses the Escape, Tab, or Backtab key.

func (*VirtualTable) SetFixed

func (t *VirtualTable) SetFixed(rows, columns int) *VirtualTable

SetFixed sets the number of fixed rows and columns which are always visible even when the rest of the cells are scrolled out of view. Rows are always the top-most ones. Columns are always the left-most ones.

func (*VirtualTable) SetGetCellsFunc

func (t *VirtualTable) SetGetCellsFunc(getCell func(row, column int) []*TableCell) *VirtualTable

SetGetCellsFunc set function to get table cell at a position

func (*VirtualTable) SetOffset

func (t *VirtualTable) SetOffset(row, column int) *VirtualTable

SetOffset sets how many rows and columns should be skipped when drawing the table. This is useful for large tables that do not fit on the screen.

Fixed rows and columns are never skipped.

func (*VirtualTable) SetOnVisibleCellsChangeFunc added in v0.8.0

func (t *VirtualTable) SetOnVisibleCellsChangeFunc(handler func(rows, columns []int)) *VirtualTable

func (*VirtualTable) SetSeparator

func (t *VirtualTable) SetSeparator(separator rune) *VirtualTable

SetSeparator sets the character used to fill the space between two neighboring cells. This is a space character ' ' per default but you may want to set it to Borders.Vertical (or any other rune) if the column separation should be more visible. If cell borders are activated, this is ignored.

Separators have the same color as borders.

func (*VirtualTable) SetShape

func (t *VirtualTable) SetShape(rowCount, columnCount int) *VirtualTable

SetShape sets total number of rows and columns

func (*VirtualTable) SetSubSeparator added in v0.8.0

func (t *VirtualTable) SetSubSeparator(separator rune) *VirtualTable

SetSubSeparator sets the character used to fill the space between two sub cells. This is a space character ' ' per default but you may want to set it to Borders.Vertical (or any other rune) if the column separation should be more visible. If cell borders are activated, this is ignored.

Separators have the same color as borders.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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