mirror of
https://github.com/nix-community/nix-on-droid-app.git
synced 2025-11-08 19:46:10 +01:00
Replace \n with \r when pasting (Fixes #678)
Termux will now properly send \r to the terminal instead of \n when pasting
multiline strings.
This fixes cat not repeating back lines and nano accidentally justifying
text (because \n maps to ^J), as well as other potential issues.
This matches the behavior of other terminals, such as iTerm2 which explicitly
does it here:
f8a5930/sources/iTermPasteHelper.m (L113)
Signed-off-by: easyaspi314 (Devin) <easyaspi314@users.noreply.github.com>
This commit is contained in:
parent
80c81b274d
commit
be6a73d862
1 changed files with 3 additions and 0 deletions
|
|
@ -2338,6 +2338,9 @@ public final class TerminalEmulator {
|
|||
public void paste(String text) {
|
||||
// First: Always remove escape key and C1 control characters [0x80,0x9F]:
|
||||
text = text.replaceAll("(\u001B|[\u0080-\u009F])", "");
|
||||
// Second: Replace all newlines (\n) with carriage returns (\r).
|
||||
text = text.replace('\n', '\r');
|
||||
|
||||
// Then: Implement bracketed paste mode if enabled:
|
||||
boolean bracketed = isDecsetInternalBitSet(DECSET_BIT_BRACKETED_PASTE_MODE);
|
||||
if (bracketed) mSession.write("\033[200~");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue