Skip to content
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

Advanced Tab Switcher #6732

Merged
64 commits merged into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b43e32b
lets take it all and move it here
leonMSFT Jun 30, 2020
f3b0106
explicitly set command palette mode on handler call
leonMSFT Jul 1, 2020
c7e1f0d
change TerminalApp::AnchorKey to VirtualKey
leonMSFT Jul 1, 2020
b5e2c77
a couple of comments, fixing ordering once again
leonMSFT Jul 6, 2020
fbff9cf
lets hardcode shift as the 'backwards' modifier key for now
leonMSFT Jul 6, 2020
8824323
ok well i have icons now but it crash but that's progress right
leonMSFT Jul 6, 2020
4414bfe
on second thought i'm going to leave this icon thing for later
leonMSFT Jul 7, 2020
83884c0
resolving merge conflicts from master
leonMSFT Jul 8, 2020
5462e36
yeah just casually miss a whole file when merging
leonMSFT Jul 8, 2020
cd828f1
reverting some stuff that shouldn't have changed
leonMSFT Jul 8, 2020
9d527a6
try and try again
leonMSFT Jul 8, 2020
33cfc86
pls
leonMSFT Jul 8, 2020
87a8174
fix the ordering when filtering
leonMSFT Jul 8, 2020
a204667
added observables to both Command and Tab
leonMSFT Jul 8, 2020
2b17953
adding default font icons to commands with no specified icons, added …
leonMSFT Jul 9, 2020
f57ce5c
convert iconstring to iconsource
leonMSFT Jul 10, 2020
9128fd9
steal griese's commandsToFilter function huehue
leonMSFT Jul 10, 2020
438f70f
remove iconpath from tab, update comments
leonMSFT Jul 10, 2020
15f7bc2
remove my converter :cry:
leonMSFT Jul 10, 2020
fa6301a
begone
leonMSFT Jul 10, 2020
bf141c6
disable anchored tab switcher from the command palette
leonMSFT Jul 14, 2020
e581b6e
add a modeswitch function to change up the xaml elements based on the…
leonMSFT Jul 15, 2020
68b99c1
placeholder text and no matches text bound
leonMSFT Jul 15, 2020
39bfa80
silly ol' me forget to inherit INotifyPropertyChanged :cry:
leonMSFT Jul 15, 2020
3df76b8
just move things around so that the tab switcher toggle gets the last…
leonMSFT Jul 15, 2020
84f2603
Merge branch 'master' into dev/lelian/ats-take2
leonMSFT Jul 15, 2020
864cbf1
selected index should start at focused index + 1
leonMSFT Jul 16, 2020
78cccc7
i see the light
leonMSFT Jul 16, 2020
3befe9a
updating schema
leonMSFT Jul 17, 2020
e8d017c
whoops didn't mean for that one line to go in heheheh
leonMSFT Jul 17, 2020
e3ede3b
whoops forgot to change the arg name
leonMSFT Jul 17, 2020
adcd8e1
pit pat formatting
leonMSFT Jul 17, 2020
2bab5fa
formatting plso
leonMSFT Jul 17, 2020
3da267f
the one that ran away
leonMSFT Jul 17, 2020
cf0489c
merge from master'
leonMSFT Jul 17, 2020
7a4d3f3
conflicts like you've never seen
leonMSFT Jul 17, 2020
fc5a34e
pls
leonMSFT Jul 17, 2020
dc4eb42
PR Comments: update comments, remove default icon for commands
leonMSFT Jul 20, 2020
cd836f5
i absolutely despise data bindings tbh
leonMSFT Jul 21, 2020
4fa8d58
allow the PQ to sort by 'insertion order' when weights and names are …
leonMSFT Jul 21, 2020
ddf2e13
remove the fallback generated name to make sure only one 'toggle tab …
leonMSFT Jul 22, 2020
2b40272
jsonutils is the best :hugs:
leonMSFT Jul 22, 2020
2dbf37a
add the ability to open the switcher with the initial action going up…
leonMSFT Jul 22, 2020
8bad8bc
in unanchored mode, initialize on the focused tab index
leonMSFT Jul 22, 2020
71dfb82
never using notepad++ again sorry vscode
leonMSFT Jul 22, 2020
91635e4
Merge branch 'master' into dev/lelian/ats-take2
leonMSFT Jul 31, 2020
a2bf95f
welp this line should definitely go a little higher
leonMSFT Aug 3, 2020
f2746f7
gut the direction for now
leonMSFT Aug 3, 2020
6e1c5a7
some smooth brained fix that just happened to work i'm annoyed
leonMSFT Aug 4, 2020
0809997
comments for followup issues
leonMSFT Aug 4, 2020
5a10c61
ffs
leonMSFT Aug 4, 2020
1f90fb1
add automationprop for ctrl name, focus listview during ats for acces…
leonMSFT Aug 5, 2020
edf1066
ffs really spellbot
leonMSFT Aug 5, 2020
a76b1cc
special detection for screen readers
leonMSFT Aug 5, 2020
e48c0e9
formatting
leonMSFT Aug 5, 2020
5113d99
thanks bot
leonMSFT Aug 5, 2020
3e2af24
pls bot
leonMSFT Aug 5, 2020
5f82064
localization, revokers, followups
leonMSFT Aug 6, 2020
1caab04
merge from master, update accessibility, on-init listview focus
leonMSFT Aug 7, 2020
8e3f74c
you get a conflict and you get a conflict and you get a con-
leonMSFT Aug 7, 2020
04fa2cf
pr comments, do the thing on the UI thread
leonMSFT Aug 10, 2020
7271bd6
merge from master
leonMSFT Aug 10, 2020
d30f8df
bot needs to go have a timeout
leonMSFT Aug 10, 2020
ec289b6
OMG SORRY ONE LAST THINGGG
leonMSFT Aug 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"wt",
"closeOtherTabs",
"closeTabsAfter",
"tabSwitcher",
"unbound"
],
"type": "string"
Expand All @@ -88,6 +89,14 @@
],
"type": "string"
},
"AnchorKey": {
"enum": [
"ctrl",
"alt",
"shift"
],
"type": "string"
},
"NewTerminalArgs": {
"properties": {
"commandline": {
Expand Down Expand Up @@ -352,6 +361,22 @@
],
"required": [ "index" ]
},
"TabSwitcherAction": {
"description": "Arguments corresponding to a Tab Switcher Action",
"allOf": [
{ "$ref": "#/definitions/ShortcutAction" },
{
"properties": {
leonMSFT marked this conversation as resolved.
Show resolved Hide resolved
"action": { "type": "string", "pattern": "tabSwitcher" },
"anchorKey": {
"$ref": "#/definitions/AnchorKey",
"default": null,
"description": "If provided, the tab switcher will stay open as long as the anchor key is held down. The anchor key should be part of the keybinding that opens the switcher."
}
}
}
]
},
"Keybinding": {
"additionalProperties": false,
"properties": {
Expand All @@ -372,6 +397,7 @@
{ "$ref": "#/definitions/WtAction" },
{ "$ref": "#/definitions/CloseOtherTabsAction" },
{ "$ref": "#/definitions/CloseTabsAfterAction" },
{ "$ref": "#/definitions/TabSwitcherAction" },
{ "type": "null" }
]
},
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalApp/ActionAndArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static constexpr std::string_view ExecuteCommandlineKey{ "wt" };
static constexpr std::string_view ToggleCommandPaletteKey{ "commandPalette" };
static constexpr std::string_view CloseOtherTabsKey{ "closeOtherTabs" };
static constexpr std::string_view CloseTabsAfterKey{ "closeTabsAfter" };
static constexpr std::string_view ToggleTabSwitcherKey{ "tabSwitcher" };

static constexpr std::string_view ActionKey{ "action" };

Expand Down Expand Up @@ -100,6 +101,7 @@ namespace winrt::TerminalApp::implementation
{ ToggleCommandPaletteKey, ShortcutAction::ToggleCommandPalette },
{ CloseOtherTabsKey, ShortcutAction::CloseOtherTabs },
{ CloseTabsAfterKey, ShortcutAction::CloseTabsAfter },
{ ToggleTabSwitcherKey, ShortcutAction::ToggleTabSwitcher },
};

using ParseResult = std::tuple<IActionArgs, std::vector<::TerminalApp::SettingsLoadWarnings>>;
Expand Down Expand Up @@ -139,6 +141,8 @@ namespace winrt::TerminalApp::implementation

{ ShortcutAction::CloseTabsAfter, winrt::TerminalApp::implementation::CloseTabsAfterArgs::FromJson },

{ ShortcutAction::ToggleTabSwitcher, winrt::TerminalApp::implementation::ToggleTabSwitcherArgs::FromJson },

{ ShortcutAction::Invalid, nullptr },
};

Expand Down
19 changes: 19 additions & 0 deletions src/cascadia/TerminalApp/ActionArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "SetTabColorArgs.g.cpp"
#include "RenameTabArgs.g.cpp"
#include "ExecuteCommandlineArgs.g.cpp"
#include "ToggleTabSwitcherArgs.g.h"

#include <LibraryResources.h>

Expand Down Expand Up @@ -303,4 +304,22 @@ namespace winrt::TerminalApp::implementation
_Index)
};
}

winrt::hstring ToggleTabSwitcherArgs::GenerateName() const
leonMSFT marked this conversation as resolved.
Show resolved Hide resolved
{
// If there's an anchor key set, don't generate a name so that
// it won't show up in the command palette. Only an unanchored
// tab switcher should be able to be toggled from the palette.
// TODO: GH#7179 - once this goes in, make sure to hide the
// anchor mode command that was given a name in settings.
if (_AnchorKey != Windows::System::VirtualKey::None)
{
return L"";
leonMSFT marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
return RS_(L"ToggleTabSwitcherCommandKey");
}
}

}
28 changes: 28 additions & 0 deletions src/cascadia/TerminalApp/ActionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "ExecuteCommandlineArgs.g.h"
#include "CloseOtherTabsArgs.g.h"
#include "CloseTabsAfterArgs.g.h"
#include "ToggleTabSwitcherArgs.g.h"

#include "../../cascadia/inc/cppwinrt_utils.h"
#include "Utils.h"
Expand Down Expand Up @@ -512,6 +513,33 @@ namespace winrt::TerminalApp::implementation
}
};

struct ToggleTabSwitcherArgs : public ToggleTabSwitcherArgsT<ToggleTabSwitcherArgs>
{
ToggleTabSwitcherArgs() = default;
GETSET_PROPERTY(Windows::System::VirtualKey, AnchorKey, Windows::System::VirtualKey::None);

static constexpr std::string_view AnchorJsonKey{ "anchorKey" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we could probably go with just anchor for the property name, though I'm sure that's a hot take

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i'm not actually sure about that one. Either one is fine with me!


public:
hstring GenerateName() const;

bool Equals(const IActionArgs& other)
{
auto otherAsUs = other.try_as<ToggleTabSwitcherArgs>();
if (otherAsUs)
{
return otherAsUs->_AnchorKey == _AnchorKey;
}
return false;
};
static FromJsonResult FromJson(const Json::Value& json)
{
// LOAD BEARING: Not using make_self here _will_ break you in the future!
auto args = winrt::make_self<ToggleTabSwitcherArgs>();
JsonUtils::GetValueForKey(json, AnchorJsonKey, args->_AnchorKey);
return { *args, {} };
}
};
}

namespace winrt::TerminalApp::factory_implementation
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalApp/ActionArgs.idl
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ namespace TerminalApp
{
UInt32 Index { get; };
};

[default_interface] runtimeclass ToggleTabSwitcherArgs : IActionArgs
{
Windows.System.VirtualKey AnchorKey { get; };
};
}
26 changes: 26 additions & 0 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ namespace winrt::TerminalApp::implementation
{
// TODO GH#6677: When we add support for commandline mode, first set the
// mode that the command palette should be in, before making it visible.
CommandPalette().EnableCommandPaletteMode();
CommandPalette().Visibility(CommandPalette().Visibility() == Visibility::Visible ?
Visibility::Collapsed :
Visibility::Visible);
Expand Down Expand Up @@ -414,6 +415,7 @@ namespace winrt::TerminalApp::implementation
actionArgs.Handled(true);
}
}

void TerminalPage::_HandleCloseTabsAfter(const IInspectable& /*sender*/,
const TerminalApp::ActionEventArgs& actionArgs)
{
Expand All @@ -436,4 +438,28 @@ namespace winrt::TerminalApp::implementation
actionArgs.Handled(true);
}
}

void TerminalPage::_HandleToggleTabSwitcher(const IInspectable& /*sender*/,
const TerminalApp::ActionEventArgs& args)
{
if (const auto& realArgs = args.ActionArgs().try_as<TerminalApp::ToggleTabSwitcherArgs>())
{
auto anchorKey = realArgs.AnchorKey();

auto opt = _GetFocusedTabIndex();
uint32_t startIdx = opt ? *opt : 0;

if (anchorKey != VirtualKey::None)
{
// TODO: GH#7178 - delta should also have the option of being -1, in the case when
// a user decides to open the tab switcher going to the prev tab.
int delta = 1;
startIdx = (startIdx + _tabs.Size() + delta) % _tabs.Size();
}

CommandPalette().EnableTabSwitcherMode(anchorKey, startIdx);
CommandPalette().Visibility(Visibility::Visible);
}
args.Handled(true);
}
}
3 changes: 3 additions & 0 deletions src/cascadia/TerminalApp/Command.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ namespace winrt::TerminalApp::implementation
static std::vector<::TerminalApp::SettingsLoadWarnings> LayerJson(std::unordered_map<winrt::hstring, winrt::TerminalApp::Command>& commands,
const Json::Value& json);

winrt::Windows::UI::Xaml::Data::INotifyPropertyChanged::PropertyChanged_revoker propertyChangedRevoker;

WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
OBSERVABLE_GETSET_PROPERTY(winrt::hstring, Name, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::TerminalApp::ActionAndArgs, Action, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::hstring, KeyChordText, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::Windows::UI::Xaml::Controls::IconSource, IconSource, _PropertyChangedHandlers, nullptr);
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/Command.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ namespace TerminalApp
String Name;
ActionAndArgs Action;
String KeyChordText;

Windows.UI.Xaml.Controls.IconSource IconSource;
}
}
Loading