diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-04-04 19:22:04 +0300 |
|---|---|---|
| committer | Can Celik <ogulcancelik@gmail.com> | 2026-04-05 01:23:06 +0300 |
| commit | 41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch) | |
| tree | 3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/src/config/Wasm.zig | |
| parent | 55c138263e190a1e79d4b997bfb9397306c0ec1f (diff) | |
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/src/config/Wasm.zig')
| -rw-r--r-- | vendor/libghostty-vt/src/config/Wasm.zig | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/src/config/Wasm.zig b/vendor/libghostty-vt/src/config/Wasm.zig new file mode 100644 index 00000000..90c06b63 --- /dev/null +++ b/vendor/libghostty-vt/src/config/Wasm.zig @@ -0,0 +1,54 @@ +const std = @import("std"); +const wasm = @import("../os/wasm.zig"); +const cli = @import("../cli.zig"); +const alloc = wasm.alloc; + +const Config = @import("Config.zig"); + +const log = std.log.scoped(.config); + +/// Create a new configuration filled with the initial default values. +export fn config_new() ?*Config { + const result = alloc.create(Config) catch |err| { + log.err("error allocating config err={}", .{err}); + return null; + }; + + result.* = Config.default(alloc) catch |err| { + log.err("error creating config err={}", .{err}); + return null; + }; + + return result; +} + +export fn config_free(ptr: ?*Config) void { + if (ptr) |v| { + v.deinit(); + alloc.destroy(v); + } +} + +/// Load the configuration from a string in the same format as +/// the file-based syntax for the desktop version of the terminal. +export fn config_load_string( + self: *Config, + str: [*]const u8, + len: usize, +) void { + config_load_string_(self, str[0..len]) catch |err| { + log.err("error loading config err={}", .{err}); + }; +} + +fn config_load_string_(self: *Config, str: []const u8) !void { + var fbs = std.io.fixedBufferStream(str); + var iter = cli.args.lineIterator(fbs.reader()); + try cli.args.parse(Config, alloc, self, &iter); +} + +export fn config_finalize(self: *Config) void { + self.finalize() catch |err| { + log.err("error finalizing config err={}", .{err}); + }; +} |
