add comments to key bindings

This commit is contained in:
Peter Fajdiga
2023-06-23 13:06:40 +02:00
parent 9318799a82
commit 81a82cbfde
6 changed files with 24 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
interface KeyBinding {
name: string;
description: string;
comment?: string;
defaultKeySequence: string;
action: string;
}
@@ -8,11 +9,16 @@ interface KeyBinding {
interface NumKeyBinding {
name: string;
description: string;
comment?: string;
defaultModifiers: string;
fKeys: boolean;
action: string;
}
function formatComment(comment: string | undefined) {
return comment === undefined ? "" : ` (${comment})`;
}
function printCols(...columns: (string[] | string)[]) {
const nCols = columns.length;
if (nCols == 0) {

View File

@@ -7,8 +7,8 @@ const colLeft = [
];
const colRight = [
...keyBindings.map((binding: KeyBinding) => binding.description),
...numKeyBindings.map((binding: NumKeyBinding) => binding.description + "N"),
...keyBindings.map((binding: KeyBinding) => `${binding.description}${formatComment(binding.comment)}`),
...numKeyBindings.map((binding: NumKeyBinding) => `${binding.description}N${formatComment(binding.comment)}`),
];
printCols(colLeft, " ", colRight);

View File

@@ -1,8 +1,8 @@
for (const binding of keyBindings) {
console.log(`${binding.defaultKeySequence} - ${binding.description}`);
console.log(`${binding.defaultKeySequence} - ${binding.description}${formatComment(binding.comment)}`);
}
for (const binding of numKeyBindings) {
const numPrefix = binding.fKeys ? "F" : "";
console.log(`${binding.defaultModifiers}+${numPrefix}[N] - ${binding.description}N`);
console.log(`${binding.defaultModifiers}+${numPrefix}[N] - ${binding.description}N${formatComment(binding.comment)}`);
}

View File

@@ -11,8 +11,8 @@ const colLeft = [
const colRight = [
"Action",
"---",
...keyBindings.map((binding: KeyBinding) => binding.description),
...numKeyBindings.map((binding: NumKeyBinding) => binding.description + "N"),
...keyBindings.map((binding: KeyBinding) => `${binding.description}${formatComment(binding.comment)}`),
...numKeyBindings.map((binding: NumKeyBinding) => `${binding.description}N${formatComment(binding.comment)}`),
];
printCols("| ", colLeft, " | ", colRight, " |");

View File

@@ -44,12 +44,14 @@ const keyBindings: KeyBinding[] = [
{
"name": "window-move-left",
"description": "Move window left",
"comment": "Moves window out of and into columns",
"defaultKeySequence": "Meta+Shift+A",
"action": "windowMoveLeft",
},
{
"name": "window-move-right",
"description": "Move window right",
"comment": "Moves window out of and into columns",
"defaultKeySequence": "Meta+Shift+D",
"action": "windowMoveRight",
},
@@ -79,7 +81,8 @@ const keyBindings: KeyBinding[] = [
},
{
"name": "window-expand",
"description": "Expand window (toggle stacked mode)",
"description": "Expand window",
"comment": "Expands focused window vertically; toggles stacked layout for focused column",
"defaultKeySequence": "Meta+X",
"action": "windowExpand",
},
@@ -110,24 +113,28 @@ const keyBindings: KeyBinding[] = [
{
"name": "column-expand",
"description": "Expand column",
"comment": "Expands focused column horizontally to fill the screen",
"defaultKeySequence": "Meta+Ctrl+X",
"action": "columnExpand",
},
{
"name": "expand-visible-columns",
"description": "Expand fully visible columns",
"comment": "Expands fully visible columns to fill the screen",
"defaultKeySequence": "Meta+Alt++",
"action": "expandVisibleColumns",
},
{
"name": "shrink-visible-columns",
"description": "Shrink visible columns",
"comment": "Shrinks fully and partially visible columns, making them fully visible and filling the screen",
"defaultKeySequence": "Meta+Alt+-",
"action": "shrinkVisibleColumns",
},
{
"name": "grid-scroll-focused",
"description": "Center focused window",
"comment": "Scrolls so that the focused window is centered in the screen",
"defaultKeySequence": "Meta+Alt+Return",
"action": "gridScrollFocused",
},
@@ -180,6 +187,7 @@ const numKeyBindings: NumKeyBinding[] = [
{
"name": "window-move-to-column-",
"description": "Move window to column ",
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
"defaultModifiers": "Meta+Shift",
"fKeys": false,
"action": "windowMoveToColumn",
@@ -187,6 +195,7 @@ const numKeyBindings: NumKeyBinding[] = [
{
"name": "column-move-to-column-",
"description": "Move column to position ",
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
"defaultModifiers": "Meta+Ctrl+Shift",
"fKeys": false,
"action": "columnMoveToColumn",

View File

@@ -1,6 +1,7 @@
interface KeyBinding {
name: string;
description: string;
comment?: string;
defaultKeySequence: string;
action: keyof ReturnType<typeof initActions>;
}
@@ -8,6 +9,7 @@ interface KeyBinding {
interface NumKeyBinding {
name: string;
description: string;
comment?: string;
defaultModifiers: string;
fKeys: boolean;
action: keyof ReturnType<typeof initNumActions>;