embedded: use separate struct to pass options to new_tab_cb

This commit is contained in:
Thorsten Ball
2023-08-18 06:50:47 +02:00
parent 12311e9707
commit cda87a6963
3 changed files with 27 additions and 12 deletions

View File

@@ -65,7 +65,7 @@ extension Ghostty {
focus_split_cb: { userdata, direction in AppState.focusSplit(userdata, direction: direction) },
goto_tab_cb: { userdata, n in AppState.gotoTab(userdata, n: n) },
toggle_fullscreen_cb: { userdata, nonNativeFullscreen in AppState.toggleFullscreen(userdata, useNonNativeFullscreen: nonNativeFullscreen) },
new_tab_cb: { userdata, fontSize in AppState.newTab(userdata, fontSize: fontSize) }
new_tab_cb: { userdata, newTabConfig in AppState.newTab(userdata, config: newTabConfig) }
)
// Create the ghostty app.
@@ -263,14 +263,18 @@ extension Ghostty {
)
}
static func newTab(_ userdata: UnsafeMutableRawPointer?, fontSize: UInt8) {
static func newTab(_ userdata: UnsafeMutableRawPointer?, config: ghostty_new_tab_config_s) {
guard let surface = self.surfaceUserdata(from: userdata) else { return }
var userInfo: [AnyHashable : Any] = [:];
if config.font_size != 0 {
userInfo[Notification.NewTabKey] = config.font_size as UInt8;
}
NotificationCenter.default.post(
name: Notification.ghosttyNewTab,
object: surface,
userInfo: [
Notification.NewTabKey: fontSize,
]
userInfo: userInfo
)
}