Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

datarig themes

The setting theme (:set theme=<name>, or the settings screen, Space ,) names a built-in theme or a theme file. A theme file is themes/<name>.toml next to the config file ($XDG_CONFIG_HOME/datarig/themes/, else ~/.config/datarig/themes/); its name is ASCII letters, digits, - and _ (at most 64), and never a built-in theme’s.

Built-in themes: terminal, dark, light, high-contrast, catppuccin, catppuccin-latte, catppuccin-mocha, tokyo-night, tokyo-night-day, tokyo-night-night, gruvbox, gruvbox-light, gruvbox-dark, nord, dracula.

The file

extends names the built-in theme the file starts from (terminal without it). [colors] sets colour tokens and [styles] style tokens; a token the file does not set keeps the value of the theme it extends, and a style it sets replaces that one whole. The dimming of the screen behind a dialog is not a token: it is the extended theme’s. An unknown token, colour or modifier is an error with its line, and the app then draws with terminal and says why.

  • A colour is #rrggbb, an ANSI name (black, red, green, yellow, blue, magenta, cyan, white, bright-black, bright-red, bright-green, bright-yellow, bright-blue, bright-magenta, bright-cyan, bright-white) or default (the terminal’s own).
  • A style is { fg = <color>, bg = <color>, modifiers = [...] }, each part optional; what it leaves out is not set.
  • Modifiers: bold, dim, italic, underlined, reversed, crossed-out.
# themes/mine.toml, used with theme = "mine"
extends = "dark"

[colors]
accent = "#89b4fa"
warning = "yellow"

[styles]
selection = { bg = "#45475a", modifiers = ["bold"] }
syn_comment = { fg = "bright-black", modifiers = ["italic"] }

Writing a theme file

  • :theme copy <from> <name> writes themes/<name>.toml with every token of the theme <from> (a built-in theme or a theme file; a family such as catppuccin as the variant drawn now) set to its value, each under a comment saying what it colours. extends names the built-in theme <from> starts from, for the dimming behind dialogs; every token is in the file, so it stands on its own.
  • :theme new <name> writes themes/<name>.toml extending the current theme when it is built in, else dark, with every token commented out and showing the value it takes from there: remove the # in front of a key to set it.
  • On the settings screen, c on the theme row copies the theme shown there (the one being previewed, else the current one) and asks for the new name.

Each writes a new file and never replaces one: a name that is taken, that is not a valid file name, that is a built-in theme’s or a Windows device name such as nul (ignoring case) is refused. The themes folder is created when it is missing. Then datarig draws with the new theme, saves theme = "<name>" to the config file and shows the file’s path.

:theme update [<name>] adds to the theme file <name> (the current theme without one) the tokens it does not list, such as tokens added after it was written: each under its description at the end of its section, commented out with the value it takes now. No line of the file changes, and the file is replaced only when it reads exactly as before; the theme drawn and the config file stay as they are. A theme file that does not list every token is said once in the status line when it is used, and again only when the tokens it does not list change.

Colours ([colors])

TokenWhat it colours
bgThe background of the panes: explorer, editor, results.
surfaceThe background of dialogs, popups, menus, the command line and the status bar.
surface_altA second surface: every other row of the result grid, form fields and buttons.
edit_inserted_rowThe background of a new row of the result grid, not applied yet: every cell, the separators and the row’s number. Its values, its defaults (muted), the mark of a cell that needs a value and the gutter’s marks must read on it; the cursor and a selection stand apart from it.
borderBorders and rules between panes and around dialogs.
accentThe main accent: the focused pane’s border, dialog borders, labels and names to notice.
accent_warmThe warm accent: values on the settings screen, an open transaction, keys in menus.
fgBody text.
fg_mutedSecondary text: descriptions, labels and hints.
fg_dimFaint text: placeholders, empty lists and notes such as a database’s default.
current_stmt_barThe bar in the editor’s gutter next to the statement a run would take.
running_stmt_barThe bar and the spinner in the editor’s gutter next to the statement that runs now.
successSuccess: rows a run returned, a connected tunnel, a success message.
warningWarnings.
errorErrors.
null_fgNULL in the result grid and the inspector.
key_pkThe mark of a primary key column.
key_fkThe mark of a foreign key column.
key_uqThe mark of a unique key column.
mode_normalThe background of the status bar’s mode badge in Normal mode.
mode_insertThe background of the mode badge in Insert mode.
mode_visualThe background of the mode badge in Visual mode.
mode_commandThe background of the mode badge while the command line is open.
mode_fgThe text of the mode badge (bold, on the mode’s colour).
chart_1The first series of a chart.
chart_2The second series of a chart.
chart_3The third series of a chart.
chart_4The fourth series of a chart.
chart_5The fifth series of a chart.
chart_6The sixth series of a chart.

