mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
implement erase line (EL) CSI
This commit is contained in:
@ -104,7 +104,7 @@ pub fn next(self: *Parser, c: u8) [3]?Action {
|
|||||||
break :effect table[c][@enumToInt(self.state)];
|
break :effect table[c][@enumToInt(self.state)];
|
||||||
};
|
};
|
||||||
|
|
||||||
log.info("next: {x}", .{c});
|
// log.info("next: {x}", .{c});
|
||||||
|
|
||||||
const next_state = effect.state;
|
const next_state = effect.state;
|
||||||
const action = effect.action;
|
const action = effect.action;
|
||||||
|
@ -160,7 +160,7 @@ fn csiDispatch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
break :mode @intToEnum(
|
break :mode @intToEnum(
|
||||||
csi.EraseDisplayMode,
|
csi.EraseDisplay,
|
||||||
action.params[0],
|
action.params[0],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -170,6 +170,27 @@ fn csiDispatch(
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Erase Line
|
||||||
|
'K' => try self.eraseLine(switch (action.params.len) {
|
||||||
|
0 => .right,
|
||||||
|
1 => mode: {
|
||||||
|
// TODO: use meta to get enum max
|
||||||
|
if (action.params[0] > 3) {
|
||||||
|
log.warn("invalid erase line command: {}", .{action});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break :mode @intToEnum(
|
||||||
|
csi.EraseLine,
|
||||||
|
action.params[0],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
else => {
|
||||||
|
log.warn("invalid erase line command: {}", .{action});
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
else => log.warn("unimplemented CSI: {}", .{action}),
|
else => log.warn("unimplemented CSI: {}", .{action}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +250,7 @@ pub fn setCursorPosition(self: *Terminal, row: usize, col: usize) !void {
|
|||||||
pub fn eraseDisplay(
|
pub fn eraseDisplay(
|
||||||
self: *Terminal,
|
self: *Terminal,
|
||||||
alloc: Allocator,
|
alloc: Allocator,
|
||||||
mode: csi.EraseDisplayMode,
|
mode: csi.EraseDisplay,
|
||||||
) !void {
|
) !void {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.complete => {
|
.complete => {
|
||||||
@ -240,6 +261,22 @@ pub fn eraseDisplay(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Erase the line.
|
||||||
|
/// TODO: test
|
||||||
|
pub fn eraseLine(
|
||||||
|
self: *Terminal,
|
||||||
|
mode: csi.EraseLine,
|
||||||
|
) !void {
|
||||||
|
switch (mode) {
|
||||||
|
.right => {
|
||||||
|
var line = &self.screen.items[self.cursor.y];
|
||||||
|
for (line.items[self.cursor.x..line.items.len]) |*cell|
|
||||||
|
cell.char = 0;
|
||||||
|
},
|
||||||
|
else => @panic("unimplemented"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Backspace moves the cursor back a column (but not less than 0).
|
/// Backspace moves the cursor back a column (but not less than 0).
|
||||||
pub fn backspace(self: *Terminal) void {
|
pub fn backspace(self: *Terminal) void {
|
||||||
const tracy = trace(@src());
|
const tracy = trace(@src());
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
// Modes for the ED CSI command.
|
// Modes for the ED CSI command.
|
||||||
pub const EraseDisplayMode = enum(u8) {
|
pub const EraseDisplay = enum(u8) {
|
||||||
below = 0,
|
below = 0,
|
||||||
above = 1,
|
above = 1,
|
||||||
complete = 2,
|
complete = 2,
|
||||||
scrollback = 3,
|
scrollback = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Modes for the EL CSI command.
|
||||||
|
pub const EraseLine = enum(u8) {
|
||||||
|
right = 0,
|
||||||
|
left = 1,
|
||||||
|
complete = 3,
|
||||||
|
right_unless_pending_wrap = 4,
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user