mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal: resize handles increased styles/graphemes
This commit is contained in:
@ -537,9 +537,6 @@ fn resizeCols(
|
|||||||
) !void {
|
) !void {
|
||||||
assert(cols != self.cols);
|
assert(cols != self.cols);
|
||||||
|
|
||||||
// Our new capacity, ensure we can fit the cols
|
|
||||||
const cap = try std_capacity.adjust(.{ .cols = cols });
|
|
||||||
|
|
||||||
// If we have a cursor position (x,y), then we try under any col resizing
|
// If we have a cursor position (x,y), then we try under any col resizing
|
||||||
// to keep the same number remaining active rows beneath it. This is a
|
// to keep the same number remaining active rows beneath it. This is a
|
||||||
// very special case if you can imagine clearing the screen (i.e.
|
// very special case if you can imagine clearing the screen (i.e.
|
||||||
@ -588,7 +585,7 @@ fn resizeCols(
|
|||||||
// Note: we can do a fast-path here if all of our rows in this
|
// Note: we can do a fast-path here if all of our rows in this
|
||||||
// page already fit within the new capacity. In that case we can
|
// page already fit within the new capacity. In that case we can
|
||||||
// do a non-reflow resize.
|
// do a non-reflow resize.
|
||||||
try self.reflowPage(cap, chunk.page);
|
try self.reflowPage(cols, chunk.page);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If our total rows is less than our active rows, we need to grow.
|
// If our total rows is less than our active rows, we need to grow.
|
||||||
@ -774,7 +771,7 @@ const ReflowCursor = struct {
|
|||||||
/// function.
|
/// function.
|
||||||
fn reflowPage(
|
fn reflowPage(
|
||||||
self: *PageList,
|
self: *PageList,
|
||||||
cap: Capacity,
|
cols: size.CellCountInt,
|
||||||
initial_node: *List.Node,
|
initial_node: *List.Node,
|
||||||
) !void {
|
) !void {
|
||||||
// The cursor tracks where we are in the source page.
|
// The cursor tracks where we are in the source page.
|
||||||
@ -810,6 +807,10 @@ fn reflowPage(
|
|||||||
// Our new capacity when growing columns may also shrink rows. So we
|
// Our new capacity when growing columns may also shrink rows. So we
|
||||||
// need to do a loop in order to potentially make multiple pages.
|
// need to do a loop in order to potentially make multiple pages.
|
||||||
dst_loop: while (true) {
|
dst_loop: while (true) {
|
||||||
|
// Our cap is based on the source page cap so we can inherit
|
||||||
|
// potentially increased styles/graphemes/etc.
|
||||||
|
const cap = try src_cursor.page.capacity.adjust(.{ .cols = cols });
|
||||||
|
|
||||||
// Create our new page and our cursor restarts at 0,0 in the new page.
|
// Create our new page and our cursor restarts at 0,0 in the new page.
|
||||||
// The new page always starts with a size of 1 because we know we have
|
// The new page always starts with a size of 1 because we know we have
|
||||||
// at least one row to copy from the src.
|
// at least one row to copy from the src.
|
||||||
|
@ -7728,6 +7728,27 @@ test "Terminal: resize with high unique style per cell" {
|
|||||||
try t.resize(alloc, 60, 30);
|
try t.resize(alloc, 60, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Terminal: resize with high unique style per cell with wrapping" {
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
var t = try init(alloc, 30, 30);
|
||||||
|
defer t.deinit(alloc);
|
||||||
|
|
||||||
|
const cell_count: u16 = @intCast(t.rows * t.cols);
|
||||||
|
for (0..cell_count) |i| {
|
||||||
|
const r: u8 = @intCast(i >> 8);
|
||||||
|
const g: u8 = @intCast(i & 0xFF);
|
||||||
|
|
||||||
|
try t.setAttribute(.{ .direct_color_bg = .{
|
||||||
|
.r = r,
|
||||||
|
.g = g,
|
||||||
|
.b = 0,
|
||||||
|
} });
|
||||||
|
try t.print('x');
|
||||||
|
}
|
||||||
|
|
||||||
|
try t.resize(alloc, 60, 30);
|
||||||
|
}
|
||||||
|
|
||||||
test "Terminal: DECCOLM without DEC mode 40" {
|
test "Terminal: DECCOLM without DEC mode 40" {
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
var t = try init(alloc, 5, 5);
|
var t = try init(alloc, 5, 5);
|
||||||
|
Reference in New Issue
Block a user