diff --git a/src/terminal/main.zig b/src/terminal/main.zig index ab5bad4d6..55625f7a6 100644 --- a/src/terminal/main.zig +++ b/src/terminal/main.zig @@ -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"); diff --git a/src/terminal/new/Terminal.zig b/src/terminal/new/Terminal.zig index e4e1077b0..b444f4888 100644 --- a/src/terminal/new/Terminal.zig +++ b/src/terminal/new/Terminal.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