summaryrefslogtreecommitdiff
path: root/src/terminal.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/terminal.zig')
-rw-r--r--src/terminal.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/terminal.zig b/src/terminal.zig
index af540202..4cdfa52d 100644
--- a/src/terminal.zig
+++ b/src/terminal.zig
@@ -380,6 +380,21 @@ pub fn reportsMouse(pane: *const Pane) bool {
return state.vt.flags.mouse_event != .none;
}
+/// A paste as xterm makes one (ghostty's encoder): the control bytes a
+/// paste could smuggle a command in by (ESC, so no ESC[201~ can end
+/// 2004's brackets early, NUL, ^C and the rest of xterm's list) become
+/// spaces, then the text goes inside the brackets when the program set
+/// 2004, else with its newlines as Returns. `text` is rewritten in place.
+pub fn encodePaste(pane: *const Pane, text: []u8) [3][]const u8 {
+ if (comptime !enabled) {
+ for (text) |*ch| if (ch.* == '\n') {
+ ch.* = '\r';
+ };
+ return .{ "", text, "" };
+ }
+ return ghostty_vt.input.encodePaste(text, .{ .bracketed = bracketedPaste(pane) });
+}
+
/// DECSET 1004: the program wants to hear when it gains and loses focus.
pub fn reportsFocus(pane: *const Pane) bool {
if (comptime !enabled) return false;