mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
drop a couple function calls and optimize scrolling a bit
This commit is contained in:
@ -861,6 +861,9 @@ pub fn copyRow(self: *Screen, dst: RowIndex, src: RowIndex) !void {
|
||||
///
|
||||
/// This can be used to implement terminal scroll regions efficiently.
|
||||
pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usize) void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
// Avoid a lot of work if we're doing nothing.
|
||||
if (count == 0) return;
|
||||
|
||||
|
@ -732,8 +732,11 @@ pub fn index(self: *Terminal) !void {
|
||||
{
|
||||
try self.screen.scroll(.{ .delta = 1 });
|
||||
} else {
|
||||
// TODO: test
|
||||
try self.scrollUp(1);
|
||||
self.screen.scrollRegionUp(
|
||||
.{ .active = self.scrolling_region.top },
|
||||
.{ .active = self.scrolling_region.bottom },
|
||||
1,
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1251,13 +1254,11 @@ pub fn scrollDown(self: *Terminal, count: usize) !void {
|
||||
/// Does not change the (absolute) cursor position.
|
||||
// TODO: test
|
||||
pub fn scrollUp(self: *Terminal, count: usize) !void {
|
||||
// Preserve the cursor
|
||||
const cursor = self.screen.cursor;
|
||||
defer self.screen.cursor = cursor;
|
||||
|
||||
// Move to the top of the scroll region
|
||||
self.screen.cursor.y = self.scrolling_region.top;
|
||||
try self.deleteLines(count);
|
||||
self.screen.scrollRegionUp(
|
||||
.{ .active = self.scrolling_region.top },
|
||||
.{ .active = self.scrolling_region.bottom },
|
||||
count,
|
||||
);
|
||||
}
|
||||
|
||||
/// Options for scrolling the viewport of the terminal grid.
|
||||
|
Reference in New Issue
Block a user