remove configurability
This commit is contained in:
parent
b13b8a7896
commit
118d1cdc02
|
@ -304,7 +304,6 @@
|
|||
"toggleSplitOrientation",
|
||||
"toggleReadOnlyMode",
|
||||
"toggleShaderEffects",
|
||||
"updateSelection",
|
||||
"wt",
|
||||
"quit",
|
||||
"unbound"
|
||||
|
@ -333,24 +332,6 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"SelectionDirection": {
|
||||
"enum": [
|
||||
"left",
|
||||
"right",
|
||||
"up",
|
||||
"down"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"SelectionMode": {
|
||||
"enum": [
|
||||
"char",
|
||||
"word",
|
||||
"view",
|
||||
"buffer"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"MoveTabDirection": {
|
||||
"enum": [
|
||||
"forward",
|
||||
|
@ -605,28 +586,6 @@
|
|||
],
|
||||
"required": [ "direction" ]
|
||||
},
|
||||
"UpdateSelectionAction": {
|
||||
"description": "Arguments corresponding to a Update Selection Action",
|
||||
"allOf": [
|
||||
{ "$ref": "#/definitions/ShortcutAction" },
|
||||
{
|
||||
"properties": {
|
||||
"action": { "type": "string", "pattern": "updateSelection" },
|
||||
"direction": {
|
||||
"$ref": "#/definitions/SelectionDirection",
|
||||
"default": "left",
|
||||
"description": "The direction to move the selection endpoint in."
|
||||
},
|
||||
"mode": {
|
||||
"$ref": "#/definitions/SelectionMode",
|
||||
"default": "cell",
|
||||
"description": "The expansion mode to move the selection endpoint by."
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": [ "direction" ]
|
||||
},
|
||||
"ResizePaneAction": {
|
||||
"description": "Arguments corresponding to a Resize Pane Action",
|
||||
"allOf": [
|
||||
|
@ -888,7 +847,7 @@
|
|||
}
|
||||
],
|
||||
"required": [ "actions" ]
|
||||
},
|
||||
},
|
||||
"CommandPaletteAction": {
|
||||
"description": "Arguments for a commandPalette action",
|
||||
"allOf": [
|
||||
|
@ -1107,7 +1066,6 @@
|
|||
{ "$ref": "#/definitions/FocusPaneAction" },
|
||||
{ "$ref": "#/definitions/GlobalSummonAction" },
|
||||
{ "$ref": "#/definitions/QuakeModeAction" },
|
||||
{ "$ref": "#/definitions/UpdateSelectionAction" },
|
||||
{ "type": "null" }
|
||||
]
|
||||
},
|
||||
|
|
|
@ -921,19 +921,4 @@ namespace winrt::TerminalApp::implementation
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalPage::_HandleUpdateSelection(const IInspectable& /*sender*/,
|
||||
const ActionEventArgs& args)
|
||||
{
|
||||
if (args)
|
||||
{
|
||||
if (const auto& realArgs = args.ActionArgs().try_as<UpdateSelectionArgs>())
|
||||
{
|
||||
if (const auto termControl{ _GetActiveControl() })
|
||||
{
|
||||
args.Handled(termControl.UpdateSelection(realArgs.Direction(), realArgs.Mode()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,38 +33,72 @@ constexpr const auto TsfRedrawInterval = std::chrono::milliseconds(100);
|
|||
// The minimum delay between updating the locations of regex patterns
|
||||
constexpr const auto UpdatePatternLocationsInterval = std::chrono::milliseconds(500);
|
||||
|
||||
static constexpr InternalSelectionDirection ConvertToInternalSelectionDirection(winrt::Microsoft::Terminal::Core::SelectionDirection dir)
|
||||
static constexpr std::optional<Terminal::SelectionDirection> ConvertVKeyToSelectionDirection(WORD vkey)
|
||||
{
|
||||
switch (dir)
|
||||
switch (vkey)
|
||||
{
|
||||
case VK_LEFT:
|
||||
case VK_HOME:
|
||||
return Terminal::SelectionDirection::Left;
|
||||
case VK_RIGHT:
|
||||
case VK_END:
|
||||
return Terminal::SelectionDirection::Right;
|
||||
case VK_UP:
|
||||
case VK_PRIOR:
|
||||
return Terminal::SelectionDirection::Up;
|
||||
case VK_DOWN:
|
||||
case VK_NEXT:
|
||||
return Terminal::SelectionDirection::Down;
|
||||
default:
|
||||
case winrt::Microsoft::Terminal::Core::SelectionDirection::Left:
|
||||
return InternalSelectionDirection::Left;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionDirection::Right:
|
||||
return InternalSelectionDirection::Right;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionDirection::Up:
|
||||
return InternalSelectionDirection::Up;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionDirection::Down:
|
||||
return InternalSelectionDirection::Down;
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr InternalSelectionExpansion ConvertToInternalSelectionExpansion(winrt::Microsoft::Terminal::Core::SelectionExpansion mode)
|
||||
static constexpr std::optional<std::tuple<Terminal::SelectionDirection, Terminal::SelectionExpansion>> ConvertKeyEventToUpdateSelectionParams(const ControlKeyStates mods, const WORD vkey)
|
||||
{
|
||||
switch (mode)
|
||||
if (mods.IsShiftPressed() && !mods.IsAltPressed())
|
||||
{
|
||||
default:
|
||||
case winrt::Microsoft::Terminal::Core::SelectionExpansion::Char:
|
||||
return InternalSelectionExpansion::Char;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionExpansion::Word:
|
||||
return InternalSelectionExpansion::Word;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionExpansion::Line:
|
||||
return InternalSelectionExpansion::Line;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionExpansion::Viewport:
|
||||
return InternalSelectionExpansion::Viewport;
|
||||
case winrt::Microsoft::Terminal::Core::SelectionExpansion::Buffer:
|
||||
return InternalSelectionExpansion::Buffer;
|
||||
if (const auto dir{ ConvertVKeyToSelectionDirection(vkey) })
|
||||
{
|
||||
if (mods.IsCtrlPressed())
|
||||
{
|
||||
switch (vkey)
|
||||
{
|
||||
case VK_LEFT:
|
||||
case VK_RIGHT:
|
||||
// Move by word
|
||||
return std::make_tuple(*dir, Terminal::SelectionExpansion::Word);
|
||||
case VK_HOME:
|
||||
case VK_END:
|
||||
// Move by buffer
|
||||
return std::make_tuple(*dir, Terminal::SelectionExpansion::Buffer);
|
||||
default:
|
||||
__fallthrough;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (vkey)
|
||||
{
|
||||
case VK_HOME:
|
||||
case VK_END:
|
||||
case VK_PRIOR:
|
||||
case VK_NEXT:
|
||||
// Move by viewport
|
||||
return std::make_tuple(*dir, Terminal::SelectionExpansion::Viewport);
|
||||
case VK_LEFT:
|
||||
case VK_RIGHT:
|
||||
case VK_UP:
|
||||
case VK_DOWN:
|
||||
// Move by character
|
||||
return std::make_tuple(*dir, Terminal::SelectionExpansion::Char);
|
||||
default:
|
||||
__fallthrough;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
@ -393,21 +427,28 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
const ControlKeyStates modifiers,
|
||||
const bool keyDown)
|
||||
{
|
||||
// When there is a selection active, escape should clear it and NOT flow through
|
||||
// to the terminal. With any other keypress, it should clear the selection AND
|
||||
// flow through to the terminal.
|
||||
// Update the selection, if it's present
|
||||
// GH#6423 - don't dismiss selection if the key that was pressed was a
|
||||
// modifier key. We'll wait for a real keystroke to dismiss the
|
||||
// GH #7395 - don't dismiss selection when taking PrintScreen
|
||||
// selection.
|
||||
// GH#8522, GH#3758 - Only dismiss the selection on key _down_. If we
|
||||
// dismiss on key up, then there's chance that we'll immediately dismiss
|
||||
// GH#8522, GH#3758 - Only modify the selection on key _down_. If we
|
||||
// modify on key up, then there's chance that we'll immediately dismiss
|
||||
// a selection created by an action bound to a keydown.
|
||||
if (HasSelection() &&
|
||||
!KeyEvent::IsModifierKey(vkey) &&
|
||||
vkey != VK_SNAPSHOT &&
|
||||
keyDown)
|
||||
{
|
||||
// try to update the selection
|
||||
if (const auto updateSlnParams{ ConvertKeyEventToUpdateSelectionParams(modifiers, vkey) })
|
||||
{
|
||||
auto lock = _terminal->LockForWriting();
|
||||
_terminal->UpdateSelection(std::get<0>(*updateSlnParams), std::get<1>(*updateSlnParams));
|
||||
_renderer->TriggerSelection();
|
||||
return true;
|
||||
}
|
||||
|
||||
// GH#8791 - don't dismiss selection if Windows key was also pressed as a key-combination.
|
||||
if (!modifiers.IsWinPressed())
|
||||
{
|
||||
|
@ -415,6 +456,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_renderer->TriggerSelection();
|
||||
}
|
||||
|
||||
// When there is a selection active, escape should clear it and NOT flow through
|
||||
// to the terminal. With any other keypress, it should clear the selection AND
|
||||
// flow through to the terminal.
|
||||
if (vkey == VK_ESCAPE)
|
||||
{
|
||||
return true;
|
||||
|
@ -961,21 +1005,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_renderer->TriggerSelection();
|
||||
}
|
||||
|
||||
bool ControlCore::UpdateSelection(Core::SelectionDirection direction, Core::SelectionExpansion mode)
|
||||
{
|
||||
// - SelectionDirection cannot be none
|
||||
// - A selection must be active for us to update it
|
||||
if (direction == Core::SelectionDirection::None || !HasSelection())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
auto lock = _terminal->LockForWriting();
|
||||
_terminal->UpdateSelection(ConvertToInternalSelectionDirection(direction), ConvertToInternalSelectionExpansion(mode));
|
||||
_renderer->TriggerSelection();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Called when the Terminal wants to set something to the clipboard, i.e.
|
||||
// when an OSC 52 is emitted.
|
||||
void ControlCore::_terminalCopyToClipboard(std::wstring_view wstr)
|
||||
|
@ -1471,18 +1500,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// handle ALT key
|
||||
_terminal->SetBlockSelection(altEnabled);
|
||||
|
||||
Core::SelectionExpansion mode = Core::SelectionExpansion::Char;
|
||||
::Terminal::SelectionExpansion mode = ::Terminal::SelectionExpansion::Char;
|
||||
if (numberOfClicks == 1)
|
||||
{
|
||||
mode = Core::SelectionExpansion::Char;
|
||||
mode = ::Terminal::SelectionExpansion::Char;
|
||||
}
|
||||
else if (numberOfClicks == 2)
|
||||
{
|
||||
mode = Core::SelectionExpansion::Word;
|
||||
mode = ::Terminal::SelectionExpansion::Word;
|
||||
}
|
||||
else if (numberOfClicks == 3)
|
||||
{
|
||||
mode = Core::SelectionExpansion::Line;
|
||||
mode = ::Terminal::SelectionExpansion::Line;
|
||||
}
|
||||
|
||||
// Update the selection appropriately
|
||||
|
@ -1504,15 +1533,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
// If shift is pressed and there is a selection we extend it using
|
||||
// the selection mode (expand the "end" selection point)
|
||||
_terminal->SetSelectionEnd(terminalPosition, ConvertToInternalSelectionExpansion(mode));
|
||||
_terminal->SetSelectionEnd(terminalPosition, mode);
|
||||
selectionNeedsToBeCopied = true;
|
||||
}
|
||||
else if (mode != Core::SelectionExpansion::Char || shiftEnabled)
|
||||
else if (mode != ::Terminal::SelectionExpansion::Char || shiftEnabled)
|
||||
{
|
||||
// If we are handling a double / triple-click or shift+single click
|
||||
// we establish selection using the selected mode
|
||||
// (expand both "start" and "end" selection points)
|
||||
_terminal->MultiClickSelection(terminalPosition, ConvertToInternalSelectionExpansion(mode));
|
||||
_terminal->MultiClickSelection(terminalPosition, mode);
|
||||
selectionNeedsToBeCopied = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
Windows::Foundation::Collections::IVector<winrt::hstring> SelectedText(bool trimTrailingWhitespace) const;
|
||||
void SetSelectionAnchor(til::point const& position);
|
||||
void SetEndSelectionPoint(til::point const& position);
|
||||
bool UpdateSelection(Core::SelectionDirection direction, Core::SelectionExpansion mode);
|
||||
|
||||
void Search(const winrt::hstring& text,
|
||||
const bool goForward,
|
||||
|
|
|
@ -80,7 +80,6 @@ namespace Microsoft.Terminal.Control
|
|||
|
||||
Boolean HasSelection { get; };
|
||||
IVector<String> SelectedText(Boolean trimTrailingWhitespace);
|
||||
Boolean UpdateSelection(Microsoft.Terminal.Core.SelectionDirection direction, Microsoft.Terminal.Core.SelectionExpansion mode);
|
||||
|
||||
String HoveredUriText { get; };
|
||||
Windows.Foundation.IReference<Microsoft.Terminal.Core.Point> HoveredCell { get; };
|
||||
|
|
|
@ -2577,9 +2577,4 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
return _core.ReadEntireBuffer();
|
||||
}
|
||||
|
||||
bool TermControl::UpdateSelection(Core::SelectionDirection direction, Core::SelectionExpansion mode)
|
||||
{
|
||||
return _core.UpdateSelection(direction, mode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
hstring GetProfileName() const;
|
||||
|
||||
bool UpdateSelection(Core::SelectionDirection direction, Core::SelectionExpansion mode);
|
||||
bool CopySelectionToClipboard(bool singleLine, const Windows::Foundation::IReference<CopyFormat>& formats);
|
||||
void PasteTextFromClipboard();
|
||||
void Close();
|
||||
|
|
|
@ -45,7 +45,6 @@ namespace Microsoft.Terminal.Control
|
|||
// We expose this and ConnectionState here so that it might eventually be data bound.
|
||||
event Windows.Foundation.TypedEventHandler<Object, IInspectable> ConnectionStateChanged;
|
||||
|
||||
Boolean UpdateSelection(Microsoft.Terminal.Core.SelectionDirection direction, Microsoft.Terminal.Core.SelectionExpansion mode);
|
||||
Boolean CopySelectionToClipboard(Boolean singleLine, Windows.Foundation.IReference<CopyFormat> formats);
|
||||
void PasteTextFromClipboard();
|
||||
void ClearBuffer(ClearBufferType clearType);
|
||||
|
|
|
@ -5,24 +5,6 @@ import "..\ICoreAppearance.idl";
|
|||
|
||||
namespace Microsoft.Terminal.Core
|
||||
{
|
||||
enum SelectionDirection
|
||||
{
|
||||
None = 0,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
};
|
||||
|
||||
enum SelectionExpansion
|
||||
{
|
||||
Char,
|
||||
Word,
|
||||
Line, // Mouse selection only! Not a setting!
|
||||
Viewport,
|
||||
Buffer
|
||||
};
|
||||
|
||||
interface ICoreSettings requires ICoreAppearance
|
||||
{
|
||||
// TODO:MSFT:20642297 - define a sentinel for Infinite Scrollback
|
||||
|
|
|
@ -35,26 +35,6 @@ namespace winrt::Microsoft::Terminal::Core
|
|||
namespace Microsoft::Terminal::Core
|
||||
{
|
||||
class Terminal;
|
||||
|
||||
// TODO GH#6999: We need to convert winrt::Microsoft::Terminal::Core::SelectionDirection/Expansion
|
||||
// into an equivalent enum class because PublicTerminalCore doesn't consume winrt. Once we introduce
|
||||
// an interactivity layer, we'll be able to remove this duplicate enum and directly use the winrt enums.
|
||||
enum class InternalSelectionDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down
|
||||
};
|
||||
|
||||
enum class InternalSelectionExpansion
|
||||
{
|
||||
Char,
|
||||
Word,
|
||||
Line, // Mouse selection only! Not a setting!
|
||||
Viewport,
|
||||
Buffer
|
||||
};
|
||||
}
|
||||
|
||||
// fwdecl unittest classes
|
||||
|
@ -247,11 +227,27 @@ public:
|
|||
|
||||
#pragma region TextSelection
|
||||
// These methods are defined in TerminalSelection.cpp
|
||||
void MultiClickSelection(const COORD viewportPos, InternalSelectionExpansion expansionMode);
|
||||
enum class SelectionDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down
|
||||
};
|
||||
|
||||
enum class SelectionExpansion
|
||||
{
|
||||
Char,
|
||||
Word,
|
||||
Line, // Mouse selection only! Not a setting!
|
||||
Viewport,
|
||||
Buffer
|
||||
};
|
||||
void MultiClickSelection(const COORD viewportPos, SelectionExpansion expansionMode);
|
||||
void SetSelectionAnchor(const COORD position);
|
||||
void SetSelectionEnd(const COORD position, std::optional<InternalSelectionExpansion> newExpansionMode = std::nullopt);
|
||||
void SetSelectionEnd(const COORD position, std::optional<SelectionExpansion> newExpansionMode = std::nullopt);
|
||||
void SetBlockSelection(const bool isEnabled) noexcept;
|
||||
void UpdateSelection(InternalSelectionDirection direction, InternalSelectionExpansion mode);
|
||||
void UpdateSelection(SelectionDirection direction, SelectionExpansion mode);
|
||||
|
||||
const TextBuffer::TextAndColor RetrieveSelectedTextFromBuffer(bool trimTrailingWhitespace);
|
||||
#pragma endregion
|
||||
|
@ -323,7 +319,7 @@ private:
|
|||
std::optional<SelectionAnchors> _selection;
|
||||
bool _blockSelection;
|
||||
std::wstring _wordDelimiters;
|
||||
InternalSelectionExpansion _multiClickSelectionMode;
|
||||
SelectionExpansion _multiClickSelectionMode;
|
||||
#pragma endregion
|
||||
|
||||
// TODO: These members are not shared by an alt-buffer. They should be
|
||||
|
@ -390,10 +386,10 @@ private:
|
|||
std::tuple<COORD, COORD, bool> _PivotSelection(const COORD targetPos) const;
|
||||
std::pair<COORD, COORD> _ExpandSelectionAnchors(std::pair<COORD, COORD> anchors) const;
|
||||
COORD _ConvertToBufferCell(const COORD viewportPos) const;
|
||||
void _MoveByChar(InternalSelectionDirection direction, COORD& pos);
|
||||
void _MoveByWord(InternalSelectionDirection direction, COORD& pos);
|
||||
void _MoveByViewport(InternalSelectionDirection direction, COORD& pos);
|
||||
void _MoveByBuffer(InternalSelectionDirection direction, COORD& pos);
|
||||
void _MoveByChar(SelectionDirection direction, COORD& pos);
|
||||
void _MoveByWord(SelectionDirection direction, COORD& pos);
|
||||
void _MoveByViewport(SelectionDirection direction, COORD& pos);
|
||||
void _MoveByBuffer(SelectionDirection direction, COORD& pos);
|
||||
#pragma endregion
|
||||
|
||||
Microsoft::Console::VirtualTerminal::SgrStack _sgrStack;
|
||||
|
|
|
@ -104,7 +104,7 @@ const bool Terminal::IsBlockSelection() const noexcept
|
|||
// Arguments:
|
||||
// - viewportPos: the (x,y) coordinate on the visible viewport
|
||||
// - expansionMode: the SelectionExpansion to dictate the boundaries of the selection anchors
|
||||
void Terminal::MultiClickSelection(const COORD viewportPos, InternalSelectionExpansion expansionMode)
|
||||
void Terminal::MultiClickSelection(const COORD viewportPos, SelectionExpansion expansionMode)
|
||||
{
|
||||
// set the selection pivot to expand the selection using SetSelectionEnd()
|
||||
_selection = SelectionAnchors{};
|
||||
|
@ -127,7 +127,7 @@ void Terminal::SetSelectionAnchor(const COORD viewportPos)
|
|||
_selection = SelectionAnchors{};
|
||||
_selection->pivot = _ConvertToBufferCell(viewportPos);
|
||||
|
||||
_multiClickSelectionMode = InternalSelectionExpansion::Char;
|
||||
_multiClickSelectionMode = SelectionExpansion::Char;
|
||||
SetSelectionEnd(viewportPos);
|
||||
|
||||
_selection->start = _selection->pivot;
|
||||
|
@ -139,7 +139,7 @@ void Terminal::SetSelectionAnchor(const COORD viewportPos)
|
|||
// Arguments:
|
||||
// - viewportPos: the (x,y) coordinate on the visible viewport
|
||||
// - newExpansionMode: overwrites the _multiClickSelectionMode for this function call. Used for ShiftClick
|
||||
void Terminal::SetSelectionEnd(const COORD viewportPos, std::optional<InternalSelectionExpansion> newExpansionMode)
|
||||
void Terminal::SetSelectionEnd(const COORD viewportPos, std::optional<SelectionExpansion> newExpansionMode)
|
||||
{
|
||||
if (!_selection.has_value())
|
||||
{
|
||||
|
@ -216,15 +216,15 @@ std::pair<COORD, COORD> Terminal::_ExpandSelectionAnchors(std::pair<COORD, COORD
|
|||
const auto bufferSize = _buffer->GetSize();
|
||||
switch (_multiClickSelectionMode)
|
||||
{
|
||||
case InternalSelectionExpansion::Line:
|
||||
case SelectionExpansion::Line:
|
||||
start = { bufferSize.Left(), start.Y };
|
||||
end = { bufferSize.RightInclusive(), end.Y };
|
||||
break;
|
||||
case InternalSelectionExpansion::Word:
|
||||
case SelectionExpansion::Word:
|
||||
start = _buffer->GetWordStart(start, _wordDelimiters);
|
||||
end = _buffer->GetWordEnd(end, _wordDelimiters);
|
||||
break;
|
||||
case InternalSelectionExpansion::Char:
|
||||
case SelectionExpansion::Char:
|
||||
default:
|
||||
// no expansion is necessary
|
||||
break;
|
||||
|
@ -241,7 +241,7 @@ void Terminal::SetBlockSelection(const bool isEnabled) noexcept
|
|||
_blockSelection = isEnabled;
|
||||
}
|
||||
|
||||
void Terminal::UpdateSelection(InternalSelectionDirection direction, InternalSelectionExpansion mode)
|
||||
void Terminal::UpdateSelection(SelectionDirection direction, SelectionExpansion mode)
|
||||
{
|
||||
// 1. Figure out which endpoint to update
|
||||
// One of the endpoints is the pivot, signifying that the other endpoint is the one we want to move.
|
||||
|
@ -251,16 +251,16 @@ void Terminal::UpdateSelection(InternalSelectionDirection direction, InternalSel
|
|||
// 2. Perform the movement
|
||||
switch (mode)
|
||||
{
|
||||
case InternalSelectionExpansion::Char:
|
||||
case SelectionExpansion::Char:
|
||||
_MoveByChar(direction, targetPos);
|
||||
break;
|
||||
case InternalSelectionExpansion::Word:
|
||||
case SelectionExpansion::Word:
|
||||
_MoveByWord(direction, targetPos);
|
||||
break;
|
||||
case InternalSelectionExpansion::Viewport:
|
||||
case SelectionExpansion::Viewport:
|
||||
_MoveByViewport(direction, targetPos);
|
||||
break;
|
||||
case InternalSelectionExpansion::Buffer:
|
||||
case SelectionExpansion::Buffer:
|
||||
_MoveByBuffer(direction, targetPos);
|
||||
break;
|
||||
}
|
||||
|
@ -287,25 +287,25 @@ void Terminal::UpdateSelection(InternalSelectionDirection direction, InternalSel
|
|||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByChar(InternalSelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByChar(SelectionDirection direction, COORD& pos)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case InternalSelectionDirection::Left:
|
||||
case SelectionDirection::Left:
|
||||
_buffer->GetSize().DecrementInBounds(pos);
|
||||
pos = _buffer->GetGlyphStart(pos);
|
||||
break;
|
||||
case InternalSelectionDirection::Right:
|
||||
case SelectionDirection::Right:
|
||||
_buffer->GetSize().IncrementInBounds(pos);
|
||||
pos = _buffer->GetGlyphEnd(pos);
|
||||
break;
|
||||
case InternalSelectionDirection::Up:
|
||||
case SelectionDirection::Up:
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
pos = { pos.X, std::clamp(base::ClampSub<short, short>(pos.Y, 1).RawValue(), bufferSize.Top(), bufferSize.BottomInclusive()) };
|
||||
break;
|
||||
}
|
||||
case InternalSelectionDirection::Down:
|
||||
case SelectionDirection::Down:
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
pos = { pos.X, std::clamp(base::ClampAdd<short, short>(pos.Y, 1).RawValue(), bufferSize.Top(), bufferSize.BottomInclusive()) };
|
||||
|
@ -314,11 +314,11 @@ void Terminal::_MoveByChar(InternalSelectionDirection direction, COORD& pos)
|
|||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByWord(InternalSelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByWord(SelectionDirection direction, COORD& pos)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case InternalSelectionDirection::Left:
|
||||
case SelectionDirection::Left:
|
||||
const auto wordStartPos{ _buffer->GetWordStart(pos, _wordDelimiters) };
|
||||
if (_buffer->GetSize().CompareInBounds(_selection->pivot, pos) < 0)
|
||||
{
|
||||
|
@ -339,7 +339,7 @@ void Terminal::_MoveByWord(InternalSelectionDirection direction, COORD& pos)
|
|||
pos = wordStartPos;
|
||||
}
|
||||
break;
|
||||
case InternalSelectionDirection::Right:
|
||||
case SelectionDirection::Right:
|
||||
const auto wordEndPos{ _buffer->GetWordEnd(pos, _wordDelimiters) };
|
||||
if (_buffer->GetSize().CompareInBounds(pos, _selection->pivot) < 0)
|
||||
{
|
||||
|
@ -360,36 +360,36 @@ void Terminal::_MoveByWord(InternalSelectionDirection direction, COORD& pos)
|
|||
pos = wordEndPos;
|
||||
}
|
||||
break;
|
||||
case InternalSelectionDirection::Up:
|
||||
case SelectionDirection::Up:
|
||||
_MoveByChar(direction, pos);
|
||||
pos = _buffer->GetWordStart(pos, _wordDelimiters);
|
||||
break;
|
||||
case InternalSelectionDirection::Down:
|
||||
case SelectionDirection::Down:
|
||||
_MoveByChar(direction, pos);
|
||||
pos = _buffer->GetWordEnd(pos, _wordDelimiters);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByViewport(InternalSelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByViewport(SelectionDirection direction, COORD& pos)
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
switch (direction)
|
||||
{
|
||||
case InternalSelectionDirection::Left:
|
||||
case SelectionDirection::Left:
|
||||
pos = { bufferSize.Left(), pos.Y };
|
||||
break;
|
||||
case InternalSelectionDirection::Right:
|
||||
case SelectionDirection::Right:
|
||||
pos = { bufferSize.RightInclusive(), pos.Y };
|
||||
break;
|
||||
case InternalSelectionDirection::Up:
|
||||
case SelectionDirection::Up:
|
||||
{
|
||||
const auto viewportHeight{ _mutableViewport.Height() };
|
||||
const auto newY{ base::ClampSub<short, short>(pos.Y, viewportHeight) };
|
||||
pos = newY < bufferSize.Top() ? bufferSize.Origin() : COORD{ pos.X, newY };
|
||||
break;
|
||||
}
|
||||
case InternalSelectionDirection::Down:
|
||||
case SelectionDirection::Down:
|
||||
{
|
||||
const auto viewportHeight{ _mutableViewport.Height() };
|
||||
const auto mutableBottom{ _mutableViewport.BottomInclusive() };
|
||||
|
@ -400,17 +400,17 @@ void Terminal::_MoveByViewport(InternalSelectionDirection direction, COORD& pos)
|
|||
}
|
||||
}
|
||||
|
||||
void Terminal::_MoveByBuffer(InternalSelectionDirection direction, COORD& pos)
|
||||
void Terminal::_MoveByBuffer(SelectionDirection direction, COORD& pos)
|
||||
{
|
||||
const auto bufferSize{ _buffer->GetSize() };
|
||||
switch (direction)
|
||||
{
|
||||
case InternalSelectionDirection::Left:
|
||||
case InternalSelectionDirection::Up:
|
||||
case SelectionDirection::Left:
|
||||
case SelectionDirection::Up:
|
||||
pos = bufferSize.Origin();
|
||||
break;
|
||||
case InternalSelectionDirection::Right:
|
||||
case InternalSelectionDirection::Down:
|
||||
case SelectionDirection::Right:
|
||||
case SelectionDirection::Down:
|
||||
pos = { bufferSize.RightInclusive(), _mutableViewport.BottomInclusive() };
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ void Terminal::SelectNewRegion(const COORD coordStart, const COORD coordEnd)
|
|||
realCoordEnd.Y -= gsl::narrow<short>(_VisibleStartIndex());
|
||||
|
||||
SetSelectionAnchor(realCoordStart);
|
||||
SetSelectionEnd(realCoordEnd, InternalSelectionExpansion::Char);
|
||||
SetSelectionEnd(realCoordEnd, SelectionExpansion::Char);
|
||||
}
|
||||
|
||||
const std::wstring_view Terminal::GetConsoleTitle() const noexcept
|
||||
|
|
|
@ -69,7 +69,6 @@ static constexpr std::string_view OpenSystemMenuKey{ "openSystemMenu" };
|
|||
static constexpr std::string_view ClearBufferKey{ "clearBuffer" };
|
||||
static constexpr std::string_view MultipleActionsKey{ "multipleActions" };
|
||||
static constexpr std::string_view QuitKey{ "quit" };
|
||||
static constexpr std::string_view UpdateSelectionKey{ "updateSelection" };
|
||||
|
||||
static constexpr std::string_view ActionKey{ "action" };
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include "FocusPaneArgs.g.cpp"
|
||||
#include "ClearBufferArgs.g.cpp"
|
||||
#include "MultipleActionsArgs.g.cpp"
|
||||
#include "UpdateSelectionArgs.g.cpp"
|
||||
|
||||
#include <LibraryResources.h>
|
||||
|
||||
|
@ -719,9 +718,4 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
{
|
||||
return L"";
|
||||
}
|
||||
|
||||
winrt::hstring UpdateSelectionArgs::GenerateName() const
|
||||
{
|
||||
return L"";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "FocusPaneArgs.g.h"
|
||||
#include "ClearBufferArgs.g.h"
|
||||
#include "MultipleActionsArgs.g.h"
|
||||
#include "UpdateSelectionArgs.g.h"
|
||||
|
||||
#include "../../cascadia/inc/cppwinrt_utils.h"
|
||||
#include "JsonUtils.h"
|
||||
|
@ -1860,67 +1859,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
|
|||
return ::Microsoft::Terminal::Settings::Model::HashUtils::HashProperty(_Actions);
|
||||
}
|
||||
};
|
||||
|
||||
struct UpdateSelectionArgs : public UpdateSelectionArgsT<UpdateSelectionArgs>
|
||||
{
|
||||
UpdateSelectionArgs() = default;
|
||||
ACTION_ARG(Core::SelectionDirection, Direction, Core::SelectionDirection::None);
|
||||
ACTION_ARG(Core::SelectionExpansion, Mode, Core::SelectionExpansion::Char);
|
||||
static constexpr std::string_view DirectionKey{ "direction" };
|
||||
static constexpr std::string_view ModeKey{ "mode" };
|
||||
|
||||
public:
|
||||
hstring GenerateName() const;
|
||||
|
||||
bool Equals(const IActionArgs& other)
|
||||
{
|
||||
auto otherAsUs = other.try_as<UpdateSelectionArgs>();
|
||||
if (otherAsUs)
|
||||
{
|
||||
return otherAsUs->_Direction == _Direction && otherAsUs->_Mode == _Mode;
|
||||
}
|
||||
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<UpdateSelectionArgs>();
|
||||
JsonUtils::GetValueForKey(json, DirectionKey, args->_Direction);
|
||||
JsonUtils::GetValueForKey(json, ModeKey, args->_Mode);
|
||||
if (args->Direction() == Core::SelectionDirection::None)
|
||||
{
|
||||
return { nullptr, { SettingsLoadWarnings::MissingRequiredParameter } };
|
||||
}
|
||||
else
|
||||
{
|
||||
return { *args, {} };
|
||||
}
|
||||
}
|
||||
static Json::Value ToJson(const IActionArgs& val)
|
||||
{
|
||||
if (!val)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
Json::Value json{ Json::ValueType::objectValue };
|
||||
const auto args{ get_self<UpdateSelectionArgs>(val) };
|
||||
JsonUtils::SetValueForKey(json, DirectionKey, args->_Direction);
|
||||
JsonUtils::SetValueForKey(json, ModeKey, args->_Mode);
|
||||
return json;
|
||||
}
|
||||
IActionArgs Copy() const
|
||||
{
|
||||
auto copy{ winrt::make_self<UpdateSelectionArgs>() };
|
||||
copy->_Direction = _Direction;
|
||||
copy->_Mode = _Mode;
|
||||
return *copy;
|
||||
}
|
||||
size_t Hash() const
|
||||
{
|
||||
return ::Microsoft::Terminal::Settings::Model::HashUtils::HashProperty(_Direction, _Mode);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace winrt::Microsoft::Terminal::Settings::Model::factory_implementation
|
||||
|
|
|
@ -323,10 +323,4 @@ namespace Microsoft.Terminal.Settings.Model
|
|||
MultipleActionsArgs();
|
||||
Windows.Foundation.Collections.IVector<ActionAndArgs> Actions;
|
||||
};
|
||||
|
||||
[default_interface] runtimeclass UpdateSelectionArgs : IActionArgs
|
||||
{
|
||||
Microsoft.Terminal.Core.SelectionDirection Direction { get; };
|
||||
Microsoft.Terminal.Core.SelectionExpansion Mode { get; };
|
||||
};
|
||||
}
|
||||
|
|
|
@ -82,8 +82,7 @@
|
|||
ON_ALL_ACTIONS(OpenSystemMenu) \
|
||||
ON_ALL_ACTIONS(ClearBuffer) \
|
||||
ON_ALL_ACTIONS(MultipleActions) \
|
||||
ON_ALL_ACTIONS(Quit) \
|
||||
ON_ALL_ACTIONS(UpdateSelection)
|
||||
ON_ALL_ACTIONS(Quit)
|
||||
|
||||
#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
|
||||
|
@ -116,5 +115,4 @@
|
|||
ON_ALL_ACTIONS_WITH_ARGS(ToggleCommandPalette) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(FocusPane) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(ClearBuffer) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(MultipleActions) \
|
||||
ON_ALL_ACTIONS_WITH_ARGS(UpdateSelection)
|
||||
ON_ALL_ACTIONS_WITH_ARGS(MultipleActions)
|
||||
|
|
|
@ -512,23 +512,3 @@ JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Settings::Model::InfoBarMessage)
|
|||
pair_type{ "keyboardServiceWarning", ValueType::KeyboardServiceWarning },
|
||||
};
|
||||
};
|
||||
|
||||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Core::SelectionDirection)
|
||||
{
|
||||
static constexpr std::array<pair_type, 4> mappings = {
|
||||
pair_type{ "left", ValueType::Left },
|
||||
pair_type{ "right", ValueType::Right },
|
||||
pair_type{ "up", ValueType::Up },
|
||||
pair_type{ "down", ValueType::Down }
|
||||
};
|
||||
};
|
||||
|
||||
JSON_ENUM_MAPPER(::winrt::Microsoft::Terminal::Core::SelectionExpansion)
|
||||
{
|
||||
static constexpr std::array<pair_type, 4> mappings = {
|
||||
pair_type{ "char", ValueType::Char },
|
||||
pair_type{ "word", ValueType::Word },
|
||||
pair_type{ "view", ValueType::Viewport },
|
||||
pair_type{ "buffer", ValueType::Buffer }
|
||||
};
|
||||
};
|
||||
|
|
|
@ -380,20 +380,6 @@
|
|||
{ "command": "paste", "keys": "ctrl+shift+v" },
|
||||
{ "command": "paste", "keys": "shift+insert" },
|
||||
|
||||
// Keyboard Selection
|
||||
{ "command": {"action": "updateSelection", "direction": "left", "mode": "char" }, "keys": "shift+left" },
|
||||
{ "command": {"action": "updateSelection", "direction": "right", "mode": "char" }, "keys": "shift+right" },
|
||||
{ "command": {"action": "updateSelection", "direction": "up", "mode": "char" }, "keys": "shift+up" },
|
||||
{ "command": {"action": "updateSelection", "direction": "down", "mode": "char" }, "keys": "shift+down" },
|
||||
{ "command": {"action": "updateSelection", "direction": "left", "mode": "word" }, "keys": "ctrl+shift+left" },
|
||||
{ "command": {"action": "updateSelection", "direction": "right", "mode": "word" }, "keys": "ctrl+shift+right" },
|
||||
{ "command": {"action": "updateSelection", "direction": "left", "mode": "view" }, "keys": "shift+home" },
|
||||
{ "command": {"action": "updateSelection", "direction": "right", "mode": "view" }, "keys": "shift+end" },
|
||||
{ "command": {"action": "updateSelection", "direction": "up", "mode": "view" }, "keys": "shift+pgup" },
|
||||
{ "command": {"action": "updateSelection", "direction": "down", "mode": "view" }, "keys": "shift+pgdn" },
|
||||
{ "command": {"action": "updateSelection", "direction": "up", "mode": "buffer" }, "keys": "ctrl+shift+home" },
|
||||
{ "command": {"action": "updateSelection", "direction": "down", "mode": "buffer" }, "keys": "ctrl+shift+end" },
|
||||
|
||||
// Scrollback
|
||||
{ "command": "scrollDown", "keys": "ctrl+shift+down" },
|
||||
{ "command": "scrollDownPage", "keys": "ctrl+shift+pgdn" },
|
||||
|
|
|
@ -295,7 +295,7 @@ void UiaTextRangeBase::_expandToEnclosingUnit(TextUnit unit)
|
|||
if (unit == TextUnit_Character)
|
||||
{
|
||||
_start = buffer.GetGlyphStart(_start, documentEnd);
|
||||
_end = buffer.GetGlyphEnd(_start, documentEnd, true);
|
||||
_end = buffer.GetGlyphEnd(_start, true, documentEnd);
|
||||
}
|
||||
else if (unit <= TextUnit_Word)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue