-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for broadcasting to all panes in a tab #14393
Conversation
@@ -1190,6 +1203,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
} | |||
} | |||
|
|||
bool TermControl::BroadcastKeyEvent(const WORD vkey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally, is there a way to converge this with IDirectKeyListener
's manual key handler?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideology discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, now that I've nitted more naming concerns (with apologies; I just think that while we're doing this we might as well get it right...) I've got some deeper worries!
Does anything that inputs a whole string at once work? This includes...
- IME
- Clipboard
- Drag/drop a filename
If I had to guess, the one most likely to cause folks trouble is the clipboard. Rarely am I going to key in a long command that I wanted to send to four servers. I'm almost certainly gonna paste it.
Also, what does mouse input do? Should it do something? I imagine clicking on things that are different sizes and locations will just suck... but what about using the scroll wheel?
I guess this is where the layering discussion comes up again. Bah.
WIP, it's the EOD here
|
Notes from Teams, abridged
|
This comment has been minimized.
This comment has been minimized.
|
||
control.KeySent(events.keySentToken); | ||
control.CharSent(events.charSentToken); | ||
control.StringSent(events.stringSentToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dumb question: do we properly revoke when you move pane to tab (!) or move tab to window (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure seem to
@@ -620,7 +622,7 @@ namespace winrt::TerminalApp::implementation | |||
_nextPaneId++; | |||
} | |||
}); | |||
|
|||
pane->EnableBroadcast(_tabStatus.IsInputBroadcastActive()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the scary for me - will a pane moved into a different tab continue broadcasting to the old tab? we don't do any event hookups or unhooks here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, works like a charm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh! Can you walk me through why it works?
As a reviewer I couldn't see the machinery that kept it safe. I'd rather know that we know the code is safe than that we tested and found the behavior safe 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I know this is gonna cause you physical pain to read:
TerminalPage::_HandleMovePane
TerminalPage::_MovePane
TerminalTab::DetachPane
Pane::DetachPane
this._DetachedHandlers
-> handled in a lambda inTerminalTab::_AttachEventHandlersToPane
- revokes all our per-pane event handlers
TerminalTab::_DetachEventHandlersFromControl
- revokes per-control handlers (including these)
TerminalTab::AttachPane
- reattaches them to the new tab.
} | ||
} | ||
} | ||
|
||
void TermControl::_pasteTextWithBroadcast(const winrt::hstring& text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name really confused me - it actually ISN'T used in paste(!) but it made me double-take because we are manually broadcasting the paste event and the incoming text doesn't come back through here. Does it? Or, does it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Since I was re-requested for review) Does this have anything to do with pasting? It looks like it doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like how the control flow goes from UI to TermControl, then back up into UI, then back down into TermControl. That seems kind of unnecessary tbh. 😅 Why can't it distribute the input across all TermControls from the get-go?
But since I'm wholly unqualified to say how I'd actually do it differently (maybe this is the only way to do it?), I can't see it as an actual fault in the PR either. ✅
} | ||
} | ||
} | ||
|
||
void TermControl::_pasteTextWithBroadcast(const winrt::hstring& text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI technically you can use winrt::param::hstring
here for 0 copy string passing, but I've heard it's considered an internal API so we can't use it. 😟 (Or can we? Technically we are in control over our code... Oh well...)
Four words: XAML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I trust you that it works for moving panes around, but I would love to know why. Approved with comments -- that "paste" thing still confuses me :)
## Summary of the Pull Request Resolves the following in #15812 > - [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! ## References and Relevant Issues x-ref: * #2634 * #14393 ## Detailed Description of the Pull Request / Additional comments There was literally no logic in the original PR for starting the cursor blinking. It's entirely unknowable how that ever worked. This makes it all much more explicit. We're taking the hacky `DisplayCursorWhileBlurred` from #15363, and promoting that to the less-hacky `CursorVisibility`. Broadcast input mode can use that to force the cursor to be visible always. The last checkbox in that issue is harder, and I didn't want to further pollute this delta with the paste plumbing.
Resurrection of #9222.
Spec draft in #9365.
Consensus from community feedback is that the whole of that spec is nice to have, but what REALLY matters is just broadcasting to all the panes in a tab. So, in the interest of best serving our community, I'm pushing this out as the initial implementation, before we figure out the rest of design. Regardless of how we choose to implement the rest of the features detailed in the spec, the UX for this part of the feature remains the same.
This PR adds a new action:
toggleBroadcastInput
. Performing this action starts broadcasting to all panes in this tab. Keystrokes in one pane will be sent to all panes in the tab.An icon in the tab is used to indicate when this mode is active. Furthermore, the borders of all panes will be highlighted with
SystemAccentColorDark2
/SystemAccentColorLight2
(depending on the theme), to indicate they're also active.Co-authored-by: Don-Vito [email protected]