This module provides a status bar component for the terminal UI system.
::: tip TIP
To use this module, you need to import it first: import("core.ui.statusbar")
:::
::: tip NOTE
The UI module is primarily used for xmake's internal xmake f --menu menu-based visual configuration. It provides basic UI components that can also be used by users to implement their own terminal UIs.
:::
The statusbar module extends panel and provides status bar display functionality.
::: tip API
statusbar:new(name: <string>, bounds: <rect>)
:::
| Parameter | Description |
|---|---|
| name | Required. Status bar name string |
| bounds | Required. Status bar bounds rectangle |
| Type | Description |
|---|---|
| statusbar | Returns a status bar instance |
Create a status bar:
import("core.ui.statusbar")
import("core.ui.rect")
local statusbar = statusbar:new("status", rect{1, 25, 80, 1})
::: tip API
statusbar:info()
:::
No parameters
| Type | Description |
|---|---|
| label | Returns the info label instance |
Access and customize the info label:
local info = statusbar:info()
info:text_set("Ready")
info:textattr_set("blue bold")
Here is a complete status bar usage example:
import("core.ui.statusbar")
import("core.ui.window")
import("core.ui.rect")
import("core.ui.application")
local demo = application()
function demo:init()
application.init(self, "demo")
self:background_set("blue")
-- Create status bar
local statusbar = statusbar:new("status", rect{1, self:height() - 1, self:width() - 1, 1})
statusbar:info():text_set("Ready")
statusbar:info():textattr_set("blue bold")
-- Create main window
local win = window:new("main", rect{1, 2, self:width() - 1, self:height() - 3}, "Main Window")
-- Add to application
self:insert(win)
self:insert(statusbar)
self._statusbar = statusbar
self._win = win
end
function demo:on_resize()
self._win:bounds_set(rect{1, 2, self:width() - 1, self:height() - 3})
self._statusbar:bounds_set(rect{1, self:height() - 1, self:width() - 1, 1})
application.on_resize(self)
end
function main(...)
demo:run(...)
end