Class ui.panel.KeyBar
Key bar panel for displaying keyboard shortcuts.
This class creates a fixed-height panel (1 or 2 lines) that displays keyboard shortcuts in equally wide cells, similar to editors like nano or tools like htop.
Each cell shows a key and a description with separate text attributes. When configured for 2 rows, columns are aligned vertically.
Methods
| ui.panel.keybar:init (opts) | Create a new KeyBar instance. |
| ui.panel.keybar:set_items (items) | Set the items (shortcuts) to display. |
| ui.panel.keybar:set_rows (rows) | Set the number of rows (1 or 2). |
Methods
- ui.panel.keybar:init (opts)
-
Create a new KeyBar instance.
A key-bar is a 1 or 2 line
panelthat displays keyboard shortcuts in equally wide columns. Do not call this method directly, call on the class instead.Parameters:
- opts Configuration options (see Panel:init for inherited properties)
- margin number Number of spaces from left and right edges. (default 1)
- padding number Minimum number of spaces between columns. (default 2)
- separator string Separator string between key and description. (default " ")
- attr table Text attributes for the entire bar area. (optional)
- key_attr table Text attributes for the key labels. (optional)
- desc_attr table Text attributes for the descriptions. (optional)
- items
table
Array of
{ key = string, desc = string }items. (optional) - rows number Number of rows (1 or 2). (default 1)
- auto_render boolean Whether to auto-render on updates. (default false)
Returns:
-
KeyBar
A new KeyBar instance.
- opts Configuration options (see Panel:init for inherited properties)
- ui.panel.keybar:set_items (items)
-
Set the items (shortcuts) to display.
Parameters:
- items
table
Array of
{ key = string, desc = string }items.
- items
table
Array of
- ui.panel.keybar:set_rows (rows)
-
Set the number of rows (1 or 2).
Adjusts height constraints accordingly.
Parameters:
- rows number 1 or 2