mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +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.
|
/// This can be used to implement terminal scroll regions efficiently.
|
||||||
pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usize) void {
|
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.
|
// Avoid a lot of work if we're doing nothing.
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
|
@ -732,8 +732,11 @@ pub fn index(self: *Terminal) !void {
|
|||||||
{
|
{
|
||||||
try self.screen.scroll(.{ .delta = 1 });
|
try self.screen.scroll(.{ .delta = 1 });
|
||||||
} else {
|
} else {
|
||||||
// TODO: test
|
self.screen.scrollRegionUp(
|
||||||
try self.scrollUp(1);
|
.{ .active = self.scrolling_region.top },
|
||||||
|
.{ .active = self.scrolling_region.bottom },
|
||||||
|
1,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1251,13 +1254,11 @@ pub fn scrollDown(self: *Terminal, count: usize) !void {
|
|||||||
/// Does not change the (absolute) cursor position.
|
/// Does not change the (absolute) cursor position.
|
||||||
// TODO: test
|
// TODO: test
|
||||||
pub fn scrollUp(self: *Terminal, count: usize) !void {
|
pub fn scrollUp(self: *Terminal, count: usize) !void {
|
||||||
// Preserve the cursor
|
self.screen.scrollRegionUp(
|
||||||
const cursor = self.screen.cursor;
|
.{ .active = self.scrolling_region.top },
|
||||||
defer self.screen.cursor = cursor;
|
.{ .active = self.scrolling_region.bottom },
|
||||||
|
count,
|
||||||
// Move to the top of the scroll region
|
);
|
||||||
self.screen.cursor.y = self.scrolling_region.top;
|
|
||||||
try self.deleteLines(count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Options for scrolling the viewport of the terminal grid.
|
/// Options for scrolling the viewport of the terminal grid.
|
||||||
|
Reference in New Issue
Block a user