mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00
terminal: index handles left/right regions
This commit is contained in:
@ -953,11 +953,7 @@ pub fn index(self: *Terminal) !void {
|
|||||||
{
|
{
|
||||||
try self.screen.scroll(.{ .screen = 1 });
|
try self.screen.scroll(.{ .screen = 1 });
|
||||||
} else {
|
} else {
|
||||||
self.screen.scrollRegionUp(
|
try self.scrollUp(1);
|
||||||
.{ .active = self.scrolling_region.top },
|
|
||||||
.{ .active = self.scrolling_region.bottom },
|
|
||||||
1,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -3744,18 +3740,26 @@ test "Terminal: index inside left/right margin" {
|
|||||||
var t = try init(alloc, 10, 5);
|
var t = try init(alloc, 10, 5);
|
||||||
defer t.deinit(alloc);
|
defer t.deinit(alloc);
|
||||||
|
|
||||||
|
try t.printString("AAAAAA");
|
||||||
|
t.carriageReturn();
|
||||||
|
try t.linefeed();
|
||||||
|
try t.printString("AAAAAA");
|
||||||
|
t.carriageReturn();
|
||||||
|
try t.linefeed();
|
||||||
|
try t.printString("AAAAAA");
|
||||||
|
t.modes.set(.enable_left_and_right_margin, true);
|
||||||
t.setTopAndBottomMargin(1, 3);
|
t.setTopAndBottomMargin(1, 3);
|
||||||
t.scrolling_region.left = 3;
|
t.setLeftAndRightMargin(1, 3);
|
||||||
t.scrolling_region.right = 5;
|
t.setCursorPos(3, 1);
|
||||||
t.setCursorPos(3, 3);
|
|
||||||
try t.print('A');
|
|
||||||
try t.index();
|
try t.index();
|
||||||
try t.print('X');
|
|
||||||
|
try testing.expectEqual(@as(usize, 2), t.screen.cursor.y);
|
||||||
|
try testing.expectEqual(@as(usize, 0), t.screen.cursor.x);
|
||||||
|
|
||||||
{
|
{
|
||||||
var str = try t.plainString(testing.allocator);
|
var str = try t.plainString(testing.allocator);
|
||||||
defer testing.allocator.free(str);
|
defer testing.allocator.free(str);
|
||||||
try testing.expectEqualStrings("\n A\n X", str);
|
try testing.expectEqualStrings("AAAAAA\nAAAAAA\n AAA", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,3 +136,24 @@ printf "X"
|
|||||||
|__________|
|
|__________|
|
||||||
|XcA_______|
|
|XcA_______|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### IND V-7: Inside of Left/Right Scroll Region
|
||||||
|
|
||||||
|
```bash
|
||||||
|
printf "\033[1;1H" # move to top-left
|
||||||
|
printf "\033[0J" # clear screen
|
||||||
|
printf "AAAAAA\n"
|
||||||
|
printf "AAAAAA\n"
|
||||||
|
printf "AAAAAA"
|
||||||
|
printf "\033[?69h" # enable left/right margins
|
||||||
|
printf "\033[1;3s" # set scroll region left/right
|
||||||
|
printf "\033[1;3r" # set scroll region top/bottom
|
||||||
|
printf "\033[3;1H" # Move to bottom left
|
||||||
|
printf "\033D" # index
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
|AAAAAA____|
|
||||||
|
|AAAAAA____|
|
||||||
|
|c__AAA____|
|
||||||
|
```
|
||||||
|
Reference in New Issue
Block a user