Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public struct TerminalEmulatorView: NSViewRepresentable {

@StateObject private var ansiColors: AnsiColors = .shared

// TODO: Persist this to not get a new terminal each time you switch file
internal static var lastTerminal: LocalProcessTerminalView?
@State internal var terminal: LocalProcessTerminalView

Expand Down Expand Up @@ -86,16 +85,6 @@ public struct TerminalEmulatorView: NSViewRepresentable {
return String(cString: pwd.pw_shell)
}

/// Returns a reorderd array of ANSI colors depending on the app's color scheme (light/drak)
private var appearanceColors: [SwiftTerm.Color] {
if colorScheme == .dark {
return colors
}
var col = colors
col.move(fromOffsets: .init(integersIn: 0...7), toOffset: 16)
return col
}

/// Returns the mapped array of `SwiftTerm.Color` objects of ANSI Colors
private var colors: [SwiftTerm.Color] {
return ansiColors.mappedColors.map { SwiftTerm.Color(hex: $0) }
Expand All @@ -122,7 +111,7 @@ public struct TerminalEmulatorView: NSViewRepresentable {
terminal.startProcess(executable: shell, execName: shellIdiom)
terminal.font = font
terminal.configureNativeColors()
terminal.installColors(self.appearanceColors)
terminal.installColors(self.colors)
}
TerminalEmulatorView.lastTerminal = terminal
}
Expand All @@ -132,7 +121,7 @@ public struct TerminalEmulatorView: NSViewRepresentable {
view.font = font
}
view.configureNativeColors()
view.installColors(self.appearanceColors)
view.installColors(self.colors)
if TerminalEmulatorView.lastTerminal != nil {
TerminalEmulatorView.lastTerminal = view
}
Expand Down