mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
bracketed paste
This commit is contained in:
@ -90,6 +90,9 @@ bg_g: f32,
|
|||||||
bg_b: f32,
|
bg_b: f32,
|
||||||
bg_a: f32,
|
bg_a: f32,
|
||||||
|
|
||||||
|
/// Bracketed paste mode
|
||||||
|
bracketed_paste: bool = false,
|
||||||
|
|
||||||
/// Create a new window. This allocates and returns a pointer because we
|
/// Create a new window. This allocates and returns a pointer because we
|
||||||
/// need a stable pointer for user data callbacks. Therefore, a stack-only
|
/// need a stable pointer for user data callbacks. Therefore, a stack-only
|
||||||
/// initialization is not currently possible.
|
/// initialization is not currently possible.
|
||||||
@ -390,8 +393,11 @@ fn keyCallback(
|
|||||||
|
|
||||||
if (data.len > 0) {
|
if (data.len > 0) {
|
||||||
const win = window.getUserPointer(Window) orelse return;
|
const win = window.getUserPointer(Window) orelse return;
|
||||||
|
|
||||||
|
if (win.bracketed_paste) win.queueWrite("\x1B[200~") catch unreachable;
|
||||||
win.queueWrite(data) catch |err|
|
win.queueWrite(data) catch |err|
|
||||||
log.warn("error pasting clipboard: {}", .{err});
|
log.warn("error pasting clipboard: {}", .{err});
|
||||||
|
if (win.bracketed_paste) win.queueWrite("\x1B[201~") catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -677,6 +683,8 @@ pub fn setMode(self: *Window, mode: terminal.Mode, enabled: bool) !void {
|
|||||||
unreachable; // TODO: implement
|
unreachable; // TODO: implement
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.bracketed_paste => self.bracketed_paste = true,
|
||||||
|
|
||||||
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
|
else => if (enabled) log.warn("unimplemented mode: {}", .{mode}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,14 @@ pub const Mode = enum(u16) {
|
|||||||
/// the current scroll region.
|
/// the current scroll region.
|
||||||
origin = 6,
|
origin = 6,
|
||||||
|
|
||||||
|
/// Bracket clipboard paste contents in delimiter sequences.
|
||||||
|
///
|
||||||
|
/// When pasting from the (e.g. system) clipboard add "ESC [ 2 0 0 ~"
|
||||||
|
/// before the clipboard contents and "ESC [ 2 0 1 ~" after the clipboard
|
||||||
|
/// contents. This allows applications to distinguish clipboard contents
|
||||||
|
/// from manually typed text.
|
||||||
|
bracketed_paste = 2004,
|
||||||
|
|
||||||
// Non-exhaustive so that @intToEnum never fails for unsupported modes.
|
// Non-exhaustive so that @intToEnum never fails for unsupported modes.
|
||||||
_,
|
_,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user