Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace \n with \r when pasting (Fixes #678) #712

Merged
merged 3 commits into from
Jun 13, 2018

Conversation

easyaspi314
Copy link
Contributor

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:
https://github.com/gnachman/iTerm2/blob/f8a5930/sources/iTermPasteHelper.m#L113

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:
https://github.com/gnachman/iTerm2/blob/f8a5930/sources/iTermPasteHelper.m#L113

Signed-off-by: easyaspi314 (Devin) <easyaspi314@users.noreply.github.com>
@fornwall
Copy link
Member

Thanks! Should perhaps \r\n be replaced with \r first /which the iTerm comment indicates)?

This should replace both \r\n and \n with \r now.

"\r?\n" matches 0 or 1 \r and one \n, which should capture both
escape sequences.
@easyaspi314
Copy link
Contributor Author

easyaspi314 commented Jun 13, 2018

This should do. Didn't want to build the whole thing, but I did a quick test:

String str = "\r \r\n \n";
String str2 = str.replaceAll("\r?\n", "\r");
if ("\r \r \r".equals(str2))
    System.out.println("PASS");

@fornwall fornwall merged commit ec1087d into termux:master Jun 13, 2018
@fornwall
Copy link
Member

Thanks a lot! This will be available in a v0.61 update which will be available shortly.

@fornwall
Copy link
Member

This has been fixed in version 0.61 of the app, which has now been released and should be available in Google Play within a few hours (and on F-Droid within a day or so)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants