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;