cursor left

This commit is contained in:
Mitchell Hashimoto
2022-05-19 15:56:06 -07:00
parent da359b8e36
commit 58b18a26f5
3 changed files with 27 additions and 0 deletions

View File

@ -547,6 +547,10 @@ pub fn carriageReturn(self: *Window) !void {
self.terminal.carriageReturn(); self.terminal.carriageReturn();
} }
pub fn setCursorLeft(self: *Window, amount: u16) !void {
self.terminal.cursorLeft(amount);
}
pub fn setCursorRight(self: *Window, amount: u16) !void { pub fn setCursorRight(self: *Window, amount: u16) !void {
self.terminal.cursorRight(amount); self.terminal.cursorRight(amount);
} }

View File

@ -358,6 +358,17 @@ pub fn eraseChars(self: *Terminal, alloc: Allocator, count: usize) !void {
} }
} }
/// Move the cursor to the left amount cells. If amount is 0, adjust it to 1.
/// TODO: test
pub fn cursorLeft(self: *Terminal, count: usize) void {
const tracy = trace(@src());
defer tracy.end();
// TODO: scroll region, wrap
self.cursor.x -|= if (count == 0) 1 else count;
}
/// Move the cursor right amount columns. If amount is greater than the /// Move the cursor right amount columns. If amount is greater than the
/// maximum move distance then it is internally adjusted to the maximum. /// maximum move distance then it is internally adjusted to the maximum.
/// This sequence will not scroll the screen or scroll region. If amount is /// This sequence will not scroll the screen or scroll region. If amount is

View File

@ -131,6 +131,18 @@ pub fn Stream(comptime Handler: type) type {
}, },
) else log.warn("unimplemented CSI callback: {}", .{action}), ) else log.warn("unimplemented CSI callback: {}", .{action}),
// CUB - Cursor Left
'D' => if (@hasDecl(T, "setCursorLeft")) try self.handler.setCursorLeft(
switch (action.params.len) {
0 => 1,
1 => action.params[0],
else => {
log.warn("invalid cursor left command: {}", .{action});
return;
},
},
) else log.warn("unimplemented CSI callback: {}", .{action}),
// HPA - Cursor Horizontal Position Absolute // HPA - Cursor Horizontal Position Absolute
// TODO: test // TODO: test
'G', '`' => if (@hasDecl(T, "setCursorCol")) switch (action.params.len) { 'G', '`' => if (@hasDecl(T, "setCursorCol")) switch (action.params.len) {