ui

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Completion-schema plumbing for the app: CompletionSchema assembles the query.Schema the SQL completer works from, WarmCompletionSchema fills the live-connection side of it off the update loop.

Package ui celledit holds the commit helpers for single-cell edits and row deletes. In database mode it builds and runs UPDATE/DELETE statements keyed on the table's primary key; in file mode it rewrites the frame in place through WithCell/WithoutRows and pushes the new frame.

Index

Constants

View Source
const (
	ActUp           = "up"
	ActDown         = "down"
	ActLeft         = "left"
	ActRight        = "right"
	ActTop          = "top"
	ActBottom       = "bottom"
	ActHalfUp       = "half-up"
	ActHalfDown     = "half-down"
	ActPageUp       = "page-up"
	ActPageDown     = "page-down"
	ActFirstCol     = "first-col"
	ActLastCol      = "last-col"
	ActSheet        = "sheet"
	ActExpand       = "expand"
	ActInfo         = "info"
	ActRandom       = "random"
	ActGoto         = "goto"
	ActFuzzy        = "fuzzy-search"
	ActExact        = "exact-search"
	ActPalette      = "palette"
	ActTabSwitch    = "tab-switch"
	ActPrevTab      = "prev-tab"
	ActNextTab      = "next-tab"
	ActPop          = "pop"
	ActQuit         = "quit"
	ActHelp         = "help"
	ActCopy         = "copy"
	ActCopyCell     = "copy-cell"
	ActCopyRow      = "copy-row"
	ActSheetUp      = "sheet-up"
	ActSheetDown    = "sheet-down"
	ActBack         = "back"
	ActEscBack      = "esc-back"
	ActEdit         = "edit"
	ActRefresh      = "refresh"
	ActDelete       = "delete"
	ActToggleSelect = "toggle-select"
	ActSheetFilter  = "sheet-filter"
	ActJsonView     = "json-view"
	ActNextPage     = "next-page"
	ActPrevPage     = "prev-page"
	ActColFocus     = "col-focus"
	ActOobeCols     = "oobe-cols"
)

Semantic action names.

Variables

View Source
var Factories = map[string]func(ctx AppContext, arg string) (Overlay, error){}

Factories maps command names to overlay constructors. Popup packages register themselves here from init(). A factory may return (nil, nil) for pure side-effect commands that need no overlay.

View Source
var GlobalBindings = []Binding{
	{Keys: []string{"Q", "shift+q"}, Action: ActQuit, Help: "quit"},
	{Keys: []string{"f1", "?"}, Action: ActHelp, Help: "help overlay"},
	{Keys: []string{":"}, Action: ActPalette, Help: "command palette"},
	{Keys: []string{"t"}, Action: ActTabSwitch, Help: "tab switcher"},
	{Keys: []string{"H", "shift+h", "shift+left"}, Action: ActPrevTab, Help: "previous tab"},
	{Keys: []string{"L", "shift+l", "shift+right"}, Action: ActNextTab, Help: "next tab"},
}

GlobalBindings apply in every non-overlay mode.

View Source
var SheetBindings = []Binding{
	{Keys: []string{"down", "j"}, Action: ActSheetDown, Help: "next field"},
	{Keys: []string{"up", "k"}, Action: ActSheetUp, Help: "prev field"},
	{Keys: []string{"shift+down", "J", "shift+j"}, Action: ActSheetDown, Help: "next field"},
	{Keys: []string{"shift+up", "K", "shift+k"}, Action: ActSheetUp, Help: "prev field"},
	{Keys: []string{"c"}, Action: ActCopy, Help: "copy row"},
	{Keys: []string{"e"}, Action: ActEdit, Help: "edit field"},
	{Keys: []string{"r"}, Action: ActJsonView, Help: "view as JSON"},
	{Keys: []string{"/"}, Action: ActSheetFilter, Help: "filter fields"},
	{Keys: []string{"q", "esc"}, Action: ActBack, Help: "back to table"},
}

