lib

package
v1.5.12 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: GPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// header+footer
	ExtraRows = 5

	HelpFooter = "?:help | "
)
View Source
const RWRR = 0755

Variables

View Source
var (

	// Cells in selected columns will be highlighted
	StyleSelected = lipgloss.NewStyle().
					Background(lipgloss.Color("#696969")).
					Foreground(lipgloss.Color("#ffffff")).
					Align(lipgloss.Left)

	StyleHeader = lipgloss.NewStyle().
				Foreground(lipgloss.Color("#ff4500")).
				Align(lipgloss.Left).Bold(true)

	// help buffer styles
	StyleKey  = lipgloss.NewStyle().Bold(true)
	StyleHelp = lipgloss.NewStyle().Foreground(lipgloss.Color("#ff4500"))

	// the default style
	NoStyle = lipgloss.NewStyle().Align(lipgloss.Left)

	HelpData = []HelpColumn{
		{
			HelpLine{"up", "navigate up"},
			HelpLine{"down", "navigate down"},
			HelpLine{"tab", "navigate columns"},
		},
		{
			HelpLine{"s", "sort alpha-numerically"},
			HelpLine{"n", "sort numerically"},
			HelpLine{"t", "sort by time"},
			HelpLine{"d", "sort by duration"},
		},
		{
			HelpLine{"spc", "[de]select a row"},
			HelpLine{"a", "[de]select all visible rows"},
			HelpLine{"f", "enter fuzzy filter"},
			HelpLine{"esc", "finish filter input"},
		},
		{
			HelpLine{"?", "show help buffer"},
			HelpLine{"q", "commit and quit"},
			HelpLine{"c-c", "discard and quit"},
		},
	}

	// rendered from Help above
	Help = ""

	// number of lines taken by help below, adjust accordingly!
	HelpRows = 0
)

Functions

func CellController

func CellController(input table.StyledCellFuncInput, m FilterTable) lipgloss.Style

Applied to every cell on every change (TAB,up,down key, resize event etc)

func Exists

func Exists[K comparable, V any](m map[K]V, v K) bool

generic map.Exists(key)

func FilterByPattern

func FilterByPattern(conf cfg.Config, input io.Reader) (io.Reader, error)

* Filters the whole input lines, returns filtered lines

func Pager

func Pager(title, message string)

func PrepareColumnVars

func PrepareColumnVars(columns string, data *Tabdata) ([]int, error)

func PrepareColumns

func PrepareColumns(conf *cfg.Config, data *Tabdata) error

parse columns list given with -c, modifies config.UseColumns based on eventually given regex. This is an output filter, because -cN,N,... is being applied AFTER processing of the input data.

func PrepareSortColumns

func PrepareSortColumns(conf *cfg.Config, data *Tabdata) error

output option, prepare -k1,2 sort fields

func PrepareTransposerColumns

func PrepareTransposerColumns(conf *cfg.Config, data *Tabdata) error

Same thing as above but for -T option, which is an input option, because transposers are being applied before output.

func ProcessFiles

func ProcessFiles(conf *cfg.Config, args []string) error

func SetHeaders

func SetHeaders(conf cfg.Config, headers []string) []string

* Setup headers, given headers might be usable headers or just the * first row, which we use to determine how many headers to generate, * if enabled.

func ValidateConsistency

func ValidateConsistency(data *Tabdata) error

validate the consitency of parsed data

Types

type Context

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

The context exists outside of the bubble loop, and is being used as pointer reciever. That way we can use it as our primary storage container.

func (*Context) Sort

func (ctx *Context) Sort(mode string)

Execute tablizer sort function, feed it with fresh config, we do NOT use the existing runtime config, because sorting is configurable in the UI separately.

type Doc

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

func (Doc) Init

func (m Doc) Init() tea.Cmd

func (Doc) Update

func (m Doc) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Doc) View

func (m Doc) View() string

type FilterTable

type FilterTable struct {
	Table table.Model

	Rows int
	// contains filtered or unexported fields
}

The actual table model, holds the context pointer, a copy of the pre-processed data and some flags

func NewModel

func NewModel(data *Tabdata, ctx *Context) FilterTable

initializes the table model

func (FilterTable) Init

func (m FilterTable) Init() tea.Cmd

func (*FilterTable) SelectNextColumn

func (m *FilterTable) SelectNextColumn()

User hit the TAB key

func (*FilterTable) Sort

func (m *FilterTable) Sort(mode string)

Forward call to context sort

func (*FilterTable) ToggleAllSelected

func (m *FilterTable) ToggleAllSelected()

Selects or deselects ALL rows

func (FilterTable) ToggleHelp

func (m FilterTable) ToggleHelp()

? pressed, display help message

func (FilterTable) Update

func (m FilterTable) Update(msg tea.Msg) (tea.Model, tea.Cmd)

Part of the bubbletea event loop, called every tick

func (FilterTable) View

func (m FilterTable) View() string

Part of the bubbletable event view, called every tick

type HelpColumn

type HelpColumn []HelpLine

type HelpLine

type HelpLine []string

type Tabdata

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

contains a whole parsed table

func FilterByFields

func FilterByFields(conf cfg.Config, data *Tabdata) (*Tabdata, bool, error)

* Filter parsed data by fields. The filter is positive, so if one or * more filters match on a row, it will be kept, otherwise it will be * excluded.

func Parse

func Parse(conf cfg.Config, input io.Reader) (Tabdata, error)

Parser switch

func PostProcess

func PostProcess(conf cfg.Config, data *Tabdata) (*Tabdata, bool, error)

func TransposeFields

func TransposeFields(conf cfg.Config, data *Tabdata) (*Tabdata, bool, error)

* Transpose fields using search/replace regexp.

func (*Tabdata) CloneEmpty

func (data *Tabdata) CloneEmpty() Tabdata

func (*Tabdata) ToMap

func (data *Tabdata) ToMap() []map[string]any

convert our internal data to a list of maps

Jump to

Keyboard shortcuts

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