move bracketed paste to terminal state

This commit is contained in:
Mitchell Hashimoto
2022-11-05 17:04:24 -07:00
parent 57b4c73bb2
commit a05b08fdc7
3 changed files with 11 additions and 9 deletions

View File

@ -80,9 +80,6 @@ grid_size: renderer.GridSize,
/// The app configuration
config: *const Config,
/// Bracketed paste mode
bracketed_paste: bool = false,
/// Set to true for a single GLFW key/char callback cycle to cause the
/// char callback to ignore. GLFW seems to always do key followed by char
/// callbacks so we abuse that here. This is to solve an issue where commands
@ -807,7 +804,13 @@ fn keyCallback(
};
if (data.len > 0) {
if (win.bracketed_paste) {
const bracketed = bracketed: {
win.renderer_state.mutex.lock();
defer win.renderer_state.mutex.unlock();
break :bracketed win.renderer_state.terminal.modes.bracketed_paste;
};
if (bracketed) {
_ = win.io_thread.mailbox.push(.{
.write_stable = "\x1B[200~",
}, .{ .forever = {} });
@ -818,7 +821,7 @@ fn keyCallback(
.write_stable = data,
}, .{ .forever = {} });
if (win.bracketed_paste) {
if (bracketed) {
_ = win.io_thread.mailbox.push(.{
.write_stable = "\x1B[201~",
}, .{ .forever = {} });

View File

@ -75,6 +75,8 @@ modes: packed struct {
mouse_event: MouseEvents = .none,
mouse_format: MouseFormat = .x10,
bracketed_paste: bool = false, // 2004
test {
// We have this here so that we explicitly fail when we change the
// size of modes. The size of modes is NOT particularly important,

View File

@ -399,9 +399,6 @@ const StreamHandler = struct {
grid_size: *renderer.GridSize,
terminal: *terminal.Terminal,
/// Bracketed paste mode
bracketed_paste: bool = false,
inline fn queueRender(self: *StreamHandler) !void {
try self.ev.queueRender();
}
@ -559,7 +556,7 @@ const StreamHandler = struct {
try self.queueRender();
},
.bracketed_paste => self.bracketed_paste = true,
.bracketed_paste => self.terminal.modes.bracketed_paste = enabled,
.enable_mode_3 => {
// Disable deccolm