mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
terminal: IND supports left/right margins
This commit is contained in:
@ -898,11 +898,16 @@ pub fn index(self: *Terminal) !void {
|
||||
// If the cursor is inside the scrolling region and on the bottom-most
|
||||
// line, then we scroll up. If our scrolling region is the full screen
|
||||
// we create scrollback.
|
||||
if (self.screen.cursor.y == self.scrolling_region.bottom) {
|
||||
if (self.screen.cursor.y == self.scrolling_region.bottom and
|
||||
self.screen.cursor.x >= self.scrolling_region.left and
|
||||
self.screen.cursor.x <= self.scrolling_region.right)
|
||||
{
|
||||
// If our scrolling region is the full screen, we create scrollback.
|
||||
// Otherwise, we simply scroll the region.
|
||||
if (self.scrolling_region.top == 0 and
|
||||
self.scrolling_region.bottom == self.rows - 1)
|
||||
self.scrolling_region.bottom == self.rows - 1 and
|
||||
self.scrolling_region.left == 0 and
|
||||
self.scrolling_region.right == self.cols - 1)
|
||||
{
|
||||
try self.screen.scroll(.{ .screen = 1 });
|
||||
} else {
|
||||
@ -2919,6 +2924,47 @@ test "Terminal: index bottom of primary screen with scroll region" {
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: index outside left/right margin" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 10, 5);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
t.setScrollingRegion(1, 3);
|
||||
t.scrolling_region.left = 3;
|
||||
t.scrolling_region.right = 5;
|
||||
t.setCursorPos(3, 3);
|
||||
try t.print('A');
|
||||
t.setCursorPos(3, 1);
|
||||
try t.index();
|
||||
try t.print('X');
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("\n\nX A", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: index inside left/right margin" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 10, 5);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
t.setScrollingRegion(1, 3);
|
||||
t.scrolling_region.left = 3;
|
||||
t.scrolling_region.right = 5;
|
||||
t.setCursorPos(3, 3);
|
||||
try t.print('A');
|
||||
try t.index();
|
||||
try t.print('X');
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("\n A\n X", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: DECALN" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 2, 2);
|
||||
|
@ -115,3 +115,25 @@ printf "X"
|
||||
|__________|
|
||||
|Xc________|
|
||||
```
|
||||
|
||||
### IND V-6: Outside of Left/Right Scroll Region
|
||||
|
||||
```bash
|
||||
printf "\033[1;1H" # move to top-left
|
||||
printf "\033[0J" # clear screen
|
||||
printf "\033[?69h" # enable left/right margins
|
||||
printf "\033[1;3r" # scroll region top/bottom
|
||||
printf "\033[3;5s" # scroll region left/right
|
||||
printf "\033[3;3H"
|
||||
printf "A"
|
||||
printf "\033[3;1H"
|
||||
printf "\033D" # index
|
||||
printf "X"
|
||||
```
|
||||
|
||||
```
|
||||
|__________|
|
||||
|__________|
|
||||
|XcA_______|
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user