diff options
| -rw-r--r-- | core/term/terminal.zig | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/core/term/terminal.zig b/core/term/terminal.zig index 535ca6dc..187ed144 100644 --- a/core/term/terminal.zig +++ b/core/term/terminal.zig @@ -631,19 +631,30 @@ pub fn resize(state: *State, cols: u16, rows: u16, later: bool) void { state.resize_to = .{ .cols = cols, .rows = rows }; return; } - state.changes +%= 1; - state.vt.resize(state.gpa, .{ .cols = cols, .rows = rows }) catch {}; + reflow(state, cols, rows); } /// The size `resize` left for later, made; whether there was one. pub fn resizeDeferred(state: *State) bool { const size = state.resize_to orelse return false; state.resize_to = null; - state.changes +%= 1; - state.vt.resize(state.gpa, .{ .cols = size.cols, .rows = size.rows }) catch {}; + reflow(state, size.cols, size.rows); return true; } +/// Its grid reflowed, and its view a row of its history again, as `viewTo` +/// and `grid` have it: ghostty's view follows a cell, which a widening +/// can leave mid-row (a wrapped line's second row joined to its first) and +/// the next narrowing carries a row down, where a view put back at its row +/// (a replica's rollback, core/replica.zig `putViews`) stays. +fn reflow(state: *State, cols: u16, rows: u16) void { + state.changes +%= 1; + state.vt.resize(state.gpa, .{ .cols = cols, .rows = rows }) catch {}; + inline for (.{ .primary, .alternate }) |which| if (state.vt.screens.get(which)) |screen| { + if (screen.pages.viewport == .pin) screen.pages.viewport_pin.x = 0; + }; +} + /// The emulator's size in pixels follows the core's cells: kitty graphics /// placements are sized by it, and CSI 14/16 t report it. pub fn cellPixels(state: *State, w: u32, h: u32) void { |
