mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-06-13 15:13:32 -07:00
feat(config): show default keybindings in generated example config (#64)
- Expand `keybindings` array in `config.example.jsonc` to list all built-in defaults instead of `[]` - Inject `DEFAULT_KEYBINDINGS` into template when resolved config has an empty keybindings array - Add regression tests for template parity, default binding compile/action mapping, overlay keyboard dispatch, and mpv plugin registration/dispatch - Add fullscreen binding to docs shortcut tables and clarify keybindings can target mpv commands or session actions
This commit is contained in:
+14
-1
@@ -3,6 +3,7 @@ import {
|
||||
CONFIG_OPTION_REGISTRY,
|
||||
CONFIG_TEMPLATE_SECTIONS,
|
||||
DEFAULT_CONFIG,
|
||||
DEFAULT_KEYBINDINGS,
|
||||
deepCloneConfig,
|
||||
} from './definitions';
|
||||
|
||||
@@ -103,9 +104,21 @@ function renderSection(
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function createTemplateConfig(config: ResolvedConfig): ResolvedConfig {
|
||||
const templateConfig = deepCloneConfig(config);
|
||||
if (templateConfig.keybindings.length === 0) {
|
||||
templateConfig.keybindings = DEFAULT_KEYBINDINGS.map((binding) => ({
|
||||
key: binding.key,
|
||||
command: binding.command === null ? null : [...binding.command],
|
||||
}));
|
||||
}
|
||||
return templateConfig;
|
||||
}
|
||||
|
||||
export function generateConfigTemplate(
|
||||
config: ResolvedConfig = deepCloneConfig(DEFAULT_CONFIG),
|
||||
): string {
|
||||
const templateConfig = createTemplateConfig(config);
|
||||
const lines: string[] = [];
|
||||
lines.push('/**');
|
||||
lines.push(' * SubMiner Example Configuration File');
|
||||
@@ -123,7 +136,7 @@ export function generateConfigTemplate(
|
||||
lines.push(
|
||||
renderSection(
|
||||
section.key,
|
||||
config[section.key],
|
||||
templateConfig[section.key],
|
||||
index === CONFIG_TEMPLATE_SECTIONS.length - 1,
|
||||
comments,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user