diff --git a/src/widgets/terminal/Screen.zig b/src/widgets/terminal/Screen.zig index b532a38..ef3ab87 100644 --- a/src/widgets/terminal/Screen.zig +++ b/src/widgets/terminal/Screen.zig @@ -311,11 +311,17 @@ pub fn sgr(self: *Screen, seq: ansi.CSI) void { } pub fn cursorLeft(self: *Screen, n: usize) void { - // default to 1, max of current cursor location - const cnt = @min(self.cursor.col, @max(n, 1)); - self.cursor.pending_wrap = false; - self.cursor.col -= cnt; + if (self.withinScrollingRegion()) + self.cursor.col = @max( + self.cursor.col -| n, + self.scrolling_region.left, + ) + else + self.cursor.col = @max( + self.cursor.col -| n, + 0, + ); } pub fn eraseRight(self: *Screen) void { diff --git a/src/widgets/terminal/Terminal.zig b/src/widgets/terminal/Terminal.zig index e20b085..7f53913 100644 --- a/src/widgets/terminal/Terminal.zig +++ b/src/widgets/terminal/Terminal.zig @@ -281,21 +281,11 @@ fn run(self: *Terminal) !void { self.back_screen.width, ); }, - 'D' => { + 'D', 'j' => { self.back_screen.cursor.pending_wrap = false; var iter = seq.iterator(u16); const delta = iter.next() orelse 1; - const within = self.back_screen.withinScrollingRegion(); - if (within) - self.back_screen.cursor.col = @max( - self.back_screen.cursor.col -| delta, - self.back_screen.scrolling_region.left, - ) - else - self.back_screen.cursor.col = @max( - self.back_screen.cursor.col -| delta, - 0, - ); + self.back_screen.cursorLeft(delta); }, 'H', 'f' => { // CUP var iter = seq.iterator(u16);