gauge (cellium v0.1.0)
View SourceGauge widget module for displaying labeled value indicators.
This module provides a gauge widget that displays a label followed by a visual bar showing a value from 0 to 100. Commonly used for volume controls, levels, or other percentage-based indicators.
Usage
Basic gauge:
gauge:new(volume_gauge)Gauge with label and value:
Widget = gauge:new(volume_gauge),
CustomWidget = Widget#{label => <<"Volume">>, value => 75, width => 30}Properties
value(integer): Current value from 0 to 100. Default: 0label(binary): Text label displayed before the gauge bar. Default: emptywidth(integer): Total width including label and bar. Set by layoutfocusable(boolean): Set to true by default
Display
The gauge displays as: Label ████████░░░░
█for filled portion (proportional to value)░for unfilled portion- The bar width is calculated as:
width - label_length - 1
When focused, foreground and background colors are swapped.
Example
% Volume at 50% with width of 20
Widget#{label => <<"Vol">>, value => 50, width => 20}
% Displays: Vol ████████░░░░░░░
Summary
Functions
Handles keyboard events for the gauge. Adjusts value with Left/Right arrow keys.
Creates a new gauge with default settings.
Renders the gauge in unfocused state.
Renders the gauge in focused state with inverted colors.
Functions
Handles keyboard events for the gauge. Adjusts value with Left/Right arrow keys.
Creates a new gauge with default settings.
Default value is 0 and label is empty.
Renders the gauge in unfocused state.
Renders the gauge in focused state with inverted colors.