-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't copy text if there's no selection (#2446)
This commit also transitions our keybinding events and event handlers to a TypedEventHandler model with an "event args" class, as specified in the keybinding arguments specification (#1349). In short, every event can be marked Handled independently, and a Handled event will stop bubbling out to the terminal. An unhandled event will be passed off to the terminal as a standard keypress. This unifies our keybinding event model and provides a convenient place for binding arguments to live. Fixes #2285. Related to #1349, #1142.
- Loading branch information
1 parent
c70fb49
commit 734fc1d
Showing
14 changed files
with
773 additions
and
237 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#include "pch.h" | ||
|
||
#include "ActionArgs.h" | ||
|
||
#include "ActionEventArgs.g.cpp" | ||
#include "CopyTextArgs.g.cpp" | ||
#include "NewTabWithProfileArgs.g.cpp" | ||
#include "SwitchToTabArgs.g.cpp" | ||
#include "ResizePaneArgs.g.cpp" | ||
#include "MoveFocusArgs.g.cpp" |
This file contains 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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
#pragma once | ||
|
||
// HEY YOU: When adding ActionArgs types, make sure to add the corresponding | ||
// *.g.cpp to ActionArgs.cpp! | ||
#include "ActionEventArgs.g.h" | ||
#include "CopyTextArgs.g.h" | ||
#include "NewTabWithProfileArgs.g.h" | ||
#include "SwitchToTabArgs.g.h" | ||
#include "ResizePaneArgs.g.h" | ||
#include "MoveFocusArgs.g.h" | ||
|
||
#include "../../cascadia/inc/cppwinrt_utils.h" | ||
|
||
// Notes on defining ActionArgs and ActionEventArgs: | ||
// * All properties specific to an action should be defined as an ActionArgs | ||
// class that implements IActionArgs | ||
// * ActionEventArgs holds a single IActionArgs. For events that don't need | ||
// additional args, this can be nullptr. | ||
|
||
namespace winrt::TerminalApp::implementation | ||
{ | ||
struct ActionEventArgs : public ActionEventArgsT<ActionEventArgs> | ||
{ | ||
ActionEventArgs() = default; | ||
ActionEventArgs(const TerminalApp::IActionArgs& args) : | ||
_ActionArgs{ args } {}; | ||
GETSET_PROPERTY(IActionArgs, ActionArgs, nullptr); | ||
GETSET_PROPERTY(bool, Handled, false); | ||
}; | ||
|
||
struct CopyTextArgs : public CopyTextArgsT<CopyTextArgs> | ||
{ | ||
CopyTextArgs() = default; | ||
GETSET_PROPERTY(bool, TrimWhitespace, false); | ||
}; | ||
|
||
struct NewTabWithProfileArgs : public NewTabWithProfileArgsT<NewTabWithProfileArgs> | ||
{ | ||
NewTabWithProfileArgs() = default; | ||
GETSET_PROPERTY(int32_t, ProfileIndex, 0); | ||
}; | ||
|
||
struct SwitchToTabArgs : public SwitchToTabArgsT<SwitchToTabArgs> | ||
{ | ||
SwitchToTabArgs() = default; | ||
GETSET_PROPERTY(int32_t, TabIndex, 0); | ||
}; | ||
|
||
struct ResizePaneArgs : public ResizePaneArgsT<ResizePaneArgs> | ||
{ | ||
ResizePaneArgs() = default; | ||
GETSET_PROPERTY(TerminalApp::Direction, Direction, TerminalApp::Direction::Left); | ||
}; | ||
|
||
struct MoveFocusArgs : public MoveFocusArgsT<MoveFocusArgs> | ||
{ | ||
MoveFocusArgs() = default; | ||
GETSET_PROPERTY(TerminalApp::Direction, Direction, TerminalApp::Direction::Left); | ||
}; | ||
|
||
} | ||
|
||
namespace winrt::TerminalApp::factory_implementation | ||
{ | ||
BASIC_FACTORY(ActionEventArgs); | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
|
||
namespace TerminalApp | ||
{ | ||
// An empty interface must specify an explicit [uuid] to ensure uniqueness. | ||
// We also manually have to specify a "version" attribute to make the compiler happy. | ||
[uuid("191C2BDE-1A60-4BAB-9765-D850F0EF2CAC")][version(1)] interface IActionArgs{}; | ||
|
||
interface IActionEventArgs | ||
{ | ||
Boolean Handled; | ||
IActionArgs ActionArgs { get; }; | ||
}; | ||
|
||
enum Direction | ||
{ | ||
Left = 0, | ||
Right, | ||
Up, | ||
Down | ||
}; | ||
|
||
[default_interface] runtimeclass ActionEventArgs : IActionEventArgs | ||
{ | ||
ActionEventArgs(IActionArgs args); | ||
}; | ||
|
||
[default_interface] runtimeclass CopyTextArgs : IActionArgs | ||
{ | ||
Boolean TrimWhitespace { get; }; | ||
}; | ||
|
||
[default_interface] runtimeclass NewTabWithProfileArgs : IActionArgs | ||
{ | ||
Int32 ProfileIndex { get; }; | ||
}; | ||
|
||
[default_interface] runtimeclass SwitchToTabArgs : IActionArgs | ||
{ | ||
Int32 TabIndex { get; }; | ||
}; | ||
|
||
[default_interface] runtimeclass ResizePaneArgs : IActionArgs | ||
{ | ||
Direction Direction { get; }; | ||
}; | ||
|
||
[default_interface] runtimeclass MoveFocusArgs : IActionArgs | ||
{ | ||
Direction Direction { get; }; | ||
}; | ||
|
||
} |
This file contains 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 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.