Lokyr
Documentation

UI engine and main features

On this page

This document covers our UI engine and the features the MVP cannot ship without: tabs, splits, search, iTerm2 themes and the cursor's options.

UI engine

ui-core is our small, platform-independent toolkit. It draws all of the chrome on the GPU, into the same drawable as the panes.

View tree and layout

Widgets: those that the chrome and F3's plugins need. A plugin describes its UI with them and the host draws it: no plugin draws pixels or opens a native window, so that its UI takes the theme, the focus, the input method and accessibility, costs the frame no more than the host allows, and no plugin can pass itself off as the system.

Focus and IME

Accessibility

Themes: plugins use tokens (tabs.active.bg, search.match, …) rather than fixed colors, so a theme restyles all the chrome. A token that a theme lacks takes the color of its name without its last part, tabs.active for tabs.active.bg, then tabs, so that a theme of a few colors still covers them all; the built-in theme gives every token of the chrome, in its light and dark variants. transparent is no color in every theme, as the tokens that fall back to it are: a progress's track of it shows nothing.

Text and icons: the chrome's text is the interface's font, the system's by default, at the optical size of its points, so that a display of twice the pixels draws the same forms twice as large and the layout's measures hold at every scale; its glyphs share the atlas of the terminal's, and take the weight of macOS's text: the GPU, which blends a glyph's coverage as it is drawn, makes dark text on a light background a quarter heavier than the system's at a scale of 1, and so thins it by a curve of the text color's luminance, as the system does, leaving light text on a dark background nearly as it is, of the glyphs drawn of the font smoothing alone, as text without it, or of thin strokes, is macOS's as drawn; each glyph falls where the shaping puts it, to a third of a pixel, as a glyph drawn past its pixel's edge, so that a display of a scale of 1 keeps the font's spacing. The terminal's text keeps its glyphs as drawn, unless [font] system-weight asks for the system's weight. The icons are the codicons of the Symbols Nerd Font that the app carries, by their names (terminal, close, search, …), in the text's color, and two that the renderer draws as macOS 27's search field does, magnifying-glass and clear-circle.

The pointer: over a window's slots' views, the pointer goes to them before the panes; its moves without a button come to the app over them alone, of areas that the host gives the platform, for their hover and their tooltips, with its leaving them, the moves over the panes waking it only for a program that asks for them all; a press over a view keeps the pointer there until its button goes up, and a press over the panes, a selection's or a program's, keeps the pointer for them, over the views too. The node under the pointer is the topmost whose box holds it, within its ancestors' clips, as the tree draws a node over its parent and over its siblings before it. Its events go to the nodes of a key, by which their plugins know them: the hover to each node of a key that the pointer is over, its ancestors with it, so that the pointer over a tab's close is over the tab too; a click, a double click, a middle click and the context menu's to the innermost node of a key, the button down and up over it, the context menu's as it goes down; a button and a toggle take the primary button's as their own, a click or a toggle at each click, and a disabled one takes none, nor do the nodes around it. The primary button held over a node of a key, past 4 points, drags it: its start, its moves, of where it started, and its end come to that node alone, wherever the pointer goes, and no click; Tab's move of the focus, or the window's loss of it, cancels the drag, which its node learns of. A reorderable node's drag moves it among its siblings that are reorderable too, along its parent's direction: the host shows it under the pointer, within their room and over them, the others sliding out of its way in 0.2 s as it passes their middles, or reaches their edges, and a scroll area around them scrolling as it goes past the area's edges, the faster the further; it keeps its press and its hover until the button goes up, and the others show neither; Escape puts it back, its drag cancelled; a drop at another place gives it a reorder, of its new index, before its drag's end, and it slides to its new place, where its plugin's render of the new order keeps it, or, without one within half a second, slides back with the others. A wheel's or a trackpad's scroll goes to the innermost node of a key under the pointer, in points. A node's style gives the pointer's shape over it, the arrow, the I-beam or the pointing hand, which its children take unless they give their own; the window server shows it as the pointer moves, of areas that the host gives it, without waking the app.

Animations

Display list

Tabs

The tabs plugin. Each window's tab list lives in the kernel. The plugin handles the tab bar, the commands and the interaction.

Window integration

macOS

Linux (F7)

Appearance

Tab contents

Interaction

Commands and shortcuts

