diff --git a/src/config.zig b/src/config.zig index ba87fb6db..34b209c09 100644 --- a/src/config.zig +++ b/src/config.zig @@ -20,6 +20,7 @@ pub const RepeatableCodepointMap = Config.RepeatableCodepointMap; pub const RepeatableFontVariation = Config.RepeatableFontVariation; pub const RepeatableString = Config.RepeatableString; pub const ShellIntegrationFeatures = Config.ShellIntegrationFeatures; +pub const WindowPaddingColor = Config.WindowPaddingColor; // Alternate APIs pub const CAPI = @import("config/CAPI.zig"); diff --git a/src/config/Config.zig b/src/config/Config.zig index b31570a14..b3da3c279 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -669,6 +669,16 @@ keybind: Keybinds = .{}, /// given a certain viewport size and grid cell size. @"window-padding-balance": bool = false, +/// The color of the padding area of the window. Valid values are: +/// +/// * `background` - The background color specified in `background`. +/// * `extend` - Extend the background color of the nearest grid cell. +/// +/// The default value is "extend". This allows for smooth resizing of a +/// terminal grid without having visible empty areas around the edge. The edge +/// cells may appear slightly larger due to the extension. +@"window-padding-color": WindowPaddingColor = .extend, + /// Synchronize rendering with the screen refresh rate. If true, this will /// minimize tearing and align redraws with the screen but may cause input /// latency. If false, this will maximize redraw frequency but may cause tearing, @@ -2678,6 +2688,11 @@ pub const OptionAsAlt = enum { right, }; +pub const WindowPaddingColor = enum { + background, + extend, +}; + /// Color represents a color using RGB. /// /// This is a packed struct so that the C API to read color values just diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index 93bf09fa1..b910cde74 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -345,6 +345,7 @@ pub const DerivedConfig = struct { invert_selection_fg_bg: bool, bold_is_bright: bool, min_contrast: f32, + padding_color: configpkg.WindowPaddingColor, custom_shaders: std.ArrayListUnmanaged([:0]const u8), links: link.Set, vsync: bool, @@ -402,6 +403,7 @@ pub const DerivedConfig = struct { .invert_selection_fg_bg = config.@"selection-invert-fg-bg", .bold_is_bright = config.@"bold-is-bright", .min_contrast = @floatCast(config.@"minimum-contrast"), + .padding_color = config.@"window-padding-color", .selection_background = if (config.@"selection-background") |bg| bg.toTerminalRGB() @@ -1960,10 +1962,16 @@ pub fn setScreenSize( const padded_dim = dim.subPadding(padding); // Blank space around the grid. - const blank = dim.blankPadding(padding, grid_size, .{ - .width = self.grid_metrics.cell_width, - .height = self.grid_metrics.cell_height, - }).add(padding); + const blank: renderer.Padding = switch (self.config.padding_color) { + // We can use zero padding because the backgroudn color is our + // clear color. + .background => .{}, + + .extend => dim.blankPadding(padding, grid_size, .{ + .width = self.grid_metrics.cell_width, + .height = self.grid_metrics.cell_height, + }).add(padding), + }; // Set the size of the drawable surface to the bounds self.layer.setProperty("drawableSize", macos.graphics.Size{