Accept CR as an alias for LF to support more platforms #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The enter key will usually end the line with a
\n
(LF) character on most Unix platforms. Common terminals also accept the ^M (CR) key in place of the ^J (LF) key.By now allowing CR as an alias for LF in this library, we can significantly improve compatibility with this common usage pattern and improve platform support. In particular, some platforms use different TTY settings (
icrnl
,igncr
and family) and depending on these settings emit different EOL characters. This fixes issues where enter was not properly detected when usingext-readline
on Mac OS X, Android and others.Note that Windows technically uses
\r\n
(CRLF), but this platform is not supported at the moment anyway (#18). I've actually implemented logic to ensure CRLF is only handled as a single line, but reverted this for the PR because this does not seem to be implemented in common terminals either (echo -en "\r\n" | bash -i
shows two independent lines and both ^J and ^M show a\n
inhd
).Resolves / closes #66
Resolves / closes #77
Supersedes #73