Skip to content

Commit 577c4dd

Browse files
committed
fix
1 parent 45b3e80 commit 577c4dd

3 files changed

Lines changed: 51 additions & 19 deletions

File tree

src/components/terminal/terminal.js

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,31 @@ export default class TerminalComponent {
418418
return false;
419419
}
420420

421+
// Keep terminal font zoom local. Shift variants are handled by app keybindings below.
422+
if (
423+
event.ctrlKey &&
424+
!event.shiftKey &&
425+
!event.altKey &&
426+
!event.metaKey &&
427+
(event.key === "+" || event.key === "=")
428+
) {
429+
event.preventDefault();
430+
this.increaseFontSize();
431+
return false;
432+
}
433+
434+
if (
435+
event.ctrlKey &&
436+
!event.shiftKey &&
437+
!event.altKey &&
438+
!event.metaKey &&
439+
event.key === "-"
440+
) {
441+
event.preventDefault();
442+
this.decreaseFontSize();
443+
return false;
444+
}
445+
421446
if (event.ctrlKey || event.altKey || event.metaKey) {
422447
if (["Control", "Alt", "Meta", "Shift"].includes(event.key)) {
423448
return true;
@@ -439,20 +464,6 @@ export default class TerminalComponent {
439464
}
440465
}
441466

442-
// Check for Ctrl+= or Ctrl++ (increase font size)
443-
if (event.ctrlKey && (event.key === "+" || event.key === "=")) {
444-
event.preventDefault();
445-
this.increaseFontSize();
446-
return false;
447-
}
448-
449-
// Check for Ctrl+- (decrease font size)
450-
if (event.ctrlKey && event.key === "-") {
451-
event.preventDefault();
452-
this.decreaseFontSize();
453-
return false;
454-
}
455-
456467
if (event.ctrlKey || event.altKey || event.metaKey) return true;
457468

458469
// Return true to allow normal processing for other keys

src/lib/settings.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class Settings {
2626
#defaultSettings;
2727
#oldSettings;
2828
#initialized = false;
29+
#uiZoomBaseFontSize = {
30+
root: null,
31+
body: null,
32+
};
2933
#on = {
3034
update: [],
3135
"update:after": [],
@@ -404,9 +408,19 @@ class Settings {
404408
applyUiZoomSetting() {
405409
const zoom = Number(this.value.uiZoom) || 100;
406410
const clamped = Math.min(160, Math.max(70, zoom));
407-
const size = `${(14 * clamped) / 100}px`;
408-
document.documentElement.style.fontSize = size;
409-
document.body.style.fontSize = size;
411+
const rootFontSize =
412+
this.#uiZoomBaseFontSize.root ||
413+
Number.parseFloat(getComputedStyle(document.documentElement).fontSize) ||
414+
14;
415+
const bodyFontSize =
416+
this.#uiZoomBaseFontSize.body ||
417+
Number.parseFloat(getComputedStyle(document.body).fontSize) ||
418+
rootFontSize;
419+
420+
this.#uiZoomBaseFontSize.root = rootFontSize;
421+
this.#uiZoomBaseFontSize.body = bodyFontSize;
422+
document.documentElement.style.fontSize = `${(rootFontSize * clamped) / 100}px`;
423+
document.body.style.fontSize = `${(bodyFontSize * clamped) / 100}px`;
410424
if (window.root) {
411425
window.root.style.zoom = "";
412426
window.root.style.width = "";

src/settings/appSettings.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ export default function otherSettings() {
7070
promptType: "number",
7171
promptOptions: {
7272
test(value) {
73-
value = Number.parseInt(value, 10);
74-
return value >= 70 && value <= 160;
73+
if (!/^\d+$/.test(String(value).trim())) return false;
74+
const zoom = Number(value);
75+
return zoom >= 70 && zoom <= 160;
7576
},
7677
},
7778
info:
@@ -431,6 +432,12 @@ export default function otherSettings() {
431432
system.setInputType(value);
432433
break;
433434

435+
case "uiZoom":
436+
value = Number(value);
437+
if (!Number.isInteger(value)) return;
438+
value = Math.min(160, Math.max(70, value));
439+
break;
440+
434441
case "fullscreen":
435442
if (value) acode.exec("enable-fullscreen");
436443
else acode.exec("disable-fullscreen");

0 commit comments

Comments
 (0)