lots of work

This commit is contained in:
Chris Kruining 2024-10-14 17:09:54 +02:00
parent 552ba7f3c9
commit 75bd06cac3
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
19 changed files with 523 additions and 314 deletions

View file

@ -0,0 +1,33 @@
export enum Modifier {
None = 0,
Shift = 1 << 0,
Control = 1 << 1,
Meta = 1 << 2,
Alt = 1 << 3,
}
export interface Command {
(): any;
label: string;
shortcut?: {
key: string;
modifier: Modifier;
};
}
export const createCommand = (label: string, command: () => any, shortcut?: Command['shortcut']): Command => {
return Object.defineProperties(command as Command, {
label: {
value: label,
configurable: false,
writable: false,
},
shortcut: {
value: shortcut ? { key: shortcut.key.toLowerCase(), modifier: shortcut.modifier } : undefined,
configurable: false,
writable: false,
}
});
};
export const noop = createCommand('noop', () => { });