Skip to content

Commit

Permalink
feat: added new key shortcut for font size(#888)
Browse files Browse the repository at this point in the history
- Increase Font size: Ctrl - + or Ctrl - =
- Decrease Font size : Ctrl + - or Ctrl - _
bajrangCoder committed Oct 17, 2024
1 parent f7743d0 commit 0ec637e
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions src/ace/commands.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fsOperation from "fileSystem";
import actions from "handlers/quickTools";
import keyBindings from "lib/keyBindings";
import settings from "lib/settings";
import Url from "utils/Url";

const commands = [
@@ -266,6 +267,26 @@ const commands = [
acode.exec("open-log-file");
},
},
{
name: "increaseFontSize",
description: "Increase font size",
exec(editor) {
let size = Number.parseInt(editor.getFontSize(), 10) || 12;
editor.setFontSize(size + 1);
settings.value.fontSize = size + 1 + "px";
settings.update(false);
},
},
{
name: "decreaseFontSize",
description: "Decrease font size",
exec(editor) {
let size = Number.parseInt(editor.getFontSize(), 10) || 12;
editor.setFontSize(Math.max(size - 1 || 1));
settings.value.fontSize = Math.max(size - 1 || 1) + "px";
settings.update(false);
},
},
];

export function setCommands(editor) {
6 changes: 3 additions & 3 deletions src/lib/keyBindings.js
Original file line number Diff line number Diff line change
@@ -580,14 +580,14 @@ export default {
},
increaseFontSize: {
description: "Increase font size",
bindKey: "Ctrl-+",
key: "Ctrl-+|Ctrl-=",
},
decreaseFontSize: {
description: "Decrease font size",
bindKey: "Ctrl+-",
key: "Ctrl+-|Ctrl-_",
},
resetFontSize: {
description: "Reset font size",
bindKey: "Ctrl+0|Ctrl-Numpad0",
key: "Ctrl+0|Ctrl-Numpad0",
},
};

0 comments on commit 0ec637e

Please sign in to comment.