mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
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.
This commit is contained in:
parent
bb3da150de
commit
c93d2b1a2d
1 changed files with 7 additions and 1 deletions
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue