Documentation
¶
Overview ¶
Package ui is the Bubble Tea front end. Inside the grid it behaves like Google Sheets (keys, selection, entry); around it, the control panel and mode indicator give it a 1-2-3 look.
Index ¶
- Constants
- type Model
- func (m *Model) AllowEditor()
- func (m *Model) Configure(s Settings)
- func (m *Model) EnableJEV(client jev.Client, cache *jev.Cache)
- func (m *Model) Filename() string
- func (m *Model) Import(name string)
- func (m *Model) Init() tea.Cmd
- func (m *Model) OpenOnStart(name string)
- func (m *Model) Recover(now time.Time) (string, error)
- func (m *Model) Serve(root confine.Root, env []string)
- func (m *Model) SetMachine(id string)
- func (m *Model) SetVimKeys(on bool)
- func (m *Model) TraceUnder(p telemetry.Parent)
- func (m *Model) Unsaved() bool
- func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m *Model) View() tea.View
- type Settings
Constants ¶
const ( // FrameRate is how many frames a second Bubble Tea may draw, its // maximum (tea.WithFPS). A key's answer waits for the next frame, so // this halves the wait at the default 60. The renderer writes a frame // only when the view changed, so an idle screen costs no more. FrameRate = 120 // FrameInterval is the time between frames. FrameInterval = time.Second / FrameRate )
const RecoveryDir = ".012-recovery"
RecoveryDir is the directory, inside the served one, recovery files are kept in.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the root of the UI, the tea.Model Bubble Tea runs. It holds the file, the mode and the grid, owns a component for everything that takes input or draws a part of the screen, routes each message to the one it's for, and composes the screen from what they draw (panel.go, view.go, overlay.go).
func (*Model) AllowEditor ¶
func (m *Model) AllowEditor()
AllowEditor lets the user edit macro scripts in their own editor ($VISUAL or $EDITOR), which runs as a program of theirs with the screen handed over. Only the local app allows it: a session served over SSH must not start programs on the server.
func (*Model) Configure ¶
Configure applies settings: the theme, chart images, notifications, and notes for the context line.
func (*Model) EnableJEV ¶
EnableJEV turns on JEV functions: the cache answers them, for this workbook and those opened later, and the client asks what it lacks.
func (*Model) Import ¶
Import sets a file to import when the program starts, e.g. from "012 sales.csv".
func (*Model) Init ¶
Init implements tea.Model. It asks the terminal for its background color so the theme can adapt to light terminals.
func (*Model) OpenOnStart ¶
OpenOnStart makes a served session start on name, as `ssh -t host name` asks: a sheet to open (or a new one to save as name, when there's no such file) or a file to import. Either way, or with name empty, the session then offers unsaved changes kept for that name.
func (*Model) Recover ¶
Recover writes the workbook to a new recovery file for its name, removing the oldest beyond recoveryKeep, and returns the file's name relative to the served directory. It's for 012 serve, when the program has stopped; a model that isn't served has nowhere to put one.
func (*Model) Serve ¶
Serve prepares m for a session served over SSH: file names resolve inside root, and env (KEY=value pairs) is the client's environment, used instead of the server's to learn about the client's terminal.
func (*Model) SetMachine ¶
SetMachine tells the model which computer it runs on, as an id kept in the user's configuration, so macros saved here run without asking and macros from files made elsewhere ask once.
func (*Model) SetVimKeys ¶
SetVimKeys turns vim keys on or off, as the setting does, for callers that know the user's choice at startup.
func (*Model) TraceUnder ¶
TraceUnder nests every span the model starts under p for good: 012 serve's session span holds each session's commands.
func (*Model) Unsaved ¶
Unsaved reports whether the workbook has changes a recovery file would keep: it was changed since it was last saved or opened, and isn't empty.
type Settings ¶
type Settings struct {
Config *config.Config
Reload func() *config.Config // reads the config file again; nil disables Reload config
ThemesDir string // the user's theme files
Keys keyring.Store // where JEV API key stores the key; nil disables it
// Connect makes a JEV client for the configured service with key.
Connect func(key string) (jev.Client, error)
Notes []string // said on the context line at startup, e.g. config warnings
}
Settings are what the app takes from outside the workbook: the config file's options, and the credential store the JEV API key lives in. cmd/012 passes them to Configure; tests pass fakes, so the user's own config and keychain are never touched.
Source Files
¶
- assist.go
- assistsheets.go
- charteditor.go
- charts.go
- chartsel.go
- clipboard.go
- cmdline.go
- columns.go
- commands.go
- context.go
- dialog.go
- download.go
- edit.go
- entry.go
- file.go
- fill.go
- filter.go
- find.go
- format.go
- freeze.go
- graphics.go
- grid.go
- help.go
- hidden.go
- hosts.go
- importplace.go
- jev.go
- links.go
- macro.go
- macrohost.go
- macrohostnav.go
- macromanage.go
- macrorec.go
- macrorun.go
- menubar.go
- menuoverlay.go
- model.go
- mouse.go
- names.go
- overlay.go
- palette.go
- panel.go
- panes.go
- pivot.go
- pivotactions.go
- pivoteditor.go
- prefs.go
- prompt.go
- recovery.go
- rows.go
- selection.go
- settings.go
- sort.go
- tabs.go
- tabstrip.go
- themepicker.go
- trace.go
- transfer.go
- view.go
- vim.go
- vimkeys.go
- vimpref.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cmdline is the command line (: with vim keys, or from the palette): what's typed on the context line, with completions from the command registry in a box under it.
|
Package cmdline is the command line (: with vim keys, or from the palette): what's typed on the context line, with completions from the command registry in a box under it. |
|
Package findbar is find and replace: a bar on the context line rather than a dialog, in the spirit of less and vim.
|
Package findbar is find and replace: a bar on the context line rather than a dialog, in the spirit of less and vim. |
|
Package formula reads the formula being typed in the UI: the reference F4 cycles through absolute markers, and the word and function call around the caret that formula assistance follows.
|
Package formula reads the formula being typed in the UI: the reference F4 cycles through absolute markers, and the word and function call around the caret that formula assistance follows. |
|
Package lineedit is the one-line text editor behind every text field of the UI.
|
Package lineedit is the one-line text editor behind every text field of the UI. |
|
Package overlay is the contract between the UI's root model and the components that take over input while open: menus, pickers, bars on the context line and dialogs.
|
Package overlay is the contract between the UI's root model and the components that take over input while open: menus, pickers, bars on the context line and dialogs. |
|
Package picker is the searchable list behind the command palette and every other picker of the UI (functions, sheets, named ranges, macros, themes, files to import): a search field on top, results below with matched characters highlighted, in the manner of fzf.
|
Package picker is the searchable list behind the command palette and every other picker of the UI (functions, sheets, named ranges, macros, themes, files to import): a search field on top, results below with matched characters highlighted, in the manner of fzf. |
|
Package rowtext lays out the text of one row of cells across the columns on screen, as Sheets does: values formatted and aligned, text running on into blank neighbors, cut to column boundaries in a single pass.
|
Package rowtext lays out the text of one row of cells across the columns on screen, as Sheets does: values formatted and aligned, text running on into blank neighbors, cut to column boundaries in a single pass. |
|
Package tabstrip is the sheet tabs at the left of the status line, the way tmux lists windows: the sheet shown is highlighted, a + adds a sheet, and when the tabs don't all fit, ‹ and › step through them.
|
Package tabstrip is the sheet tabs at the left of the status line, the way tmux lists windows: the sheet shown is highlighted, a + adds a sheet, and when the tabs don't all fit, ‹ and › step through them. |
|
Package theme is the look of the UI: the style roles every view draws with, and the small widgets built from them (framed boxes, key chips, key hints).
|
Package theme is the look of the UI: the style roles every view draws with, and the small widgets built from them (framed boxes, key chips, key hints). |
|
Package themepicker is File > Settings > Theme: every theme in a picker, fuzzy searched by name, "dark" or "light".
|
Package themepicker is File > Settings > Theme: every theme in a picker, fuzzy searched by name, "dark" or "light". |
|
Package transfer runs imports in the background and draws their progress: the mode indicator says WAIT, the context line offers Esc, the status line counts rows with a progress bar, and the terminal shows its own progress indicator.
|
Package transfer runs imports in the background and draws their progress: the mode indicator says WAIT, the context line offers Esc, the status line counts rows with a progress bar, and the terminal shows its own progress indicator. |