terminal: setprotectedmode
parent
25eee9379d
commit
c1e57dd330
|
|
@ -76,6 +76,9 @@ pub const Action = union(Key) {
|
||||||
request_mode: Mode,
|
request_mode: Mode,
|
||||||
request_mode_unknown: RawMode,
|
request_mode_unknown: RawMode,
|
||||||
modify_key_format: ansi.ModifyKeyFormat,
|
modify_key_format: ansi.ModifyKeyFormat,
|
||||||
|
protected_mode_off,
|
||||||
|
protected_mode_iso,
|
||||||
|
protected_mode_dec,
|
||||||
|
|
||||||
pub const Key = lib.Enum(
|
pub const Key = lib.Enum(
|
||||||
lib_target,
|
lib_target,
|
||||||
|
|
@ -126,6 +129,9 @@ pub const Action = union(Key) {
|
||||||
"request_mode",
|
"request_mode",
|
||||||
"request_mode_unknown",
|
"request_mode_unknown",
|
||||||
"modify_key_format",
|
"modify_key_format",
|
||||||
|
"protected_mode_off",
|
||||||
|
"protected_mode_iso",
|
||||||
|
"protected_mode_dec",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -1288,24 +1294,26 @@ pub fn Stream(comptime Handler: type) type {
|
||||||
|
|
||||||
// DECSCA
|
// DECSCA
|
||||||
'"' => {
|
'"' => {
|
||||||
if (@hasDecl(T, "setProtectedMode")) {
|
const mode_: ?ansi.ProtectedMode = switch (input.params.len) {
|
||||||
const mode_: ?ansi.ProtectedMode = switch (input.params.len) {
|
else => null,
|
||||||
|
0 => .off,
|
||||||
|
1 => switch (input.params[0]) {
|
||||||
|
0, 2 => .off,
|
||||||
|
1 => .dec,
|
||||||
else => null,
|
else => null,
|
||||||
0 => .off,
|
},
|
||||||
1 => switch (input.params[0]) {
|
};
|
||||||
0, 2 => .off,
|
|
||||||
1 => .dec,
|
|
||||||
else => null,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const mode = mode_ orelse {
|
const mode = mode_ orelse {
|
||||||
log.warn("invalid set protected mode command: {f}", .{input});
|
log.warn("invalid set protected mode command: {f}", .{input});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
try self.handler.setProtectedMode(mode);
|
switch (mode) {
|
||||||
} else log.warn("unimplemented CSI callback: {f}", .{input});
|
.off => try self.handler.vt(.protected_mode_off, {}),
|
||||||
|
.iso => try self.handler.vt(.protected_mode_iso, {}),
|
||||||
|
.dec => try self.handler.vt(.protected_mode_dec, {}),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// XTVERSION
|
// XTVERSION
|
||||||
|
|
@ -1930,14 +1938,16 @@ pub fn Stream(comptime Handler: type) type {
|
||||||
} else log.warn("unimplemented invokeCharset: {f}", .{action}),
|
} else log.warn("unimplemented invokeCharset: {f}", .{action}),
|
||||||
|
|
||||||
// SPA - Start of Guarded Area
|
// SPA - Start of Guarded Area
|
||||||
'V' => if (@hasDecl(T, "setProtectedMode") and action.intermediates.len == 0) {
|
'V' => switch (action.intermediates.len) {
|
||||||
try self.handler.setProtectedMode(ansi.ProtectedMode.iso);
|
0 => try self.handler.vt(.protected_mode_iso, {}),
|
||||||
} else log.warn("unimplemented ESC callback: {f}", .{action}),
|
else => log.warn("unimplemented ESC callback: {f}", .{action}),
|
||||||
|
},
|
||||||
|
|
||||||
// EPA - End of Guarded Area
|
// EPA - End of Guarded Area
|
||||||
'W' => if (@hasDecl(T, "setProtectedMode") and action.intermediates.len == 0) {
|
'W' => switch (action.intermediates.len) {
|
||||||
try self.handler.setProtectedMode(ansi.ProtectedMode.off);
|
0 => try self.handler.vt(.protected_mode_off, {}),
|
||||||
} else log.warn("unimplemented ESC callback: {f}", .{action}),
|
else => log.warn("unimplemented ESC callback: {f}", .{action}),
|
||||||
|
},
|
||||||
|
|
||||||
// DECID
|
// DECID
|
||||||
'Z' => if (@hasDecl(T, "deviceAttributes") and action.intermediates.len == 0) {
|
'Z' => if (@hasDecl(T, "deviceAttributes") and action.intermediates.len == 0) {
|
||||||
|
|
@ -2269,18 +2279,18 @@ test "stream: DECSCA" {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
v: ?ansi.ProtectedMode = null,
|
v: ?ansi.ProtectedMode = null,
|
||||||
|
|
||||||
pub fn setProtectedMode(self: *Self, v: ansi.ProtectedMode) !void {
|
|
||||||
self.v = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn vt(
|
pub fn vt(
|
||||||
self: *@This(),
|
self: *Self,
|
||||||
comptime action: anytype,
|
comptime action: Stream(Self).Action.Tag,
|
||||||
value: anytype,
|
value: Stream(Self).Action.Value(action),
|
||||||
) !void {
|
) !void {
|
||||||
_ = self;
|
|
||||||
_ = action;
|
|
||||||
_ = value;
|
_ = value;
|
||||||
|
switch (action) {
|
||||||
|
.protected_mode_off => self.v = .off,
|
||||||
|
.protected_mode_iso => self.v = .iso,
|
||||||
|
.protected_mode_dec => self.v = .dec,
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,6 +256,9 @@ pub const StreamHandler = struct {
|
||||||
.request_mode => try self.requestMode(value.mode),
|
.request_mode => try self.requestMode(value.mode),
|
||||||
.request_mode_unknown => try self.requestModeUnknown(value.mode, value.ansi),
|
.request_mode_unknown => try self.requestModeUnknown(value.mode, value.ansi),
|
||||||
.modify_key_format => try self.setModifyKeyFormat(value),
|
.modify_key_format => try self.setModifyKeyFormat(value),
|
||||||
|
.protected_mode_off => self.terminal.setProtectedMode(.off),
|
||||||
|
.protected_mode_iso => self.terminal.setProtectedMode(.iso),
|
||||||
|
.protected_mode_dec => self.terminal.setProtectedMode(.dec),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -804,10 +807,6 @@ pub const StreamHandler = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub inline fn setProtectedMode(self: *StreamHandler, mode: terminal.ProtectedMode) !void {
|
|
||||||
self.terminal.setProtectedMode(mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub inline fn decaln(self: *StreamHandler) !void {
|
pub inline fn decaln(self: *StreamHandler) !void {
|
||||||
try self.terminal.decaln();
|
try self.terminal.decaln();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue