mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
esc dispatch is handled in parser
This commit is contained in:
@ -63,11 +63,19 @@ pub const Action = union(enum) {
|
|||||||
/// structure are only valid until the next call to "next".
|
/// structure are only valid until the next call to "next".
|
||||||
csi_dispatch: CSI,
|
csi_dispatch: CSI,
|
||||||
|
|
||||||
|
/// Execute the ESC command.
|
||||||
|
esc_dispatch: ESC,
|
||||||
|
|
||||||
pub const CSI = struct {
|
pub const CSI = struct {
|
||||||
intermediates: []u8,
|
intermediates: []u8,
|
||||||
params: []u16,
|
params: []u16,
|
||||||
final: u8,
|
final: u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const ESC = struct {
|
||||||
|
intermediates: []u8,
|
||||||
|
final: u8,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Maximum number of intermediate characters during parsing.
|
/// Maximum number of intermediate characters during parsing.
|
||||||
@ -192,6 +200,12 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
.esc_dispatch => Action{
|
||||||
|
.esc_dispatch = .{
|
||||||
|
.intermediates = self.intermediates[0..self.intermediates_idx],
|
||||||
|
.final = c,
|
||||||
|
},
|
||||||
|
},
|
||||||
else => {
|
else => {
|
||||||
std.log.err("unimplemented action: {}", .{action});
|
std.log.err("unimplemented action: {}", .{action});
|
||||||
@panic("TODO");
|
@panic("TODO");
|
||||||
|
@ -129,6 +129,7 @@ pub fn appendChar(self: *Terminal, alloc: Allocator, c: u8) !void {
|
|||||||
.print => |p| try self.print(alloc, p),
|
.print => |p| try self.print(alloc, p),
|
||||||
.execute => |code| try self.execute(alloc, code),
|
.execute => |code| try self.execute(alloc, code),
|
||||||
.csi_dispatch => |csi| try self.csiDispatch(alloc, csi),
|
.csi_dispatch => |csi| try self.csiDispatch(alloc, csi),
|
||||||
|
.esc_dispatch => |esc| log.warn("unhandled esc: {}", .{esc}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,7 +290,13 @@ pub fn eraseLine(
|
|||||||
) !void {
|
) !void {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
.right => {
|
.right => {
|
||||||
|
// If our cursor is outside our screen, we can't erase anything.
|
||||||
|
if (self.cursor.y >= self.screen.items.len) return;
|
||||||
var line = &self.screen.items[self.cursor.y];
|
var line = &self.screen.items[self.cursor.y];
|
||||||
|
|
||||||
|
// If our cursor is outside our screen, we can't erase anything.
|
||||||
|
if (self.cursor.x >= line.items.len) return;
|
||||||
|
|
||||||
for (line.items[self.cursor.x..line.items.len]) |*cell|
|
for (line.items[self.cursor.x..line.items.len]) |*cell|
|
||||||
cell.char = 0;
|
cell.char = 0;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user