From 935d37fbf1eea969245e144757116e8fbe93192a Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 5 Apr 2026 07:20:07 -0700 Subject: [PATCH] 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. --- src/terminal/Terminal.zig | 15 +++++++++++++++ src/termio/Termio.zig | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 0dfde8236..b128cdd3d 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -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); diff --git a/src/termio/Termio.zig b/src/termio/Termio.zig index 1b446e268..1d1bfe25a 100644 --- a/src/termio/Termio.zig +++ b/src/termio/Termio.zig @@ -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;