Styles ([styles])

TokenWhat it styles
selectionThe selected row or item, and the grid’s cursor cell.
rangeCells and headers of a selected range in the result grid (the cursor’s cell keeps selection).
cursor_lineThe row under the cursor of an unfocused list or plan, the editor’s line, and (its background) the chart’s cursor while focused.
grid_cursor_rowThe result grid’s cursor row (its bg): every cell, the separators and the row’s number, and every row of a selected range of cells or of whole rows. Keep it subtle: apart from bg and surface_alt (the alternate rows), and from selection (the cursor’s cell), range and hover, with body and muted text reading on it. A file that leaves it out but sets bg or selection gets, when both are RGB, the selection blended into its bg.
grid_cursor_headerThe header of the result grid’s cursor column (both lines; patched over the header). Keep it apart from surface (the header) and range (the headers of selected columns), with body and muted text and the key marks reading on it. A file that leaves it out but sets surface or selection gets, when both are RGB, the selection blended into its surface.
hoverWhat is under the mouse pointer: a list row, a grid cell, a tab, a button.
yank_flashCells copied from the result grid, for a moment after the copy was sent to the clipboard (set fg and bg: it covers the cursor’s cell too). With RGB colours it fades back into each cell’s own colours; with terminal colours it goes off at once.
current_stmtA faint tint behind the statement a run would take.
running_stmtA tint behind the statement that runs now.
run_hintThe hint after a statement’s last line that says what its last run did.
syn_keywordSQL keywords.
syn_functionSQL function names.
syn_stringSQL strings and dollar-quoted bodies.
syn_numberSQL numbers.
syn_commentSQL comments.
syn_operatorSQL operators and punctuation.
syn_identifierSQL names, parameters and variables.
syn_quoted_identSQL quoted names.
syn_exec_commentThe opening and closing of a MySQL executable comment (/*! … */).
search_matchA match of the editor’s search on the lines on screen.
match_parenThe bracket matching the one at the editor’s cursor (not drawn yet).
read_only_markThe mark of read-only rules (its fg): the lock on a profile’s row and tabs, and the rule’s words.
danger_markThe mark of something that changes or deletes data, or of a production profile (not drawn yet).
plan_hotThe plan nodes that take the most time, in every view of a query plan and its summary.
plan_misestimateHow far a plan node’s estimated rows are from the actual ones, in the plan, its summary, detail and funnel.
size_warmExplorer size estimates of 1 MiB or more (with five levels: 100 MiB or more).
size_hotExplorer size estimates of 1 GiB or more (with five levels: 10 GiB or more).
size_mildWith five size levels, explorer size estimates of 1 MiB or more.
size_heatedWith five size levels, explorer size estimates of 1 GiB or more.
tab_activeThe active tab’s fill (its bg; the alternate surface without one). An fg replaces every text colour on it but the environment’s badge (a connected tab’s number becomes a chip of its profile’s colour); without one the tab’s colours stay, made to read on it. A file that leaves it out but sets bg or accent, both RGB, gets that accent blended into that bg; else the fill of the theme it extends stays.
grid_matchA cell of the result grid that the grid’s search matches (the whole cell is tinted: its value may be cut). Keep it apart from the selection, a selected range, the alternate rows, the hover and the copy flash.
grid_match_currentThe grid’s cursor cell while it is a match of the grid’s search.
edit_changedA cell of the result grid changed and not applied yet (its text: the cell keeps its background, so it must read on the alternate rows, the selection and a selected range).
edit_pendingHow many changes of a result are pending, on the result tab strip and the hint line.
edit_insertedThe cells of a new row of the result grid, not applied yet (their text: the cell keeps its background, so it must read on the alternate rows, the selection and a selected range).
edit_deletedA row of the result grid to be deleted, not applied yet (its text; crossed out, so it shows without colour).
edit_appliedA value of the result grid an Apply wrote, until the query runs again (its text: the cell keeps its background; italic, so it shows without colour).
edit_invalidA value a paste put in a cell of the result grid that its column does not take, not applied yet, and a new row’s cell that needs a value its column has no default for (its text: the cell keeps its background; underlined, so it shows without colour).