rules

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package rules is the side panel for a sheet's rules, as Sheets' Conditional formatting and Data validation sidebars: a list of the rules, and a form to add or edit one. It is docked at the right of the grid in the manner of lazygit's panels, and knows the UI only through Host.

Index

Constants

View Source
const GridTop = 4

GridTop is the first screen row of the grid, under the control panel and the column headers.

View Source
const ID = "rules"

ID identifies the panel's box in mouse events.

Variables

This section is empty.

Functions

This section is empty.

Types

type Editor

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

Editor is the rules panel.

func Formats

func Formats(h Host) *Editor

Formats opens the panel on the sheet's conditional formats.

func Validations

func Validations(h Host) *Editor

Validations opens the panel on the sheet's data validation.

func (*Editor) Add

func (e *Editor) Add(dropdown bool) *Editor

Add opens the form for a new rule over the selection, as Insert > Dropdown and a new rule do; with dropdown, a dropdown list.

func (*Editor) Changed

func (e *Editor) Changed()

Changed keeps what's typed in the picked text row.

func (*Editor) Cursor

func (e *Editor) Cursor() (int, int)

Cursor is the caret in a text row being typed into.

func (*Editor) Indicator

func (e *Editor) Indicator() string

func (*Editor) Key

func (e *Editor) Key(k tea.KeyPressMsg) tea.Cmd

func (*Editor) Layout

func (e *Editor) Layout() []overlay.Box

func (*Editor) Mouse

func (e *Editor) Mouse(ev overlay.MouseEvent) tea.Cmd

func (*Editor) Status

func (e *Editor) Status() (string, string)

type Host

type Host interface {
	Theme() *theme.Theme
	Size() (width, height int)
	// Line is the shared edit line text rows are typed in.
	Line() *lineedit.Line
	// Close closes the open overlay.
	Close()
	// Sheet is the sheet whose rules are edited.
	Sheet() *sheet.Sheet
	// Selection is the range a new rule applies to.
	Selection() sheet.Rect
	// SaveFormat and SaveValidation store rule i (-1 adds one), as the
	// commands macros record do, reporting why they couldn't.
	SaveFormat(i int, f sheet.CondFormat) error
	SaveValidation(i int, v sheet.Validation) error
	// Reworked follows a rule removed or moved: the file is modified,
	// and a macro being recorded records the command id that does the
	// same, answered with answer.
	Reworked(id, answer string)
	// Slot is the terminal's color for an ANSI slot, for color scales.
	Slot(i int) color.Color
}

Host is what the rules panel needs of the UI.

Jump to

Keyboard shortcuts

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