mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-29 08:04:32 +00:00
Terminal Work In Progress
This commit is contained in:
parent
40457aa84c
commit
e59d35d89a
12 changed files with 570 additions and 77 deletions
|
|
@ -28,6 +28,7 @@
|
||||||
7ECFE0C62F4A2323000DD9BD /* MijickCalendarView in Frameworks */ = {isa = PBXBuildFile; productRef = 7ECFE0C52F4A2323000DD9BD /* MijickCalendarView */; };
|
7ECFE0C62F4A2323000DD9BD /* MijickCalendarView in Frameworks */ = {isa = PBXBuildFile; productRef = 7ECFE0C52F4A2323000DD9BD /* MijickCalendarView */; };
|
||||||
7EE1D73D2E6B1E0B00997219 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE1D73C2E6B1E0B00997219 /* ApplicationServices.framework */; };
|
7EE1D73D2E6B1E0B00997219 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE1D73C2E6B1E0B00997219 /* ApplicationServices.framework */; };
|
||||||
7EE1D73F2E6B1E1200997219 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE1D73E2E6B1E1200997219 /* IOKit.framework */; };
|
7EE1D73F2E6B1E1200997219 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EE1D73E2E6B1E1200997219 /* IOKit.framework */; };
|
||||||
|
7EF19C172F577040005B9929 /* SwiftTerm in Frameworks */ = {isa = PBXBuildFile; productRef = 7EF19C162F577040005B9929 /* SwiftTerm */; };
|
||||||
7EF1D4B92FFFCE3C008D2C32 /* ExtensionEventBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EF1D4B82FFFCE3C008D2C32 /* ExtensionEventBridge.swift */; };
|
7EF1D4B92FFFCE3C008D2C32 /* ExtensionEventBridge.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7EF1D4B82FFFCE3C008D2C32 /* ExtensionEventBridge.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
|
|
@ -62,6 +63,7 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
7EF19C172F577040005B9929 /* SwiftTerm in Frameworks */,
|
||||||
7E1ADF1D2EA209B1001DA867 /* SkyLightWindow in Frameworks */,
|
7E1ADF1D2EA209B1001DA867 /* SkyLightWindow in Frameworks */,
|
||||||
7EE1D73F2E6B1E1200997219 /* IOKit.framework in Frameworks */,
|
7EE1D73F2E6B1E1200997219 /* IOKit.framework in Frameworks */,
|
||||||
7EE1D73D2E6B1E0B00997219 /* ApplicationServices.framework in Frameworks */,
|
7EE1D73D2E6B1E0B00997219 /* ApplicationServices.framework in Frameworks */,
|
||||||
|
|
@ -174,6 +176,7 @@
|
||||||
7E61181E2E24071E0050006C /* SkyLightWindow */,
|
7E61181E2E24071E0050006C /* SkyLightWindow */,
|
||||||
7E288D112F1659EF0020C117 /* AtollExtensionKit */,
|
7E288D112F1659EF0020C117 /* AtollExtensionKit */,
|
||||||
7ECFE0C52F4A2323000DD9BD /* MijickCalendarView */,
|
7ECFE0C52F4A2323000DD9BD /* MijickCalendarView */,
|
||||||
|
7EF19C162F577040005B9929 /* SwiftTerm */,
|
||||||
);
|
);
|
||||||
productName = DynamicIsland;
|
productName = DynamicIsland;
|
||||||
productReference = F54406E72CD4987A00C7AFD9 /* Atoll.app */;
|
productReference = F54406E72CD4987A00C7AFD9 /* Atoll.app */;
|
||||||
|
|
@ -220,6 +223,7 @@
|
||||||
7E09D5962EB7B497005AF41D /* XCRemoteSwiftPackageReference "open-meteo" */,
|
7E09D5962EB7B497005AF41D /* XCRemoteSwiftPackageReference "open-meteo" */,
|
||||||
7E288D102F1659EF0020C117 /* XCRemoteSwiftPackageReference "AtollExtensionKit" */,
|
7E288D102F1659EF0020C117 /* XCRemoteSwiftPackageReference "AtollExtensionKit" */,
|
||||||
7ECFE0C42F4A2323000DD9BD /* XCRemoteSwiftPackageReference "CalendarView" */,
|
7ECFE0C42F4A2323000DD9BD /* XCRemoteSwiftPackageReference "CalendarView" */,
|
||||||
|
7EF19C152F577040005B9929 /* XCRemoteSwiftPackageReference "SwiftTerm" */,
|
||||||
);
|
);
|
||||||
preferredProjectObjectVersion = 77;
|
preferredProjectObjectVersion = 77;
|
||||||
productRefGroup = F54406E82CD4987A00C7AFD9 /* Products */;
|
productRefGroup = F54406E82CD4987A00C7AFD9 /* Products */;
|
||||||
|
|
@ -601,6 +605,14 @@
|
||||||
minimumVersion = 1.1.1;
|
minimumVersion = 1.1.1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
7EF19C152F577040005B9929 /* XCRemoteSwiftPackageReference "SwiftTerm" */ = {
|
||||||
|
isa = XCRemoteSwiftPackageReference;
|
||||||
|
repositoryURL = "https://github.com/migueldeicaza/SwiftTerm";
|
||||||
|
requirement = {
|
||||||
|
kind = upToNextMajorVersion;
|
||||||
|
minimumVersion = 1.5.0;
|
||||||
|
};
|
||||||
|
};
|
||||||
9A987A112C73CAA1005CA465 /* XCRemoteSwiftPackageReference "Pow" */ = {
|
9A987A112C73CAA1005CA465 /* XCRemoteSwiftPackageReference "Pow" */ = {
|
||||||
isa = XCRemoteSwiftPackageReference;
|
isa = XCRemoteSwiftPackageReference;
|
||||||
repositoryURL = "https://github.com/EmergeTools/Pow";
|
repositoryURL = "https://github.com/EmergeTools/Pow";
|
||||||
|
|
@ -682,6 +694,11 @@
|
||||||
package = 7ECFE0C42F4A2323000DD9BD /* XCRemoteSwiftPackageReference "CalendarView" */;
|
package = 7ECFE0C42F4A2323000DD9BD /* XCRemoteSwiftPackageReference "CalendarView" */;
|
||||||
productName = MijickCalendarView;
|
productName = MijickCalendarView;
|
||||||
};
|
};
|
||||||
|
7EF19C162F577040005B9929 /* SwiftTerm */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
package = 7EF19C152F577040005B9929 /* XCRemoteSwiftPackageReference "SwiftTerm" */;
|
||||||
|
productName = SwiftTerm;
|
||||||
|
};
|
||||||
9A987A0F2C73CA8D005CA465 /* Collections */ = {
|
9A987A0F2C73CA8D005CA465 /* Collections */ = {
|
||||||
isa = XCSwiftPackageProductDependency;
|
isa = XCSwiftPackageProductDependency;
|
||||||
package = F54407082CD4A23F00C7AFD9 /* XCRemoteSwiftPackageReference "swift-collections" */;
|
package = F54407082CD4A23F00C7AFD9 /* XCRemoteSwiftPackageReference "swift-collections" */;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"originHash" : "802e15fea0dccd2d325dc082d8d36162007adcd2fa301070eb26448d0a2cf6c5",
|
"originHash" : "e56c82928835ebd09a259cfbf30486c2ebf4c785c9519f893675e244e709ec46",
|
||||||
"pins" : [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"identity" : "atollextensionkit",
|
"identity" : "atollextensionkit",
|
||||||
|
|
@ -109,6 +109,15 @@
|
||||||
"version" : "2.7.0"
|
"version" : "2.7.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-argument-parser",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-argument-parser",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "c5d11a805e765f52ba34ec7284bd4fcd6ba68615",
|
||||||
|
"version" : "1.7.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swift-collections",
|
"identity" : "swift-collections",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
|
@ -127,6 +136,15 @@
|
||||||
"version" : "601.0.1"
|
"version" : "601.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swiftterm",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/migueldeicaza/SwiftTerm",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "b1262db5b6bea699a8260a8c66999436c508ca56",
|
||||||
|
"version" : "1.11.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"identity" : "swiftui-introspect",
|
"identity" : "swiftui-introspect",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,14 @@ struct ContentView: View {
|
||||||
return CGSize(width: baseSize.width, height: resolvedHeight)
|
return CGSize(width: baseSize.width, height: resolvedHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if coordinator.currentView == .terminal {
|
||||||
|
// Dynamic height: up to terminalMaxHeightFraction of screen, min 300pt
|
||||||
|
let screenHeight = NSScreen.main?.visibleFrame.height ?? 800
|
||||||
|
let maxFraction = Defaults[.terminalMaxHeightFraction]
|
||||||
|
let terminalHeight = min(screenHeight * maxFraction, max(300, screenHeight * maxFraction))
|
||||||
|
return CGSize(width: baseSize.width, height: terminalHeight)
|
||||||
|
}
|
||||||
|
|
||||||
if coordinator.currentView == .extensionExperience {
|
if coordinator.currentView == .extensionExperience {
|
||||||
if let preferredHeight = extensionTabPreferredHeight(baseSize: baseSize) {
|
if let preferredHeight = extensionTabPreferredHeight(baseSize: baseSize) {
|
||||||
return CGSize(width: baseSize.width, height: preferredHeight)
|
return CGSize(width: baseSize.width, height: preferredHeight)
|
||||||
|
|
@ -832,6 +840,8 @@ struct ContentView: View {
|
||||||
NotchNotesView()
|
NotchNotesView()
|
||||||
case .clipboard:
|
case .clipboard:
|
||||||
NotchNotesView()
|
NotchNotesView()
|
||||||
|
case .terminal:
|
||||||
|
NotchTerminalView()
|
||||||
case .extensionExperience:
|
case .extensionExperience:
|
||||||
if let payload = currentExtensionTabPayload() {
|
if let payload = currentExtensionTabPayload() {
|
||||||
ExtensionNotchExperienceTabView(payload: payload)
|
ExtensionNotchExperienceTabView(payload: payload)
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
} else if coordinator.currentView == .notes || coordinator.currentView == .clipboard {
|
} else if coordinator.currentView == .notes || coordinator.currentView == .clipboard {
|
||||||
let preferredHeight = coordinator.notesLayoutState.preferredHeight
|
let preferredHeight = coordinator.notesLayoutState.preferredHeight
|
||||||
baseSize.height = max(baseSize.height, preferredHeight)
|
baseSize.height = max(baseSize.height, preferredHeight)
|
||||||
|
} else if coordinator.currentView == .terminal {
|
||||||
|
let screenHeight = NSScreen.main?.visibleFrame.height ?? 800
|
||||||
|
let maxFraction = Defaults[.terminalMaxHeightFraction]
|
||||||
|
baseSize.height = min(screenHeight * maxFraction, max(300, screenHeight * maxFraction))
|
||||||
}
|
}
|
||||||
|
|
||||||
let adjustedContentSize = statsAdjustedNotchSize(
|
let adjustedContentSize = statsAdjustedNotchSize(
|
||||||
|
|
@ -423,8 +427,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
PrivacyIndicatorManager.shared.startMonitoring()
|
PrivacyIndicatorManager.shared.startMonitoring()
|
||||||
|
|
||||||
// Observe tab changes - use immediate resize to keep the notch pinned
|
// Observe tab changes - use immediate resize to keep the notch pinned
|
||||||
|
// Deferred to next run loop tick because @Published fires on willSet,
|
||||||
|
// so coordinator.currentView still holds the OLD value at emission time.
|
||||||
coordinator.$currentView.sink { [weak self] _ in
|
coordinator.$currentView.sink { [weak self] _ in
|
||||||
|
DispatchQueue.main.async {
|
||||||
self?.updateWindowSizeForTabSwitch()
|
self?.updateWindowSizeForTabSwitch()
|
||||||
|
}
|
||||||
}.store(in: &cancellables)
|
}.store(in: &cancellables)
|
||||||
|
|
||||||
coordinator.$notesLayoutState
|
coordinator.$notesLayoutState
|
||||||
|
|
@ -463,6 +471,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
self?.debouncedUpdateWindowSize()
|
self?.debouncedUpdateWindowSize()
|
||||||
}.store(in: &cancellables)
|
}.store(in: &cancellables)
|
||||||
|
|
||||||
|
// Observe terminal settings changes
|
||||||
|
Defaults.publisher(.enableTerminalFeature, options: []).sink { [weak self] _ in
|
||||||
|
self?.debouncedUpdateWindowSize()
|
||||||
|
}.store(in: &cancellables)
|
||||||
|
|
||||||
|
Defaults.publisher(.terminalMaxHeightFraction, options: []).sink { [weak self] _ in
|
||||||
|
self?.debouncedUpdateWindowSize()
|
||||||
|
}.store(in: &cancellables)
|
||||||
|
|
||||||
MemoryUsageMonitor.shared.startMonitoring()
|
MemoryUsageMonitor.shared.startMonitoring()
|
||||||
|
|
||||||
ReminderLiveActivityManager.shared.$activeWindowReminders
|
ReminderLiveActivityManager.shared.$activeWindowReminders
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ class DynamicIslandViewCoordinator: ObservableObject {
|
||||||
static let shared = DynamicIslandViewCoordinator()
|
static let shared = DynamicIslandViewCoordinator()
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
|
|
||||||
private static let tabOrder: [NotchViews] = [.home, .shelf, .timer, .stats, .colorPicker, .notes, .clipboard, .extensionExperience]
|
private static let tabOrder: [NotchViews] = [.home, .shelf, .timer, .stats, .colorPicker, .notes, .clipboard, .terminal, .extensionExperience]
|
||||||
|
|
||||||
/// Direction of the most recent tab switch (true = forward/right, false = backward/left)
|
/// Direction of the most recent tab switch (true = forward/right, false = backward/left)
|
||||||
@Published var tabSwitchForward: Bool = true
|
@Published var tabSwitchForward: Bool = true
|
||||||
|
|
|
||||||
|
|
@ -1054,6 +1054,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"%lld pt" : {
|
||||||
|
"comment" : "A label displaying the current font size of the terminal. The value is shown in point size.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"%lld px" : {
|
"%lld px" : {
|
||||||
"comment" : "A label displaying the current expanded notch width value. The value is shown in pixels.",
|
"comment" : "A label displaying the current expanded notch width value. The value is shown in pixels.",
|
||||||
"isCommentAutoGenerated" : true,
|
"isCommentAutoGenerated" : true,
|
||||||
|
|
@ -1591,10 +1595,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"±10 Seconds" : {
|
|
||||||
"comment" : "Display name for the \"±10 Seconds\" music skip behavior.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"0" : {
|
"0" : {
|
||||||
"comment" : "A label displayed in a circular gauge to indicate the minimum battery level.",
|
"comment" : "A label displayed in a circular gauge to indicate the minimum battery level.",
|
||||||
"isCommentAutoGenerated" : true,
|
"isCommentAutoGenerated" : true,
|
||||||
|
|
@ -1911,10 +1911,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Accent" : {
|
|
||||||
"comment" : "Name of the Caps Lock Indicator Tint Mode option that uses the accent color.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Accent color" : {
|
"Accent color" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -2260,10 +2256,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Adaptive gradient" : {
|
|
||||||
"comment" : "Name of the timer icon color mode that uses an adaptive gradient.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Add" : {
|
"Add" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -2756,6 +2748,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Adds a Guake-style dropdown terminal tab. The terminal runs a shell session that persists while the notch is open." : {
|
||||||
|
"comment" : "A description of the terminal settings feature.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Adds a notch HUD when Caps Lock is enabled, with optional label and tint controls." : {
|
"Adds a notch HUD when Caps Lock is enabled, with optional label and tint controls." : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"pt-BR" : {
|
"pt-BR" : {
|
||||||
|
|
@ -3853,10 +3849,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Apple Music" : {
|
|
||||||
"comment" : "Names for the different media player types available in the app.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Applies the notch-style parallax effect to the lock screen media widget album art." : {
|
"Applies the notch-style parallax effect to the lock screen media widget album art." : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"pt-BR" : {
|
"pt-BR" : {
|
||||||
|
|
@ -4268,10 +4260,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Bar" : {
|
|
||||||
"comment" : "Localized name for the \"Bar\" timer progress style.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Battery" : {
|
"Battery" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -8530,10 +8518,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Digital" : {
|
|
||||||
"comment" : "The name of the \"Digital\" style of reminder presentation.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Dimensions" : {
|
"Dimensions" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"pt-BR" : {
|
"pt-BR" : {
|
||||||
|
|
@ -10016,6 +10000,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Enable it in Settings → Terminal" : {
|
||||||
|
|
||||||
},
|
},
|
||||||
"Enable media panel blur" : {
|
"Enable media panel blur" : {
|
||||||
"comment" : "A toggle switch that enables or disables the blur effect on the media panel.",
|
"comment" : "A toggle switch that enables or disables the blur effect on the media panel.",
|
||||||
|
|
@ -11064,6 +11051,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Font size" : {
|
||||||
|
"comment" : "A label displayed above a slider that controls the font size of the terminal",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Free · %@" : {
|
"Free · %@" : {
|
||||||
"comment" : "A label displaying the amount of free storage on a disk device. The argument is the number of free bytes on the disk.",
|
"comment" : "A label displaying the amount of free storage on a disk device. The argument is the number of free bytes on the disk.",
|
||||||
"isCommentAutoGenerated" : true,
|
"isCommentAutoGenerated" : true,
|
||||||
|
|
@ -11919,10 +11910,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Green" : {
|
|
||||||
"comment" : "Display name for the \"Green\" Caps Lock Indicator Tint Mode.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Height:" : {
|
"Height:" : {
|
||||||
"extractionState" : "stale",
|
"extractionState" : "stale",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
@ -14396,6 +14383,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Maximum height" : {
|
||||||
|
"comment" : "A label for the terminal's maximum height setting.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Media" : {
|
"Media" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -15593,6 +15584,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Minutes" : {
|
"Minutes" : {
|
||||||
|
"extractionState" : "stale",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"fr" : {
|
"fr" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
|
|
@ -17809,10 +17801,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Now Playing" : {
|
|
||||||
"comment" : "Localized name for each media controller type.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Off" : {
|
"Off" : {
|
||||||
"comment" : "Text displayed in a status label at the top of the screen indicating whether low power mode is on or off.",
|
"comment" : "Text displayed in a status label at the top of the screen indicating whether low power mode is on or off.",
|
||||||
"isCommentAutoGenerated" : true
|
"isCommentAutoGenerated" : true
|
||||||
|
|
@ -18179,10 +18167,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Panel" : {
|
|
||||||
"comment" : "Display name for the \"Panel\" clipboard display mode.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Panel mode shows clipboard in a floating window near the notch." : {
|
"Panel mode shows clipboard in a floating window near the notch." : {
|
||||||
"comment" : "A description of the \"Panel\" clipboard display mode.",
|
"comment" : "A description of the \"Panel\" clipboard display mode.",
|
||||||
"isCommentAutoGenerated" : true,
|
"isCommentAutoGenerated" : true,
|
||||||
|
|
@ -19707,6 +19691,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Restart shell" : {
|
||||||
|
"comment" : "A button label that says \"Restart shell\".",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
|
"Restart Shell" : {
|
||||||
|
"comment" : "A button that restarts the shell process. Any unsaved work in the terminal will be lost.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
|
"Restarts the shell process. Any unsaved work in the terminal will be lost." : {
|
||||||
|
"comment" : "A footer description for the \"Restart Shell\" button in the Terminal settings view.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Restore" : {
|
"Restore" : {
|
||||||
"comment" : "The text for a button that restores default settings.",
|
"comment" : "The text for a button that restores default settings.",
|
||||||
"isCommentAutoGenerated" : true,
|
"isCommentAutoGenerated" : true,
|
||||||
|
|
@ -19785,10 +19781,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Ring" : {
|
|
||||||
"comment" : "Localized name for the \"Ring\" timer progress style.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Rotation:" : {
|
"Rotation:" : {
|
||||||
"extractionState" : "stale",
|
"extractionState" : "stale",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
@ -20609,10 +20601,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Separate Tab" : {
|
|
||||||
"comment" : "Name of the clipboard display mode option that opens the clipboard in a separate tab.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Separate Tab mode integrates Copied Items and Notes into a single view. If both are enabled, Notes appear on the right and Clipboard on the left." : {
|
"Separate Tab mode integrates Copied Items and Notes into a single view. If both are enabled, Notes appear on the right and Clipboard on the left." : {
|
||||||
"comment" : "A description of the \"Separate Tab\" clipboard display mode.",
|
"comment" : "A description of the \"Separate Tab\" clipboard display mode.",
|
||||||
"isCommentAutoGenerated" : true,
|
"isCommentAutoGenerated" : true,
|
||||||
|
|
@ -20877,6 +20865,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Shell path" : {
|
||||||
|
"comment" : "A setting option for the path to the shell to use in the terminal",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Shortcuts" : {
|
"Shortcuts" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -21667,14 +21659,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Shows screen assistant as a dropdown attached to the AI button" : {
|
|
||||||
"comment" : "Description of the \"popover\" display mode for the screen assistant.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Shows screen assistant in a floating panel near the notch" : {
|
|
||||||
"comment" : "Description of the \"Panel\" screen assistant display mode.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Shows the model's reasoning process before the final answer" : {
|
"Shows the model's reasoning process before the final answer" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"fr" : {
|
"fr" : {
|
||||||
|
|
@ -21737,10 +21721,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Skip forward or backward by ten seconds" : {
|
|
||||||
"comment" : "Description of the \"Skip forward or backward by ten seconds\" music skip behavior option.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Slider color" : {
|
"Slider color" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -22309,10 +22289,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Spotify" : {
|
|
||||||
"comment" : "Add more media player types here.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Square" : {
|
"Square" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
@ -22425,10 +22401,6 @@
|
||||||
},
|
},
|
||||||
"Standard notch media controls are hidden. Re-enable the toggle above to restore them." : {
|
"Standard notch media controls are hidden. Re-enable the toggle above to restore them." : {
|
||||||
|
|
||||||
},
|
|
||||||
"Standard previous/next track controls" : {
|
|
||||||
"comment" : "Description of a music skip behavior option that uses standard previous/next track controls.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
},
|
||||||
"Start" : {
|
"Start" : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
@ -23173,6 +23145,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Terminal" : {
|
||||||
|
"comment" : "The title of the settings view related to the terminal.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
|
"Terminal is disabled" : {
|
||||||
|
"comment" : "A message displayed when the terminal feature is disabled.",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
|
"Terminal opacity" : {
|
||||||
|
"comment" : "A label displayed above a slider that controls the opacity of the terminal view",
|
||||||
|
"isCommentAutoGenerated" : true
|
||||||
|
},
|
||||||
"Text" : {
|
"Text" : {
|
||||||
"comment" : "Name of a clipboard item type that contains plain text.",
|
"comment" : "Name of a clipboard item type that contains plain text.",
|
||||||
"isCommentAutoGenerated" : true
|
"isCommentAutoGenerated" : true
|
||||||
|
|
@ -23778,10 +23762,6 @@
|
||||||
},
|
},
|
||||||
"shouldTranslate" : false
|
"shouldTranslate" : false
|
||||||
},
|
},
|
||||||
"Track Skip" : {
|
|
||||||
"comment" : "Name of the music skip behavior option that skips to the next track.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"Transform" : {
|
"Transform" : {
|
||||||
"extractionState" : "stale",
|
"extractionState" : "stale",
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
|
|
@ -25700,10 +25680,6 @@
|
||||||
"comment" : "A footer note explaining the app's funding.",
|
"comment" : "A footer note explaining the app's funding.",
|
||||||
"isCommentAutoGenerated" : true
|
"isCommentAutoGenerated" : true
|
||||||
},
|
},
|
||||||
"Youtube Music" : {
|
|
||||||
"comment" : "Name for the \"Youtube Music\" media controller type in settings.",
|
|
||||||
"isCommentAutoGenerated" : true
|
|
||||||
},
|
|
||||||
"YouTube Music requires this third-party app to be installed: " : {
|
"YouTube Music requires this third-party app to be installed: " : {
|
||||||
"localizations" : {
|
"localizations" : {
|
||||||
"ar" : {
|
"ar" : {
|
||||||
|
|
|
||||||
165
DynamicIsland/components/Notch/NotchTerminalView.swift
Normal file
165
DynamicIsland/components/Notch/NotchTerminalView.swift
Normal file
|
|
@ -0,0 +1,165 @@
|
||||||
|
/*
|
||||||
|
* Atoll (DynamicIsland)
|
||||||
|
* Copyright (C) 2024-2026 Atoll Contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
import SwiftTerm
|
||||||
|
import Defaults
|
||||||
|
|
||||||
|
// MARK: - NSViewRepresentable wrapper for SwiftTerm
|
||||||
|
|
||||||
|
/// Bridges SwiftTerm's `LocalProcessTerminalView` (NSView) into SwiftUI.
|
||||||
|
///
|
||||||
|
/// Returns `TerminalManager.containerView` (a stable NSView) so that
|
||||||
|
/// SwiftUI's view lifecycle never tears down the actual terminal. The
|
||||||
|
/// real `LocalProcessTerminalView` lives as a subview of that container
|
||||||
|
/// and survives notch close/open and tab-switch cycles.
|
||||||
|
struct TerminalNSViewRepresentable: NSViewRepresentable {
|
||||||
|
@ObservedObject var terminalManager = TerminalManager.shared
|
||||||
|
|
||||||
|
func makeNSView(context: Context) -> NSView {
|
||||||
|
context.coordinator.terminalManager = terminalManager
|
||||||
|
terminalManager.ensureTerminalView(delegate: context.coordinator)
|
||||||
|
if !terminalManager.isProcessRunning {
|
||||||
|
terminalManager.startShellProcess()
|
||||||
|
}
|
||||||
|
return terminalManager.containerView
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateNSView(_ nsView: NSView, context: Context) {
|
||||||
|
// Re-mount terminal if it was restarted (generation bumped).
|
||||||
|
terminalManager.ensureTerminalView(delegate: context.coordinator)
|
||||||
|
if !terminalManager.isProcessRunning {
|
||||||
|
terminalManager.startShellProcess()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func makeCoordinator() -> Coordinator {
|
||||||
|
Coordinator()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Coordinator: NSObject, LocalProcessTerminalViewDelegate {
|
||||||
|
var terminalManager: TerminalManager?
|
||||||
|
|
||||||
|
func sizeChanged(source: LocalProcessTerminalView, newCols: Int, newRows: Int) {
|
||||||
|
// Terminal resized — no action needed; SwiftTerm handles reflow.
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTerminalTitle(source: LocalProcessTerminalView, title: String) {
|
||||||
|
Task { @MainActor in
|
||||||
|
terminalManager?.updateTitle(title)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func hostCurrentDirectoryUpdate(source: TerminalView, directory: String?) {
|
||||||
|
// Could be used for breadcrumbs in the future.
|
||||||
|
}
|
||||||
|
|
||||||
|
func processTerminated(source: TerminalView, exitCode: Int32?) {
|
||||||
|
Task { @MainActor in
|
||||||
|
terminalManager?.processDidTerminate(exitCode: exitCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Notch Tab View
|
||||||
|
|
||||||
|
/// Guake-style dropdown terminal tab for the notch.
|
||||||
|
/// Dynamically sizes up to half the screen height; content scrolls when the
|
||||||
|
/// terminal buffer exceeds the visible area (handled internally by SwiftTerm).
|
||||||
|
struct NotchTerminalView: View {
|
||||||
|
@ObservedObject var terminalManager = TerminalManager.shared
|
||||||
|
@EnvironmentObject var vm: DynamicIslandViewModel
|
||||||
|
@Default(.enableTerminalFeature) var enableTerminalFeature
|
||||||
|
@State private var suppressionToken = UUID()
|
||||||
|
@State private var isSuppressing = false
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
VStack(spacing: 0) {
|
||||||
|
if enableTerminalFeature {
|
||||||
|
// Terminal header bar
|
||||||
|
HStack {
|
||||||
|
Image(systemName: "apple.terminal")
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.font(.system(size: 11))
|
||||||
|
|
||||||
|
Text(terminalManager.terminalTitle)
|
||||||
|
.font(.system(size: 11, weight: .medium))
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.lineLimit(1)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
// Restart button
|
||||||
|
Button {
|
||||||
|
terminalManager.restartShell()
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "arrow.counterclockwise")
|
||||||
|
.font(.system(size: 10))
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
.buttonStyle(.plain)
|
||||||
|
.help("Restart shell")
|
||||||
|
}
|
||||||
|
.padding(.horizontal, 12)
|
||||||
|
.padding(.top, 6)
|
||||||
|
.padding(.bottom, 4)
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
.padding(.horizontal, 8)
|
||||||
|
|
||||||
|
// Terminal content — .id(sessionGeneration) forces
|
||||||
|
// representable recreation only after an explicit restart.
|
||||||
|
TerminalNSViewRepresentable(terminalManager: terminalManager)
|
||||||
|
.id(terminalManager.sessionGeneration)
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 6, style: .continuous))
|
||||||
|
.padding(.horizontal, 8)
|
||||||
|
.padding(.bottom, 8)
|
||||||
|
.padding(.top, 4)
|
||||||
|
.onHover { hovering in
|
||||||
|
updateSuppression(for: hovering)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Feature disabled placeholder
|
||||||
|
VStack(spacing: 8) {
|
||||||
|
Image(systemName: "apple.terminal")
|
||||||
|
.font(.system(size: 28))
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
|
||||||
|
Text("Terminal is disabled")
|
||||||
|
.font(.system(size: 12, weight: .medium))
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
|
||||||
|
Text("Enable it in Settings → Terminal")
|
||||||
|
.font(.system(size: 10))
|
||||||
|
.foregroundStyle(.tertiary)
|
||||||
|
}
|
||||||
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onDisappear {
|
||||||
|
updateSuppression(for: false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateSuppression(for hovering: Bool) {
|
||||||
|
guard hovering != isSuppressing else { return }
|
||||||
|
isSuppressing = hovering
|
||||||
|
vm.setScrollGestureSuppression(hovering, token: suppressionToken)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,7 @@ private enum SettingsTab: String, CaseIterable, Identifiable {
|
||||||
case shelf
|
case shelf
|
||||||
case shortcuts
|
case shortcuts
|
||||||
case notes
|
case notes
|
||||||
|
case terminal
|
||||||
case about
|
case about
|
||||||
|
|
||||||
var id: String { rawValue }
|
var id: String { rawValue }
|
||||||
|
|
@ -62,6 +63,7 @@ private enum SettingsTab: String, CaseIterable, Identifiable {
|
||||||
case .shelf: return "Shelf"
|
case .shelf: return "Shelf"
|
||||||
case .shortcuts: return "Shortcuts"
|
case .shortcuts: return "Shortcuts"
|
||||||
case .notes: return "Notes"
|
case .notes: return "Notes"
|
||||||
|
case .terminal: return "Terminal"
|
||||||
case .about: return "About"
|
case .about: return "About"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +89,7 @@ private enum SettingsTab: String, CaseIterable, Identifiable {
|
||||||
case .shelf: return "books.vertical"
|
case .shelf: return "books.vertical"
|
||||||
case .shortcuts: return "keyboard"
|
case .shortcuts: return "keyboard"
|
||||||
case .notes: return "note.text"
|
case .notes: return "note.text"
|
||||||
|
case .terminal: return "apple.terminal"
|
||||||
case .about: return "info.circle"
|
case .about: return "info.circle"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -112,6 +115,7 @@ private enum SettingsTab: String, CaseIterable, Identifiable {
|
||||||
case .shelf: return .brown
|
case .shelf: return .brown
|
||||||
case .shortcuts: return .orange
|
case .shortcuts: return .orange
|
||||||
case .notes: return Color(red: 0.979, green: 0.716, blue: 0.153, opacity: 1.000)
|
case .notes: return Color(red: 0.979, green: 0.716, blue: 0.153, opacity: 1.000)
|
||||||
|
case .terminal: return Color(red: 0.2, green: 0.8, blue: 0.4)
|
||||||
case .about: return .secondary
|
case .about: return .secondary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -421,6 +425,7 @@ struct SettingsView: View {
|
||||||
.downloads,
|
.downloads,
|
||||||
.shelf,
|
.shelf,
|
||||||
.shortcuts,
|
.shortcuts,
|
||||||
|
.terminal,
|
||||||
.extensions,
|
.extensions,
|
||||||
.about
|
.about
|
||||||
]
|
]
|
||||||
|
|
@ -781,13 +786,20 @@ struct SettingsView: View {
|
||||||
SettingsSearchEntry(tab: .colorPicker, title: "Show Color Picker Icon", keywords: ["color icon", "toolbar"], highlightID: SettingsTab.colorPicker.highlightID(for: "Show Color Picker Icon")),
|
SettingsSearchEntry(tab: .colorPicker, title: "Show Color Picker Icon", keywords: ["color icon", "toolbar"], highlightID: SettingsTab.colorPicker.highlightID(for: "Show Color Picker Icon")),
|
||||||
SettingsSearchEntry(tab: .colorPicker, title: "Display Mode", keywords: ["color", "list"], highlightID: SettingsTab.colorPicker.highlightID(for: "Display Mode")),
|
SettingsSearchEntry(tab: .colorPicker, title: "Display Mode", keywords: ["color", "list"], highlightID: SettingsTab.colorPicker.highlightID(for: "Display Mode")),
|
||||||
SettingsSearchEntry(tab: .colorPicker, title: "History Size", keywords: ["color history"], highlightID: SettingsTab.colorPicker.highlightID(for: "History Size")),
|
SettingsSearchEntry(tab: .colorPicker, title: "History Size", keywords: ["color history"], highlightID: SettingsTab.colorPicker.highlightID(for: "History Size")),
|
||||||
SettingsSearchEntry(tab: .colorPicker, title: "Show All Color Formats", keywords: ["hex", "hsl", "color formats"], highlightID: SettingsTab.colorPicker.highlightID(for: "Show All Color Formats"))
|
SettingsSearchEntry(tab: .colorPicker, title: "Show All Color Formats", keywords: ["hex", "hsl", "color formats"], highlightID: SettingsTab.colorPicker.highlightID(for: "Show All Color Formats")),
|
||||||
|
|
||||||
|
// Terminal
|
||||||
|
SettingsSearchEntry(tab: .terminal, title: "Enable terminal", keywords: ["terminal", "guake", "shell"], highlightID: SettingsTab.terminal.highlightID(for: "Enable terminal")),
|
||||||
|
SettingsSearchEntry(tab: .terminal, title: "Shell path", keywords: ["shell", "zsh", "bash", "terminal"], highlightID: SettingsTab.terminal.highlightID(for: "Shell path")),
|
||||||
|
SettingsSearchEntry(tab: .terminal, title: "Font size", keywords: ["terminal", "font", "text size"], highlightID: SettingsTab.terminal.highlightID(for: "Font size")),
|
||||||
|
SettingsSearchEntry(tab: .terminal, title: "Terminal opacity", keywords: ["terminal", "opacity", "transparency"], highlightID: SettingsTab.terminal.highlightID(for: "Terminal opacity")),
|
||||||
|
SettingsSearchEntry(tab: .terminal, title: "Maximum height", keywords: ["terminal", "height", "size"], highlightID: SettingsTab.terminal.highlightID(for: "Maximum height")),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
private func isTabVisible(_ tab: SettingsTab) -> Bool {
|
private func isTabVisible(_ tab: SettingsTab) -> Bool {
|
||||||
switch tab {
|
switch tab {
|
||||||
case .timer, .stats, .clipboard, .screenAssistant, .colorPicker, .shelf, .notes:
|
case .timer, .stats, .clipboard, .screenAssistant, .colorPicker, .shelf, .notes, .terminal:
|
||||||
return !enableMinimalisticUI
|
return !enableMinimalisticUI
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
|
|
@ -873,6 +885,10 @@ struct SettingsView: View {
|
||||||
SettingsForm(tab: .notes) {
|
SettingsForm(tab: .notes) {
|
||||||
NotesSettingsView()
|
NotesSettingsView()
|
||||||
}
|
}
|
||||||
|
case .terminal:
|
||||||
|
SettingsForm(tab: .terminal) {
|
||||||
|
TerminalSettings()
|
||||||
|
}
|
||||||
case .about:
|
case .about:
|
||||||
if let controller = updaterController {
|
if let controller = updaterController {
|
||||||
SettingsForm(tab: .about) {
|
SettingsForm(tab: .about) {
|
||||||
|
|
@ -6990,3 +7006,109 @@ struct NotesSettingsView: View {
|
||||||
.navigationTitle("Notes")
|
.navigationTitle("Notes")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Terminal Settings
|
||||||
|
|
||||||
|
struct TerminalSettings: View {
|
||||||
|
@ObservedObject var terminalManager = TerminalManager.shared
|
||||||
|
@Default(.enableTerminalFeature) var enableTerminalFeature
|
||||||
|
@Default(.terminalShellPath) var terminalShellPath
|
||||||
|
@Default(.terminalFontSize) var terminalFontSize
|
||||||
|
@Default(.terminalOpacity) var terminalOpacity
|
||||||
|
@Default(.terminalMaxHeightFraction) var terminalMaxHeightFraction
|
||||||
|
|
||||||
|
private func highlightID(_ title: String) -> String {
|
||||||
|
SettingsTab.terminal.highlightID(for: title)
|
||||||
|
}
|
||||||
|
|
||||||
|
private var formattedMaxHeight: String {
|
||||||
|
"\(Int(terminalMaxHeightFraction * 100))% of screen"
|
||||||
|
}
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
Form {
|
||||||
|
Section {
|
||||||
|
Defaults.Toggle("Enable terminal", key: .enableTerminalFeature)
|
||||||
|
.settingsHighlight(id: highlightID("Enable terminal"))
|
||||||
|
} header: {
|
||||||
|
Text("General")
|
||||||
|
} footer: {
|
||||||
|
Text("Adds a Guake-style dropdown terminal tab. The terminal runs a shell session that persists while the notch is open.")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
|
||||||
|
if enableTerminalFeature {
|
||||||
|
Section {
|
||||||
|
HStack {
|
||||||
|
Text("Shell path")
|
||||||
|
Spacer()
|
||||||
|
TextField("", text: $terminalShellPath)
|
||||||
|
.textFieldStyle(.roundedBorder)
|
||||||
|
.frame(width: 200)
|
||||||
|
.multilineTextAlignment(.trailing)
|
||||||
|
}
|
||||||
|
.settingsHighlight(id: highlightID("Shell path"))
|
||||||
|
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
HStack {
|
||||||
|
Text("Font size")
|
||||||
|
Spacer()
|
||||||
|
Text("\(Int(terminalFontSize)) pt")
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.monospacedDigit()
|
||||||
|
}
|
||||||
|
Slider(value: $terminalFontSize, in: 8...24, step: 1)
|
||||||
|
.onChange(of: terminalFontSize) { _, newValue in
|
||||||
|
terminalManager.applyFontSize(newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.settingsHighlight(id: highlightID("Font size"))
|
||||||
|
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
HStack {
|
||||||
|
Text("Terminal opacity")
|
||||||
|
Spacer()
|
||||||
|
Text("\(Int(terminalOpacity * 100))%")
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.monospacedDigit()
|
||||||
|
}
|
||||||
|
Slider(value: $terminalOpacity, in: 0.3...1.0, step: 0.05)
|
||||||
|
.onChange(of: terminalOpacity) { _, newValue in
|
||||||
|
terminalManager.applyOpacity(newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.settingsHighlight(id: highlightID("Terminal opacity"))
|
||||||
|
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
HStack {
|
||||||
|
Text("Maximum height")
|
||||||
|
Spacer()
|
||||||
|
Text(formattedMaxHeight)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
.monospacedDigit()
|
||||||
|
}
|
||||||
|
Slider(value: $terminalMaxHeightFraction, in: 0.2...0.5, step: 0.05)
|
||||||
|
}
|
||||||
|
.settingsHighlight(id: highlightID("Maximum height"))
|
||||||
|
} header: {
|
||||||
|
Text("Appearance")
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
Button("Restart Shell") {
|
||||||
|
terminalManager.restartShell()
|
||||||
|
}
|
||||||
|
.disabled(!terminalManager.isProcessRunning)
|
||||||
|
} header: {
|
||||||
|
Text("Actions")
|
||||||
|
} footer: {
|
||||||
|
Text("Restarts the shell process. Any unsaved work in the terminal will be lost.")
|
||||||
|
.font(.caption)
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.navigationTitle("Terminal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@ struct TabSelectionView: View {
|
||||||
let icon = Defaults[.enableNotes] ? "note.text" : "doc.on.clipboard"
|
let icon = Defaults[.enableNotes] ? "note.text" : "doc.on.clipboard"
|
||||||
tabsArray.append(TabModel(label: label, icon: icon, view: .notes))
|
tabsArray.append(TabModel(label: label, icon: icon, view: .notes))
|
||||||
}
|
}
|
||||||
|
if Defaults[.enableTerminalFeature] {
|
||||||
|
tabsArray.append(TabModel(label: "Terminal", icon: "apple.terminal", view: .terminal))
|
||||||
|
}
|
||||||
if extensionTabsEnabled {
|
if extensionTabsEnabled {
|
||||||
for payload in extensionTabPayloads {
|
for payload in extensionTabPayloads {
|
||||||
guard let tab = payload.descriptor.tab else { continue }
|
guard let tab = payload.descriptor.tab else { continue }
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ public enum NotchViews {
|
||||||
case colorPicker
|
case colorPicker
|
||||||
case notes
|
case notes
|
||||||
case clipboard
|
case clipboard
|
||||||
|
case terminal
|
||||||
case extensionExperience
|
case extensionExperience
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
157
DynamicIsland/managers/TerminalManager.swift
Normal file
157
DynamicIsland/managers/TerminalManager.swift
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
/*
|
||||||
|
* Atoll (DynamicIsland)
|
||||||
|
* Copyright (C) 2024-2026 Atoll Contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
import SwiftTerm
|
||||||
|
import Defaults
|
||||||
|
|
||||||
|
/// Manages the Guake-style dropdown terminal session lifecycle.
|
||||||
|
/// The terminal is lazily created when the user first switches to the terminal tab,
|
||||||
|
/// and the process is kept alive across notch open/close cycles.
|
||||||
|
///
|
||||||
|
/// Uses a stable `containerView` (NSView) as the host so that SwiftUI's
|
||||||
|
/// `NSViewRepresentable` lifecycle (make/update/dismantle) never tears down
|
||||||
|
/// the actual terminal. The `LocalProcessTerminalView` is added as a subview
|
||||||
|
/// of the container and survives notch close/open cycles.
|
||||||
|
@MainActor
|
||||||
|
class TerminalManager: ObservableObject {
|
||||||
|
static let shared = TerminalManager()
|
||||||
|
|
||||||
|
/// Whether a shell process is currently running.
|
||||||
|
@Published var isProcessRunning: Bool = false
|
||||||
|
|
||||||
|
/// The current terminal title reported by the shell.
|
||||||
|
@Published var terminalTitle: String = "Terminal"
|
||||||
|
|
||||||
|
/// Bumped on restart so the `NSViewRepresentable` can recreate via `.id()`.
|
||||||
|
@Published var sessionGeneration: Int = 0
|
||||||
|
|
||||||
|
/// Stable container returned to SwiftUI — never deallocated.
|
||||||
|
let containerView: NSView = {
|
||||||
|
let v = NSView(frame: .zero)
|
||||||
|
v.autoresizingMask = [.width, .height]
|
||||||
|
v.wantsLayer = true
|
||||||
|
return v
|
||||||
|
}()
|
||||||
|
|
||||||
|
/// The actual terminal view (child of `containerView`).
|
||||||
|
private(set) var terminalView: LocalProcessTerminalView?
|
||||||
|
|
||||||
|
private init() {}
|
||||||
|
|
||||||
|
// MARK: - Lifecycle
|
||||||
|
|
||||||
|
/// Ensures the terminal view exists inside the container and returns the container.
|
||||||
|
/// Call this from the `NSViewRepresentable` wrapper.
|
||||||
|
func ensureTerminalView(delegate: LocalProcessTerminalViewDelegate) {
|
||||||
|
if let existing = terminalView, existing.superview === containerView {
|
||||||
|
// Already mounted — just re-wire the delegate in case the coordinator changed.
|
||||||
|
existing.processDelegate = delegate
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let view = LocalProcessTerminalView(frame: containerView.bounds)
|
||||||
|
view.autoresizingMask = [.width, .height]
|
||||||
|
|
||||||
|
// Apply font size from settings
|
||||||
|
let fontSize = CGFloat(Defaults[.terminalFontSize])
|
||||||
|
if let font = NSFont.monospacedSystemFont(ofSize: fontSize, weight: .regular) as NSFont? {
|
||||||
|
view.font = font
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply opacity
|
||||||
|
view.layer?.opacity = Float(Defaults[.terminalOpacity])
|
||||||
|
|
||||||
|
// Configure the dark terminal appearance
|
||||||
|
view.nativeBackgroundColor = .black
|
||||||
|
view.nativeForegroundColor = .white
|
||||||
|
|
||||||
|
view.processDelegate = delegate
|
||||||
|
|
||||||
|
// Mount inside the stable container
|
||||||
|
containerView.subviews.forEach { $0.removeFromSuperview() }
|
||||||
|
containerView.addSubview(view)
|
||||||
|
terminalView = view
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Starts the shell process if not already running.
|
||||||
|
func startShellProcess() {
|
||||||
|
guard let view = terminalView, !isProcessRunning else { return }
|
||||||
|
|
||||||
|
let shell = Defaults[.terminalShellPath]
|
||||||
|
let execName = "-" + (shell as NSString).lastPathComponent // login shell convention
|
||||||
|
|
||||||
|
view.startProcess(
|
||||||
|
executable: shell,
|
||||||
|
args: [],
|
||||||
|
environment: buildEnvironment(),
|
||||||
|
execName: execName
|
||||||
|
)
|
||||||
|
isProcessRunning = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called when the shell process terminates.
|
||||||
|
func processDidTerminate(exitCode: Int32?) {
|
||||||
|
isProcessRunning = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Restarts the shell by tearing down the old terminal and creating a fresh one.
|
||||||
|
func restartShell() {
|
||||||
|
// Terminate the running process gracefully
|
||||||
|
terminalView?.terminate()
|
||||||
|
// Remove old terminal from container
|
||||||
|
terminalView?.removeFromSuperview()
|
||||||
|
terminalView = nil
|
||||||
|
isProcessRunning = false
|
||||||
|
terminalTitle = "Terminal"
|
||||||
|
// Bump generation so the SwiftUI representable re-mounts
|
||||||
|
sessionGeneration += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates the terminal title from the shell escape sequence.
|
||||||
|
func updateTitle(_ title: String) {
|
||||||
|
terminalTitle = title
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates font size on the live terminal view.
|
||||||
|
func applyFontSize(_ size: Double) {
|
||||||
|
guard let view = terminalView else { return }
|
||||||
|
if let font = NSFont.monospacedSystemFont(ofSize: CGFloat(size), weight: .regular) as NSFont? {
|
||||||
|
view.font = font
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Updates opacity on the live terminal view.
|
||||||
|
func applyOpacity(_ opacity: Double) {
|
||||||
|
guard let view = terminalView else { return }
|
||||||
|
view.layer?.opacity = Float(opacity)
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Environment
|
||||||
|
|
||||||
|
/// Builds the environment for the child shell process.
|
||||||
|
private func buildEnvironment() -> [String] {
|
||||||
|
var env = ProcessInfo.processInfo.environment
|
||||||
|
env["TERM"] = "xterm-256color"
|
||||||
|
env["LANG"] = env["LANG"] ?? "en_US.UTF-8"
|
||||||
|
// Remove TERM_PROGRAM if set by a parent terminal
|
||||||
|
env.removeValue(forKey: "TERM_PROGRAM")
|
||||||
|
return env.map { "\($0.key)=\($0.value)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -911,6 +911,13 @@ extension Defaults.Keys {
|
||||||
static let showNetworkGraph = Key<Bool>("showNetworkGraph", default: false)
|
static let showNetworkGraph = Key<Bool>("showNetworkGraph", default: false)
|
||||||
static let showDiskGraph = Key<Bool>("showDiskGraph", default: false)
|
static let showDiskGraph = Key<Bool>("showDiskGraph", default: false)
|
||||||
|
|
||||||
|
// MARK: Terminal Feature
|
||||||
|
static let enableTerminalFeature = Key<Bool>("enableTerminalFeature", default: false)
|
||||||
|
static let terminalShellPath = Key<String>("terminalShellPath", default: "/bin/zsh")
|
||||||
|
static let terminalFontSize = Key<Double>("terminalFontSize", default: 12.0)
|
||||||
|
static let terminalOpacity = Key<Double>("terminalOpacity", default: 1.0)
|
||||||
|
static let terminalMaxHeightFraction = Key<Double>("terminalMaxHeightFraction", default: 0.4)
|
||||||
|
|
||||||
// MARK: Timer Feature
|
// MARK: Timer Feature
|
||||||
static let enableTimerFeature = Key<Bool>("enableTimerFeature", default: true)
|
static let enableTimerFeature = Key<Bool>("enableTimerFeature", default: true)
|
||||||
static let timerDisplayMode = Key<TimerDisplayMode>("timerDisplayMode", default: .tab)
|
static let timerDisplayMode = Key<TimerDisplayMode>("timerDisplayMode", default: .tab)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue