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 Crash
- type Guarded
- 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) LeaveRoom() bool
- func (m *Model) Listen()
- func (m *Model) OfferKept()
- func (m *Model) OpenNotebook()
- func (m *Model) OpenOnStart(name string)
- func (m *Model) Others() (int, string)
- func (m *Model) Piped() (*fileio.Snapshot, fileio.Kind, bool)
- func (m *Model) ReadStdin(r io.Reader)
- 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) SetPipe(to fileio.Kind)
- func (m *Model) SetSend(s Send)
- func (m *Model) SetShellRunner(r nushell.Runner)
- func (m *Model) SetVimKeys(on bool)
- func (m *Model) ShareRooms(reg *room.Registry, user string)
- func (m *Model) StopListening()
- 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 Send
- type Settings
- type Shared
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.
const StdinName = "stdin"
StdinName is what a table read from standard input is called: its sheet's name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Crash ¶ added in v0.3.0
type Crash struct {
Where string // "update", "view", "init" or "a command"
Value any // what was panicked with
Stack []byte // the panicking goroutine's stack; nil when Bubble Tea caught it
}
Crash is a panic Guard caught.
func (*Crash) Report ¶ added in v0.3.0
func (c *Crash) Report(dir, version, file, kept string, keepErr error, now time.Time) (string, error)
Report writes a short report of the crash into dir, for the user to send with an issue, and returns its path. It says where the panic was, what with, the stack, the build (version), the system, the file open and where its unsaved work was kept; never the workbook's contents.
type Guarded ¶ added in v0.3.0
type Guarded struct {
// contains filtered or unexported fields
}
Guarded is a model run under Guard.
func Guard ¶ added in v0.3.0
Guard wraps m so a panic in it stops the program without losing the terminal; see Finish for what's left afterwards.
func (*Guarded) Finish ¶ added in v0.3.0
Finish is called once the program has stopped, with what Run returned. It reports the crash that stopped it, if one did: one Guard caught, or one only Bubble Tea caught (a panic in a sequence's command), whose stack it printed on the terminal.
func (*Guarded) Keep ¶ added in v0.3.0
Keep writes the model's unsaved work to a recovery file, returning its name ("" when there was nothing unsaved). A model a panic left too broken to write is reported as an error rather than panicking again.
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, and holds the screen until it knows (termbg.go).
func (*Model) LeaveRoom ¶ added in v0.5.0
LeaveRoom gives up the session's seat as it ends, reporting whether it was the last one there (or had a workbook of its own), whose unsaved changes are then its to keep: others keep a room's workbook open. The last one out stops what the room ran.
func (*Model) Listen ¶ added in v0.6.0
func (m *Model) Listen()
Listen has the session listen for agents from the start, letting them suggest changes to the whole workbook: 012 --listen.
func (*Model) OfferKept ¶ added in v0.3.0
func (m *Model) OfferKept()
OfferKept makes a local session offer, once it starts, the changes kept for its file (or for an untitled book) when 012 last stopped on an internal error. cmd/012 asks for it when started on a file or on nothing, not on an import or standard input.
func (*Model) OpenNotebook ¶ added in v0.3.0
func (m *Model) OpenNotebook()
OpenNotebook starts on the workbook's notebook, as 012 nu does: a new file's empty sheet becomes the notebook, with a code cell ready to type in; a workbook without one gets one.
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) Others ¶ added in v0.5.0
Others is how many others share the session's workbook, and their names.
func (*Model) Piped ¶ added in v0.3.0
Piped is what quitting sent: the table and its format, or false when the user quit without sending.
func (*Model) ReadStdin ¶ added in v0.3.0
ReadStdin sets a table to read from r, standard input, as the program starts, into a new unsaved sheet named stdin.
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 in 012 serve, its full path in a local session. It's for when the program has stopped; a local model without Settings.RecoveryDir 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. Notebooks' commands run only when the server's serve-shell allows.
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) SetPipe ¶ added in v0.3.0
SetPipe makes quitting send a table to standard output, in format to (a text format; 0 for the input's, or NUON when the input isn't text).
func (*Model) SetSend ¶ added in v0.3.0
SetSend makes quitting in a pipeline send s rather than ask.
func (*Model) SetShellRunner ¶ added in v0.3.0
SetShellRunner makes cells run, and the code editor ask, with r rather than nu, for tests; it's set before anything is asked.
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) ShareRooms ¶ added in v0.5.0
ShareRooms makes a served session open files in the rooms of reg, as user: sessions opening the same file share its workbook.
func (*Model) StopListening ¶ added in v0.6.0
func (m *Model) StopListening()
StopListening closes the session's socket; agents attached leave.
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 Send ¶ added in v0.3.0
type Send int
Send is what quitting sends in a pipeline (012 --pipe --send).
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
// RecoveryDir is where a local session keeps its unsaved work when
// it stops on an internal error, and finds it again: recovery.go.
// "" keeps none; 012 serve keeps them in the served directory.
RecoveryDir string
// Version is 012's, which live mode's MCP server reports to agents.
Version string
}
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.
type Shared ¶ added in v0.5.0
type Shared struct {
// contains filtered or unexported fields
}
Shared is a served session's guarded model as Bubble Tea runs it when workbooks are shared: every turn the model takes (Init, Update, View) holds its room's lock (room.Seat.Do), with its steps made in its own name, so sessions act on the workbook one at a time, in the order the server takes them. Between turns it joins and leaves rooms, never holding two locks. It also holds back input while someone else's step is open (a macro they run spans several turns) and hands it on once the step ends, and in a one-writer room it takes back what a follower changed by a way no check stopped.
func (*Shared) Attach ¶ added in v0.5.0
Attach sends the program a roomMsg whenever the model's room changes, until ctx ends.
Source Files
¶
- agentask.go
- agentdraw.go
- agents.go
- alignfmt.go
- assist.go
- assistsheets.go
- bands.go
- bars.go
- chartaxes.go
- charteditor.go
- chartmacro.go
- charts.go
- chartsel.go
- clipboard.go
- cmdline.go
- columns.go
- commands.go
- context.go
- crash.go
- dialog.go
- download.go
- edit.go
- entry.go
- errbox.go
- evaluate.go
- file.go
- fill.go
- filter.go
- find.go
- follow.go
- format.go
- freeze.go
- graphics.go
- grid.go
- gridlines.go
- help.go
- hidden.go
- hosts.go
- importplace.go
- jev.go
- keyboard.go
- layoutfmt.go
- linked.go
- links.go
- locale.go
- looks.go
- macro.go
- macrohost.go
- macrohostnav.go
- macromanage.go
- macrorec.go
- macrorun.go
- menubar.go
- menuoverlay.go
- model.go
- mouse.go
- names.go
- nbcells.go
- nbcommands.go
- nbgrid.go
- nbgridcmd.go
- nbgridin.go
- nbgridstream.go
- nbjob.go
- nblang.go
- nbrun.go
- nbscreen.go
- nbsend.go
- nbstream.go
- notebook.go
- notes.go
- overlay.go
- palette.go
- panel.go
- panes.go
- pipe.go
- pivot.go
- pivotactions.go
- pivoteditor.go
- prefs.go
- prompt.go
- protect.go
- recovery.go
- rooms.go
- rowheights.go
- rows.go
- rulemacro.go
- rules.go
- selection.go
- settings.go
- share.go
- sharecmds.go
- sharedraw.go
- sixel.go
- sort.go
- sources.go
- srccmds.go
- srcscreen.go
- tables.go
- tabs.go
- tabstrip.go
- termbg.go
- themepicker.go
- trace.go
- traceview.go
- transfer.go
- undocost.go
- view.go
- vim.go
- vimkeys.go
- vimmarks.go
- vimpref.go
- vimregs.go
- vimrepeat.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package choicebar is a small question asked on the context line and answered with a key, the way terminal programs confirm things, e.g.
|
Package choicebar is a small question asked on the context line and answered with a key, the way terminal programs confirm things, e.g. |
|
Package cmdhelp is a nushell command's help, F1 on a command in a notebook's cell: a scrollable box over the notebook with what the command does, a link to its page in nushell's docs, its usage, flags, parameters, input and output types and examples, as nu's help has them.
|
Package cmdhelp is a nushell command's help, F1 on a command in a notebook's cell: a scrollable box over the notebook with what the command does, a link to its page in nushell's docs, its usage, flags, parameters, input and output types and examples, as nu's help has them. |
|
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 evalview is Data > Evaluate formula, after Excel's Evaluate Formula: a box over the grid showing the active cell's formula with the part computed next underlined and its value below.
|
Package evalview is Data > Evaluate formula, after Excel's Evaluate Formula: a box over the grid showing the active cell's formula with the part computed next underlined and its value below. |
|
Package filterpick is the values list and condition of one column of a filter, in the manner of fzf: a condition on top, then the column's values with checkboxes, narrowed by a fuzzy search as you type.
|
Package filterpick is the values list and condition of one column of a filter, in the manner of fzf: a condition on top, then the column's values with checkboxes, narrowed by a fuzzy search as you type. |
|
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 nbview draws a notebook tab and takes its keys and clicks, as Jupyter does: cells one under another, a code cell's pipeline in a box with its [n]: prompt and a ▶ that runs it, its output under it after Out[n]:, and a note cell's Markdown drawn as text.
|
Package nbview draws a notebook tab and takes its keys and clicks, as Jupyter does: cells one under another, a code cell's pipeline in a box with its [n]: prompt and a ▶ that runs it, its output under it after Out[n]:, and a note cell's Markdown drawn as text. |
|
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 review is live mode's suggestions panel (docs/agents/live.md): a box at the right of the grid listing the agents' suggestions waiting for the person, each by agent and message with the cells it would set, to accept or reject whole or cell by cell, with keys or the mouse.
|
Package review is live mode's suggestions panel (docs/agents/live.md): a box at the right of the grid listing the agents' suggestions waiting for the person, each by agent and message with the cells it would set, to accept or reject whole or cell by cell, with keys or the mouse. |
|
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 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.
|
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. |
|
Package shortcuts is the keyboard shortcuts view: a scrollable box over the grid listing every key by what it does, in two columns when the screen is wide enough.
|
Package shortcuts is the keyboard shortcuts view: a scrollable box over the grid listing every key by what it does, in two columns when the screen is wide enough. |
|
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.
|
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. |
|
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.
|
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. |
|
Package suggest is formula assistance, as in Sheets: while a function, range or sheet name is being typed, a list of matching functions, named ranges and other sheets drops down from the formula bar at the caret, and while the caret is inside a function's parentheses the context line shows its signature with the current argument marked.
|
Package suggest is formula assistance, as in Sheets: while a function, range or sheet name is being typed, a list of matching functions, named ranges and other sheets drops down from the formula bar at the caret, and while the caret is inside a function's parentheses the context line shows its signature with the current argument marked. |
|
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, narrowed to one kind by a search starting with "dark" or "light".
|
Package themepicker is File > Settings > Theme: every theme in a picker, fuzzy searched by name, narrowed to one kind by a search starting with "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. |