SheetBindings apply in sheet mode.

View Source
var TableBindings = []Binding{
	{Keys: []string{"up", "k"}, Action: ActUp, Help: "row up"},
	{Keys: []string{"down", "j"}, Action: ActDown, Help: "row down"},
	{Keys: []string{"left", "h"}, Action: ActLeft, Help: "previous column"},
	{Keys: []string{"right", "l"}, Action: ActRight, Help: "next column"},
	{Keys: []string{"g", "home"}, Action: ActTop, Help: "first row"},
	{Keys: []string{"G", "shift+g", "end"}, Action: ActBottom, Help: "last row"},
	{Keys: []string{"ctrl+u"}, Action: ActHalfUp, Help: "half page up"},
	{Keys: []string{"ctrl+j"}, Action: ActHalfDown, Help: "half page down"},
	{Keys: []string{"pgup", "ctrl+b"}, Action: ActPageUp, Help: "page up"},
	{Keys: []string{"pgdown", "ctrl+f"}, Action: ActPageDown, Help: "page down"},
	{Keys: []string{"_"}, Action: ActFirstCol, Help: "first column"},
	{Keys: []string{"$"}, Action: ActLastCol, Help: "last column"},
	{Keys: []string{"enter"}, Action: ActSheet, Help: "open row sheet"},
	{Keys: []string{"w"}, Action: ActExpand, Help: "toggle fit/wide columns"},
	{Keys: []string{"i"}, Action: ActInfo, Help: "table info"},
	{Keys: []string{"R", "shift+r"}, Action: ActRandom, Help: "random row"},
	{Keys: []string{"r"}, Action: ActRefresh, Help: "refresh data"},
	{Keys: []string{"1", "2", "3", "4", "5", "6", "7", "8", "9"}, Action: ActGoto, Help: "go to row"},
	{Keys: []string{"y"}, Action: ActCopyCell, Help: "copy current cell"},
	{Keys: []string{"Y", "shift+y"}, Action: ActCopyRow, Help: "copy row (tab-separated)"},
	{Keys: []string{"/"}, Action: ActFuzzy, Help: "fuzzy search"},
	{Keys: []string{"s"}, Action: ActExact, Help: "exact search"},
	{Keys: []string{"q"}, Action: ActPop, Help: "pop frame / close tab"},
	{Keys: []string{"esc"}, Action: ActEscBack, Help: "back / previous level"},
	{Keys: []string{"ctrl+d"}, Action: ActDelete, Help: "delete row(s)"},
	{Keys: []string{"space"}, Action: ActToggleSelect, Help: "toggle select"},
	{Keys: []string{">"}, Action: ActNextPage, Help: "next page"},
	{Keys: []string{"<"}, Action: ActPrevPage, Help: "prev page"},
	{Keys: []string{"z"}, Action: ActColFocus, Help: "zoom current column (h/l to scroll)"},
	{Keys: []string{"v"}, Action: ActOobeCols, Help: "select display columns (OpenObserve)"},
}

TableBindings apply in table mode.

Functions

func Box

func Box(title, content string, w int, th *theme.Theme) string

Box frames content in a rounded border of total width w, with the title embedded in the top edge. Content lines are truncated/padded to fit.

func CloseOverlay

func CloseOverlay() tea.Msg

CloseOverlay is a convenience command that emits CloseOverlayMsg.

func Composite

func Composite(base, box string, w, h int) string

Composite centers box over base within a w x h area, splicing the box into the base line by line. Both strings may contain ANSI escapes; splicing is width-aware. Base lines are padded (with spaces) to w and the base is padded to h lines so the overlay always lands where expected.

func FillPage

func FillPage(box string, w, h int) string

FillPage centers box within a blank w x h area: every line is padded to exactly w cells and the area to exactly h lines, so a fullscreen page overlay lets nothing from the view behind it show through.

func FilterLine

func FilterLine(filter string, filtering bool, width int, hint string, th *theme.Theme) string

FilterLine renders the unified filter input line used across all views. When !filtering && filter=="" the caller should skip rendering this line. Hint is the placeholder text shown when filtering but no text typed yet.

func HighlightPad

func HighlightPad(s, needle string, w int, matchStyle, baseStyle lipgloss.Style) string

HighlightPad is like padLine but uses HighlightSubstr on the content before padding. The returned string already contains ANSI codes so ansi.StringWidth must be used (not len) when measuring it.

func HighlightRunes

func HighlightRunes(s string, indices []int, matchStyle, baseStyle lipgloss.Style) string

HighlightRunes wraps the rune positions listed in indices with matchStyle; all other runes use baseStyle. Indices must be valid 0-based rune positions in s.

func HighlightSubstr

func HighlightSubstr(s, needle string, matchStyle, baseStyle lipgloss.Style) string

HighlightSubstr finds all case-insensitive occurrences of needle in s and wraps them with matchStyle; surrounding text uses baseStyle. Returns baseStyle.Render(s) when needle is empty or not found.

func Run

func Run(app *App) error

Run drives the app to completion on the terminal.

Types

type App

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

App is the root model: tabs of panes, an overlay stack, the search bar and the bottom status line.

func New

func New(opts Options) *App

New builds the app from options. Each frame becomes a tab.

func (*App) ActivePaneID

func (a *App) ActivePaneID() int

func (*App) ActiveTab

func (a *App) ActiveTab() int

func (*App) Backend

func (a *App) Backend() db.Backend

func (*App) BaseCrumb

func (a *App) BaseCrumb() string

func (*App) ColumnNames

func (a *App) ColumnNames() []string

func (*App) CompletionSchema

func (a *App) CompletionSchema() query.Schema

CompletionSchema builds the completion schema without ever blocking on the live connection: engine tables come from PRAGMA lookups against the in-memory database (cheap, safe on the update loop), live tables come from whatever WarmCompletionSchema has cached so far, and Current is the column set of the frame under view.

func (*App) Crumbs

func (a *App) Crumbs() []string

func (*App) CurrentFrame

func (a *App) CurrentFrame() *data.Frame

func (*App) CurrentRow

func (a *App) CurrentRow() int

func (*App) CurrentTableNamespace

func (a *App) CurrentTableNamespace() string

CurrentTableNamespace reports the namespace the active table was loaded from, so the refresh command can re-fetch the same table. It consults the completion cache's table-to-namespace map first, then falls back to the backend's connected namespace (when the backend exposes one), and finally returns "" (the backend then treats it as the default namespace).

func (*App) Engine

func (a *App) Engine() *query.Engine

func (*App) Init

func (a *App) Init() tea.Cmd

func (*App) KV

func (a *App) KV() db.KVBackend

func (*App) PendingDelete

func (a *App) PendingDelete() *PendingDelete

PendingDelete reports the in-flight row delete awaiting commit, or nil when no delete is in progress.

func (*App) PendingEdit

func (a *App) PendingEdit() *PendingEdit

PendingEdit reports the in-flight cell edit awaiting commit, or nil when no edit is in progress. Confirm popups read it to render the proposed change; the "saveedit" command consumes it.

func (*App) PushOverlay

func (a *App) PushOverlay(ov Overlay)

PushOverlay adds an overlay before the program starts. Database mode uses it to show the connection form on top of the empty workspace.

func (*App) SheetFieldCursor

func (a *App) SheetFieldCursor() int

SheetFieldCursor reports the selected field index in sheet mode. It is always a valid column index for the current frame, or 0 when no pane is open.

func (*App) ShowBorders

func (a *App) ShowBorders() bool

func (*App) ShowRowNumbers

func (a *App) ShowRowNumbers() bool

func (*App) TableNames

func (a *App) TableNames() []string

func (*App) Tabs

