srcview

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: 7 Imported by: 0

Documentation

Overview

Package srcview is a linked source's tab: a window of the source's rows drawn as a sheet with a frozen header row, the row numbers and a scrollbar over the whole source, however many millions of rows it has. The rows come from the Host a page at a time as the window moves (paged.Pages); rows on their way show as a dim ellipsis. The view owns the active cell and the scroll; the UI owns the rest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name   string
	Format sheet.Format
}

Column is one of the source's columns.

type Hit

type Hit struct {
	Row      int64
	Col      int
	Cell     bool
	Bar      bool
	BarLines int // how many lines the scrollbar has, for ScrollBar
	BarAt    int // the line of the scrollbar hit
}

Hit is what the screen position x, y of the view is: a cell (its row and column), the scrollbar, or nothing.

type Host

type Host interface {
	Theme() *theme.Theme
	Locale() *locale.Locale
	// Columns are the source's columns, left to right.
	Columns() []Column
	// Rows counts the rows the tab shows, false while they're being
	// counted (a sort or a filter being applied).
	Rows() (int64, bool)
	// Row is the tab's row i: its number in the source, counting from
	// 0, and its values, false while its page is on its way.
	Row(i int64) (int64, []sheet.LiveCell, bool)
	// Want asks for the rows from through to.
	Want(from, to int64)
}

Host is what the view needs of the UI.

type View

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

View is a source's tab.

func New

func New(h Host) *View

New is a view of what h shows.

func (*View) Active

func (v *View) Active() (int64, int)

Active is the active cell: its row among the tab's, its column.

func (*View) Cell

func (v *View) Cell() (int64, sheet.LiveCell, bool)

Cell is the active cell's number in the source and value, with false while its row is on its way.

func (*View) ColX

func (v *View) ColX(col int) int

ColX is the screen column column col starts at, from the view's left edge: the row numbers' width when it isn't shown.

func (*View) DragBar

func (v *View) DragBar(y int)

DragBar moves the window to where the scrollbar's line at y (from the view's first line) stands for, as the thumb is dragged.

func (*View) Draw

func (v *View) Draw() []string

Draw draws the view's lines: the column letters, the header row of the columns' names, the divider under it, then the rows, the scrollbar at the right edge. It asks the host for the rows shown and a page either side, so scrolling finds them read.

func (*View) HitAt

func (v *View) HitAt(x, y int) Hit

HitAt says what x, y (from the view's first line) is.

func (*View) Key

func (v *View) Key(k tea.KeyPressMsg) bool

Key moves the active cell as a sheet's keys do, reporting whether the key was the view's: the arrows, Page Up and Down, Home and End, and with Ctrl the data's edges, which on a source are its first and last rows and columns.

func (*View) Lines

func (v *View) Lines() int

Lines are how many rows show.

func (*View) Move

func (v *View) Move(rows int64, cols int)

Move moves the active cell by rows and cols, keeping it in the window.

func (*View) MoveTo

func (v *View) MoveTo(row int64, col int)

MoveTo makes row and col the active cell, row -1 meaning the last.

func (*View) Prefetch

func (v *View) Prefetch()

Prefetch asks for the rows shown and a window's worth either side, so scrolling finds them read.

func (*View) Refit

func (v *View) Refit()

Refit sizes the columns again once rows are read, as when the source is read again.

func (*View) Reset

func (v *View) Reset()

Reset goes back to the first row, as when the rows are sorted or filtered again.

func (*View) Resize

func (v *View) Resize(width, height int)

Resize gives the view width columns and height lines.

func (*View) Scroll

func (v *View) Scroll(d int64)

Scroll moves the window d rows, leaving the active cell where it is unless it would leave the window.

func (*View) ScrollBar

func (v *View) ScrollBar(at, lines int)

ScrollBar moves the window to where line at of a scrollbar of lines lines stands for: a click on the track, or the thumb dragged there.

func (*View) ScrollTo

func (v *View) ScrollTo(top int64)

ScrollTo shows the rows from top on.

func (*View) Top

func (v *View) Top() int64

Top is the first row shown.

Jump to

Keyboard shortcuts

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