mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-23 01:48:37 +03:00
Reworked proxy icon, added config options.
This commit is contained in:
@ -236,8 +236,14 @@ class BaseTerminalController: NSWindowController,
|
||||
// Set the main window title
|
||||
window.title = to
|
||||
|
||||
}
|
||||
|
||||
func proxyIconURLDidChange(to: URL?){
|
||||
|
||||
guard let window else { return }
|
||||
|
||||
// Get the current working directory from the focused surface
|
||||
if let pwd = focusedSurface?.pwd {
|
||||
if ghostty.config.macosTitlebarProxyIcon == "visible", let pwd = focusedSurface?.pwd {
|
||||
// Set the window's representedURL to the current working directory
|
||||
window.representedURL = URL(fileURLWithPath: pwd)
|
||||
} else {
|
||||
|
@ -307,6 +307,10 @@ class TerminalController: BaseTerminalController {
|
||||
window.standardWindowButton(.closeButton)?.isHidden = true
|
||||
window.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
||||
window.standardWindowButton(.zoomButton)?.isHidden = true
|
||||
|
||||
// Hide document icon button(proxy icon)
|
||||
window.representedURL = nil
|
||||
window.standardWindowButton(.documentIconButton)?.isHidden = true
|
||||
|
||||
// Disallow tabbing if the titlebar is hidden, since that will (should) also hide the tab bar.
|
||||
window.tabbingMode = .disallowed
|
||||
|
@ -10,6 +10,9 @@ protocol TerminalViewDelegate: AnyObject {
|
||||
|
||||
/// The title of the terminal should change.
|
||||
func titleDidChange(to: String)
|
||||
|
||||
/// The URL of the proxy icon should change.
|
||||
func proxyIconURLDidChange(to: URL?)
|
||||
|
||||
/// The cell size changed.
|
||||
func cellSizeDidChange(to: NSSize)
|
||||
@ -62,7 +65,15 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
||||
|
||||
return title
|
||||
}
|
||||
|
||||
|
||||
// The proxy icon URL for our window
|
||||
private var proxyIconURL: URL? {
|
||||
guard let proxyURLString = focusedSurface?.pwd else {
|
||||
return nil
|
||||
}
|
||||
return URL(string: proxyURLString)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
switch ghostty.readiness {
|
||||
case .loading:
|
||||
@ -87,6 +98,10 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
||||
.onChange(of: title) { newValue in
|
||||
self.delegate?.titleDidChange(to: newValue)
|
||||
}
|
||||
.onChange(of: proxyIconURL) { newValue in
|
||||
self.delegate?.proxyIconURLDidChange(to: newValue)
|
||||
|
||||
}
|
||||
.onChange(of: cellSize) { newValue in
|
||||
guard let size = newValue else { return }
|
||||
self.delegate?.cellSizeDidChange(to: size)
|
||||
|
@ -228,6 +228,16 @@ extension Ghostty {
|
||||
guard let ptr = v else { return defaultValue }
|
||||
return String(cString: ptr)
|
||||
}
|
||||
|
||||
var macosTitlebarProxyIcon: String {
|
||||
let defaultValue = "visible"
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
let key = "macos-titlebar-proxy-icon"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
return String(cString: ptr)
|
||||
}
|
||||
|
||||
var macosWindowShadow: Bool {
|
||||
guard let config = self.config else { return false }
|
||||
|
Reference in New Issue
Block a user