Skip to content

Commit

Permalink
Handle the BEL, BS, TAB, and CR control characters in the OutputState…
Browse files Browse the repository at this point in the history
…Machine.
  • Loading branch information
j4james committed Jan 9, 2020
1 parent 0feb68d commit f7c2480
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/terminal/parser/OutputStateMachineEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,38 @@ ITermDispatch& OutputStateMachineEngine::Dispatch() noexcept
// - true iff we successfully dispatched the sequence.
bool OutputStateMachineEngine::ActionExecute(const wchar_t wch)
{
// microsoft/terminal#1825 - VT applications expect to be able to write NUL
// and have _nothing_ happen. Filter the NULs here, so they don't fill the
// buffer with empty spaces.
if (wch == AsciiChars::NUL)
{
return true;
}

_dispatch->Execute(wch);
_ClearLastChar();

if (wch == AsciiChars::BEL)
switch (wch)
{
case AsciiChars::NUL:
// microsoft/terminal#1825 - VT applications expect to be able to write NUL
// and have _nothing_ happen. Filter the NULs here, so they don't fill the
// buffer with empty spaces.
break;
case AsciiChars::BEL:
_dispatch->WarningBell();
// microsoft/terminal#2952
// If we're attached to a terminal, let's also pass the BEL through.
if (_pfnFlushToTerminal != nullptr)
{
_pfnFlushToTerminal();
}
break;
case AsciiChars::BS:
_dispatch->CursorBackward(1);
break;
case AsciiChars::TAB:
_dispatch->ForwardTab(1);
break;
case AsciiChars::CR:
_dispatch->CarriageReturn();
break;
default:
_dispatch->Execute(wch);
break;
}

_ClearLastChar();

return true;
}

Expand Down

0 comments on commit f7c2480

Please sign in to comment.