MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / keymapSectionLines

Function keymapSectionLines

apps/desktop/src/main/app-config.ts:429–462  ·  view source on GitHub ↗

Build the `[keymaps]` block: active overrides followed by every action's * default binding as a commented, grouped reference so users can discover and * uncomment what they want to remap.

(rawOverrides: unknown)

Source from the content-addressed store, hash-verified

427 * default binding as a commented, grouped reference so users can discover and
428 * uncomment what they want to remap. */
429function keymapSectionLines(rawOverrides: unknown): string[] {
430 const overrides: Record<string, string> = {}
431 if (rawOverrides && typeof rawOverrides === 'object' && !Array.isArray(rawOverrides)) {
432 for (const [key, value] of Object.entries(rawOverrides as Record<string, unknown>)) {
433 if (typeof value === 'string') overrides[key] = value
434 }
435 }
436
437 const lines = [
438 '',
439 '# Keymap overrides. Add or uncomment "<action.id>" = "<binding>" lines.',
440 '# Binding syntax: "Mod+P" = Cmd/Ctrl+P, "Shift+Mod+K", "Ctrl+W", "Space",',
441 '# or a two-key sequence like "g g". Uncomment a reference line to remap it.',
442 '[keymaps]'
443 ]
444
445 for (const [key, value] of Object.entries(overrides)) {
446 lines.push(`${tomlKey(key)} = ${tomlValue(value)}`)
447 }
448
449 lines.push('', '# --- All actions (defaults shown; uncomment + edit to override) ---')
450 for (const group of KEYMAP_GROUP_ORDER) {
451 const entries = KEYMAP_CATALOG.filter(
452 (entry) => entry.group === group && !(entry.id in overrides)
453 )
454 if (entries.length === 0) continue
455 lines.push(`# ${KEYMAP_GROUP_LABELS[group] ?? group}`)
456 for (const entry of entries) {
457 lines.push(`# ${tomlKey(entry.id)} = ${tomlValue(entry.defaultBinding)} # ${entry.title}`)
458 }
459 }
460
461 return lines
462}
463
464/** Parse TOML text into a portable config object plus its version. Throws on
465 * malformed TOML — callers fall back to the last good config. */

Callers 1

serializeConfigFunction · 0.85

Calls 2

tomlKeyFunction · 0.85
tomlValueFunction · 0.85

Tested by

no test coverage detected