parseStatusLineConfig function
Parses the tui.statusLine: yaml node. Strict on schema: unknown
keys, a non-list left/right, an unknown preset or separator name,
or a non-string segment id all throw ConfigException.
Implementation
StatusLineConfig parseStatusLineConfig(Object? node) {
if (node == null) return const StatusLineConfig();
if (node is! YamlMap) {
throw ConfigException('tui.statusLine must be a map, got: $node');
}
_checkStrictKeys(node, 'tui.statusLine', const {
'preset',
'left',
'right',
'separator',
'segmentOptions',
'transparent',
'nerdSymbols',
'rateWindowMs',
});
final preset = _statusLinePreset(node['preset']);
final optionsNode = _statusLineOptionsNode(node);
final separator = node['separator'];
final rateWindowMs = node['rateWindowMs'];
if (rateWindowMs != null && (rateWindowMs is! int || rateWindowMs <= 0)) {
throw ConfigException(
'"tui.statusLine.rateWindowMs" must be a positive integer',
);
}
return StatusLineConfig(
preset: preset,
left: _statusLineSegmentIds(node, 'left'),
right: _statusLineSegmentIds(node, 'right'),
separator: separator == null
? null
: parseStatusLineSeparator('$separator'),
segmentOptions: optionsNode == null
? null
: parseSegmentOptions(optionsNode),
transparent: _statusLineBoolFlag(node, 'transparent') ?? false,
nerdSymbols: _statusLineBoolFlag(node, 'nerdSymbols'),
rateWindowMs: rateWindowMs as int?,
);
}