mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
terminal: boilerplate for tmux control mode parsing
This commit is contained in:
@ -98,6 +98,8 @@ pub const Handler = struct {
|
|||||||
.ignore,
|
.ignore,
|
||||||
=> {},
|
=> {},
|
||||||
|
|
||||||
|
.tmux => {},
|
||||||
|
|
||||||
.xtgettcap => |*list| {
|
.xtgettcap => |*list| {
|
||||||
if (list.items.len >= self.max_bytes) {
|
if (list.items.len >= self.max_bytes) {
|
||||||
return error.OutOfMemory;
|
return error.OutOfMemory;
|
||||||
@ -126,6 +128,8 @@ pub const Handler = struct {
|
|||||||
.ignore,
|
.ignore,
|
||||||
=> null,
|
=> null,
|
||||||
|
|
||||||
|
.tmux => null,
|
||||||
|
|
||||||
.xtgettcap => |list| .{ .xtgettcap = .{ .data = list } },
|
.xtgettcap => |list| .{ .xtgettcap = .{ .data = list } },
|
||||||
|
|
||||||
.decrqss => |buffer| .{ .decrqss = switch (buffer.len) {
|
.decrqss => |buffer| .{ .decrqss = switch (buffer.len) {
|
||||||
@ -157,6 +161,8 @@ pub const Handler = struct {
|
|||||||
.xtgettcap => |*list| list.deinit(),
|
.xtgettcap => |*list| list.deinit(),
|
||||||
|
|
||||||
.decrqss => {},
|
.decrqss => {},
|
||||||
|
|
||||||
|
.tmux => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
self.state = .{ .inactive = {} };
|
self.state = .{ .inactive = {} };
|
||||||
@ -170,10 +176,14 @@ pub const Command = union(enum) {
|
|||||||
/// DECRQSS
|
/// DECRQSS
|
||||||
decrqss: DECRQSS,
|
decrqss: DECRQSS,
|
||||||
|
|
||||||
|
/// Tmux control mode
|
||||||
|
tmux: Tmux,
|
||||||
|
|
||||||
pub fn deinit(self: Command) void {
|
pub fn deinit(self: Command) void {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
.xtgettcap => |*v| v.data.deinit(),
|
.xtgettcap => |*v| v.data.deinit(),
|
||||||
.decrqss => {},
|
.decrqss => {},
|
||||||
|
.tmux => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,6 +217,12 @@ pub const Command = union(enum) {
|
|||||||
decstbm,
|
decstbm,
|
||||||
decslrm,
|
decslrm,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Tmux control mode
|
||||||
|
pub const Tmux = union(enum) {
|
||||||
|
enter: void,
|
||||||
|
exit: void,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const State = union(enum) {
|
const State = union(enum) {
|
||||||
@ -225,6 +241,9 @@ const State = union(enum) {
|
|||||||
data: [2]u8 = undefined,
|
data: [2]u8 = undefined,
|
||||||
len: u2 = 0,
|
len: u2 = 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Tmux control mode: https://github.com/tmux/tmux/wiki/Control-Mode
|
||||||
|
tmux: void,
|
||||||
};
|
};
|
||||||
|
|
||||||
test "unknown DCS command" {
|
test "unknown DCS command" {
|
||||||
|
@ -1880,6 +1880,11 @@ const StreamHandler = struct {
|
|||||||
fn dcsCommand(self: *StreamHandler, cmd: *terminal.dcs.Command) !void {
|
fn dcsCommand(self: *StreamHandler, cmd: *terminal.dcs.Command) !void {
|
||||||
// log.warn("DCS command: {}", .{cmd});
|
// log.warn("DCS command: {}", .{cmd});
|
||||||
switch (cmd.*) {
|
switch (cmd.*) {
|
||||||
|
.tmux => |tmux| {
|
||||||
|
// TODO: process it
|
||||||
|
log.warn("tmux control mode event unimplemented cmd={}", .{tmux});
|
||||||
|
},
|
||||||
|
|
||||||
.xtgettcap => |*gettcap| {
|
.xtgettcap => |*gettcap| {
|
||||||
const map = comptime terminfo.ghostty.xtgettcapMap();
|
const map = comptime terminfo.ghostty.xtgettcapMap();
|
||||||
while (gettcap.next()) |key| {
|
while (gettcap.next()) |key| {
|
||||||
@ -1887,6 +1892,7 @@ const StreamHandler = struct {
|
|||||||
self.messageWriter(.{ .write_stable = response });
|
self.messageWriter(.{ .write_stable = response });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
.decrqss => |decrqss| {
|
.decrqss => |decrqss| {
|
||||||
var response: [128]u8 = undefined;
|
var response: [128]u8 = undefined;
|
||||||
var stream = std.io.fixedBufferStream(&response);
|
var stream = std.io.fixedBufferStream(&response);
|
||||||
|
Reference in New Issue
Block a user