mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-02 06:22:42 -08:00
feat(core): add Electron runtime, services, and app composition
This commit is contained in:
27
src/core/utils/keybindings.ts
Normal file
27
src/core/utils/keybindings.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Config, Keybinding } from '../../types';
|
||||
|
||||
export function resolveKeybindings(config: Config, defaultKeybindings: Keybinding[]): Keybinding[] {
|
||||
const userBindings = config.keybindings || [];
|
||||
const bindingMap = new Map<string, (string | number)[] | null>();
|
||||
|
||||
for (const binding of defaultKeybindings) {
|
||||
bindingMap.set(binding.key, binding.command);
|
||||
}
|
||||
|
||||
for (const binding of userBindings) {
|
||||
if (binding.command === null) {
|
||||
bindingMap.delete(binding.key);
|
||||
} else {
|
||||
bindingMap.set(binding.key, binding.command);
|
||||
}
|
||||
}
|
||||
|
||||
const keybindings: Keybinding[] = [];
|
||||
for (const [key, command] of bindingMap) {
|
||||
if (command !== null) {
|
||||
keybindings.push({ key, command });
|
||||
}
|
||||
}
|
||||
|
||||
return keybindings;
|
||||
}
|
||||
Reference in New Issue
Block a user