Skip to content
Tildev0.6.1

The bar context

ctx is the argument of a bar function (see Bars): a snapshot of the screen. Changing it does nothing to the interface. This page lists its fields.

Field Value
ctx.focus Where the focus is: "sidebar" or "list". It is the name of the key context of the window when a window is open ("window" if it has none); the reader covers the whole screen, bars included.
ctx.place Where you are: work ▸ INBOX, work for an account with no folder open, and tilde before the first account exists.
ctx.counts The counts of the folder as one text: 4 messages, 3 unread. Empty when no folder is open. The messages are the ones that are loaded (at most 1000, the newest), the unread are the ones of the whole folder, so 1000 messages, 1500 unread can happen.
ctx.conn The connection of the account you are on, always a table. See the connection.
ctx.notes A list of { kind, text, role } for what else the line tells, in this order: position (message 2 of 4, with (120 in the folder) when the list shows only the newest messages) and search (search: invoice). role is nil when the note has none.
ctx.keys A list of { key, desc, priority } for the pane that has the focus. See the key hints.
ctx.width The columns of the screen.
ctx.mail { account, folder, total, unread } once a folder is open, otherwise nil. total is the number of messages that are loaded.

ctx.conn.state is "online", "offline", "connecting", "error" or "none". The program fills role and symbol with the defaults below, so a bar can draw the connection in one piece. text is the state in words.

state role symbol
online success ●
offline muted ○
connecting warning ○
error error ✖
none muted empty, and text is empty too

none means there is no account yet.

ctx.keys is built from the key map, in its notation, so a key you rebind shows here. Each hint is { key = "j/k", desc = "move", priority = 2 }. A command that no key runs is left out. A command with several keys shows the shortest one (j and not <Down>; the first one among equals). The keys are the ones that the pane binds and the global ones that the pane does not give to another command: if the list binds ? to something else, a hint for help.show_keys on ? does not show. ? help has priority 3, so it stays while the left side is cut.

bar.hints(ctx.keys, style) turns the list into items, one group for each hint: the key, a space and what it does, with two spaces before every group after the first. A group keeps the priority of its hint. style is optional: { key = { bold = true }, desc = { fg = "muted" } }. The default status line uses exactly this.