mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
Merge pull request #2075 from ghostty-org/extend
window-padding-color improvements
This commit is contained in:
@ -701,6 +701,8 @@ keybind: Keybinds = .{},
|
|||||||
///
|
///
|
||||||
/// * `background` - The background color specified in `background`.
|
/// * `background` - The background color specified in `background`.
|
||||||
/// * `extend` - Extend the background color of the nearest grid cell.
|
/// * `extend` - Extend the background color of the nearest grid cell.
|
||||||
|
/// * `extend-always` - Same as "extend" but always extends without applying
|
||||||
|
/// any of the heuristics that disable extending noted below.
|
||||||
///
|
///
|
||||||
/// The "extend" value will be disabled in certain scenarios. On primary
|
/// The "extend" value will be disabled in certain scenarios. On primary
|
||||||
/// screen applications (i.e. not something like Neovim), the color will not
|
/// screen applications (i.e. not something like Neovim), the color will not
|
||||||
@ -712,11 +714,10 @@ keybind: Keybinds = .{},
|
|||||||
/// * The nearest row is a prompt row (requires shell integration). The
|
/// * The nearest row is a prompt row (requires shell integration). The
|
||||||
/// thinking here is that prompts often contain powerline glyphs that
|
/// thinking here is that prompts often contain powerline glyphs that
|
||||||
/// do not look good extended.
|
/// do not look good extended.
|
||||||
|
/// * The nearest row contains a perfect fit powerline character. These
|
||||||
|
/// don't look good extended.
|
||||||
///
|
///
|
||||||
/// The default value is "extend". This allows for smooth resizing of a
|
@"window-padding-color": WindowPaddingColor = .extend,
|
||||||
/// 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 = .background,
|
|
||||||
|
|
||||||
/// Synchronize rendering with the screen refresh rate. If true, this will
|
/// Synchronize rendering with the screen refresh rate. If true, this will
|
||||||
/// minimize tearing and align redraws with the screen but may cause input
|
/// minimize tearing and align redraws with the screen but may cause input
|
||||||
@ -2730,6 +2731,7 @@ pub const OptionAsAlt = enum {
|
|||||||
pub const WindowPaddingColor = enum {
|
pub const WindowPaddingColor = enum {
|
||||||
background,
|
background,
|
||||||
extend,
|
extend,
|
||||||
|
@"extend-always",
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Color represents a color using RGB.
|
/// Color represents a color using RGB.
|
||||||
|
@ -1955,13 +1955,26 @@ pub fn setScreenSize(
|
|||||||
}).add(padding);
|
}).add(padding);
|
||||||
|
|
||||||
var padding_extend = self.uniforms.padding_extend;
|
var padding_extend = self.uniforms.padding_extend;
|
||||||
if (self.config.padding_color == .extend) {
|
switch (self.config.padding_color) {
|
||||||
// If padding extension is enabled, we extend left and right always.
|
.extend => {
|
||||||
padding_extend.left = true;
|
// If padding extension is enabled, we extend left and right always
|
||||||
padding_extend.right = true;
|
// because there is no downside to this. Up/down is dependent
|
||||||
} else {
|
// on some heuristics (see rebuildCells).
|
||||||
// Otherwise, disable all padding extension.
|
padding_extend.left = true;
|
||||||
padding_extend = .{};
|
padding_extend.right = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
.@"extend-always" => {
|
||||||
|
padding_extend.up = true;
|
||||||
|
padding_extend.down = true;
|
||||||
|
padding_extend.left = true;
|
||||||
|
padding_extend.right = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
.background => {
|
||||||
|
// Otherwise, disable all padding extension.
|
||||||
|
padding_extend = .{};
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the size of the drawable surface to the bounds
|
// Set the size of the drawable surface to the bounds
|
||||||
@ -2105,6 +2118,8 @@ fn rebuildCells(
|
|||||||
// std.log.warn("[rebuildCells time] {}\t{}", .{start_micro, end.since(start) / std.time.ns_per_us});
|
// std.log.warn("[rebuildCells time] {}\t{}", .{start_micro, end.since(start) / std.time.ns_per_us});
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
_ = screen_type; // we might use this again later so not deleting it yet
|
||||||
|
|
||||||
// Create an arena for all our temporary allocations while rebuilding
|
// Create an arena for all our temporary allocations while rebuilding
|
||||||
var arena = ArenaAllocator.init(self.alloc);
|
var arena = ArenaAllocator.init(self.alloc);
|
||||||
defer arena.deinit();
|
defer arena.deinit();
|
||||||
@ -2138,9 +2153,19 @@ fn rebuildCells(
|
|||||||
self.cells.reset();
|
self.cells.reset();
|
||||||
|
|
||||||
// We also reset our padding extension depending on the screen type
|
// We also reset our padding extension depending on the screen type
|
||||||
if (self.config.padding_color == .extend) {
|
switch (self.config.padding_color) {
|
||||||
self.uniforms.padding_extend.up = screen_type == .alternate;
|
.background => {},
|
||||||
self.uniforms.padding_extend.down = screen_type == .alternate;
|
|
||||||
|
// For extension, assume we are extending in all directions.
|
||||||
|
// For "extend" this may be disabled due to heuristics below.
|
||||||
|
.extend, .@"extend-always" => {
|
||||||
|
self.uniforms.padding_extend = .{
|
||||||
|
.up = true,
|
||||||
|
.down = true,
|
||||||
|
.left = true,
|
||||||
|
.right = true,
|
||||||
|
};
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2178,12 +2203,16 @@ fn rebuildCells(
|
|||||||
// under certain conditions we feel are safe. This helps make some
|
// under certain conditions we feel are safe. This helps make some
|
||||||
// scenarios look better while avoiding scenarios we know do NOT look
|
// scenarios look better while avoiding scenarios we know do NOT look
|
||||||
// good.
|
// good.
|
||||||
if (self.config.padding_color == .extend) {
|
switch (self.config.padding_color) {
|
||||||
if (y == 0 and screen_type == .primary) {
|
// These already have the correct values set above.
|
||||||
|
.background, .@"extend-always" => {},
|
||||||
|
|
||||||
|
// Apply heuristics for padding extension.
|
||||||
|
.extend => if (y == 0) {
|
||||||
self.uniforms.padding_extend.up = !row.neverExtendBg();
|
self.uniforms.padding_extend.up = !row.neverExtendBg();
|
||||||
} else if (y == self.cells.size.rows - 1 and screen_type == .primary) {
|
} else if (y == self.cells.size.rows - 1) {
|
||||||
self.uniforms.padding_extend.down = !row.neverExtendBg();
|
self.uniforms.padding_extend.down = !row.neverExtendBg();
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split our row into runs and shape each one.
|
// Split our row into runs and shape each one.
|
||||||
|
@ -169,7 +169,7 @@ const SetScreenSize = struct {
|
|||||||
// clear color.
|
// clear color.
|
||||||
.background => .{},
|
.background => .{},
|
||||||
|
|
||||||
.extend => self.size.blankPadding(padding, grid_size, .{
|
.extend, .@"extend-always" => self.size.blankPadding(padding, grid_size, .{
|
||||||
.width = r.grid_metrics.cell_width,
|
.width = r.grid_metrics.cell_width,
|
||||||
.height = r.grid_metrics.cell_height,
|
.height = r.grid_metrics.cell_height,
|
||||||
}).add(padding),
|
}).add(padding),
|
||||||
@ -1172,6 +1172,8 @@ pub fn rebuildCells(
|
|||||||
cursor_style_: ?renderer.CursorStyle,
|
cursor_style_: ?renderer.CursorStyle,
|
||||||
color_palette: *const terminal.color.Palette,
|
color_palette: *const terminal.color.Palette,
|
||||||
) !void {
|
) !void {
|
||||||
|
_ = screen_type;
|
||||||
|
|
||||||
// Bg cells at most will need space for the visible screen size
|
// Bg cells at most will need space for the visible screen size
|
||||||
self.cells_bg.clearRetainingCapacity();
|
self.cells_bg.clearRetainingCapacity();
|
||||||
self.cells.clearRetainingCapacity();
|
self.cells.clearRetainingCapacity();
|
||||||
@ -1213,9 +1215,14 @@ pub fn rebuildCells(
|
|||||||
var cursor_cell: ?CellProgram.Cell = null;
|
var cursor_cell: ?CellProgram.Cell = null;
|
||||||
|
|
||||||
if (rebuild) {
|
if (rebuild) {
|
||||||
// We also reset our padding extension depending on the screen type
|
switch (self.config.padding_color) {
|
||||||
self.padding_extend_top = screen_type == .alternate;
|
.background => {},
|
||||||
self.padding_extend_bottom = screen_type == .alternate;
|
|
||||||
|
.extend, .@"extend-always" => {
|
||||||
|
self.padding_extend_top = true;
|
||||||
|
self.padding_extend_bottom = true;
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build each cell
|
// Build each cell
|
||||||
@ -1268,10 +1275,16 @@ pub fn rebuildCells(
|
|||||||
// under certain conditions we feel are safe. This helps make some
|
// under certain conditions we feel are safe. This helps make some
|
||||||
// scenarios look better while avoiding scenarios we know do NOT look
|
// scenarios look better while avoiding scenarios we know do NOT look
|
||||||
// good.
|
// good.
|
||||||
if (y == 0 and screen_type == .primary) {
|
switch (self.config.padding_color) {
|
||||||
self.padding_extend_top = !row.neverExtendBg();
|
// These already have the correct values set above.
|
||||||
} else if (y == self.grid_size.rows - 1 and screen_type == .primary) {
|
.background, .@"extend-always" => {},
|
||||||
self.padding_extend_bottom = !row.neverExtendBg();
|
|
||||||
|
// Apply heuristics for padding extension.
|
||||||
|
.extend => if (y == 0) {
|
||||||
|
self.padding_extend_top = !row.neverExtendBg();
|
||||||
|
} else if (y == self.grid_size.rows - 1) {
|
||||||
|
self.padding_extend_bottom = !row.neverExtendBg();
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split our row into runs and shape each one.
|
// Split our row into runs and shape each one.
|
||||||
|
@ -3272,8 +3272,25 @@ pub const Pin = struct {
|
|||||||
// extend because the default background color probably looks
|
// extend because the default background color probably looks
|
||||||
// good enough as an extension.
|
// good enough as an extension.
|
||||||
switch (cell.content_tag) {
|
switch (cell.content_tag) {
|
||||||
|
// We assume bg color cells are setting non-default colors.
|
||||||
.bg_color_palette, .bg_color_rgb => {},
|
.bg_color_palette, .bg_color_rgb => {},
|
||||||
|
|
||||||
|
// If its a codepoint cell we can check the style.
|
||||||
.codepoint, .codepoint_grapheme => {
|
.codepoint, .codepoint_grapheme => {
|
||||||
|
// For codepoint containing, we also never extend bg
|
||||||
|
// if any cell has a powerline glyph because these are
|
||||||
|
// perfect-fit.
|
||||||
|
switch (cell.codepoint()) {
|
||||||
|
// Powerline
|
||||||
|
0xE0B0...0xE0C8,
|
||||||
|
0xE0CA,
|
||||||
|
0xE0CC...0xE0D2,
|
||||||
|
0xE0D4,
|
||||||
|
=> return true,
|
||||||
|
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
|
|
||||||
const s = self.style(cell);
|
const s = self.style(cell);
|
||||||
if (s.bg_color == .none) return true;
|
if (s.bg_color == .none) return true;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user