func (a *App) Tabs() []TabInfo

func (*App) Theme

func (a *App) Theme() *theme.Theme

func (*App) ThemeName

func (a *App) ThemeName() string

func (*App) Update

func (a *App) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*App) View

func (a *App) View() tea.View

func (*App) WarmCompletionSchema

func (a *App) WarmCompletionSchema(tables ...string)

WarmCompletionSchema populates the live-connection side of the completion cache. It issues catalog queries and therefore blocks: call it only from inside a tea.Cmd goroutine, never on the update loop. With no arguments it fetches the namespace/table listing (once per connection); given table names it additionally fetches those tables' columns on first use. A replaced connection resets the cache automatically. File mode (no backend) is a no-op. Errors are swallowed: completion degrades to whatever is cached rather than interrupting typing.

type AppContext

type AppContext interface {
	CurrentFrame() *data.Frame // top of current pane stack (nil if no tabs)
	CurrentRow() int           // selected row in current table view
	SheetFieldCursor() int     // selected field in sheet mode
	CurrentTableNamespace() string
	BaseCrumb() string // current tab title
	Crumbs() []string  // full breadcrumb chain
	ColumnNames() []string
	Engine() *query.Engine // embedded SQL engine (may be nil in db mode)
	TableNames() []string  // engine-registered + backend tables for completion
	Backend() db.Backend   // nil in file mode
	KV() db.KVBackend      // nil unless redis mode
	Theme() *theme.Theme
	ThemeName() string
	ShowBorders() bool
	ShowRowNumbers() bool
	Tabs() []TabInfo
	ActiveTab() int
	ActivePaneID() int // stable identity of the active pane (0 if no tabs)
	PendingEdit() *PendingEdit
	PendingDelete() *PendingDelete
}

AppContext is the read-only view of the application that popup factories receive. It exists so popup packages can be wired in without importing the app (avoiding cycles).

type ApplyFrameMsg

type ApplyFrameMsg struct {
	Frame    *data.Frame
	Crumb    string
	NewTab   bool
	TabTitle string
	// PaneID identifies the pane the operation was started from (see
	// AppContext.ActivePaneID). When set (non-zero) and NewTab is false the
	// frame is pushed onto that pane even if the user has switched tabs while
	// the command ran; if the pane is gone the frame opens as a new tab.
	PaneID int
	// RegisterAs, when non-empty, also registers Frame in the embedded SQL
	// engine under this name (no-op in db mode), so imported tables are
	// queryable by name like CLI-loaded ones.
	RegisterAs string
	// TableCols, when non-nil, limits which column indices the table view
	// renders. Sheet/row-detail mode always shows all columns.
	TableCols []int
}

ApplyFrameMsg pushes a derived frame onto a pane's stack, or opens it as a new tab when NewTab is set. Crumb is a short operation label ("filter", "query", "sort") shown in the breadcrumb.

type Binding

type Binding struct {
	Keys   []string
	Action string
	Help   string
}

Binding ties one or more key strings (tea.KeyPressMsg.String() forms) to a semantic action. The lists below are the single source of truth for both dispatch and the help overlay.

type CloseOverlayMsg

type CloseOverlayMsg struct{}

CloseOverlayMsg pops the top overlay off the stack.

type CloseTabMsg

type CloseTabMsg struct{ Index int }

CloseTabMsg closes the tab at Index; closing the last tab quits.

type CopyTextMsg

type CopyTextMsg struct{ Text string }

CopyTextMsg copies text to the system clipboard via OSC52.

type ErrorMsg

type ErrorMsg struct{ Err error }

ErrorMsg surfaces an error to the user in the error popup.

type ExecProcessMsg

type ExecProcessMsg struct {
	Cmd    *exec.Cmd
	OnDone func(error) tea.Msg
}

ExecProcessMsg runs an external program with the terminal released and resumes the app afterwards. OnDone (optional) converts the process error into a follow-up message.

type FullscreenOverlay

type FullscreenOverlay interface{ Fullscreen() bool }

FullscreenOverlay marks an overlay that renders as a full page: it covers the whole body area instead of floating over it. Database mode uses it to make the connection form, the schema/key browsers and the value viewer feel like a page stack (login -> browser -> table) rather than popups over the table.

type JumpToRowMsg

type JumpToRowMsg struct{ Row int }

JumpToRowMsg selects a row (0-based) in the current table view.

type JumpToTabMsg

type JumpToTabMsg struct{ Index int }

JumpToTabMsg activates the tab at Index (0-based, clamped).

type OobeColsSelectedMsg

type OobeColsSelectedMsg struct{ Columns []string }

OobeColsSelectedMsg updates the active pane TableCols after the user picks columns.

type Options

type Options struct {
	Frames  []reader.NamedFrame // initial tabs (already engine-registered)
	Engine  *query.Engine       // embedded SQL engine (nil in db mode)
	Backend db.Backend          // live SQL connection (nil in file mode)
	KV      db.KVBackend        // live redis connection (nil otherwise)

	ThemeName      string
	ShowBorders    bool
	ShowRowNumbers bool
}

Options configures a new App.

type Overlay

type Overlay interface {
	// Update handles a message and returns the (possibly replaced) overlay.
	Update(msg tea.Msg) (Overlay, tea.Cmd)
	// View renders the overlay box for the given available area.
	View(width, height int, th *theme.Theme) string
}

Overlay is a modal component rendered on top of the main view. The app keeps a stack of overlays; only the top one receives key input.

type OverlayIniter

type OverlayIniter interface {
	Init() tea.Cmd
}

OverlayIniter is an optional extension of Overlay: an overlay that needs to kick off an asynchronous command as soon as it is shown (loading data, scanning keys, ...) implements Init. The app runs the returned command right after pushing the overlay.

type Pane

type Pane struct {
	Title string

	Table      TableView
	Mode       ViewMode
	SheetOff   int // left-list scroll offset (key column)
	SheetField int // cursored field index in sheet mode
	// SheetValOff is the right-pane value scroll offset within the cursored
	// field. It is reset to 0 each time the cursor moves to a new field.
	SheetValOff int
	// SheetEditing is true while the sheet view is inline-editing the
	// cursored field. The "e" key toggles it on; saveedit/canceledit clear it.
	SheetEditing bool
	// SheetEdit holds the runes typed during an inline sheet edit.
	SheetEdit []rune
	// SheetEditCur is the rune cursor within SheetEdit.
	SheetEditCur int
	// SheetFilter holds the current field-filter pattern typed after "/".
	// SheetField is always interpreted as an index INTO the matched set
	// (sheetMatchedCols), not a raw column index; with an empty filter the
	// matched set is every column so the two coincide.
	SheetFilter    []rune
	SheetFiltering bool
	// JsonViewOff is the scroll offset when viewing a row as JSON.
	JsonViewOff int

	// SortCol is the column name currently sorted on ("" = unsorted).
	// SortAsc is true for ascending order, false for descending.
	SortCol   string
	SortAsc   bool
	ColZoomed bool // true when user zoomed into a single column via z key

	// TableCols, when non-nil, restricts which columns the table view renders.
	// Sheet/row-detail mode always shows all columns regardless of this field.
	TableCols []int
	// HScroll is the character-level horizontal offset applied to the last
	// TableCols column so the user can pan within wide content (e.g. body).
	HScroll int
	// contains filtered or unexported fields
}

Pane is one tab: a stack of frames (base + one per applied operation), a table view state and a sheet scroll offset.

func NewPane

func NewPane(title string, f *data.Frame) *Pane

NewPane creates a pane with a base frame.

func (*Pane) Crumbs

func (p *Pane) Crumbs() []string

Crumbs returns the breadcrumb chain: tab title, then one label per derived frame.

func (*Pane) Current

