Class ui.panel.Bar

Panel bar for single-line terminal UI elements.

This class creates a fixed-height panel (1 line) that displays content in a structured format with left, center, and right sections separated by configurable spacing. The bar uses margin and padding parameters to control spacing, and supports text attributes for styling individual sections or the entire bar.

The typical use case is a header or footer bar for full-screen UI applications. See ui.panel.Screen for an example.

Methods

ui.panel.bar:init (opts) Create a new Bar instance.
ui.panel.bar:set_center (content) Set the center section content.
ui.panel.bar:set_left (content) Set the left section content.
ui.panel.bar:set_right (content) Set the right section content.


Methods

ui.panel.bar:init (opts)
Create a new Bar instance. A bar is a single line panel with left, center, and right (text) sections. 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 each section. (default 2)
    • name string Name for the bar-panel. Defaults to tostring(self) if not provided. (optional)
    • attr table Text attributes for the entire bar. (optional)
    • left table Left section configuration. (optional)
    • left.text string Left section content. (optional)
    • left.type string Truncation type for left section ("left", "right", or "drop"). (default "right")
    • left.attr table Text attributes for left section content. (optional)
    • center table Center section configuration. (optional)
    • center.text string Center section content. (optional)
    • center.type string Truncation type for center section ("left", "right", or "drop"). (default "right")
    • center.attr table Text attributes for center section content. (optional)
    • right table Right section configuration. (optional)
    • right.text string Right section content. (optional)
    • right.type string Truncation type for right section ("left", "right", or "drop"). (default "right")
    • right.attr table Text attributes for right section content. (optional)
    • auto_render boolean Whether to automatically re-render when text content changes. (default false)

Returns:

    Bar A new Bar instance.

Usage:

    local Bar = require("terminal.ui.panel.bar")
    local bar = Bar {
      margin = 1,
      padding = 2,
      left = {
        text = "File",
        type = "right",
        attr = { fg = "blue" }
      },
      center = {
        text = "Editor",
        type = "left",
        attr = { fg = "yellow", brightness = "bright" }
      },
      right = {
        text = "Help",
        type = "drop",
        attr = { fg = "green" }
      },
      attr = { bg = "black" }
    }
ui.panel.bar:set_center (content)
Set the center section content.

Parameters:

  • content string The center section content.

Returns:

    nothing
ui.panel.bar:set_left (content)
Set the left section content.

Parameters:

  • content string The left section content.

Returns:

    nothing
ui.panel.bar:set_right (content)
Set the right section content.

Parameters:

  • content string The right section content.

Returns:

    nothing
generated by LDoc 1.5.0