mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: listen for config change and post a notification
This commit is contained in:
@ -524,6 +524,9 @@ extension Ghostty {
|
|||||||
case GHOSTTY_ACTION_KEY_SEQUENCE:
|
case GHOSTTY_ACTION_KEY_SEQUENCE:
|
||||||
keySequence(app, target: target, v: action.action.key_sequence)
|
keySequence(app, target: target, v: action.action.key_sequence)
|
||||||
|
|
||||||
|
case GHOSTTY_ACTION_CONFIG_CHANGE:
|
||||||
|
configChange(app, target: target, v: action.action.config_change)
|
||||||
|
|
||||||
case GHOSTTY_ACTION_COLOR_CHANGE:
|
case GHOSTTY_ACTION_COLOR_CHANGE:
|
||||||
fallthrough
|
fallthrough
|
||||||
case GHOSTTY_ACTION_CLOSE_ALL_WINDOWS:
|
case GHOSTTY_ACTION_CLOSE_ALL_WINDOWS:
|
||||||
@ -1159,6 +1162,31 @@ extension Ghostty {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static func configChange(
|
||||||
|
_ app: ghostty_app_t,
|
||||||
|
target: ghostty_target_s,
|
||||||
|
v: ghostty_action_config_change_s) {
|
||||||
|
switch (target.tag) {
|
||||||
|
case GHOSTTY_TARGET_APP:
|
||||||
|
NotificationCenter.default.post(
|
||||||
|
name: .ghosttyConfigChange,
|
||||||
|
object: nil
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
case GHOSTTY_TARGET_SURFACE:
|
||||||
|
guard let surface = target.target.surface else { return }
|
||||||
|
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||||
|
NotificationCenter.default.post(
|
||||||
|
name: .ghosttyConfigChange,
|
||||||
|
object: surfaceView
|
||||||
|
)
|
||||||
|
|
||||||
|
default:
|
||||||
|
assertionFailure()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: User Notifications
|
// MARK: User Notifications
|
||||||
|
|
||||||
/// Handle a received user notification. This is called when a user notification is clicked or dismissed by the user
|
/// Handle a received user notification. This is called when a user notification is clicked or dismissed by the user
|
||||||
|
@ -206,6 +206,10 @@ extension Ghostty {
|
|||||||
// MARK: Surface Notification
|
// MARK: Surface Notification
|
||||||
|
|
||||||
extension Notification.Name {
|
extension Notification.Name {
|
||||||
|
/// Configuration change. If the object is nil then it is app-wide. Otherwise its surface-specific.
|
||||||
|
static let ghosttyConfigChange = Notification.Name("com.mitchellh.ghostty.configChange")
|
||||||
|
static let GhosttyConfigChangeKey = ghosttyConfigChange.rawValue
|
||||||
|
|
||||||
/// Goto tab. Has tab index in the userinfo.
|
/// Goto tab. Has tab index in the userinfo.
|
||||||
static let ghosttyMoveTab = Notification.Name("com.mitchellh.ghostty.moveTab")
|
static let ghosttyMoveTab = Notification.Name("com.mitchellh.ghostty.moveTab")
|
||||||
static let GhosttyMoveTabKey = ghosttyMoveTab.rawValue
|
static let GhosttyMoveTabKey = ghosttyMoveTab.rawValue
|
||||||
|
Reference in New Issue
Block a user