From 5261df0665590a7b37071513e099cccb57064627 Mon Sep 17 00:00:00 2001 From: luah5 Date: Tue, 28 Mar 2023 21:35:39 +0100 Subject: [PATCH 1/5] add terminal zoom in/out (building on top of #1191) --- CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift | 2 +- CodeEdit/Features/WindowCommands/ViewCommands.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift index 1301b3b2e3..3ee5b3f7a8 100644 --- a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift +++ b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift @@ -31,7 +31,7 @@ struct TerminalEmulatorView: NSViewRepresentable { private var font: NSFont { if !prefs.preferences.terminal.font.customFont { - return systemFont + return systemFont.withSize(CGFloat(prefs.preferences.terminal.font.size)) } return NSFont( name: prefs.preferences.terminal.font.name, diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index 0a5cd954bc..b58719e102 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -28,6 +28,7 @@ struct ViewCommands: Commands { Button("Zoom in") { prefs.preferences.textEditing.font.size += 1 + prefs.preferences.terminal.font.size += 1 } .keyboardShortcut("+") @@ -35,6 +36,9 @@ struct ViewCommands: Commands { if !(prefs.preferences.textEditing.font.size <= 1) { prefs.preferences.textEditing.font.size -= 1 } + if !(prefs.preferences.terminal.font.size <= 1) { + prefs.preferences.terminal.font.size -= 1 + } } .keyboardShortcut("-") From 53a2ad15e7f0c369a067dcd07fcd770b55cf7c28 Mon Sep 17 00:00:00 2001 From: luah5 Date: Wed, 29 Mar 2023 13:23:46 +0100 Subject: [PATCH 2/5] respond to @austincondiff's review --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index b58719e102..8d21b2ed1b 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -8,6 +8,8 @@ import SwiftUI struct ViewCommands: Commands { + let documentController: CodeEditDocumentController = CodeEditDocumentController() + let statusBarViewModel: StatusBarViewModel = StatusBarViewModel() private var prefs: AppPreferencesModel = .shared @State var windowController: CodeEditWindowController? @@ -27,14 +29,18 @@ struct ViewCommands: Commands { .keyboardShortcut("p", modifiers: [.shift, .command]) Button("Zoom in") { - prefs.preferences.textEditing.font.size += 1 + if !(CodeEditDocumentController.shared.documents.count > 1) { + prefs.preferences.textEditing.font.size += 1 + } prefs.preferences.terminal.font.size += 1 } .keyboardShortcut("+") Button("Zoom out") { - if !(prefs.preferences.textEditing.font.size <= 1) { - prefs.preferences.textEditing.font.size -= 1 + if !(CodeEditDocumentController.shared.documents.count > 1) { + if !(prefs.preferences.textEditing.font.size <= 1) { + prefs.preferences.textEditing.font.size -= 1 + } } if !(prefs.preferences.terminal.font.size <= 1) { prefs.preferences.terminal.font.size -= 1 From 365bf9b0f50a05d0adf6bf496f0f01806d0964ad Mon Sep 17 00:00:00 2001 From: luah5 Date: Wed, 29 Mar 2023 13:29:07 +0100 Subject: [PATCH 3/5] make variables private --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index 8d21b2ed1b..a747b2f54f 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -8,11 +8,14 @@ import SwiftUI struct ViewCommands: Commands { - let documentController: CodeEditDocumentController = CodeEditDocumentController() - let statusBarViewModel: StatusBarViewModel = StatusBarViewModel() + @ObservedObject private var prefs: AppPreferencesModel = .shared + @State var windowController: CodeEditWindowController? + private let documentController: CodeEditDocumentController = CodeEditDocumentController() + private let statusBarViewModel: StatusBarViewModel = StatusBarViewModel() + var navigatorCollapsed: Bool { windowController?.navigatorCollapsed ?? false } From 7ff1e0e2fd7761334e6dcb3d46ec28694e3b4c54 Mon Sep 17 00:00:00 2001 From: luah5 Date: Wed, 29 Mar 2023 14:40:35 +0100 Subject: [PATCH 4/5] fix logic --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index a747b2f54f..0abfdc03b5 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -32,7 +32,7 @@ struct ViewCommands: Commands { .keyboardShortcut("p", modifiers: [.shift, .command]) Button("Zoom in") { - if !(CodeEditDocumentController.shared.documents.count > 1) { + if CodeEditDocumentController.shared.documents.count > 1 { prefs.preferences.textEditing.font.size += 1 } prefs.preferences.terminal.font.size += 1 @@ -40,7 +40,7 @@ struct ViewCommands: Commands { .keyboardShortcut("+") Button("Zoom out") { - if !(CodeEditDocumentController.shared.documents.count > 1) { + if CodeEditDocumentController.shared.documents.count > 1 { if !(prefs.preferences.textEditing.font.size <= 1) { prefs.preferences.textEditing.font.size -= 1 } From c4234906a913e120f175e4133ebc9f5442ae4629 Mon Sep 17 00:00:00 2001 From: luah5 <128280019+luah5@users.noreply.github.com> Date: Wed, 29 Mar 2023 17:55:30 +0100 Subject: [PATCH 5/5] fix @matthijseikelenboom's review comments --- CodeEdit/Features/WindowCommands/ViewCommands.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CodeEdit/Features/WindowCommands/ViewCommands.swift b/CodeEdit/Features/WindowCommands/ViewCommands.swift index 0abfdc03b5..df6ddeb988 100644 --- a/CodeEdit/Features/WindowCommands/ViewCommands.swift +++ b/CodeEdit/Features/WindowCommands/ViewCommands.swift @@ -31,7 +31,7 @@ struct ViewCommands: Commands { } .keyboardShortcut("p", modifiers: [.shift, .command]) - Button("Zoom in") { + Button("Increase font size") { if CodeEditDocumentController.shared.documents.count > 1 { prefs.preferences.textEditing.font.size += 1 } @@ -39,7 +39,7 @@ struct ViewCommands: Commands { } .keyboardShortcut("+") - Button("Zoom out") { + Button("Decrease font size") { if CodeEditDocumentController.shared.documents.count > 1 { if !(prefs.preferences.textEditing.font.size <= 1) { prefs.preferences.textEditing.font.size -= 1