mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
apprt/embedded: supporting setting working directory in config
This commit is contained in:
@ -309,6 +309,7 @@ typedef struct {
|
|||||||
void *nsview;
|
void *nsview;
|
||||||
double scale_factor;
|
double scale_factor;
|
||||||
uint16_t font_size;
|
uint16_t font_size;
|
||||||
|
const char *working_directory;
|
||||||
} ghostty_surface_config_s;
|
} ghostty_surface_config_s;
|
||||||
|
|
||||||
typedef void (*ghostty_runtime_wakeup_cb)(void *);
|
typedef void (*ghostty_runtime_wakeup_cb)(void *);
|
||||||
|
@ -208,6 +208,9 @@ pub const Surface = struct {
|
|||||||
|
|
||||||
/// The font size to inherit. If 0, default font size will be used.
|
/// The font size to inherit. If 0, default font size will be used.
|
||||||
font_size: u16 = 0,
|
font_size: u16 = 0,
|
||||||
|
|
||||||
|
/// The working directory to load into.
|
||||||
|
working_directory: [*:0]const u8 = "",
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
pub fn init(self: *Surface, app: *App, opts: Options) !void {
|
||||||
@ -236,6 +239,11 @@ pub const Surface = struct {
|
|||||||
var config = try apprt.surface.newConfig(app.core_app, app.config);
|
var config = try apprt.surface.newConfig(app.core_app, app.config);
|
||||||
defer config.deinit();
|
defer config.deinit();
|
||||||
|
|
||||||
|
// If we have a working directory from the options then we set it.
|
||||||
|
// TODO: validate the working directory
|
||||||
|
const wd = std.mem.sliceTo(opts.working_directory, 0);
|
||||||
|
if (wd.len > 0) config.@"working-directory" = wd;
|
||||||
|
|
||||||
// Initialize our surface right away. We're given a view that is
|
// Initialize our surface right away. We're given a view that is
|
||||||
// ready to use.
|
// ready to use.
|
||||||
try self.core_surface.init(
|
try self.core_surface.init(
|
||||||
|
Reference in New Issue
Block a user