Reference · Panelith 0.1.0 · plain HTML edition; the interactive edition has search and live examples
Context
On this page 4 sections
ctx, the object every handler and command receives, with the pane record and the client context behind it.
Context#
Context(app: "'App'", client: 's.ClientContext', pane: 'PaneRef | None' = None, args: 'dict[str, Any]' =
| Attribute | Meaning |
|---|---|
ctx.app |
the running App: ctx.app.kind(id), ctx.app.list_source(id), ctx.app.panes, ctx.app.push(...) |
ctx.client |
the ClientContext the shell sent with the request |
ctx.pane |
the PaneRef of the pane the event came from (None for a global command) |
ctx.args |
arguments a command was called with (a list row under row) |
ctx.user |
reserved for an app's own authentication; None |
ctx.cid |
shorthand for ctx.pane.cid |
ctx.focused |
the focused tab as the shell reported it (cid, kind, parent) |
ctx.tabs |
every open tab in reading order |
ctx.viewport |
the window size the shell reported |
ctx.narrow |
True on a phone-sized window (under 700px wide) |
Helpers#
tabs_of_kind#
tabs_of_kind(self, kind: str) -> list[s.TabRef]
children_of#
children_of(self, cid: str, kind: str | None = None) -> list[s.TabRef]
state_of#
state_of(self, cid: str) -> dict[str, Any] | None
PaneRef#
A live pane as the shell reported it, plus the server-side state record.
| Field | Type |
|---|---|
cid |
str |
kind |
str |
name |
str | None |
parent |
str | None |
state |
dict[str, Any] |
What the shell sends#
ClientContext#
What the shell knows that a handler may want: the focused tab, every open tab (cid, kind, parent) in reading order, and the window size.
| Field | Type | Default | Description |
|---|---|---|---|
focused |
TabRef | None |
None |
the focused tab |
tabs |
list[TabRef] |
[] |
every open tab in reading order |
columns |
int |
1 |
how many columns the canvas has |
viewport |
Viewport | None |
None |
the window size |
TabRef#
| Field | Type | Default | Description |
|---|---|---|---|
cid |
str |
required | the tab's content id |
kind |
str |
required | its kind |
name |
str | None |
None |
its name |
parent |
str | None |
None |
the cid it is tethered to |
Viewport#
| Field | Type | Default | Description |
|---|---|---|---|
width |
int |
0 |
window width in CSS pixels |
height |
int |
0 |
window height in CSS pixels |