summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiorgio Gallo <giorgio.gallo@bitnic.it>2018-01-07 18:38:16 +0100
committerJoe Wilm <jwilm@users.noreply.github.com>2018-01-07 13:11:46 -0800
commitc93d2b1a2d9332bd0c477997d108ba8e9e84ca9c (patch)
treeeaa7fb1d59b108943a507b3de48689681e469063
parentbb3da150de0b63fce3b3f329f60f428ce469d537 (diff)
Non-bracketed paste support for DOS CRLFs.
When pasting in non-bracketed more, all line endings (including DOS-style CRLFs) get normalized to a single CR to simulate a keypress of the <return> key.
-rw-r--r--src/input.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/input.rs b/src/input.rs
index ff9b7b03..ff1eb796 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -240,7 +240,13 @@ impl Action {
ctx.write_to_pty(contents.into_bytes());
ctx.write_to_pty(&b"\x1b[201~"[..]);
} else {
- ctx.write_to_pty(contents.replace("\n","\r").into_bytes());
+ // In non-bracketed (ie: normal) mode, terminal applications cannot distinguish
+ // pasted data from keystrokes.
+ // In theory, we should construct the keystrokes needed to produce the data we are
+ // pasting... since that's neither practical nor sensible (and probably an impossible
+ // task to solve in a general way), we'll just replace line breaks (windows and unix
+ // style) with a singe carriage return (\r, which is what the Enter key produces).
+ ctx.write_to_pty(contents.replace("\r\n","\r").replace("\n","\r").into_bytes());
}
}
}