terminal: stream handleManually => vtRaw

This commit is contained in:
Mitchell Hashimoto
2026-01-29 21:08:45 -08:00
parent 4fa2dab20d
commit 75eac6e3ea
2 changed files with 13 additions and 9 deletions

View File

@@ -693,7 +693,7 @@ const VTHandler = struct {
}
/// This is called with every single terminal action.
pub fn handleManually(self: *VTHandler, action: terminal.Parser.Action) !bool {
pub fn vtRaw(self: *VTHandler, action: terminal.Parser.Action) !bool {
const state: *State = if (self.state) |*s| s else return true;
const alloc = state.alloc;
const vt_events = state.events;
@@ -748,7 +748,9 @@ const VTHandler = struct {
else => return err,
};
return true;
// Do NOT skip it, because we want to record more information
// about this event.
return false;
}
};

View File

@@ -707,19 +707,21 @@ pub fn Stream(comptime Handler: type) type {
const action = action_opt orelse continue;
if (comptime debug) log.info("action: {f}", .{action});
// If this handler handles everything manually then we do nothing
// if it can be processed.
if (@hasDecl(T, "handleManually")) {
const processed = self.handler.handleManually(action) catch |err| err: {
// A handler can expose this to get the raw action before
// it is further parsed. If this returns `true` then we skip
// processing ourselves.
if (@hasDecl(T, "vtRaw")) {
const skip = self.handler.vtRaw(action) catch |err| err: {
log.warn("error handling action manually err={} action={f}", .{
err,
action,
});
break :err false;
// Always skip erroneous actions because we can't
// be sure...
break :err true;
};
if (processed) continue;
if (skip) continue;
}
switch (action) {