-
Notifications
You must be signed in to change notification settings - Fork 9k
Add support for focusPane action, focus-pane subcommand
#10142
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
97c9213
Accidentally the whole thing. `wtd -w 0 fp -t 1 ; sp` doesn't seem to…
zadjii-msft e6ed505
Fix this specific scenario
zadjii-msft 8bba2e4
Tests, tests are good
zadjii-msft 103091d
schema schmema
zadjii-msft 6623fbb
Merge remote-tracking branch 'origin/main' into dev/migrie/f/focus-pane
zadjii-msft 408eeb9
fricken VS and it's dumb resw rules
zadjii-msft 31b823a
This would be a merge conflict
zadjii-msft 0ceee82
Apply suggestions from code review
DHowett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -597,18 +597,25 @@ void Pane::_FocusFirstChild() | |
| { | ||
| if (_IsLeaf()) | ||
| { | ||
| if (_root.ActualWidth() == 0 && _root.ActualHeight() == 0) | ||
| { | ||
| // When these sizes are 0, then the pane might still be in startup, | ||
| // and doesn't yet have a real size. In that case, the control.Focus | ||
| // event won't be handled until _after_ the startup events are all | ||
| // processed. This will lead to the Tab not being notified that the | ||
| // focus moved to a different Pane. | ||
| // | ||
| // In that scenario, trigger the event manually here, to correctly | ||
| // inform the Tab that we're now focused. | ||
| _GotFocusHandlers(shared_from_this()); | ||
| } | ||
| // Originally, we would only raise a GotFocus event here when: | ||
| // | ||
| // if (_root.ActualWidth() == 0 && _root.ActualHeight() == 0) | ||
| // | ||
| // When these sizes are 0, then the pane might still be in startup, | ||
| // and doesn't yet have a real size. In that case, the control.Focus | ||
| // event won't be handled until _after_ the startup events are all | ||
| // processed. This will lead to the Tab not being notified that the | ||
| // focus moved to a different Pane. | ||
| // | ||
| // However, with the ability to execute multiple actions at a time, in | ||
| // already existing windows, we need to always raise this event manually | ||
| // here, to correctly inform the Tab that we're now focused. This will | ||
| // take care of commandlines like: | ||
| // | ||
| // `wtd -w 0 mf down ; sp` | ||
| // `wtd -w 0 fp -t 1 ; sp` | ||
|
|
||
| _GotFocusHandlers(shared_from_this()); | ||
|
|
||
| _control.Focus(FocusState::Programmatic); | ||
| } | ||
|
|
@@ -1564,7 +1571,7 @@ void Pane::Restore(std::shared_ptr<Pane> zoomedPane) | |
| // otherwise the ID value will not make sense (leaves have IDs, parents do not) | ||
| // Return Value: | ||
| // - The ID of this pane | ||
| std::optional<uint16_t> Pane::Id() noexcept | ||
| std::optional<uint32_t> Pane::Id() noexcept | ||
| { | ||
| return _id; | ||
| } | ||
|
|
@@ -1574,7 +1581,7 @@ std::optional<uint16_t> Pane::Id() noexcept | |
| // - Panes are given IDs upon creation by TerminalTab | ||
| // Arguments: | ||
| // - The number to set this pane's ID to | ||
| void Pane::Id(uint16_t id) noexcept | ||
| void Pane::Id(uint32_t id) noexcept | ||
| { | ||
| _id = id; | ||
| } | ||
|
|
@@ -1583,20 +1590,24 @@ void Pane::Id(uint16_t id) noexcept | |
| // - Recursive function that focuses a pane with the given ID | ||
| // Arguments: | ||
| // - The ID of the pane we want to focus | ||
| void Pane::FocusPane(const uint16_t id) | ||
| bool Pane::FocusPane(const uint32_t id) | ||
| { | ||
| if (_IsLeaf() && id == _id) | ||
| { | ||
| _control.Focus(FocusState::Programmatic); | ||
| // Make sure to use _FocusFirstChild here - that'll properly update the | ||
| // focus if we're in startup. | ||
| _FocusFirstChild(); | ||
| return true; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this returns, you don't need the |
||
| } | ||
| else | ||
| { | ||
| if (_firstChild && _secondChild) | ||
| { | ||
| _firstChild->FocusPane(id); | ||
| _secondChild->FocusPane(id); | ||
| return _firstChild->FocusPane(id) || | ||
| _secondChild->FocusPane(id); | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| // Method Description: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.