mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
terminal: scroll up full top/bottom region was off by one
Fixes #689 See test cases, verified with xterm.
This commit is contained in:
@ -1765,7 +1765,7 @@ pub fn deleteLines(self: *Terminal, count: usize) !void {
|
||||
self.screen.scrollRegionUp(
|
||||
.{ .active = self.screen.cursor.y },
|
||||
.{ .active = self.scrolling_region.bottom },
|
||||
@min(count, self.scrolling_region.bottom - self.screen.cursor.y),
|
||||
@min(count, (self.scrolling_region.bottom - self.screen.cursor.y) + 1),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@ -6364,6 +6364,44 @@ test "Terminal: scrollUp preserves pending wrap" {
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: scrollUp full top/bottom region" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 5, 5);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
try t.printString("top");
|
||||
t.setCursorPos(5, 1);
|
||||
try t.printString("ABCDE");
|
||||
t.setTopAndBottomMargin(2, 5);
|
||||
try t.scrollUp(4);
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("top", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: scrollUp full top/bottomleft/right scroll region" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 5, 5);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
try t.printString("top");
|
||||
t.setCursorPos(5, 1);
|
||||
try t.printString("ABCDE");
|
||||
t.modes.set(.enable_left_and_right_margin, true);
|
||||
t.setTopAndBottomMargin(2, 5);
|
||||
t.setLeftAndRightMargin(2, 4);
|
||||
try t.scrollUp(4);
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("top\n\n\n\nA E", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: tabClear single" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 30, 5);
|
||||
|
@ -469,6 +469,8 @@ pub inline fn queueWrite(self: *Exec, data: []const u8, linefeed: bool) !void {
|
||||
break :slice buf[0..buf_i];
|
||||
};
|
||||
|
||||
// for (slice) |b| log.warn("write: {x}", .{b});
|
||||
|
||||
ev.data_stream.queueWrite(
|
||||
ev.loop,
|
||||
&ev.write_queue,
|
||||
|
@ -95,3 +95,19 @@ printf "X"
|
||||
|________|
|
||||
|X_______|
|
||||
```
|
||||
|
||||
### SU V-5: Scroll Full Top/Bottom Scroll Region
|
||||
|
||||
```bash
|
||||
printf "\033[1;1H" # move to top-left
|
||||
printf "\033[0J" # clear screen
|
||||
printf "top"
|
||||
printf "\033[5;1H"
|
||||
printf "ABCDEF"
|
||||
printf "\033[2;5r" # scroll region top/bottom
|
||||
printf "\033[4S"
|
||||
```
|
||||
|
||||
```
|
||||
|top_____|
|
||||
```
|
||||
|
Reference in New Issue
Block a user