cursor right

This commit is contained in:
Mitchell Hashimoto
2022-05-08 20:42:24 -07:00
parent 566872f407
commit 54783e3624

View File

@ -139,6 +139,16 @@ fn csiDispatch(
action: Parser.Action.CSI,
) !void {
switch (action.final) {
// CUF - Cursor Right
'C' => self.cursorRight(switch (action.params.len) {
0 => 1,
1 => action.params[0],
else => {
log.warn("invalid cursor right command: {}", .{action});
return;
},
}),
// CUP - Set Cursor Position.
'H' => {
switch (action.params.len) {
@ -319,6 +329,21 @@ pub fn deleteChars(self: *Terminal, count: usize) !void {
}
}
/// Move the cursor right amount columns. If amount is greater than the
/// maximum move distance then it is internally adjusted to the maximum.
/// This sequence will not scroll the screen or scroll region. If amount is
/// 0, adjust it to 1.
/// TODO: test
pub fn cursorRight(self: *Terminal, count: usize) void {
const tracy = trace(@src());
defer tracy.end();
self.cursor.x += count;
if (self.cursor.x == self.cols) {
self.cursor.x -= 1;
}
}
/// Backspace moves the cursor back a column (but not less than 0).
pub fn backspace(self: *Terminal) void {
const tracy = trace(@src());