terminal: have left/right scrolling region data but can't be set yet

This commit is contained in:
Mitchell Hashimoto
2023-10-06 11:28:20 -07:00
parent 944a879ecb
commit e3b455444d

View File

@ -136,6 +136,12 @@ const ScrollingRegion = struct {
// Precondition: top < bottom // Precondition: top < bottom
top: usize, top: usize,
bottom: usize, bottom: usize,
// Left/right scroll regions.
// Precondition: right > left
// Precondition: right <= cols - 1
left: usize,
right: usize,
}; };
/// Initialize a new terminal. /// Initialize a new terminal.
@ -152,6 +158,8 @@ pub fn init(alloc: Allocator, cols: usize, rows: usize) !Terminal {
.scrolling_region = .{ .scrolling_region = .{
.top = 0, .top = 0,
.bottom = rows - 1, .bottom = rows - 1,
.left = 0,
.right = cols - 1,
}, },
.pwd = std.ArrayList(u8).init(alloc), .pwd = std.ArrayList(u8).init(alloc),
}; };
@ -326,6 +334,8 @@ pub fn resize(self: *Terminal, alloc: Allocator, cols_req: usize, rows: usize) !
self.scrolling_region = .{ self.scrolling_region = .{
.top = 0, .top = 0,
.bottom = rows - 1, .bottom = rows - 1,
.left = 0,
.right = cols - 1,
}; };
} }
@ -1759,11 +1769,8 @@ pub fn setScrollingRegion(self: *Terminal, top: usize, bottom: usize) void {
b = self.rows; b = self.rows;
} }
self.scrolling_region = .{ self.scrolling_region.top = t - 1;
.top = t - 1, self.scrolling_region.bottom = b - 1;
.bottom = b - 1,
};
self.setCursorPos(1, 1); self.setCursorPos(1, 1);
} }
@ -1871,7 +1878,12 @@ pub fn fullReset(self: *Terminal, alloc: Allocator) void {
self.screen.saved_cursor = .{}; self.screen.saved_cursor = .{};
self.screen.selection = null; self.screen.selection = null;
self.screen.kitty_keyboard = .{}; self.screen.kitty_keyboard = .{};
self.scrolling_region = .{ .top = 0, .bottom = self.rows - 1 }; self.scrolling_region = .{
.top = 0,
.bottom = self.rows - 1,
.left = 0,
.right = self.cols - 1,
};
self.previous_char = null; self.previous_char = null;
self.eraseDisplay(alloc, .scrollback, false); self.eraseDisplay(alloc, .scrollback, false);
self.eraseDisplay(alloc, .complete, false); self.eraseDisplay(alloc, .complete, false);