Panel views
You dock a view into a panel container with
panel_view (dropterm.panel_view(view_id, config, handler)); its
container names the target (the
panel containers' page covers the shell side,
and bands the bands):
container | The seat |
|---|---|
right-rail, left-rail | the two edge rails, each behind its own config gate |
tab-strip | the tab strip's band |
| a declared band's id | that band |
The host asks every registered view in one batched interpreter trip:
| The views are asked | when |
|---|---|
| at each show | of the drop-down |
| at the standing cadence | while it is shown - the once-a-second interval, plus a script's status-refresh pull |
| on registry change | whenever the set of registered views changes |
The answer paints as the view's titled section. One seat per view id: a replacement takes it, and the log says so. An interpreter reload clears the seats. The rail keeps its last painted content across the gap (the stale-degrade story, for panels too).
dropterm.panel_view('tasks', {
container = 'right-rail',
title = 'Tasks',
}, function(ctx)
return { kind = 'panel', rows = {
{ text = 'ship the spec review' },
{ text = 'walk the dialog', class = 'task done',
style = { color = 'green', icon = '◉' } },
} }
end)
dropterm.on('slot-event', function(p)
if p.slot == 'tasks' and p.element_id == '0' then ... end
end)
The answer's shapes are the typed-answers contract's, additive:
| The view's answer | What paints |
|---|---|
| a flat answer (styled spans) | one row |
the rows shape | one row per entry - either the spec example's span keys directly on the row, or a spans array for many |
a row's optional numeric id key | presses carry it as the event's element_id, the positional index (0, the first row) standing in when it is absent |
| a wrong shape | the answer costs one dropterm: log line and the view keeps its previous content - never a raise into the terminal |
nil | hides the view this round |
| a long view | the rail scrolls its own content; the view scrolls within it (no per-view scroll machinery in v1) |
The rail is display + click only, except its text fields: the terminal
keeps the keyboard while the rail stands, and a field holds it while
it has focus (panel fields). Which sections the rail
shows, and in what order, is the user's say: the panel_rail_sections
config key (configuration) lists them,
and a view the list leaves out stays registered and is still asked -
only not painted.
The container word decides the rail, and the user decides whether
that rail stands: left_rail_enabled stands the left rail, and
left_rail_sections lists its sections, the right pair's rules one
rail over (configuration). One ask
covers the views of both rails, whichever gate is on, and an output
channel stays on the right. A left-rail view is the same view, painted
by the same painter, so its rows are press targets and its fields take
the keyboard as a right-rail view's do:
dropterm.panel_view('notes', {
container = 'left-rail',
title = 'Notes',
}, function(ctx)
return { kind = 'panel', rows = {
{ text = 'water the plant' },
{ text = 'call the bank', id = 8 },
} }
end)
Panel fields
A view's rows can hold text fields beside its text rows. A row table
with a field key is one: it paints as a single-line input in the
rail, in row order among the rows, and the text rows stay the buttons.
The example is a working filter - the field first, the rows that match
after it, and a handler that keeps each change and pulls a refresh so
the list narrows at once:
local items = { 'alpha', 'bravo', 'charlie' }
local query, set = '', 0
dropterm.panel_view('search', {
container = 'right-rail',
title = 'Search',
}, function()
local rows = {
{ field = 'q', placeholder = 'Filter…', value = query, set = set },
}
for _, item in ipairs(items) do
if item:sub(1, #query) == query then
rows[#rows + 1] = { text = item }
end
end
return { rows = rows }
end)
dropterm.on('slot-event', function(p)
if p.slot == 'search' and p.kind == 'input:change' then
query = p.value
dropterm.emit('status-refresh')
end
end)
A field row has its own closed keyset. A text row's keys are not a
field's, and the reverse: a key of the other kind is an unknown key,
and costs the answer its one dropterm: line while the view keeps its
previous content.
| Key | Meaning |
|---|---|
field | the field's id - non-empty, unique inside its view; the event's element_id |
placeholder | optional; the hint painted while the field is empty |
value | optional; the text the script puts in the field - it travels with set, and one without the other costs the answer its line |
set | optional; a non-negative whole number - value applies only when this changes |
A field takes a place in the positional press ids: with a field first,
the text rows after it number from 1.
A field is no press target. Its events reach the owning plugin's
slot-event handlers alone, while a row's press stays on the bus for
every plugin:
| Word | Keys | Meaning |
|---|---|---|
input:change | the four, plus value | the text changed; value is the field's text, whole |
input:submit | the four, plus value | the user pressed Enter; value is the text, whole |
Neither carries request_id. A slow handler never sees a queue of
older changes: while one of a field's changes waits, a newer one
replaces it, and the handler sees the newest text once. A submit is
never held back, and always carries its own text.
The host keeps what the user typed. It asks the view every second and
each answer replaces the view's whole content, so the typed text would
be wiped each time if the script's answer decided it. A script sets or
clears the text with value and a changed set: an answer repeating
the same set never replaces the typed text, however its value
reads, and a set never comes back as an input:change. A field dies
with its view's content - a nil answer, or a view that leaves the
registry, drops the field and its text.
The keyboard: the terminal keeps it while the rail stands, except while a field has focus. A click gives a field the keyboard. Enter submits, and the field keeps it. Escape, or a click on the terminal, returns it to the terminal. Tab and Shift-Tab move among one view's fields and never leave the rail. While a field has the keyboard the terminal's own chords wait. A field whose view stops painting - the rail switched off, or the section list hiding the view - hands the keyboard back and keeps its text.
One style word restyles every field: panel-input
(styling), its color for the typed text (the hint
keeps the theme's color).
Bands, chips, and tabs
A view seated in a band lays chips, and your plugin can declare its own
band, act on the tabs with dropterm.tabs, decorate them with
dropterm.tab_chips, and fill them with dropterm.tab_rows - the
bands page covers the manifest key, the chip's keys and its
click, the ctx a band view receives, when it is asked, and what a
filled tab shows.
dropterm.status_segment is retired: a chip
replaces it. dropterm.tab_title names a tab whenever a provider is
registered - their own page covers the provider
contract, the ask gating, and the stale ladder.
Commands and send_text
dropterm.command(name, description, handler) puts your script's own
verbs on the keyboard - their own page covers
the slug rules, fire-and-forget dispatch, and dropterm.send_text.
Declared commands (the manifest section) advertise without
running; a runtime registration from the loaded script is what
dispatch runs. A manifest's menu rows put a declared
command on the terminal's context menu too.
Panels
A Panel is the unit the user summons: a titled group of a plugin's
sections, its panel views and its output channels, declared in the
manifest's panels list or assembled by the sections themselves.
Summoning shows that Panel alone, never a rail of other plugins'
sections.
Membership. A view joins a Panel by naming it, and so does a channel:
dropterm.panel_view('tasks', {
container = 'right-rail',
title = 'Tasks',
panel = 'review',
}, function(ctx)
return { kind = 'panel', rows = { { text = 'ship the spec review' } } }
end)
local log = dropterm.output('review-log', { panel = 'review' })
log:line('review opened')
The view's panel key and the channel's panel option name the Panel
the section joins:
The panel key | The rule |
|---|---|
| its value | a Panel's id, a slug |
| a bad value | the call costs one dropterm: line - the view takes no seat, the channel answers nil |
| absent | the view or channel joins its own plugin's Panel, titled with the plugin's display name: a plugin that declares nothing has one Panel all the same |
| names a Panel no manifest declares | the Panel stands under its id as its title |
| set on a view seated in a band or the tab strip | no member whatever it says; the key costs one line saying so while the seat stands - only a view in the right rail joins a Panel |
| the same id on two plugins | one Panel, one palette row, and one floating window |
A plugin that declares a Panel and has no member in it holds its row from the moment it is installed. Summoning it wakes the plugin if it is lazy, and the Panel shows once its sections are in.
The rows. Every standing Panel has one row in the
command palette under Plugin panels, titled
with the Panel's title and listed by Panel id, unbound until the user
binds panel/<id> to a chord (keybindings); the
Keybindings editor lists the rows under the same title.
Summoning. Picking the row, or pressing its chord, summons the Panel alone, and picking it again is the other way round:
| The declared act | The summon |
|---|---|
reveal (the default) | the members that stand in the rail flash where they are for about a second and a half; when the rail cannot show them - it is off, the user's panel_rail_sections list hides every member, or no member has content - the Panel floats instead, and nothing is written to the config |
float | the Panel pops out of the rail into a window of its own inside the drop-down |
Both moves are always the user's, whatever the plugin declared: a pop-out icon stands on any of the Panel's rail sections while the pointer is over it, and a dock button stands on the floating window's header. A floating Panel's row docks it back.
The floating window. A floated Panel is a titled window inside the drop-down:
| A floating Panel | |
|---|---|
| dragging | by its header |
| resizing | from its right and bottom edges, never under 240 by 160 px |
| raising | by a click |
| opening | a step down and left of the one before it |
| dismissal | never by a click elsewhere; its dock button returns the sections to the rail where they stood |
| membership | shows every member, whatever the section list hides |
| across hide and show | keeps its place |
| across a reload | stays while a reload refreshes its content in place; a deleted plugin's sections leave it |
| the keyboard | the terminal keeps it; only a text field inside takes it, under panel fields' rule |
| size and place | remembered in panels.ron under the state directory, beside the bands' arrangement (the panel containers); every Panel starts docked at launch |
A plugin's own calls. A plugin can put a Panel in front of the user from its own code - a finished build, a selected item, a command
- wherever a handler runs: a command, an event, or a panel view's ask.
local dropterm = require('dropterm')
-- A command that shows the plugin's panel where the plugin first wants it.
dropterm.command('show-build', 'Show the build panel', function()
dropterm.panels.float('dev', { x = 40, y = 48, width = 560, height = 320 })
end)
panels is the table's name on the port, and it has three calls:
| Call | On a docked Panel | On a floating Panel |
|---|---|---|
open | performs the Panel's declared act: a reveal flashes its members where they stand, or floats the Panel where the rail cannot show them; a float pops it out | comes to the front, and stays floating |
float | pops it out, whatever the declared act | comes to the front |
dock | nothing | returns it to the rail, as the dock button does |
Each answers true or false: true when a Panel of that id stands
and the call was queued, false when none stands, at one dropterm:
line naming the call and the id. The id is a slug, the rule every
script id follows; an id that is not a string or not a slug costs one
line too. A call names any standing Panel, whoever declares it: the
Panel ids are one flat space, as the palette rows are. The row's chord
is a toggle, docking a floating Panel back into the rail; a call named
open never docks, so a handler can make it again and again. There is
no close call, because closing a Panel is docking it. A declared
Panel whose plugin is still asleep wakes on open and on float, as
its palette row does, and shows once its sections are in.
Every call works from every handler - a slot-event handler and a
panel view's ask included - where send_text has no tab to write to
and drops. Nothing is gated and nothing is asked: the calls are the
plugin's own, and the user's drag, resize, dock button, and palette
row keep their say. All three end in the moves the user's own controls
make, so the Panel lands exactly where they would put it.
open and float take a second argument, bounds: a suggestion for
where the Panel first opens, as a table of four pixel numbers - x,
y, width, and height, the example's shape. It is a first-open
default. It applies while panels.ron holds nothing for the Panel,
and is written there once, so the place lasts across restarts; from
then on the user's drag and resize win, and a later suggestion changes
neither the window nor the file. The bounds are clamped like any
geometry: never under 240 by 160 px, never off the drop-down. A
bounds that is not a table answers false at one line. A table that
is missing a field or holds something other than a number costs one
line, and the Panel still opens, where the cascade puts it. A
suggestion rides the opening alone: on a floating Panel the call only
brings it to the front, and a reveal that flashes writes nothing.