mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
terminal: implement DECRQM (request mode)
This commit is contained in:
@ -569,6 +569,35 @@ pub fn Stream(comptime Handler: type) type {
|
||||
),
|
||||
},
|
||||
|
||||
// DECRQM - Request Mode
|
||||
'p' => switch (action.intermediates.len) {
|
||||
2 => decrqm: {
|
||||
if (action.intermediates[0] != '?' and
|
||||
action.intermediates[1] != '$')
|
||||
{
|
||||
log.warn(
|
||||
"ignoring unimplemented CSI p with intermediates: {s}",
|
||||
.{action.intermediates},
|
||||
);
|
||||
break :decrqm;
|
||||
}
|
||||
|
||||
if (action.params.len != 1) {
|
||||
log.warn("invalid DECRQM command: {}", .{action});
|
||||
break :decrqm;
|
||||
}
|
||||
|
||||
if (@hasDecl(T, "requestMode")) {
|
||||
try self.handler.requestMode(action.params[0]);
|
||||
} else log.warn("unimplemented DECRQM callback: {}", .{action});
|
||||
},
|
||||
|
||||
else => log.warn(
|
||||
"ignoring unimplemented CSI p with intermediates: {s}",
|
||||
.{action.intermediates},
|
||||
),
|
||||
},
|
||||
|
||||
// DECSCUSR - Select Cursor Style
|
||||
// TODO: test
|
||||
'q' => if (@hasDecl(T, "setCursorStyle")) try self.handler.setCursorStyle(
|
||||
|
@ -1267,6 +1267,27 @@ const StreamHandler = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn requestMode(self: *StreamHandler, mode_raw: u16) !void {
|
||||
// Get the mode value and respond.
|
||||
const code: u8 = code: {
|
||||
if (!terminal.modes.hasSupport(mode_raw)) break :code 0;
|
||||
if (self.terminal.modes.get(@enumFromInt(mode_raw))) break :code 1;
|
||||
break :code 2;
|
||||
};
|
||||
|
||||
var msg: termio.Message = .{ .write_small = .{} };
|
||||
const resp = try std.fmt.bufPrint(
|
||||
&msg.write_small.data,
|
||||
"\x1B[?{};{}$y",
|
||||
.{
|
||||
mode_raw,
|
||||
code,
|
||||
},
|
||||
);
|
||||
msg.write_small.len = @intCast(resp.len);
|
||||
self.messageWriter(msg);
|
||||
}
|
||||
|
||||
pub fn saveMode(self: *StreamHandler, mode: terminal.Mode) !void {
|
||||
// log.debug("save mode={}", .{mode});
|
||||
self.terminal.modes.save(mode);
|
||||
|
Reference in New Issue
Block a user