mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
terminal: add kitty image limits to Terminal.Options
Move kitty_image_storage_limit and kitty_image_loading_limits into Terminal.Options so callers can set them at construction time rather than calling setter functions after init. The values flow through to Screen.Options during ScreenSet initialization. Termio now passes both at construction, keeping the setter functions for the updateConfig path.
This commit is contained in:
@@ -191,6 +191,19 @@ pub const Options = struct {
|
||||
/// The default mode state. When the terminal gets a reset, it
|
||||
/// will revert back to this state.
|
||||
default_modes: modespkg.ModePacked = .{},
|
||||
|
||||
/// The total storage limit for Kitty images in bytes. Has no effect
|
||||
/// if kitty images are disabled at build-time.
|
||||
kitty_image_storage_limit: usize = 320 * 1000 * 1000, // 320MB
|
||||
|
||||
/// The limits for what medium types are allowed for Kitty image loading.
|
||||
/// Has no effect if kitty images are disabled otherwise. For example,
|
||||
// if no `sys.decode_png` hook is specified, png formats are disabled
|
||||
// no matter what.
|
||||
kitty_image_loading_limits: if (build_options.kitty_graphics)
|
||||
kitty.graphics.LoadingImage.Limits
|
||||
else
|
||||
void = if (build_options.kitty_graphics) .direct else {},
|
||||
};
|
||||
|
||||
/// Initialize a new terminal.
|
||||
@@ -205,6 +218,8 @@ pub fn init(
|
||||
.cols = cols,
|
||||
.rows = rows,
|
||||
.max_scrollback = opts.max_scrollback,
|
||||
.kitty_image_storage_limit = opts.kitty_image_storage_limit,
|
||||
.kitty_image_loading_limits = opts.kitty_image_loading_limits,
|
||||
});
|
||||
errdefer screen_set.deinit(alloc);
|
||||
|
||||
|
||||
@@ -255,14 +255,12 @@ pub fn init(self: *Termio, alloc: Allocator, opts: termio.Options) !void {
|
||||
},
|
||||
.palette = .init(opts.config.palette),
|
||||
},
|
||||
.kitty_image_storage_limit = opts.config.image_storage_limit,
|
||||
.kitty_image_loading_limits = .all,
|
||||
};
|
||||
});
|
||||
errdefer term.deinit(alloc);
|
||||
|
||||
// Set the Kitty image settings
|
||||
try term.setKittyGraphicsSizeLimit(alloc, opts.config.image_storage_limit);
|
||||
term.setKittyGraphicsLoadingLimits(.all);
|
||||
|
||||
// Set our default cursor style
|
||||
term.screens.active.cursor.cursor_style = opts.config.cursor_style;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user