mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal: parse APC strings
This commit is contained in:
@ -48,6 +48,7 @@ pub const TransitionAction = enum {
|
|||||||
csi_dispatch,
|
csi_dispatch,
|
||||||
put,
|
put,
|
||||||
osc_put,
|
osc_put,
|
||||||
|
apc_put,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Action is the action that a caller of the parser is expected to
|
/// Action is the action that a caller of the parser is expected to
|
||||||
@ -74,6 +75,11 @@ pub const Action = union(enum) {
|
|||||||
dcs_put: u8,
|
dcs_put: u8,
|
||||||
dcs_unhook: void,
|
dcs_unhook: void,
|
||||||
|
|
||||||
|
/// APC data
|
||||||
|
apc_start: void,
|
||||||
|
apc_put: u8,
|
||||||
|
apc_end: void,
|
||||||
|
|
||||||
pub const CSI = struct {
|
pub const CSI = struct {
|
||||||
intermediates: []u8,
|
intermediates: []u8,
|
||||||
params: []u16,
|
params: []u16,
|
||||||
@ -247,6 +253,7 @@ pub fn next(self: *Parser, c: u8) [3]?Action {
|
|||||||
else
|
else
|
||||||
null,
|
null,
|
||||||
.dcs_passthrough => Action{ .dcs_unhook = {} },
|
.dcs_passthrough => Action{ .dcs_unhook = {} },
|
||||||
|
.sos_pm_apc_string => Action{ .apc_end = {} },
|
||||||
else => null,
|
else => null,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -269,6 +276,7 @@ pub fn next(self: *Parser, c: u8) [3]?Action {
|
|||||||
.final = c,
|
.final = c,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
.sos_pm_apc_string => Action{ .apc_start = {} },
|
||||||
.utf8 => utf8: {
|
.utf8 => utf8: {
|
||||||
// When entering the UTF8 state, we need to grab the
|
// When entering the UTF8 state, we need to grab the
|
||||||
// last intermediate as our first byte and reset
|
// last intermediate as our first byte and reset
|
||||||
@ -426,9 +434,8 @@ fn doAction(self: *Parser, action: TransitionAction, c: u8) ?Action {
|
|||||||
.final = c,
|
.final = c,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.put => Action{
|
.put => Action{ .dcs_put = c },
|
||||||
.dcs_put = c,
|
.apc_put => Action{ .apc_put = c },
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,10 +125,10 @@ fn genTable() Table {
|
|||||||
const source = State.sos_pm_apc_string;
|
const source = State.sos_pm_apc_string;
|
||||||
|
|
||||||
// events
|
// events
|
||||||
single(&result, 0x19, source, source, .ignore);
|
single(&result, 0x19, source, source, .apc_put);
|
||||||
range(&result, 0, 0x17, source, source, .ignore);
|
range(&result, 0, 0x17, source, source, .apc_put);
|
||||||
range(&result, 0x1C, 0x1F, source, source, .ignore);
|
range(&result, 0x1C, 0x1F, source, source, .apc_put);
|
||||||
range(&result, 0x20, 0x7F, source, source, .ignore);
|
range(&result, 0x20, 0x7F, source, source, .apc_put);
|
||||||
}
|
}
|
||||||
|
|
||||||
// escape
|
// escape
|
||||||
|
@ -64,8 +64,11 @@ pub fn Stream(comptime Handler: type) type {
|
|||||||
.esc_dispatch => |esc| try self.escDispatch(esc),
|
.esc_dispatch => |esc| try self.escDispatch(esc),
|
||||||
.osc_dispatch => |cmd| try self.oscDispatch(cmd),
|
.osc_dispatch => |cmd| try self.oscDispatch(cmd),
|
||||||
.dcs_hook => |dcs| log.warn("unhandled DCS hook: {}", .{dcs}),
|
.dcs_hook => |dcs| log.warn("unhandled DCS hook: {}", .{dcs}),
|
||||||
.dcs_put => |code| log.warn("unhandled DCS put: {}", .{code}),
|
.dcs_put => |code| log.warn("unhandled DCS put: {x}", .{code}),
|
||||||
.dcs_unhook => log.warn("unhandled DCS unhook", .{}),
|
.dcs_unhook => log.warn("unhandled DCS unhook", .{}),
|
||||||
|
.apc_start => log.warn("unhandled APC start", .{}),
|
||||||
|
.apc_put => |code| log.warn("unhandled APC put: {x}", .{code}),
|
||||||
|
.apc_end => log.warn("unhandled APC end", .{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user