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',
});
final preset = _statusLinePreset(node['preset']);
final optionsNode = node['segmentOptions'];
if (optionsNode != null && optionsNode is! YamlMap) {
throw ConfigException(
'"tui.statusLine.segmentOptions" must be a map, got: $optionsNode',
);
}
final transparent = _statusLineBoolFlag(node, 'transparent');
final separator = node['separator'];
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: transparent ?? false,
nerdSymbols: _statusLineBoolFlag(node, 'nerdSymbols'),
);
}