func (p *Pane) Current() *data.Frame

Current returns the frame on top of the stack (nil for an empty pane).

func (*Pane) Depth

func (p *Pane) Depth() int

Depth reports the stack depth.

func (*Pane) ID

func (p *Pane) ID() int

ID returns the pane's stable unique identity (positive; 0 is never used, so it can act as an "unset" marker in messages).

func (*Pane) Pop

func (p *Pane) Pop() bool

Pop removes the top frame. It reports false when the stack is already at its base (the caller then closes the tab instead).

func (*Pane) Push

func (p *Pane) Push(f *data.Frame, crumb string)

Push adds a derived frame with a crumb label and resets the view onto it.

func (*Pane) ReplaceBase

func (p *Pane) ReplaceBase(f *data.Frame)

ReplaceBase swaps the pane's base frame (stack[0]) and re-clamps the view onto it, used by the refresh command to reload the current table.

func (*Pane) Reset

func (p *Pane) Reset()

Reset drops every derived frame, back to the base.

type PendingDelete

type PendingDelete struct {
	Frame     *data.Frame
	Rows      []int
	Table     string
	Namespace string
}

PendingDelete captures one or more rows awaiting deletion. The app populates it from the multi-select set (or the single cursor row) and commits it via the "deleterows" command.

type PendingEdit

type PendingEdit struct {
	Frame     *data.Frame
	Row       int
	Col       int
	ColName   string
	OldValue  string
	NewValue  string
	Table     string
	Namespace string
}

PendingEdit captures an in-flight cell edit awaiting confirmation. The popup that collects the new value populates this and the app commits it via the "saveedit" command.

type PushOverlayMsg

type PushOverlayMsg struct{ Overlay Overlay }

PushOverlayMsg pushes a new overlay onto the stack.

type RegisterTableMsg

type RegisterTableMsg struct{ Name string }

RegisterTableMsg registers the current frame in the SQL engine under Name.

type RenderOpts

type RenderOpts struct {
	Width, Height  int
	Theme          *theme.Theme
	ShowBorders    bool
	ShowRowNumbers bool
	MatchRows      map[int]bool // rows emphasized with the match style

	SortCol   string // currently sorted column name ("" = unsorted)
	SortAsc   bool   // true = ASC indicator, false = DESC indicator
	HeaderCur int    // column index to highlight in header (-1 or 0+ valid)
	// SeverityCol, when non-empty, names a column whose value determines the row foreground color.
	// Values matching TRACE/DEBUG/INFO/WARN/ERROR/FATAL (case-insensitive) get distinct colors.
	SeverityCol string
	// TableCols, when non-nil, renders only these column indices.
	// Sheet mode passes nil here so all columns are always visible in detail.
	TableCols []int
	// NoEllipsis disables the "…" truncation indicator on cell values —
	// text is hard-clipped at the column boundary instead.
	NoEllipsis bool
	// HighlightQuery, when non-empty, highlights matching substrings in cell values.
	HighlightQuery string
	// HighlightCols restricts highlighting to these column indices (nil = all cols).
	HighlightCols []int
	// HScroll is the character-level horizontal scroll offset applied to the
	// last visible column. Used when TableCols is set to let the user pan
	// within a single wide column (e.g. OpenObserve body) with h/l keys.
	HScroll int
}

RenderOpts carries everything Render needs besides the frame.

type ReplaceBaseMsg

type ReplaceBaseMsg struct {
	Frame  *data.Frame
	PaneID int
}

ReplaceBaseMsg swaps the base frame of the pane identified by PaneID (or the active pane when zero), used by the refresh command to reload the current table without opening a new tab.

type ResetStackMsg

type ResetStackMsg struct{}

ResetStackMsg pops the current pane back to its base frame.

type RunCommandMsg

type RunCommandMsg struct {
	Name string
	Arg  string
}