CommandmacOSLinux (F7)
tabs.new⌘TCtrl+Shift+T
tabs.close⌘W (closes the pane first when there are splits)Ctrl+Shift+W
tabs.next / tabs.prev⌘⇧] / ⌘⇧[, ⌃Tab / ⌃⇧TabCtrl+PgDn / Ctrl+PgUp
tabs.goto { index }⌘1 … ⌘9Alt+1 … Alt+9
tabs.move { delta }⌘⇧← / ⌘⇧→Ctrl+Shift+PgUp / Ctrl+Shift+PgDn
tabs.rename, tabs.set-color, tabs.detachmenu and palettemenu and palette
[plugins.tabs]
position = "top"          # top | bottom | left | right
style = "unified"         # standard | unified | seamless
hide-when-single = true
show-index = true
close-button = "hover"    # always | hover | never
min-width = 120
max-width = 260

The programs' progress

The progress plugin, after iTerm2 and Ghostty: a program's progress, of OSC 9;4, as Gradle's, which the VT core reads. Some programs, Gradle, cargo and Claude Code among them, send it only to the terminals that they recognize by their environment's variables, which Lokyr is not among yet: the README's Programs' progress tells how to turn each on.

The gutter

A few points at the left of each pane's cells, in its padding, which takes no column of the grid, with a thin bar on the prompt of each command that ran, of the commands that the shell marks with OSC 133: faint gray for a success, red for a failure, the accent while it runs, the theme's gutter.succeeded, gutter.failed and gutter.running; plugins lay marks of their own colors in it by the rows' numbers, which keep their rows as output and a reflow move them. [window] gutter turns it off.

The scroll bar

Each pane's, drawn by the host, as the dividers and a search's matches are, at the pane's right edge, as macOS's scroll bars look: a knob whose length and place tell how much of the scrollback and the screen the view shows, and where, of the theme's scrollbar tokens. Shown as the view moves, over the pane, it takes no column of the grid; shown always, each pane keeps a room for it at its right, past its padding, as macOS's legacy scroll bars take theirs, so that no cell lies under it. · Since 1.6.1

A long command's end

A command that the shell marks with OSC 133 and that runs for [notifications] long-command seconds at least, 10 by default, tells its end in a notification of the system's while its window has no focus: the command as it was typed, whether it succeeded or its exit status, and how long it ran. Its time runs from its output's mark to its end's, as the workspace finds them in the pane's output, a frame's pace apart at most, without a timer meanwhile; a click on the notification brings forward the pane that told it, with its tab and its window, as a click on any program's notification does.

The command's sticky header

The command-header plugin, after iTerm2: the command whose output the view shows stays at the pane's top, over the grid's top rows, which it takes no row of, so that the grid keeps its size as it shows and hides, over OSC 133's marks.

Splits

The splits plugin. Each tab's layout tree lives in the kernel, because session restore, IPC and tmux -CC need it too. The plugin provides the commands; the host draws the dividers from the layout tree, in the theme's pane.divider, and takes their drags itself, giving their splits ratios in the workspace, which the plugins learn of by layout-changed. Without the plugin, every tab has exactly one pane.

LayoutTree = Split { direction: horizontal | vertical, ratio?, first: LayoutTree, second: LayoutTree }
           | Leaf(PaneId)
plus an optional zoomed pane

A split without a ratio shares its room by its parts' panes along its
direction, so that three panes split alike take a third each; a divider's
drag gives it a ratio, between 5% and 95%, which `splits.equalize` takes away.
CommandmacOS (same as iTerm2)
splits.split { direction = "right" }⌘D
splits.split { direction = "down" }⌘⇧D
splits.focus { direction }⌘⌥ + arrows
splits.focus-next / splits.focus-prev⌘] / ⌘[
splits.resize { direction, cells }⌃⌘ + arrows
splits.zoom-toggle⌘⇧↩
splits.equalize, splits.swap { direction }, splits.move-to-tab, splits.move-to-windowpalette

On macOS the shortcuts are the keymap-macos plugin's, which binds the keys of every plugin's commands; on Linux (F7) they use Ctrl+Shift and are defined in keymap-linux.

Behavior

[plugins.splits]
dim-inactive = 0.15        # 0 = no dimming
pane-titles = false
focus-follows-mouse = false

Alternative layouts, such as kitty's tall, fat, grid and stack, can be added later as other plugins that edit the same tree.

The kernel's search service (the engine) plus the search plugin (UI and commands).

Engine

UI

[plugins.search]
case = "smart"            # smart | insensitive, while the case toggle is off
highlight-all = true
wrap-around = true

Copy mode

The copy-mode plugin, of the host's selection by a range, its scroll to a row, and a cursor of the plugin's own: a cursor of the keyboard's over the scrollback and the screen, which vi's keys move, as tmux's copy mode has them, to select and copy without the mouse.

iTerm2 themes

The host's, as it draws them: the app reads [theme] and the themes' files, light/dark switching, the importer of .itermcolors; the palette's picker, a plugin's, writes [theme].

Internal model

GroupFields
Terminal16 ANSI colors, 256-color palette (derived or explicit), foreground, background, bold, cursor, cursor text, selection (background and text), link, underline, badge
Searchsearch.match, search.match.current
UITokens for the tab bar; active, inactive and hovered tabs; dividers; overlays; accent; borders
ChromeThe colors of the chrome that the plugins draw, a section of each plugin's, as the tab bar's: the bar, the active, inactive and hovered tabs, their marks. The chrome's look, as the tab bar's style, place and shape, stays in the config, never in a theme
OptionsLight/dark variants; minimum-contrast, the minimum ratio between text and background (as in iTerm2 and Ghostty)

UI tokens that are not specified are derived from the terminal colors, the way iTerm2 derives its tab bar, each of the opacities of the built-in theme of its appearance, a theme dark where its background is darker than its text:

TokenDerived from
The tab bar's background, tabs.bar.bgbackground mixed 6% toward the foreground
A panel, panel.bgbackground mixed 4% (light) or 6% (dark) toward the foreground
The active tab, a fieldbackground
Textforeground
Secondary text, an inactive tab'sforeground mixed 38% and 40% toward the background, of three quarters of the theme's own contrast at least, 4.5 at most
Dividers, separators, borders, the buttons' and the hovers' veilsthe foreground at 10% to 18%
Accent, a focus ring, a list's selection, the progressthe palette's blue, or its bright blue, where it reads on the background at 3:1, else the foreground; the text on it white or black, whichever reads better
The search's matchesthe palette's yellow; the current one between its yellow and its red
The progress's error and pausethe palette's red and yellow

This gives every imported iTerm2 theme matching tabs right away; the chrome's colors that an iTerm2 theme does not give derive from its terminal's colors. The tokens' names are the theme's sections': the tab bar's tabs.*, the plugin's namespace, the segmented control's segments.*, the host's own as panel.* or field.*.

minimum-contrast is the least contrast ratio of a cell's text to the background under it, from 1, none, to 21: a text of less moves toward white or black, whichever reads better, as little as gives it, its opacity kept.

The default theme's terminal colors are the built-in palette of F2, with a light and a dark variant, whose colors meet WCAG's contrast on their backgrounds.

.itermcolors importer

Where themes come from

Usage

[theme]
light = "Rose Pine Dawn"
dark = "Dracula"          # the names of the collection's schemes, or of the themes' folder's files
minimum-contrast = 1.0

Verification

Command palette

The command-palette plugin (⌘⇧P on macOS, Ctrl+Shift+P on Linux):

Windows restored

As Lokyr quits, the windows that are open, the quick terminal's and the man pages' aside, are kept in the state's directory, in windows.json, and open again as it starts, as [app] restore-windows says: as macOS restores an app's windows, of its setting "Close windows when quitting an application", by default, or always, or never.

The Finder's services and the Dock

A window, or a tab, at a folder, from the Finder, as a daily path into a project:

Lokyr as the default terminal

Lokyr › Make Lokyr the Default Terminal asks macOS, through Launch Services' default handlers, NSWorkspace's setDefaultApplicationAtURL:, to open in Lokyr the shell scripts, Terminal's com.apple.terminal.shell-script, .command and .tool, and public.shell-script, .sh, the executables, public.unix-executable, and the ssh and x-man-page links; macOS asks to confirm the changes, one after the other, and what is declined stays as it was, as the log tells. The item is ticked and dimmed while Lokyr is the default of them all, as the platform asks Launch Services on a thread of its own after the start and as the app becomes active, as another app may take the default meanwhile, out of their way, and again as the changes end; nothing changes but as the item is chosen.

The command line tools

Lokyr › Install Command Line Tools… links lokyr and sleip, the binaries of the bundle's Contents/MacOS, into /usr/local/bin, on macOS's default PATH (/etc/paths), so that another terminal and the scripts run them as Lokyr's panes do, whose PATH ends in that folder. Both run through a link: Sleip finds the app's plugin API of its bundle, the link resolved, and the app's command line, as lokyr --api-version, of its own.

Basic actions

The core-actions plugin:

The app's own, of no plugin: Window › Float on Top, window.toggle-float-on-top, keeps a window above the other applications' windows, at AppKit's floating level, each window of its own, its item ticked as the window in front floats and dimmed for the quick terminal, which floats of its own; a window in full screen takes the normal level there, and floats again as it leaves it.

View › Use Transparency, window.toggle-opacity, of ⌘U by default, shows a window that [window] background-opacity makes translucent opaque, of no backdrop, its background and the chrome's backgrounds whole, and translucent again, each window of its own, its item ticked as the window in front is translucent and dimmed for one that the config keeps opaque and for the settings window; the config's opacity and blur stay as they are, and a new value of either shows in every window, those shown opaque too.

The pane's context menu

A right click, or a Control click, opens a native menu at the pointer, after macOS's Terminal; a program that takes the mouse's clicks has them, but with Shift. The click selects first: within the selection it keeps it, on a word it selects the word, on a blank cell it takes the selection away. Its items are the commands that take the click's cell, then the clipboard's and the editing's; an item that would do nothing there is dimmed, as its context or its plugin tells.

The actions come with the features that they belong to, from Terminal's (T), iTerm2's (i) and Ghostty's (G) menus:

PhaseActions
F2Open Link (T, i); Look Up “word” (T); Open man Page for “word” (T); Copy, Paste (T, i, G); Select All, Clear (i)
F3, with the tabs, the splits and the plugins' itemsSplit Right, Left, Down and Up, Close Split (G, i); New Window and New Tab at the folder under the pointer (T); move the pane to a tab or a window (i); rename the tab (G); Search man Page Index (T); Search the Web, with the engine in the config (T, i); Copy Link Address (i)
F5a, with the OSC 133 marks and the blocksmark a line, as a bookmark too (T); the command's details, run it again, select its output, fold it (i)
F5b, with the broadcast and the floating panesleave the window's broadcast and join it again (i), float a pane or move a floating one into the splits · Since 1.5; make a pane read-only (i, G); annotate the selection, save the selection as a snippet (i)
F5c, with the links' smart selectionopen a file:line in the editor, Quick Look the link, the smart selection's own actions (i)
Plugins, from F4the selection as pretty-printed JSON, Base64 decoded or encoded, the colors that it names (i)
Tools, laterreset the terminal, the inspector, the terminal's modes (G, i)

Its items show no keys, as macOS's context menus and Terminal's, the menu bar telling them.

A trigger is written in the config's [triggers] or in the settings window's Triggers section, rather than made of the selection (Triggers) · Since 1.7.

Its groups, from the top: what opens at the cell, Open Link, Copy Link Address, New Window and New Tab at Folder, and the man pages of the selection; Look Up and Search the Web, of the selection; the clipboard's; the editing's; Leave Broadcast, or Join Broadcast for a pane left out, while the window broadcasts its typed input, and Float Pane, of a tab of several split panes, or Move Pane into Splits, of a floating pane · Since 1.5; then the plugins' items, a group of each plugin, as tabs' Rename Tab…, splits' Pane submenu of Split Right, Left, Down and Up, the moves of the pane to a tab or a window, and Close Pane, and blocks' Block submenu of a block's actions · Since 1.4. A plugin adds its items through the HostApi, each a command of its arguments, as it adds them to the menu bar's menus, where they show their keys; an item of a submenu goes into it with the plugin's other items of the same submenu, and an item of a command of a cell, of no arguments of its own, takes the cell clicked. An item of one of Lokyr's own plugins that goes into a submenu takes its command's place in the menu, though the command is another plugin's, as blocks' items of core-actions' Copy Command Output and Select Command Output · Since 1.4.

A right click, or a Control click, on the prompt rows of a block that the host pins at a pane's top goes to the plugins as prompt-rows-menu, of the pane, its window and the block's command, the terminal and the program taking none of it: blocks opens a menu of the block's actions there, as it does of a context click on its pill · Since 1.4.

Left out: downloads with scp (i), as the app has no networking code, and editing the session (i), as the settings are the config's.

Agents

AI agents that run in a pane, such as Claude Code, Codex, Gemini CLI, OpenCode or Aider, are recognized, and can drive the terminal.

Cursor

render-metal draws the cursor's cells into a layer of their own, over the pane's, which the window server blinks. Its options sit in the [cursor] section of the config, and hot reload applies them at once.

[cursor]
shape = "block"           # block | bar | underline | hollow
blink = true
thickness = 2             # a bar's width and an underline's height, in points (0.5–20); the face's underline thickness when absent
blink-interval = 500      # how long the cursor stays on, then off, in ms (100–5000)
smooth-blink = "breathing" # off | breathing | linear | fast | slow | subtle | custom
fade-in = 900             # with smooth-blink = "custom": the fades, in ms
fade-in-curve = "ease-in-out" # linear | ease-in | ease-out | ease-in-out
visible = 500             # how long it holds, visible, then hidden, between fades, in ms
fade-out = 900
fade-out-curve = "ease-in-out"
hidden = 500
blink-timeout = 15        # seconds without keys or output before blinking stops; 0 never stops
movement = "instant"      # instant | snappy