mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-07-19 07:31:25 +00:00
Add the context to the Swift layer.
- Define NewSurfaceContext to match the Zig enum name and avoid magic numbers.
This commit is contained in:
@@ -625,6 +625,13 @@ extension Ghostty {
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Context for surface creation, matching the Zig NewSurfaceContext enum
|
||||
enum NewSurfaceContext: Int32 {
|
||||
case window = 0
|
||||
case tab = 1
|
||||
case split = 2
|
||||
}
|
||||
|
||||
/// The configuration for a surface. For any configuration not set, defaults will be chosen from
|
||||
/// libghostty, usually from the Ghostty configuration.
|
||||
struct SurfaceConfiguration {
|
||||
@@ -646,6 +653,9 @@ extension Ghostty {
|
||||
/// Wait after the command
|
||||
var waitAfterCommand: Bool = false
|
||||
|
||||
/// Context for surface creation
|
||||
var context: NewSurfaceContext = .window
|
||||
|
||||
init() {}
|
||||
|
||||
init(from config: ghostty_surface_config_s) {
|
||||
@@ -667,6 +677,7 @@ extension Ghostty {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.context = NewSurfaceContext(rawValue: config.context) ?? .window
|
||||
}
|
||||
|
||||
/// Provides a C-compatible ghostty configuration within a closure. The configuration
|
||||
@@ -700,6 +711,9 @@ extension Ghostty {
|
||||
// Set wait after command
|
||||
config.wait_after_command = waitAfterCommand
|
||||
|
||||
// Set context
|
||||
config.context = context.rawValue
|
||||
|
||||
// Use withCString to ensure strings remain valid for the duration of the closure
|
||||
return try workingDirectory.withCString { cWorkingDir in
|
||||
config.working_directory = cWorkingDir
|
||||
|
||||
Reference in New Issue
Block a user