mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
terminal: HPR, VPR
This commit is contained in:
@ -432,6 +432,18 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
},
|
},
|
||||||
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||||
|
|
||||||
|
// HPR - Cursor Horizontal Position Relative
|
||||||
|
'a' => if (@hasDecl(T, "setCursorColRelative")) try self.handler.setCursorColRelative(
|
||||||
|
switch (action.params.len) {
|
||||||
|
0 => 1,
|
||||||
|
1 => action.params[0],
|
||||||
|
else => {
|
||||||
|
log.warn("invalid HPR command: {}", .{action});
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||||
|
|
||||||
// Repeat Previous Char (REP)
|
// Repeat Previous Char (REP)
|
||||||
'b' => if (@hasDecl(T, "printRepeat")) try self.handler.printRepeat(
|
'b' => if (@hasDecl(T, "printRepeat")) try self.handler.printRepeat(
|
||||||
switch (action.params.len) {
|
switch (action.params.len) {
|
||||||
@ -474,6 +486,18 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
},
|
},
|
||||||
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||||
|
|
||||||
|
// VPR - Cursor Vertical Position Relative
|
||||||
|
'e' => if (@hasDecl(T, "setCursorRowRelative")) try self.handler.setCursorRowRelative(
|
||||||
|
switch (action.params.len) {
|
||||||
|
0 => 1,
|
||||||
|
1 => action.params[0],
|
||||||
|
else => {
|
||||||
|
log.warn("invalid VPR command: {}", .{action});
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
) else log.warn("unimplemented CSI callback: {}", .{action}),
|
||||||
|
|
||||||
// TBC - Tab Clear
|
// TBC - Tab Clear
|
||||||
// TODO: test
|
// TODO: test
|
||||||
'g' => if (@hasDecl(T, "tabClear")) try self.handler.tabClear(
|
'g' => if (@hasDecl(T, "tabClear")) try self.handler.tabClear(
|
||||||
|
@ -1316,10 +1316,24 @@ const StreamHandler = struct {
|
|||||||
self.terminal.setCursorPos(self.terminal.screen.cursor.y + 1, col);
|
self.terminal.setCursorPos(self.terminal.screen.cursor.y + 1, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setCursorColRelative(self: *StreamHandler, offset: u16) !void {
|
||||||
|
self.terminal.setCursorPos(
|
||||||
|
self.terminal.screen.cursor.y + 1,
|
||||||
|
self.terminal.screen.cursor.x + 1 + offset,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setCursorRow(self: *StreamHandler, row: u16) !void {
|
pub fn setCursorRow(self: *StreamHandler, row: u16) !void {
|
||||||
self.terminal.setCursorPos(row, self.terminal.screen.cursor.x + 1);
|
self.terminal.setCursorPos(row, self.terminal.screen.cursor.x + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn setCursorRowRelative(self: *StreamHandler, offset: u16) !void {
|
||||||
|
self.terminal.setCursorPos(
|
||||||
|
self.terminal.screen.cursor.y + 1 + offset,
|
||||||
|
self.terminal.screen.cursor.x + 1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setCursorPos(self: *StreamHandler, row: u16, col: u16) !void {
|
pub fn setCursorPos(self: *StreamHandler, row: u16, col: u16) !void {
|
||||||
self.terminal.setCursorPos(row, col);
|
self.terminal.setCursorPos(row, col);
|
||||||
}
|
}
|
||||||
|
@ -7,3 +7,8 @@ import VTSequence from "@/components/VTSequence";
|
|||||||
This sequence performs [cursor position (CUP)](/vt/cup) with `x` set
|
This sequence performs [cursor position (CUP)](/vt/cup) with `x` set
|
||||||
to the parameterized value and `y` set to the current cursor position.
|
to the parameterized value and `y` set to the current cursor position.
|
||||||
There is no additional or different behavior for using `HPA`.
|
There is no additional or different behavior for using `HPA`.
|
||||||
|
|
||||||
|
Because this invokes `CUP`, the cursor row (`x`) can change if it is
|
||||||
|
outside the bounds of the `CUP` operation. For example, if
|
||||||
|
[origin mode](#TODO) is set and the current cursor position is outside
|
||||||
|
of the scroll region, the row will be adjusted.
|
||||||
|
17
website/app/vt/hpr/page.mdx
Normal file
17
website/app/vt/hpr/page.mdx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import VTSequence from "@/components/VTSequence";
|
||||||
|
|
||||||
|
# Horizontal Position Relative (HPR)
|
||||||
|
|
||||||
|
<VTSequence sequence={["CSI", "Px", "a"]} />
|
||||||
|
|
||||||
|
This sequence performs [cursor position (CUP)](/vt/cup) with `x` set
|
||||||
|
to the current cursor column plus `x` and `y` set to the current cursor row.
|
||||||
|
There is no additional or different behavior for using `HPR`.
|
||||||
|
|
||||||
|
The parameter `x` must be an integer greater than or equal to 1. If `x` is less than
|
||||||
|
or equal to 0, adjust `x` to be 1. If `x` is omitted, `x` defaults to 1.
|
||||||
|
|
||||||
|
Because this invokes `CUP`, the cursor row (`y`) can change if it is
|
||||||
|
outside the bounds of the `CUP` operation. For example, if
|
||||||
|
[origin mode](#TODO) is set and the current cursor position is outside
|
||||||
|
of the scroll region, the row will be adjusted.
|
@ -7,3 +7,8 @@ import VTSequence from "@/components/VTSequence";
|
|||||||
This sequence performs [cursor position (CUP)](/vt/cup) with `y` set
|
This sequence performs [cursor position (CUP)](/vt/cup) with `y` set
|
||||||
to the parameterized value and `x` set to the current cursor position.
|
to the parameterized value and `x` set to the current cursor position.
|
||||||
There is no additional or different behavior for using `VPA`.
|
There is no additional or different behavior for using `VPA`.
|
||||||
|
|
||||||
|
Because this invokes `CUP`, the cursor column (`y`) can change if it is
|
||||||
|
outside the bounds of the `CUP` operation. For example, if
|
||||||
|
[origin mode](#TODO) is set and the current cursor position is outside
|
||||||
|
of the scroll region, the column will be adjusted.
|
||||||
|
17
website/app/vt/vpr/page.mdx
Normal file
17
website/app/vt/vpr/page.mdx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import VTSequence from "@/components/VTSequence";
|
||||||
|
|
||||||
|
# Vertical Position Relative (VPR)
|
||||||
|
|
||||||
|
<VTSequence sequence={["CSI", "Py", "e"]} />
|
||||||
|
|
||||||
|
This sequence performs [cursor position (CUP)](/vt/cup) with `y` set
|
||||||
|
to the current cursor row plus `y` and `x` set to the current cursor column.
|
||||||
|
There is no additional or different behavior for using `VPR`.
|
||||||
|
|
||||||
|
The parameter `y` must be an integer greater than or equal to 1. If `y` is less than
|
||||||
|
or equal to 0, adjust `y` to be 1. If `y` is omitted, `y` defaults to 1.
|
||||||
|
|
||||||
|
Because this invokes `CUP`, the cursor column (`x`) can change if it is
|
||||||
|
outside the bounds of the `CUP` operation. For example, if
|
||||||
|
[origin mode](#TODO) is set and the current cursor position is outside
|
||||||
|
of the scroll region, the column will be adjusted.
|
Reference in New Issue
Block a user