RunCommandMsg invokes a named command. Built-in names (quit, reset, toggleborders, togglerownumbers, reloadconfig) are handled by the app directly; everything else is resolved through the Factories registry.

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

SearchBar implements live search over the current frame. While active it keeps a preview frame (the filtered rows) that the app displays instead of the pane's top frame; the stack is only touched on commit.

func (*SearchBar) Active

func (s *SearchBar) Active() bool

func (*SearchBar) Backspace

func (s *SearchBar) Backspace()

Backspace removes the last rune and recomputes the preview.

func (*SearchBar) Cancel

func (s *SearchBar) Cancel()

Cancel deactivates the bar and drops the preview.

func (*SearchBar) Commit

func (s *SearchBar) Commit() (f *data.Frame, crumb string, ok bool)

Commit deactivates the bar and returns the filtered frame plus a crumb label. ok is false when there is nothing to commit (empty query).

func (*SearchBar) Fuzzy

func (s *SearchBar) Fuzzy() bool

func (*SearchBar) Paste

func (s *SearchBar) Paste(text string)

Paste appends pasted text as a single edit (bracketed paste delivers the whole chunk in one message, not per-rune key presses), flattened to one line first.

func (*SearchBar) Preview

func (s *SearchBar) Preview() *data.Frame

Preview returns the frame to display while the bar is active (never nil while active with a base frame).

func (*SearchBar) Query

func (s *SearchBar) Query() string

func (*SearchBar) Start

func (s *SearchBar) Start(f *data.Frame, fuzzy bool)

Start activates the bar over frame f.

func (*SearchBar) StartCols

func (s *SearchBar) StartCols(f *data.Frame, fuzzy bool, cols []int)

StartCols activates the bar over frame f, restricting the search to the given column indices (nil = search all columns).

func (*SearchBar) Type

func (s *SearchBar) Type(text string)

Type appends printable input and recomputes the preview.

func (*SearchBar) View

func (s *SearchBar) View(width int, th *theme.Theme) string

View renders the input line shown at the bottom of the screen.

type SetBackendMsg

type SetBackendMsg struct {
	Backend db.Backend
	KV      db.KVBackend
}

SetBackendMsg attaches a live database connection to a running app. Database mode starts the UI with no connection and wires one in after the connection form succeeds. Nil fields are left untouched.

type SetPageMsg

type SetPageMsg struct{ Page int }

SetPageMsg navigates to a specific page in paginated results.

type SetQueryParamsMsg

type SetQueryParamsMsg struct {
	Minutes  int
	Page     int
	PageSize int
}

SetQueryParamsMsg sets time range, page, and page size on an OpenObserve backend and triggers a single table refresh.

type SetThemeMsg

type SetThemeMsg struct{ Name string }

SetThemeMsg switches the active theme by built-in name.

type SetTimeRangeMsg

type SetTimeRangeMsg struct{ Minutes int }

SetTimeRangeMsg sets the time range for OpenObserve queries.

type TabInfo

type TabInfo struct {
	Title string
	Shape string // e.g. "120 x 5"
}

TabInfo is a summary of one open tab for switchers and schema listings.

type TableView

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

TableView holds the scroll/selection state of one table widget. Rendering is stateless apart from remembering the last page size for paging keys.

func (*TableView) Bottom

func (tv *TableView) Bottom(nrows int)

func (*TableView) ClampTo

func (tv *TableView) ClampTo(f *data.Frame)

ClampTo clamps selection and cursor to the bounds of f (used when the underlying frame changes but position should be roughly kept). A frame change invalidates the multi-select set, so it is cleared here too.

func (*TableView) ClearSelect

func (tv *TableView) ClearSelect()

ClearSelect empties the multi-select set.

func (*TableView) ColCursor

func (tv *TableView) ColCursor() int

func (*TableView) ColOff

func (tv *TableView) ColOff() int

func (*TableView) Expanded

func (tv *TableView) Expanded() bool

func (*TableView) FirstCol

func (tv *TableView) FirstCol()

