terminal: device attributes
parent
109376115b
commit
e347ab6915
|
|
@ -53,11 +53,14 @@ pub const RenditionAspect = enum(u16) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The device attribute request type (ESC [ c).
|
/// The device attribute request type (ESC [ c).
|
||||||
pub const DeviceAttributeReq = enum {
|
pub const DeviceAttributeReq = lib.Enum(
|
||||||
primary, // Blank
|
lib_target,
|
||||||
secondary, // >
|
&.{
|
||||||
tertiary, // =
|
"primary", // Blank
|
||||||
};
|
"secondary", // >
|
||||||
|
"tertiary", // =
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
/// Possible cursor styles (ESC [ q)
|
/// Possible cursor styles (ESC [ q)
|
||||||
pub const CursorStyle = enum(u16) {
|
pub const CursorStyle = enum(u16) {
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ pub const Action = union(Key) {
|
||||||
title_push: u16,
|
title_push: u16,
|
||||||
title_pop: u16,
|
title_pop: u16,
|
||||||
xtversion,
|
xtversion,
|
||||||
|
device_attributes: ansi.DeviceAttributeReq,
|
||||||
kitty_keyboard_query,
|
kitty_keyboard_query,
|
||||||
kitty_keyboard_push: KittyKeyboardFlags,
|
kitty_keyboard_push: KittyKeyboardFlags,
|
||||||
kitty_keyboard_pop: u16,
|
kitty_keyboard_pop: u16,
|
||||||
|
|
@ -177,6 +178,7 @@ pub const Action = union(Key) {
|
||||||
"title_push",
|
"title_push",
|
||||||
"title_pop",
|
"title_pop",
|
||||||
"xtversion",
|
"xtversion",
|
||||||
|
"device_attributes",
|
||||||
"kitty_keyboard_query",
|
"kitty_keyboard_query",
|
||||||
"kitty_keyboard_push",
|
"kitty_keyboard_push",
|
||||||
"kitty_keyboard_pop",
|
"kitty_keyboard_pop",
|
||||||
|
|
@ -1042,22 +1044,24 @@ pub fn Stream(comptime Handler: type) type {
|
||||||
},
|
},
|
||||||
|
|
||||||
// c - Device Attributes (DA1)
|
// c - Device Attributes (DA1)
|
||||||
'c' => if (@hasDecl(T, "deviceAttributes")) {
|
'c' => {
|
||||||
const req: ansi.DeviceAttributeReq = switch (input.intermediates.len) {
|
const req: ?ansi.DeviceAttributeReq = switch (input.intermediates.len) {
|
||||||
0 => ansi.DeviceAttributeReq.primary,
|
0 => .primary,
|
||||||
1 => switch (input.intermediates[0]) {
|
1 => switch (input.intermediates[0]) {
|
||||||
'>' => ansi.DeviceAttributeReq.secondary,
|
'>' => .secondary,
|
||||||
'=' => ansi.DeviceAttributeReq.tertiary,
|
'=' => .tertiary,
|
||||||
else => null,
|
else => null,
|
||||||
},
|
},
|
||||||
else => @as(?ansi.DeviceAttributeReq, null),
|
else => null,
|
||||||
} orelse {
|
};
|
||||||
|
|
||||||
|
if (req) |r| {
|
||||||
|
try self.handler.vt(.device_attributes, r);
|
||||||
|
} else {
|
||||||
log.warn("invalid device attributes command: {f}", .{input});
|
log.warn("invalid device attributes command: {f}", .{input});
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
},
|
||||||
try self.handler.deviceAttributes(req, input.params);
|
|
||||||
} else log.warn("unimplemented CSI callback: {f}", .{input}),
|
|
||||||
|
|
||||||
// VPA - Cursor Vertical Position Absolute
|
// VPA - Cursor Vertical Position Absolute
|
||||||
'd' => switch (input.intermediates.len) {
|
'd' => switch (input.intermediates.len) {
|
||||||
|
|
@ -1963,8 +1967,8 @@ pub fn Stream(comptime Handler: type) type {
|
||||||
},
|
},
|
||||||
|
|
||||||
// DECID
|
// DECID
|
||||||
'Z' => if (@hasDecl(T, "deviceAttributes") and action.intermediates.len == 0) {
|
'Z' => if (action.intermediates.len == 0) {
|
||||||
try self.handler.deviceAttributes(.primary, &.{});
|
try self.handler.vt(.device_attributes, .primary);
|
||||||
} else log.warn("unimplemented ESC callback: {f}", .{action}),
|
} else log.warn("unimplemented ESC callback: {f}", .{action}),
|
||||||
|
|
||||||
// RIS - Full Reset
|
// RIS - Full Reset
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,7 @@ pub const StreamHandler = struct {
|
||||||
.mouse_shift_capture => self.terminal.flags.mouse_shift_capture = if (value) .true else .false,
|
.mouse_shift_capture => self.terminal.flags.mouse_shift_capture = if (value) .true else .false,
|
||||||
.size_report => self.sendSizeReport(value),
|
.size_report => self.sendSizeReport(value),
|
||||||
.xtversion => try self.reportXtversion(),
|
.xtversion => try self.reportXtversion(),
|
||||||
|
.device_attributes => try self.deviceAttributes(value),
|
||||||
.kitty_keyboard_query => try self.queryKittyKeyboard(),
|
.kitty_keyboard_query => try self.queryKittyKeyboard(),
|
||||||
.kitty_keyboard_push => {
|
.kitty_keyboard_push => {
|
||||||
log.debug("pushing kitty keyboard mode: {}", .{value.flags});
|
log.debug("pushing kitty keyboard mode: {}", .{value.flags});
|
||||||
|
|
@ -722,10 +723,7 @@ pub const StreamHandler = struct {
|
||||||
pub fn deviceAttributes(
|
pub fn deviceAttributes(
|
||||||
self: *StreamHandler,
|
self: *StreamHandler,
|
||||||
req: terminal.DeviceAttributeReq,
|
req: terminal.DeviceAttributeReq,
|
||||||
params: []const u16,
|
|
||||||
) !void {
|
) !void {
|
||||||
_ = params;
|
|
||||||
|
|
||||||
// For the below, we quack as a VT220. We don't quack as
|
// For the below, we quack as a VT220. We don't quack as
|
||||||
// a 420 because we don't support DCS sequences.
|
// a 420 because we don't support DCS sequences.
|
||||||
switch (req) {
|
switch (req) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue