terminal icon indicating copy to clipboard operation
terminal copied to clipboard

Broadcast Input ship list

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

From the 1.19.2201 Bug Bash. x-ref:

  • #2634
  • #14393
### Tasks
- [x] `toggleBroadcastInput` isn't in the default settings
- [x] The cursors forget to keep blinking if you focus each pane and then unfocus them
- [x] They don't stop blinking when you unbroadcast
- [x] Broadcast border doesn't appear when you make new panes, but they ARE broadcasted-to!
- [ ] Broadcast doesn't work if you use context menu paste
- [ ] https://github.com/microsoft/terminal/issues/16287

dev/migrie/b/15812-broadcast-nits

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

I've read the original PR like, 15 times and I cannot for the life of me find where it actually enables blinking cursors for inactive, broadcasted panes

zadjii-msft avatar Sep 05 '23 16:09 zadjii-msft

  • TermControl::_PasteCommandHandler is called for the context menu. (The same path is followed for the normal r-click paste)
    • ControlInteractivity::RequestPasteTextFromClipboard raises a PasteFromClipboard event
      • handled in TerminalPage::_PasteFromClipboardHandler
        • Calls the event's HandleClipboardData() property
          • calls to ControlInteractivity::_sendPastedTextToConnection
            • calls ControlCore::PasteText

BUT

TermControl::_pasteTextWithBroadcast is only on TermControl (while the rest of that madness occurs in TerminalPage and ControlInteractivity). GAH.


When we do a paste action (TerminalPage::_PasteText), we just have every control in the tab do a TermControl::PasteTextFromClipboard, which does a _interactivity.RequestPasteTextFromClipboard. The app is orchestrating them all asking for the clipboard contents.

zadjii-msft avatar Sep 18 '23 16:09 zadjii-msft

a dumb solution:

  • don't have the app orchestrate telling all the broadcasted-to panes ask for a paste on paste.
  • INSTEAD on ControlInteractivity::_sendPastedTextToConnection, raise a StringSent to TermControl.
    • TermControl can then check if it's got _StringSentHandlers and re-raise if needed

I feel like that's how it was originally done in an earlier form of #14393...

zadjii-msft avatar Sep 18 '23 16:09 zadjii-msft

I remember we were talking about adding an API to TermControl along the lines of WriteString(Source, String), where Source would control whether it was (1) bracketed (2) stripped of control sequences (3) etc. Like, "Pasted" strings got the configured treatment, Raw or Input or whatever strings get no treatment at all.

That would afford us the ability to add Source::Broadcast (as a flag(!)), funnel almost all inputs through WriteString, and not accidentally rebroadcast broadcast strings.

DHowett avatar Sep 18 '23 17:09 DHowett

okay something else I tried: 35aba0cdc

even simpler than before. The way this is layered:

  • TerminalPage will only be asked to look up the clipboard once
  • It will apply the paste warnings as needed. One time.
  • Then, it'll write it to the control that asked for the paste's callback.
  • The control itself will then StringSent that text to the other controls.
    • The sending control does get to do the bracketed paste thing
    • The others however just get the RawWriteString. That ends up in a non-bracketed paste
      • uhg okay, so I would need to send the source with the StringSentEventArgs. That'll pollute the tree a bit...

zadjii-msft avatar Sep 18 '23 19:09 zadjii-msft