terminal/src/cascadia/TerminalApp/ActionArgs.h
Mike Griese 734fc1dcc6 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.
2019-08-16 15:43:51 -07:00

70 lines
2.2 KiB
C++

// 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);
}