Convert \r into \n (#350)

This resolves:
https://github.com/ArthurSonzogni/FTXUI/issues/337
This commit is contained in:
Arthur Sonzogni
2022-03-04 13:23:45 +01:00
committed by GitHub
parent a254e36632
commit 3e28fd6520
3 changed files with 11 additions and 5 deletions

View File

@@ -52,7 +52,14 @@ void TerminalInputParser::Send(TerminalInputParser::Output output) {
return;
case SPECIAL:
out_->Send(Event::Special(std::move(pending_)));
// Microsoft's terminal uses a different new line character for the return
// key. This also happens with linux with the `bind` command:
// See https://github.com/ArthurSonzogni/FTXUI/issues/337
// Here, we uniformize the new line character to `\n`.
if (pending_ == "\r")
out_->Send(Event::Special("\n"));
else
out_->Send(Event::Special(std::move(pending_)));
pending_.clear();
return;