func (*TableView) HalfPageDown

func (tv *TableView) HalfPageDown(nrows int)

func (*TableView) HalfPageUp

func (tv *TableView) HalfPageUp(nrows int)

func (*TableView) IsSelected

func (tv *TableView) IsSelected(row int) bool

IsSelected reports whether a row is in the multi-select set.

func (*TableView) JumpTo

func (tv *TableView) JumpTo(row, nrows int)

JumpTo selects a specific row (clamped).

func (*TableView) LastCol

func (tv *TableView) LastCol(ncols int)

LastCol moves the column cursor to the last column and requests that it be scrolled into view (wide mode).

func (*TableView) Move

func (tv *TableView) Move(delta, nrows int)

func (*TableView) NextCol

func (tv *TableView) NextCol(ncols int)

NextCol / PrevCol / FirstCol move the column cursor (both column modes) and request that it be scrolled into view (wide mode).

func (*TableView) PageDown

func (tv *TableView) PageDown(nrows int)

func (*TableView) PageSize

func (tv *TableView) PageSize() int

PageSize is the number of body rows shown at the last render (fallback 10).

func (*TableView) PageUp

func (tv *TableView) PageUp(nrows int)

func (*TableView) PrevCol

func (tv *TableView) PrevCol(ncols int)

func (*TableView) Random

func (tv *TableView) Random(nrows int)

func (*TableView) Render

func (tv *TableView) Render(f *data.Frame, o RenderOpts) string

Render draws the table into a Width x Height cell area.

func (*TableView) Reset

func (tv *TableView) Reset()

Reset returns the view to the top-left with row 0 selected and re-arms the automatic column-mode pick for the next frame shown.

func (*TableView) Sel

func (tv *TableView) Sel() int

func (*TableView) SelectedRows

func (tv *TableView) SelectedRows() []int

SelectedRows returns the multi-select members in ascending order. The returned slice is freshly allocated; callers may mutate it freely.

func (*TableView) SetColCursor

func (tv *TableView) SetColCursor(i, ncols int)

SetColCursor sets the column cursor to the given index (clamped to valid range).

func (*TableView) ToggleExpanded

func (tv *TableView) ToggleExpanded()

ToggleExpanded flips the column mode manually; the choice sticks for the frame currently shown (no later auto-pick overrides it).

func (*TableView) ToggleSelect

func (tv *TableView) ToggleSelect(row int)

ToggleSelect adds a row to (or removes it from) the multi-select set. The set is lazy-initialized on first use so an untouched view stays allocation free.

func (*TableView) Top

func (tv *TableView) Top()

type ToastMsg

type ToastMsg struct{ Text string }

ToastMsg shows a transient success/info message at the bottom.

type ToggleBordersMsg

type ToggleBordersMsg struct{}

ToggleBordersMsg flips the table border toggle.

type ToggleRowNumbersMsg

type ToggleRowNumbersMsg struct{}

ToggleRowNumbersMsg flips the row-number gutter toggle.

type ViewMode

type ViewMode int

ViewMode selects what the pane body shows.

const (
	ModeTable ViewMode = iota
	ModeSheet
	ModeJsonView
)

Directories

Path Synopsis
Package dbmode wires the live-database mode into the UI: the mysql / postgres / redis subcommands start an empty workspace with a connection form overlay on top, then browse schemas, tables and keys through the shared overlay system.
Package dbmode wires the live-database mode into the UI: the mysql / postgres / redis subcommands start an empty workspace with a connection form overlay on top, then browse schemas, tables and keys through the shared overlay system.
Package plot renders pure-text charts (histograms, scatter plots) for the UI.
Package plot renders pure-text charts (histograms, scatter plots) for the UI.
Confirm-delete overlay: prompts the user to commit or cancel a pending row delete.
Confirm-delete overlay: prompts the user to commit or cancel a pending row delete.

Jump to

Keyboard shortcuts

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