Settings in ctx
Every dispatch carries the dispatching plugin's current settings as a Lua table on the ctx - command handlers, event handlers, band views, tab titles, panel views:
dropterm.command('paste-uptime', 'Paste system uptime', function(p)
local prefix = p.settings.prefix -- the declared row's name
local fmt = p.settings['uptime-format']
...
end)
dropterm.on('x', function(payload, settings_ctx)
print(settings_ctx.settings.prefix)
end)
Every declared row appears, filled with the stored value or the
row's default - it is never missing. A plugin with no rows gets an
empty table. The event handler's payload stays exactly the documented
shape. The settings ride the second argument. Values persist across
relaunch in plugins-settings.json under the config dir - user
config the Plugins page writes (atomically), and scripts never touch.
Hand edits to the file load at the next launch.
The runtime
Inside a script, require('dropterm') yields the bus port:
local dropterm = require('dropterm')
dropterm.on('my-event', function(payload)
print('saw my-event') -- a script's print lands in the dropterm log
end)
dropterm.emit('my-event', {}) -- reaches every registered handler
on(event, handler) registers a handler. emit(event, payload)
dispatches to every handler registered for that event, in registration
order, script to script. An event nobody registered for dispatches to
nobody, silently. A handler that raises costs one log line and never
stops its siblings.
One host event has an audience of its own: clipboard-change reaches
the plugins that declare the clipboard-watch
permission alone.
Every observable step logs one line in the dropterm: plugins:
namespace - the host starting, each plugin activated or skipped with
its reason, each handler raise, each forwarded print.
Terminal events
The terminal's own life reaches the bus. Seven event names deliver from real sources - five from the engine's event stream, two from the window's focus - each with a minimal payload:
| Event | Payload | Fires |
|---|---|---|
bell | { tab } | the terminal bell (printf '\a') |
title | { tab, title } | an OSC 0/2 title report - change-gated: only when the title actually moves, so a shell re-reporting the same title on every prompt stays quiet |
title-reset | { tab } | the title cleared (an empty OSC 0/2 report) - only when one was set |
child-exit | { tab, code } | a command finished (the OSC 133;D report; code is its exit status) |
exit | { tab } | the tab's shell exited, as the pane tears down |
focus-gained | { tab } | the DropTerm window became keyboard-active - the active tab |
focus-lost | { tab } | the window stopped being keyboard-active - the tab that lost |
tab is the pane's tab id as an opaque number: stable for the pane's
life and meaningful only to correlate events. Delivery is
fire-and-forget on the host thread. Terminal events flow only when the
plugins/ dir stood at launch - a no-plugins session forwards
nothing, and its channel stays empty.
Link events
Links reach the bus as two events. A link-open handler is asked
before anything opens, and may decide; a link-hover handler is only
told.
| Event | Payload | Fires |
|---|---|---|
link-open | { tab, url, text, kind, via } | a link is about to open - from a click, a menu row, the picker, or another app |
link-hover | { tab, url, text, kind } | the pointer came onto a link |
link-hover | { tab } | the pointer left the last link |
| Key | Value |
|---|---|
tab | the link's tab, the same opaque number the terminal events carry |
url | the address the link opens |
text | the on-screen text |
kind | tagged, spotted, or path |
via | click, menu, picker, or outside - the open payload alone |
path | the file's address - a path link alone |
line, col | a position the text names - a path link alone |
The keys of the last two rows are absent on every other link, not
present as nil.
A link-open handler answers with one of three shapes. The first
decided answer ends the walk:
| The handler returns | The link |
|---|---|
{ handled = true } | is the plugin's: nothing else runs for it |
{ warn = 'text' } | is refused: text shows as the verdict |
nothing, nil, or {} | passes to the next handler |
The walk asks your handlers in registration order, then the core
rules, which are the embedded plugin core-links - so yours are
always asked first. A profile's plugins list scopes both events too
(profiles). A handler that returns
anything else - a string, a table with another key - costs one log
line and passes, and so does one that raises.
Like any event, link-open never activates a lazy plugin: a plugin
is asked once it is loaded, so one that wants links declares
on_startup.
link-hover is watch-only. What its handlers return is dropped, and
it reaches only the plugins that declare
link-watch, each inside the
hovered tab's scope.
Typed answers
Every slot's answer is one plain string, and a plain string stays
valid forever. The typed-answers contract adds one more shape: a
styled answer - an ordered list of flat spans, no nesting - which the
painters resolve through the style engine: each span's
classes, id, and inline declarations compete by the CSS cascade, and
the glyph rides as an icon declaration:
dropterm.panel_view('net', { container = 'chips', title = 'Net' }, function()
return { rows = {
{ chip = 'net', spans = {
{ text = ' 1.2 MB/s', class = 'net metric', id = 'rx',
style = { ['font-weight'] = 'bold', color = 'accent', icon = '↓' } },
} },
} }
end)
The icon declaration's glyph is prepended like the chips band's
builtin sigils ({icon} {text} - the chips band's ⎇ ⊞ ◉ shapes, not an
icon font). A glyph works:
{ text = ' 1.2 MB/s', style = { color = 'green', icon = '↓' } }
The vocabulary is closed - every key it declares:
| Key | Where | Meaning |
|---|---|---|
kind | the answer table | optional; when present it must be 'styled' - anything else costs the answer its one log line |
spans | the answer table | the ordered span list; required for a styled answer, 16 spans at most |
side | the answer table | the side word - required for a text answer exactly as before; a styled answer may omit it and takes left |
text | inside each span | the span's text - the part the chips band renders |
class | inside each span | optional; space-separated class names, the rules' .class parts |
id | inside each span | optional; the span's #id |
style | inside each span | optional; the inline declarations table - one kebab-case property with one value, the engine's closed vocabulary (color, background, font-weight, font-style, text-decoration, icon) |
color | (removed) | was a span key; one dropterm: line and ignored - style = { color = ... } or a rule instead |
icon | (removed) | was a span key; one dropterm: line and ignored - the icon declaration instead |
The style table's words resolve against the chips band's palette:
accent (the scheme's BrightBlue), attention (the scheme's red),
fg (the pane's foreground), bg (the worn scheme's background),
and the ANSI words - black,
red, green, yellow, blue, magenta, cyan, white, and
their bright_black, bright_red, bright_green,
bright_yellow, bright_blue, bright_magenta, bright_cyan,
bright_white forms. An unknown word costs one dropterm: log line
and renders unstyled (the span still paints its text, in the row's
own color). A #rrggbb literal paints directly. The chips band's
builtin looks are the host's own rules in the same layer
(styling a chip) - a plugin overriding
color there replaces one by ordinary cascade.
A plain-string answer renders exactly as it always did.
The evolution rule, stated plainly: the keyset grows additive-only - a new key arrives as a release, an existing key never changes meaning. Anything outside the vocabulary costs the answer exactly one log line and the slot keeps its prior - never a raise into the terminal.
Interactive slots report back over the bus under one event name,
slot-event, with one payload shape - four keys, no others:
surface, slot, element_id, kind. The dialog surface, the
chips band's progress chip, the panel views, and a chip
inside a tab row (filling a tab)
produce them. The shape is pinned by test on
both sides. On the tab surface slot is a number, the tab's id. On
every other surface it is a string. A dialog's answer can carry two
more keys, request_id and value, and only when it has them
(the input and pick kinds).
A panel field's two events carry value too
(panel fields). Every other event has
exactly the four.
Timeouts and reloads
Every unit of Lua work runs under a soft bound (100 ms) and a hard cap (1 s), enforced by an instruction-counting debug hook. Past the soft bound, a dispatch is marked stale - one log line - and its result is discarded when result-carrying surfaces arrive. Past the hard cap, the whole interpreter is torn down and recreated: every registration is lost by design, and the scripts reload with the current active set on the next work item. That reload is the runaway-script escape hatch. A script that hangs itself on every load costs one interpreter cycle per wake and never takes the terminal down with it.
The bounds cover Lua running on the host's main thread. A script
blocked inside a C call (say io.read on a pipe with no writer) or
spinning inside a coroutine it created executes no hook-checked
instructions and cannot be interrupted - full trust means exactly
that. Close the app if you write one.
Editing anything in plugins/ hot-reloads: the interpreter is
recreated whole (the only sound reload unit - a re-run file cannot
un-register its old handlers), all manifests and scripts are rescanned
at once, and the advertising rows re-merge. Deleting a plugin's
manifest drops its declared rows on the next reload. Deleting the
directory drops its registrations. Removing the directory itself
leaves the host idle and quiet.