Repository: microsoft/terminal
File: src/terminal/adapter/adaptDispatch.cpp (C++)

Code before:
}

//Routine Description:
// Enable Any Event mode - send all mouse events to the input.
//Arguments:
// - enabled - true to enable, false to disable.
// Return value:
// True if handled successfully. False otherwise.
bool AdaptDispatch::EnableAnyEventMouseMode(const bool enabled)
{
    return _pConApi->SetInputMode(TerminalInput::Mode::AnyEventMouseTracking, enabled);
}

// Method Description:
// - Enables/disables focus event mode. A client may enable this if they want to
//   receive focus events.
// - ConPTY always enables this mode and never disables it. Internally, we'll
//   always set this mode, but conpty will never request this to be disabled by
//   the hosting terminal.
// Arguments:
// - enabled - true to enable, false to disable.
// Return Value:
// - True if handled successfully. False otherwise.
bool AdaptDispatch::EnableFocusEventMode(const bool enabled)
{
    return _pConApi->SetInputMode(TerminalInput::Mode::FocusEvent, enabled);
}

//Routine Description:
// Enable Alternate Scroll Mode - When in the Alt Buffer, send CUP and CUD on
//      scroll up/down events instead of the usual sequences
//Arguments:
// - enabled - true to enable, false to disable.
// Return value:
// True if handled successfully. False otherwise.
bool AdaptDispatch::EnableAlternateScroll(const bool enabled)
{
    return _pConApi->SetInputMode(TerminalInput::Mode::AlternateScroll, enabled);
}

//Routine Description:
// Enable "bracketed paste mode".
//Arguments:
// - enabled - true to enable, false to disable.
// Return value:
// True if handled successfully. False otherwise.
bool AdaptDispatch::EnableXtermBracketedPasteMode(const bool /*enabled*/) noexcept
{
    return NoOp();
}


Review comment (suggestion):
As mentioned above, `SetInputMode` has gone from the congetset api now, so this will need to change to a `_SetInputMode` call.

Code after:
//   viewport is always at the bottom. So, we can accomplish the same behavior
//   by using the LastNonspaceCharacter as the "bottom", and placing the new
//   viewport underneath that character.
// Arguments:
// - <none>
// Return value:
// - <none>
void AdaptDispatch::_EraseAll()
{
    const auto viewport = _pConApi->GetViewport();
    const auto viewportHeight = gsl::narrow_cast<short>(viewport.bottom - viewport.top);
    auto& textBuffer = _pConApi->GetTextBuffer();
    const auto bufferSize = textBuffer.GetSize();

    // Stash away the current position of the cursor within the viewport.
    // We'll need to restore the cursor to that same relative position, after
    //      we move the viewport.
    auto& cursor = textBuffer.GetCursor();
    const auto row = cursor.GetPosition().Y - viewport.top;

    // Calculate new viewport position
    short newViewportTop = textBuffer.GetLastNonSpaceCharacter().Y + 1;
    const short newViewportBottom = newViewportTop + viewportHeight;
    const auto delta = newViewportBottom - (bufferSize.Height());
    for (auto i = 0; i < delta; i++)
    {
        textBuffer.IncrementCircularBuffer();
        newViewportTop--;
    }
    // Move the viewport
    _pConApi->SetViewportPosition({ viewport.left, newViewportTop });
    // Restore the relative cursor position
    cursor.SetYPosition(row + newViewportTop);
    cursor.SetHasMoved(true);

    // Erase all the rows in the current viewport.
    auto eraseAttributes = textBuffer.GetCurrentAttributes();
    eraseAttributes.SetStandardErase();
    _FillRect(textBuffer, { 0, newViewportTop, bufferSize.Width(), newViewportBottom }, L' ', eraseAttributes);

    // Also reset the line rendition for the erased rows.
    textBuffer.ResetLineRenditionRange(newViewportTop, newViewportBottom);
}

// Routine Description:
// - Enables or disables support for the DECCOLM escape sequence.
// Arguments:
// - enabled - set to true to allow DECCOLM to be used, false to disallow.
// Return Value:
// - True.
bool AdaptDispatch::EnableDECCOLMSupport(const bool enabled) noexcept