mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal/new: add scrollViewport
This commit is contained in:
@ -25,6 +25,7 @@ pub const CSI = Parser.Action.CSI;
|
||||
pub const DCS = Parser.Action.DCS;
|
||||
pub const MouseShape = @import("mouse_shape.zig").MouseShape;
|
||||
pub const Terminal = @import("Terminal.zig");
|
||||
//pub const Terminal = new.Terminal;
|
||||
pub const Parser = @import("Parser.zig");
|
||||
pub const Selection = @import("Selection.zig");
|
||||
pub const Screen = @import("Screen.zig");
|
||||
|
@ -1195,6 +1195,27 @@ pub fn scrollUp(self: *Terminal, count: usize) void {
|
||||
self.deleteLines(count);
|
||||
}
|
||||
|
||||
/// Options for scrolling the viewport of the terminal grid.
|
||||
pub const ScrollViewport = union(enum) {
|
||||
/// Scroll to the top of the scrollback
|
||||
top: void,
|
||||
|
||||
/// Scroll to the bottom, i.e. the top of the active area
|
||||
bottom: void,
|
||||
|
||||
/// Scroll by some delta amount, up is negative.
|
||||
delta: isize,
|
||||
};
|
||||
|
||||
/// Scroll the viewport of the terminal grid.
|
||||
pub fn scrollViewport(self: *Terminal, behavior: ScrollViewport) !void {
|
||||
self.screen.scroll(switch (behavior) {
|
||||
.top => .{ .top = {} },
|
||||
.bottom => .{ .active = {} },
|
||||
.delta => |delta| .{ .delta_row = delta },
|
||||
});
|
||||
}
|
||||
|
||||
/// Insert amount lines at the current cursor row. The contents of the line
|
||||
/// at the current cursor row and below (to the bottom-most line in the
|
||||
/// scrolling region) are shifted down by amount lines. The contents of the
|
||||
|
Reference in New Issue
Block a user