terminal icon indicating copy to clipboard operation
terminal copied to clipboard

`sendInput` should be previewable

Open zadjii-msft opened this issue 3 years ago • 2 comments

See #9818, 60f63b09cc59f1a46d142952f49dbf7599bc4cf8, #3121. I literally have this prototyped, just need to check it in. It's important for future issues...

zadjii-msft avatar Apr 08 '22 16:04 zadjii-msft

More cleanly pulled to its own branch: https://github.com/microsoft/terminal/pull/new/dev/migrie/f/12861-preview-input

Note: You'll also want the backspace trimming thing. That merged into TSFControl in 0f32692 but I don't know where its origin was before that.


    void TSFInputControl::ManuallyDisplayText(const winrt::hstring& text)
    {
        _focused = !text.empty();
        Canvas().Visibility(text.empty() ? Visibility::Collapsed : Visibility::Visible);

        _inputBuffer.clear();
        // _editContext.NotifyFocusLeave();
        _activeTextStart = 0;
        _inComposition = false;

        // HACK trim off leading DEL chars.
        std::wstring_view view{ text.c_str() };
        const auto strBegin = view.find_first_not_of(L"\x7f");
        if (strBegin != std::wstring::npos)
        {
            view = view.substr(strBegin * 2);
        }

        TextBlock().Text(winrt::hstring{ view });
        TextBlock().UpdateLayout();
        TryRedrawCanvas();
    }

zadjii-msft avatar Apr 29 '22 11:04 zadjii-msft

Curious how this will handle sendInputd escape sequences!

DHowett avatar Jun 29 '22 19:06 DHowett

Protip, revert 7c3fd2aeecf57d0320ff915d7c8c68e10acb1763

I backed it out because it:

  • worked wacky with wide glyphs / unicode surrogates and the backspacing code
  • the backspacing code was hacky kinda always
  • it didn't always scale and offset to the correct position
  • didn't really handle line wrapping well
  • with the pwsh ghost text, was very confusing

you may also need 8f0b6f8a2

zadjii-msft avatar Aug 08 '23 11:08 zadjii-msft

Punting out of 1.19. This was wacky as-is. We may want to come back to re-try this with more runway.

zadjii-msft avatar Aug 17 '23 21:08 zadjii-msft