sortbar

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package sortbar is the bar that picks the columns and order to sort a range by, as Sheets' "Advanced range sorting options" dialog, on the context line. It shows each sort column as a chip; arrows change the focused one, and the model highlights the range being sorted with the sort column's header lit. It knows the UI only through Host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OrderName

func OrderName(desc bool) string

OrderName is a sort order as the bar and notes show it.

Types

type Bar

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

Bar is the sort bar over a range.

func New

func New(h Host, rng sheet.Rect, headers, col int) *Bar

New returns a bar sorting rng, whose first headers rows are headers, by column col.

func (*Bar) Active

func (b *Bar) Active() sheet.Addr

Active is the cell drawn as active while the bar is open: the top of the focused sort column, so its header lights up.

func (*Bar) Answer

func (b *Bar) Answer(text string) (tea.Cmd, error)

Answer makes the choices a macro recorded (see answerJSON) and sorts, as if they were picked and Enter pressed.

func (*Bar) ContextLine

func (b *Bar) ContextLine() (string, string)

ContextLine renders the bar for the context line.

func (*Bar) Data

func (b *Bar) Data() sheet.Rect

Data is the range the sort moves: the range without its headers.

func (*Bar) Indicator

func (b *Bar) Indicator() string

func (*Bar) Key

func (b *Bar) Key(k tea.KeyPressMsg) tea.Cmd

func (*Bar) Layout

func (b *Bar) Layout() []overlay.Box

func (*Bar) Mouse

func (b *Bar) Mouse(e overlay.MouseEvent) tea.Cmd

Mouse focuses a key's chip (a second click flips its order) or flips the header row toggle; a click anywhere else cancels.

func (*Bar) Status

func (b *Bar) Status() (string, string)

Status shows the keys, the most useful ones first on narrow screens.

type Host

type Host interface {
	Theme() *theme.Theme
	Size() (width, height int)
	// Sheet is the sheet sorted, for the headers' text.
	Sheet() *sheet.Sheet
	// Close closes the open overlay.
	Close()
	// Sort sorts data by keys, after the bar has closed. answer is the
	// bar's choices as a macro records them, the answer Answer takes.
	Sort(data sheet.Rect, keys []sheet.SortKey, answer string) tea.Cmd
}

Host is what the sort bar needs of the UI.

Jump to

Keyboard shortcuts

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