mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
terminal: proper reverseIndex behavior with scroll region set
Fixes #298 This fix is quite simple and the code should be more or less obvious: we weren't handling scroll regions properly for the reverse index (RI) escape sequence.
This commit is contained in:
@ -909,9 +909,11 @@ pub fn reverseIndex(self: *Terminal) !void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
// TODO: scrolling region
|
||||
|
||||
if (self.screen.cursor.y == 0) {
|
||||
// If the cursor is on the top-most line of the scroll region or
|
||||
// its on the top of the screen we scroll down.
|
||||
if (self.screen.cursor.y == self.scrolling_region.top or
|
||||
self.screen.cursor.y == 0)
|
||||
{
|
||||
try self.scrollDown(1);
|
||||
} else {
|
||||
self.screen.cursor.y -|= 1;
|
||||
@ -2222,6 +2224,39 @@ test "Terminal: reverseIndex from the top" {
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: reverseIndex top of scrolling region" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 2, 10);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
// Initial value
|
||||
t.setCursorPos(2, 1);
|
||||
try t.print('A');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
try t.print('B');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
try t.print('C');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
try t.print('D');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
|
||||
// Set our scroll region
|
||||
t.setScrollingRegion(2, 5);
|
||||
t.setCursorPos(2, 1);
|
||||
try t.reverseIndex();
|
||||
try t.print('X');
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("\nX\nA\nB\nC", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: index" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 2, 5);
|
||||
|
Reference in New Issue
Block a user