diff --git a/CodeEdit.xcodeproj/project.pbxproj b/CodeEdit.xcodeproj/project.pbxproj index 4ad2c4204d..1b139db83c 100644 --- a/CodeEdit.xcodeproj/project.pbxproj +++ b/CodeEdit.xcodeproj/project.pbxproj @@ -3738,7 +3738,7 @@ repositoryURL = "https://github.com/CodeEditApp/CodeEditTextView.git"; requirement = { kind = exactVersion; - version = 0.3.3; + version = 0.3.4; }; }; 58F2EB18292FB91C004A9BDE /* XCRemoteSwiftPackageReference "Preferences" */ = { diff --git a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 63f87438c2..af7aed9b03 100644 --- a/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/CodeEditApp/CodeEditTextView.git", "state" : { - "revision" : "9f79fa8a77ac8708951ef08ccfd4e9ba2e2ba7b2", - "version" : "0.3.3" + "revision" : "58f794154e9a392a9ac5aae93c39631b79ca7b9c", + "version" : "0.3.4" } }, { diff --git a/CodeEdit/Features/AppPreferences/Model/Terminal/TerminalPreferences.swift b/CodeEdit/Features/AppPreferences/Model/Terminal/TerminalPreferences.swift index a4b78d9485..e125525a91 100644 --- a/CodeEdit/Features/AppPreferences/Model/Terminal/TerminalPreferences.swift +++ b/CodeEdit/Features/AppPreferences/Model/Terminal/TerminalPreferences.swift @@ -15,6 +15,9 @@ extension AppPreferences { /// If true terminal appearance will always be `dark`. Otherwise it adapts to the system setting. var darkAppearance: Bool = false + /// if true, the terminal uses the background color of the theme, otherwise it is clear + var useThemeBackground: Bool = true + /// If true, the terminal treats the `Option` key as the `Meta` key var optionAsMeta: Bool = false diff --git a/CodeEdit/Features/AppPreferences/Sections/ThemePreferences/TerminalThemeView.swift b/CodeEdit/Features/AppPreferences/Sections/ThemePreferences/TerminalThemeView.swift index 07a3e75b1d..6d481bb4f2 100644 --- a/CodeEdit/Features/AppPreferences/Sections/ThemePreferences/TerminalThemeView.swift +++ b/CodeEdit/Features/AppPreferences/Sections/ThemePreferences/TerminalThemeView.swift @@ -35,6 +35,7 @@ struct TerminalThemeView: View { private var topToggles: some View { VStack(alignment: .leading) { Toggle("Always use dark terminal appearance", isOn: $prefs.preferences.terminal.darkAppearance) + Toggle("Use theme background ", isOn: $prefs.preferences.terminal.useThemeBackground) } } diff --git a/CodeEdit/Features/CodeFile/CodeFileView.swift b/CodeEdit/Features/CodeFile/CodeFileView.swift index 6fc2990d2a..fe19c8c8fc 100644 --- a/CodeEdit/Features/CodeFile/CodeFileView.swift +++ b/CodeEdit/Features/CodeFile/CodeFileView.swift @@ -69,10 +69,26 @@ struct CodeFileView: View { tabWidth: $prefs.preferences.textEditing.defaultTabWidth, lineHeight: $prefs.preferences.textEditing.lineHeightMultiple, wrapLines: $prefs.preferences.textEditing.wrapLinesToEditorWidth, - cursorPosition: codeFile.$cursorPosition + cursorPosition: codeFile.$cursorPosition, + useThemeBackground: prefs.preferences.theme.useThemeBackground ) .id(codeFile.fileURL) - .background(selectedTheme.editor.background.swiftColor) + .background { + if colorScheme == .dark { + if prefs.preferences.theme.selectedTheme == prefs.preferences.theme.selectedLightTheme { + Color.white + } else { + EffectView(.underPageBackground) + } + } else { + if prefs.preferences.theme.selectedTheme == prefs.preferences.theme.selectedDarkTheme { + Color.black + } else { + EffectView(.contentBackground) + } + + } + } .disabled(!editable) .frame(maxHeight: .infinity) .onChange(of: ThemeModel.shared.selectedTheme) { newValue in diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarDrawer/StatusBarDrawer.swift b/CodeEdit/Features/StatusBar/Views/StatusBarDrawer/StatusBarDrawer.swift index 131a88a215..9280bcb1b1 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarDrawer/StatusBarDrawer.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarDrawer/StatusBarDrawer.swift @@ -11,6 +11,12 @@ struct StatusBarDrawer: View { @EnvironmentObject private var model: StatusBarViewModel + @ObservedObject + private var prefs: AppPreferencesModel = .shared + + @Environment(\.colorScheme) + private var colorScheme + @State private var searchText = "" @@ -27,7 +33,24 @@ struct StatusBarDrawer: View { var body: some View { VStack(spacing: 0) { switch model.selectedTab { - case 0: TerminalEmulatorView(url: model.workspaceURL) + case 0: + TerminalEmulatorView(url: model.workspaceURL) + .background { + if colorScheme == .dark { + if prefs.preferences.theme.selectedTheme == prefs.preferences.theme.selectedLightTheme { + Color.white + } else { + EffectView(.underPageBackground) + } + } else { + if prefs.preferences.theme.selectedTheme == prefs.preferences.theme.selectedDarkTheme { + Color.black + } else { + EffectView(.contentBackground) + } + + } + } default: Rectangle().foregroundColor(Color(nsColor: .textBackgroundColor)) } HStack(alignment: .center, spacing: 10) { diff --git a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift index 9dc8b7b1c8..391d37dab0 100644 --- a/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift +++ b/CodeEdit/Features/TerminalEmulator/TerminalEmulatorView.swift @@ -175,7 +175,8 @@ struct TerminalEmulatorView: NSViewRepresentable { terminal.caretColor = cursorColor terminal.selectedTextBackgroundColor = selectionColor terminal.nativeForegroundColor = textColor - terminal.nativeBackgroundColor = backgroundColor + terminal.nativeBackgroundColor = prefs.preferences.terminal.useThemeBackground ? backgroundColor : .clear + terminal.layer?.backgroundColor = .clear terminal.optionAsMetaKey = optionAsMeta } terminal.appearance = colorAppearance @@ -201,7 +202,8 @@ struct TerminalEmulatorView: NSViewRepresentable { view.caretColor = cursorColor view.selectedTextBackgroundColor = selectionColor view.nativeForegroundColor = textColor - view.nativeBackgroundColor = backgroundColor + view.nativeBackgroundColor = prefs.preferences.terminal.useThemeBackground ? backgroundColor : .clear + view.layer?.backgroundColor = .clear view.optionAsMetaKey = optionAsMeta view.appearance = colorAppearance if TerminalEmulatorView.lastTerminal[url.path] != nil {