Bands and chips
Bands are the slim strips at the top and bottom edges of the drop-down's column. They are panel containers, like the right rail: your plugin's views lay chips in them - small labeled items that copy a value, run one host action, or report a press. One band ships filled: DropTerm embeds a Lua plugin (core-chips) whose chips show the foreground process, the working directory, the git branch, the last command, the scrolled-back lines, the clock, the missed-activity mark, and the tab's pasted images. Everything it does is on this page. The tab strip is a band too, and it has its own page (the tab strip): Lua can lay chips beside the tabs, decorate the tabs, fill them, and act on them.
The plugins page covers the runtime these scripts run on: the host, hot reload, timeouts, and the trust model. Every log line this page quotes carries the dropterm: plugins: prefix. The Lua examples assume local dropterm = require('dropterm') at the top of the script (the runtime).
Declaring a band
You declare a band in your plugin's manifest with one key, bands, a list:
{
"bands": [
{ "id": "build", "edge": "top" }
]
}
| Key | Holds |
|---|---|
id | a slug: lowercase letters, digits, hyphens, up to 64 characters |
edge | the band's edge: top, bottom, or free. free, the default, is the edge opposite the screen anchor |
A band that breaks a rule is skipped, and your plugin still loads. The checks run in the order the keys appear, and a row with several faults costs one log line - the first fault:
- The id:
<plugin>: a declared band is missing its 'id'; skipping the band,<plugin>: a declared band has an 'id' that is not a string; skipping the band, or, for an id outside the slug shape,<plugin>: band '<id>' has an id that would not register: names are lowercase slugs (letters, digits, hyphens) up to 64 characters; skipping the band. tab-stripis reserved for the tab strip's own band:<plugin>: band 'tab-strip' is the shell's own id; skipping the band.- The edge:
<plugin>: band '<id>' has an 'edge' that is not 'top', 'bottom', or 'free'; skipping the band.
Unknown keys are not a fault: each costs one line (<plugin>: ignoring unknown band key '<key>'), and the band is still declared. The same goes for a bands that is not an array (<plugin>: ignoring the 'bands' key: it is not an array) and a row that is not an object (<plugin>: a declared band is not an object; skipping the band). If one manifest declares the same id twice, the first stands: <plugin>: band '<id>' declared twice; keeping the first. If two plugins declare the same id, the plugin with the lower id wins silently: the scan runs in plugin id order, and no line is logged.
The id is the name your views seat under, and the user's controls address the band by it. The command palette carries one row per band, shown or hidden. Toggle the chips band is bound to Ctrl+Shift+B, and Toggle the tab bar to Ctrl+Shift+J - the way back once the tab strip's own menu has hidden it. Every other band's row is unbound until the user binds it. Right-clicking a band opens its menu - Move to top, Move to bottom, Hide, New Tab, Pasted Images…, Settings… - and dragging its handle resizes it. Whatever the user does to a band (hide it, move it to the other edge, resize it) is remembered across restarts in panels.ron. No config key governs a band.
Seating a view in a band
You seat a view with dropterm.panel_view(view_id, config, handler) (panel views); its container value names the surface:
container | The surface |
|---|---|
right-rail | the right rail, the one container v1 had |
left-rail | the left rail, the right rail's twin behind its own gate |
tab-strip | the tab strip's band. The view's chips lay after the last tab row, inside the strip's scrolling row area |
a declared band's id, as chips | that band |
Any other value costs one log line and takes no seat: panel_view 'x' rejected: the container 'nowhere' is not 'right-rail', 'left-rail', 'tab-strip', or a band a manifest declares. A missing or empty title is refused the same way.
A view id holds one seat across the four surfaces. Registering the same id on another surface moves it, and the log says so (panel_view 'x' replaced (one live seat, moved from 'right-rail' to 'chips')); the new registration is the last of its band's views.
A band appears only while a view is seated in it. It grows as tall as its chips need: chips that do not fit one row wrap onto the next, up to half the column. Past the cap, the longest chip on the row elides, then chips drop from the end.
The height you drag a band to becomes its minimum. It stays there when the view paints nothing, and shrinks back to it when the chips fit fewer rows. The terminal loses a row whenever chips spill onto a new one (say, when a command starts running or you scroll back) and gains it back when they fit again; to hold the room, drag the band a row taller. The chips band also appears while one of the shell's own chips stands - a plugin's progress item, or a paste's refusal.
Chips
A chip is a panel row carrying the key chip. It has seven keys, and no others:
| Key | Holds |
|---|---|
chip | the chip's id: a non-empty string, unique inside its view, and the press event's element_id |
text or spans | the label: exactly one of the two. text is plain; spans is the typed answers span list, each span with its own class and style |
badge | optional: a small trailing label (a count, a state word) |
tip | optional: the hover tip |
class | optional: the style hook, the chip's chip.<class> rule (styling) |
copy | optional: clicking copies this value to the clipboard |
action | optional: clicking runs one host action. The set holds two actions, scroll_to_bottom and open_images_panel |
copy and action never stand together: a click does one thing. A chip with the wrong shape costs the answer one log line, and the answer is rejected, so the view keeps its previous content. These shapes are wrong: a key outside the seven, a key of the wrong type, text and spans both present or both missing, copy and action together, an action outside the set, an empty chip, or two chips of one view sharing an id.
Two of the embedded plugin's views - the core clock, with its copy value, and the scrolled chip:
dropterm.panel_view('clock', { container = 'chips', title = 'Clock' }, function(ctx)
return { rows = {
{ chip = 'clock', text = '◷ ' .. ctx.clock, copy = ctx.clock,
tip = 'Click to copy' },
} }
end)
-- The scrolled chip: shown only off the bottom, its click the jump
dropterm.panel_view('scrolled', { container = 'chips', title = 'Scrolled' }, function(ctx)
local lines = ctx.scrolled_back
if not lines or lines == 0 then return nil end
return { rows = {
{ chip = 'scrolled', text = '↑' .. lines, class = 'scrolled',
tip = 'Scrolled back ' .. lines .. ' lines. Click to jump to bottom.',
action = 'scroll_to_bottom' },
} }
end)
What a click does
| The chip carries | A click |
|---|---|
copy | the shell writes the value to the clipboard, and the chip shows ✓ in place of its label for 800 ms. Nothing reaches Lua |
action | the shell runs it: scroll_to_bottom jumps the active terminal to its bottom; open_images_panel opens the pasted-images panel over the active tab, wherever the chip sits. Nothing reaches Lua |
| neither | the shell sends the owning plugin's handler a slot-event of kind chip:press, and nobody else's: exactly the four keys { surface = 'panel', slot = <the view id>, element_id = <the chip id>, kind = 'chip:press' } |
A view docked in the strip band lays a chip beside the tabs the same way. This one's chip has no verb, so its click is the plugin's own:
local busy = false
dropterm.panel_view('build', {
container = 'tab-strip',
title = 'Build',
}, function()
return { rows = {
{ chip = 'build', text = busy and 'building…' or 'ok',
tip = 'The build widget' },
} }
end)
The band view's ctx
A view seated in a band - tab-strip included - receives the status mirror flattened into its ctx, next to settings. A rail view receives settings alone. The mirror holds what the tick already gathered for the chips: no engine state is read on a script's behalf, and a fact the terminal does not have is a key the ctx does not carry:
home, cwd, reported_cwd ({host, path}, the shell's OSC 7 report), hostname, shell, profile_name, zoom_adj, zoom_step_mul_100, foreground, branch, grid ({cols, rows}), spawn_grid, tab_position ({index, total}), clock, running_elapsed (seconds), frozen ({name, duration_seconds}), exit_status, scrolled_back, pasted, progress ({state, value}), program_status ({state, progress}), ssh_destination, missed_activity.
shell, zoom_adj, zoom_step_mul_100, and missed_activity are always present; the rest appear only when the terminal has the fact. The core command chip reads three of them. On Windows, the running fact is the shell's own C mark - the prompt zone - and the exit verdict comes from its D mark; PowerShell reports both. A shell that reports neither shows the chip without them: no elapsed time, no verdict (cmd and Git Bash, known issues):
-- Durations read `0:04`, `2:41`, and `1:00:00` past the hour.
local function format(seconds)
seconds = math.floor(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = seconds % 60
if hours > 0 then
return string.format('%d:%02d:%02d', hours, minutes, secs)
end
return string.format('%d:%02d', minutes, secs)
end
-- The command chip (core-chips): the live elapsed, the frozen pair,
-- the failed exit in the attention class
local ATTENTION = { class = 'attention' }
dropterm.panel_view('command', { container = 'chips', title = 'Command' }, function(ctx)
local name, seconds
if ctx.running_elapsed then
name, seconds = ctx.foreground, ctx.running_elapsed
elseif ctx.frozen then
name, seconds = ctx.frozen.name, ctx.frozen.duration_seconds
else
return nil
end
local failed = ctx.exit_status ~= nil and ctx.exit_status ~= 0
return { rows = {
{ chip = 'command', text = '⧗ ' .. name .. ' ' .. format(seconds),
class = failed and 'attention' or nil,
copy = failed and tostring(ctx.exit_status) or name,
tip = failed and 'Last command failed. Click to copy the code.'
or 'Click to copy the name' },
} }
end)
When a band view is asked
Every registered view - in the rails and in the bands - is asked together, in one interpreter trip. A trip fires:
- when the registry changes: once at launch, so the first summon paints chips, and again whenever the set of registered views changes, shown or hidden;
- at each show: one ask lands when a hidden drop-down is shown;
- while shown, when the status mirror changed since the last trip, and never sooner than 250 ms after the previous ask. Only a registry holding a view seated in a band reads the mirror, since a rail view does not;
- while shown, once a second regardless, so a view that polls its own state (
io.popen, a file) refreshes with no input change; - while shown, when a script pulls:
dropterm.emit('status-refresh', {}).
While hidden, none of the last four fires: the bands keep what they show until the next summon.
Each trip runs under the plugins runtime's soft bound (100 ms) and hard cap (1 s). A trip past the soft bound is stale: its answers are discarded, and every view keeps what it shows. A trip past the hard cap reloads the interpreter and re-runs the registrations; the bands keep their content across the gap. A handler that raises, or answers an unusable shape, costs one log line, and the view keeps its previous content. A nil answer is a fresh answer of nothing: the view hides until an answer comes back.
Styling a chip
Three element names address a chip (styling): chip for every chip, and the two classes the core chips wear, chip.attention and chip.scrolled. The host's builtin layer holds a rule for each: the failed command's chip and the missed-activity mark paint in the attention token (the scheme's red), and the scrolled-back chip paints in bright_black. Your own chip.<class> rule restyles the chips carrying that class, by ordinary cascade.
The core chips
core-chips is one plugin embedded in the binary: it is never written to your plugins dir, it declares no setting and no profile (so it has no card on the Plugins page), and it loads before every plugin in that dir. Its eight views sit in the chips band, one chip each: process, cwd, branch, command, scrolled, clock, activity, pasted. The last is the tab's pasted-image count (▦ 3 images, singular at one): it is absent while the tab has no pasted images, and its click opens the images panel.
To replace one chip, register a view with its id in the chips band. The later registration takes the seat, whatever the plugins' id order, and one log line names it (panel_view 'clock' replaced (one live seat)). To replace the whole set, put a plugin dir named core-chips in your plugins dir: it shadows the embedded plugin whole, at one line (core-chips: shadowed whole by the user's plugin dir with its id), and the embedded script never runs.
The core labels
core-labels is a second plugin embedded in the binary, beside core-chips: it is never written to your plugins dir, it declares no setting and no profile, and it loads before every plugin in that dir. It paints each tab's label through dropterm.tab_chips - the label's text as the badge, its palette word as the class - and ships one tab-badge.<word> rule per palette word so a label's color lands on the badge alone (styling). It owns the label's door: one Label… row on the tab's own menu, under Plugins, running its tab-label command. The pick offers the labels used before, New label…, and Clear label only when the tab wears one; a new label is typed, then colored from a seven-word pick. The recents live in the plugin's state, eight at most.
The command is a palette row and bindable, so a chord or palette run labels the active tab. To replace the plugin whole, put a plugin dir named core-labels in your plugins dir: it shadows the embedded plugin at one line (core-labels: shadowed whole by the user's plugin dir with its id), and the embedded script never runs. The label itself is the app's, not this plugin's: dropterm.tabs.label writes it, the session saves it, and another tab_chips source paints its badge if you retire this one.
Acting on tabs: dropterm.tabs
The tabs table (dropterm.tabs) holds eight verbs: your plugin can act on the tabs and build its own tab UI anywhere - in the rail, say. Each verb is checked at the call against the tab list the shell last pushed. A wrong-shaped argument, an id the list does not hold, or a move index outside the list answers false, with one log line naming the verb and the reason (dropterm.tabs.select dropped: no tab has the id 9); nothing raises. A good call answers true, and the shell applies it the way the tab strip's own controls do. None of the verbs is gated.
| Verb | Does |
|---|---|
new | dropterm.tabs.new([profile]) opens a tab: the plain default spawn, or the named profile's |
select | dropterm.tabs.select(id) activates the tab |
close | dropterm.tabs.close(id) closes the tab through the close gate: a pinned tab is refused, and a running command may raise the still-running warning |
rename | dropterm.tabs.rename(id, title) is the user's rename, which wins over every plugin's title. An empty title clears it |
duplicate | dropterm.tabs.duplicate(id) opens a copy: a fresh plain shell in the tab's directory, landed after the active tab |
move | dropterm.tabs.move(id, index) moves the tab to index, counted from 1 as Lua counts. A pinned tab refuses |
pin | dropterm.tabs.pin(id) toggles the tab's pin |
label | dropterm.tabs.label(id, text, color) is the tab's label: a short text and a palette word painted beside the title, never part of it. An empty text clears it, and a nil color is accent |
Three refusals that only the shell can know about cost one log line there, and nothing happens: a tab closed since the list was pushed (tabs select dropped: tab 9 is gone), a pinned tab's move (tabs move dropped: tab 3 is pinned), or a profile the config does not carry (tabs new dropped: no profile named web).
A plugin reaches a tab from the tab's own menu too: a manifest's tab-menu rows stand on every tab's right-click menu under one Plugins entry, and a pick runs the command on the clicked tab, active or not.
Decorating tabs: dropterm.tab_chips
dropterm.tab_chips(handler) registers a tab strip decoration source. Every plugin may register one; a plugin registering again replaces its own source, logged. The tab_chips handler receives the tab list as an array, each row { id, title, cwd, profile, label }, where title is the tab's raw OSC 0/2 report, cwd, profile, and label stand only when the tab has them, and label is the tab's { text, color }. It returns, per tab id, a table of { badge?, class?, tip? }:
-- The strip's decoration source: a badge, a class, a tip; never the label
dropterm.tab_chips(function(tabs)
local out = {}
for _, tab in ipairs(tabs) do
if tab.title == 'ssh' or tab.title:match('^ssh ') then
out[tab.id] = { badge = 'remote', tip = 'A remote shell' }
end
end
return out
end)
The label is always the tab's own title. A text key in an entry, or any other key, costs one line naming the plugin, and its source sets nothing on that tab. A tab the answer leaves out, or gives an empty entry, wears nothing from that source. No interaction rides the seat.
A tab reads Terminal N until a provider names it, and a manual rename always wins on a tab the app draws itself. On a tab that a dropterm.tab_rows source fills, the source is told the new name and is trusted to show it. The provider is dropterm.tab_title (script tab titles). This one recipe reproduces the titles the old Shell mode gave:
-- A plugin that names tabs the way the old `Shell` mode did
dropterm.tab_title(function(tab)
return (tab.title ~= '' and tab.title) or nil
end)
Several sources
Every registered source receives the tab list, over the tabs its plugin may reach, and the answers merge per tab and per key: a tab wears every key a source set on it. Where two sources set the same key on one tab, the later registration's value stands, at one line naming both (git-badges: the tab chips source's 'badge' for tab 3 stands over ssh-tags's). A source's fault costs that source alone: a malformed entry, a raise, or an answer that is not a table costs one line naming the plugin, and every other source's answer lands. When a source joins, or leaves while others stand, the whole strip is asked again: a joined source lands at once, and a departed source's keys withdraw. A reload that registers the same sources again asks nobody, and the last source leaving changes nothing: the strip stays as it was painted.
Filling a tab: dropterm.tab_rows
dropterm.tab_rows(handler) registers the tab rows source, a third seat beside the two above. There is one seat, and a replacement is logged. The source decides what each tab shows inside the tab the app draws. The handler receives the tab list as an array, each row { id, title, name, cwd, profile, label }: title is the tab's raw OSC 0/2 report, name is the title the strip shows on the tab (a manual rename first, without the pin and attention marks), and cwd, profile, and label stand only when the tab has them. It returns, per tab id, a table of three keys:
| Key | Holds |
|---|---|
class | a string: the tab's style class; a tab.<class> rule reaches that tab alone |
wrap | a boolean, false when absent: the tab's text wraps onto the lines the row has room for |
rows | an array: the tab's content, replacing the app's own title and badge |
A tab the answer leaves out, or whose entry is nil or empty, is the app's own tab as it stands, its dropterm.tab_chips decoration included. An entry with no rows, or an empty rows, is the app's own tab with class and wrap applied.
The rows are what a panel view's rows are (panel views): a text row (text, or spans for styled text - when both stand, the spans are the ones laid - plus class and style), or a chip (chip, an id that is non-empty and unique inside the tab; exactly one of text and spans; badge, tip, class, copy, action). A field row is refused: no text input goes inside a tab.
-- A tab's rows: two chips and the tab's name; a long name wraps
dropterm.tab_rows(function(tabs)
local out = {}
for _, tab in ipairs(tabs) do
local host = tab.title:match('^ssh ([%w%._%-]+)')
if host then
out[tab.id] = { class = 'remote', rows = {
{ chip = 'host', text = '⇄', tip = 'Copy the host', copy = host },
{ chip = 'dup', text = '⧉', tip = 'Open a copy of this tab' },
{ text = tab.name },
} }
elseif #tab.name > 24 then
out[tab.id] = { wrap = true }
end
end
return out
end)
-- A chip with neither `copy` nor `action` reports its press to this
-- plugin alone, naming its tab. Read `surface` first: on this surface
-- `slot` is the tab's id, a number.
dropterm.on('slot-event', function(p)
if p.surface == 'tab' and p.kind == 'chip:press' and p.element_id == 'dup' then
dropterm.tabs.duplicate(p.slot)
end
end)
The app keeps the tab itself, on every tab: the close button and its gated close, the pin and attention marks (drawn ahead of the content on a filled tab), the right-click menu, drag to reorder, click to select, and double-click to rename. A press on text inside a tab is a press on the tab: it selects, and it may start a drag. Only a chip takes its own click, and a tab chip's click is one of a band chip's three verbs. copy writes the clipboard and flashes ✓ for 800 ms. action runs its host action - scroll_to_bottom on the chip's own tab, active or not, and open_images_panel the images panel over the active tab. A chip carrying either sends nothing to Lua. Any other chip reports its press to the plugin holding the seat alone, under slot-event's four keys:
{ surface = 'tab', slot = <the tab's id>, element_id = <the chip id>, kind = 'chip:press' }
Here slot is a number, the tab's id - it is a string on every other surface - so a handler reads surface before it indexes slot. No tab is set for that dispatch, so send_text in the handler keeps its standing drop. A chip may carry its own tip.
Refusals cost one log line each, and the tab keeps its previous answer. A malformed entry, an entry with another key, a wrap that is not a boolean, a field row, a chip with both text and spans, or an entry that is not a table, logs the tab rows source's entry for tab {id} was refused: {verdict}. A handler that raises logs one line and lands nothing; the same goes for an answer that is not a table. A nil answer returns every tab to the app's own.
Three facts belong to a filled tab:
- The name on hover. A filled tab may carry no title text, so its hover tip is the tab's
name. - The rename. The source receives
name, so showing a rename is the plugin's to do; the promise that a manual rename always wins carries this one caveat (the rename). While the rename box is open, the app swaps it into the row in place of the content, and hands the row back afterwards. - The width and the wrap. The row stays 128 to 200 px wide, by what it holds - never a width a plugin chooses. Text rows are the part that gives; a chip keeps its width; whatever does not fit at the cap is clipped.
wrap = truelays the text onto the lines the row has room for, the last ending in...; a text row of several styled spans wraps span by span. Two lines need the strip dragged to about 70 px or taller; the default is 48 px, and until then a wrapping tab shows one line.
Styling: a tab.<class> rule may set color and weight as for any tab, and background besides. The fill shows on an inactive tab, and the active tab keeps its highlight (the addressable tree). Inside the content, a text row's class and style and a chip's class resolve as a view's do, and a span that sets no color or weight of its own paints in the tab's own, dimmed on an inactive tab the way its siblings' titles are.
The life of an answer: nothing is saved in the session, and a fresh launch asks every tab once, when the source appears. The source is asked again, over the whole list, when a tab's facts change - its report, its folder, its profile, or its name - and never per tick. A raise, or a trip past the soft bound (100 ms), keeps every previous answer and costs one log line. A reload that registers the seat again is not an arrival: nothing is cleared and nothing is asked. A reload that ends with no source returns every tab to the app's own.
One fact about older binaries: on a DropTerm without the name, a plugin that calls dropterm.tab_rows at its top level is skipped whole, with one log line, so the script's other registrations never run. Keep the call where an older binary losing it costs nothing else.
Retired: dropterm.status_segment
dropterm.status_segment is retired. Calling it costs one log line naming the retirement, nothing renders, and a status chip is a panel view in the chips band.