mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-22 01:18:36 +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
|
// Set the main window title
|
||||||
window.title = to
|
window.title = to
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func proxyIconURLDidChange(to: URL?){
|
||||||
|
|
||||||
|
guard let window else { return }
|
||||||
|
|
||||||
// Get the current working directory from the focused surface
|
// 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
|
// Set the window's representedURL to the current working directory
|
||||||
window.representedURL = URL(fileURLWithPath: pwd)
|
window.representedURL = URL(fileURLWithPath: pwd)
|
||||||
} else {
|
} else {
|
||||||
|
@ -308,6 +308,10 @@ class TerminalController: BaseTerminalController {
|
|||||||
window.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
window.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
||||||
window.standardWindowButton(.zoomButton)?.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.
|
// Disallow tabbing if the titlebar is hidden, since that will (should) also hide the tab bar.
|
||||||
window.tabbingMode = .disallowed
|
window.tabbingMode = .disallowed
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,9 @@ protocol TerminalViewDelegate: AnyObject {
|
|||||||
/// The title of the terminal should change.
|
/// The title of the terminal should change.
|
||||||
func titleDidChange(to: String)
|
func titleDidChange(to: String)
|
||||||
|
|
||||||
|
/// The URL of the proxy icon should change.
|
||||||
|
func proxyIconURLDidChange(to: URL?)
|
||||||
|
|
||||||
/// The cell size changed.
|
/// The cell size changed.
|
||||||
func cellSizeDidChange(to: NSSize)
|
func cellSizeDidChange(to: NSSize)
|
||||||
|
|
||||||
@ -63,6 +66,14 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
|||||||
return title
|
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 {
|
var body: some View {
|
||||||
switch ghostty.readiness {
|
switch ghostty.readiness {
|
||||||
case .loading:
|
case .loading:
|
||||||
@ -87,6 +98,10 @@ struct TerminalView<ViewModel: TerminalViewModel>: View {
|
|||||||
.onChange(of: title) { newValue in
|
.onChange(of: title) { newValue in
|
||||||
self.delegate?.titleDidChange(to: newValue)
|
self.delegate?.titleDidChange(to: newValue)
|
||||||
}
|
}
|
||||||
|
.onChange(of: proxyIconURL) { newValue in
|
||||||
|
self.delegate?.proxyIconURLDidChange(to: newValue)
|
||||||
|
|
||||||
|
}
|
||||||
.onChange(of: cellSize) { newValue in
|
.onChange(of: cellSize) { newValue in
|
||||||
guard let size = newValue else { return }
|
guard let size = newValue else { return }
|
||||||
self.delegate?.cellSizeDidChange(to: size)
|
self.delegate?.cellSizeDidChange(to: size)
|
||||||
|
@ -229,6 +229,16 @@ extension Ghostty {
|
|||||||
return String(cString: ptr)
|
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 {
|
var macosWindowShadow: Bool {
|
||||||
guard let config = self.config else { return false }
|
guard let config = self.config else { return false }
|
||||||
var v = false;
|
var v = false;
|
||||||
|
Reference in New Issue
Block a user