Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modifyOtherKeys state 2 should send sequences for all chars #286

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ pub fn charCallback(
// Critical area
const critical: struct {
alt_esc_prefix: bool,
modify_other_keys: bool,
} = critical: {
self.renderer_state.mutex.lock();
defer self.renderer_state.mutex.unlock();
Expand All @@ -1024,11 +1025,38 @@ pub fn charCallback(

break :critical .{
.alt_esc_prefix = self.io.terminal.modes.alt_esc_prefix,
.modify_other_keys = self.io.terminal.modes.modify_other_keys,
};
};

// Where we're going to write any data. Any data we write has to
// fit into the fixed size array so we just define it up front.
var data: termio.Message.WriteReq.Small.Array = undefined;

// In modify other keys state 2, we send the CSI 27 sequence
// for any char with a modifier. Ctrl sequences like Ctrl+A
// are handled in keyCallback and should never have reached this
// point.
if (critical.modify_other_keys and !mods.empty()) {
for (input.function_keys.modifiers, 2..) |modset, code| {
if (!mods.equal(modset)) continue;

const resp = try std.fmt.bufPrint(
&data,
"\x1B[27;{};{}~",
.{ code, codepoint },
);
_ = self.io_thread.mailbox.push(.{
.write_small = .{
.data = data,
.len = @intCast(resp.len),
},
}, .{ .forever = {} });
try self.io_thread.wakeup.notify();
return;
}
}

// Prefix our data with ESC if we have alt pressed.
var i: u8 = 0;
if (mods.alt) alt: {
Expand Down