mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-04 05:35:20 +00:00
combine mark mode and quick edit mode
This commit is contained in:
@@ -417,7 +417,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
vkey != VK_SNAPSHOT &&
|
||||
keyDown)
|
||||
{
|
||||
if (_terminal->IsInMarkMode() && modifiers.IsCtrlPressed() && vkey == 'A')
|
||||
const auto isInMarkMode = static_cast<Control::SelectionInteractionMode>(_terminal->SelectionMode()) == Control::SelectionInteractionMode::Mark;
|
||||
if (isInMarkMode && modifiers.IsCtrlPressed() && vkey == 'A')
|
||||
{
|
||||
auto lock = _terminal->LockForWriting();
|
||||
_terminal->SelectAll();
|
||||
@@ -1088,14 +1089,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
_updateSelection();
|
||||
}
|
||||
|
||||
bool ControlCore::IsInMarkMode() const
|
||||
Control::SelectionInteractionMode ControlCore::SelectionMode() const
|
||||
{
|
||||
return _terminal->IsInMarkMode();
|
||||
}
|
||||
|
||||
bool ControlCore::IsInQuickEditMode() const
|
||||
{
|
||||
return _terminal->IsInQuickEditMode();
|
||||
return static_cast<Control::SelectionInteractionMode>(_terminal->SelectionMode());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@@ -84,8 +84,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
void SelectAll();
|
||||
bool ToggleBlockSelection();
|
||||
void ToggleMarkMode();
|
||||
bool IsInMarkMode() const;
|
||||
bool IsInQuickEditMode() const;
|
||||
Control::SelectionInteractionMode SelectionMode() const;
|
||||
|
||||
void GotFocus();
|
||||
void LostFocus();
|
||||
|
||||
@@ -29,6 +29,13 @@ namespace Microsoft.Terminal.Control
|
||||
All
|
||||
};
|
||||
|
||||
enum SelectionInteractionMode
|
||||
{
|
||||
Mouse,
|
||||
Keyboard,
|
||||
Mark
|
||||
};
|
||||
|
||||
[flags]
|
||||
enum SelectionEndpointTarget
|
||||
{
|
||||
@@ -84,7 +91,6 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean ToggleBlockSelection();
|
||||
void ToggleMarkMode();
|
||||
void ClearBuffer(ClearBufferType clearType);
|
||||
Boolean IsInMarkMode();
|
||||
|
||||
void SetHoveredCell(Microsoft.Terminal.Core.Point terminalPosition);
|
||||
void ClearHoveredCell();
|
||||
@@ -107,6 +113,7 @@ namespace Microsoft.Terminal.Control
|
||||
Boolean HasSelection { get; };
|
||||
IVector<String> SelectedText(Boolean trimTrailingWhitespace);
|
||||
SelectionData SelectionInfo { get; };
|
||||
SelectionInteractionMode SelectionMode();
|
||||
|
||||
String HoveredUriText { get; };
|
||||
Windows.Foundation.IReference<Microsoft.Terminal.Core.Point> HoveredCell { get; };
|
||||
|
||||
@@ -263,7 +263,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// CopyOnSelect:
|
||||
// 1. keyboard selection? --> copy the new content first
|
||||
// 2. right click always pastes!
|
||||
if (_core->IsInQuickEditMode() || _core->IsInMarkMode())
|
||||
if (_core->SelectionMode() > SelectionInteractionMode::Keyboard)
|
||||
{
|
||||
CopySelectionToClipboard(shiftEnabled, nullptr);
|
||||
}
|
||||
|
||||
@@ -1188,7 +1188,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
// Manually show the cursor when a key is pressed. Restarting
|
||||
// the timer prevents flickering.
|
||||
_core.CursorOn(!_core.IsInMarkMode());
|
||||
_core.CursorOn(_core.SelectionMode() != SelectionInteractionMode::Mark);
|
||||
_cursorTimer->Start();
|
||||
}
|
||||
|
||||
@@ -1659,7 +1659,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
if (_cursorTimer)
|
||||
{
|
||||
// When the terminal focuses, show the cursor immediately
|
||||
_core.CursorOn(!_core.IsInMarkMode());
|
||||
_core.CursorOn(_core.SelectionMode() != SelectionInteractionMode::Mark);
|
||||
_cursorTimer->Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ Terminal::Terminal() :
|
||||
_snapOnInput{ true },
|
||||
_altGrAliasing{ true },
|
||||
_blockSelection{ false },
|
||||
_markMode{ false },
|
||||
_quickEditMode{ false },
|
||||
_selectionMode{ 0 },
|
||||
_selection{ std::nullopt },
|
||||
_selectionEndpoint{ static_cast<SelectionEndpoint>(0) },
|
||||
_taskbarState{ 0 },
|
||||
@@ -1371,7 +1370,7 @@ void Terminal::SetCursorOn(const bool isOn)
|
||||
bool Terminal::IsCursorBlinkingAllowed() const noexcept
|
||||
{
|
||||
const auto& cursor = _activeBuffer().GetCursor();
|
||||
return !_markMode && cursor.IsBlinkingAllowed();
|
||||
return _selectionMode != SelectionInteractionMode::Mark && cursor.IsBlinkingAllowed();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
||||
@@ -233,6 +233,13 @@ public:
|
||||
|
||||
#pragma region TextSelection
|
||||
// These methods are defined in TerminalSelection.cpp
|
||||
enum class SelectionInteractionMode
|
||||
{
|
||||
Mouse,
|
||||
Keyboard,
|
||||
Mark
|
||||
};
|
||||
|
||||
enum class SelectionDirection
|
||||
{
|
||||
Left,
|
||||
@@ -262,8 +269,7 @@ public:
|
||||
void SetBlockSelection(const bool isEnabled) noexcept;
|
||||
void UpdateSelection(SelectionDirection direction, SelectionExpansion mode, ControlKeyStates mods);
|
||||
void SelectAll();
|
||||
const bool IsInQuickEditMode() const noexcept;
|
||||
bool IsInMarkMode() const;
|
||||
SelectionInteractionMode SelectionMode() const noexcept;
|
||||
void ToggleMarkMode();
|
||||
|
||||
using UpdateSelectionParams = std::optional<std::pair<SelectionDirection, SelectionExpansion>>;
|
||||
@@ -340,8 +346,7 @@ private:
|
||||
bool _blockSelection;
|
||||
std::wstring _wordDelimiters;
|
||||
SelectionExpansion _multiClickSelectionMode;
|
||||
bool _markMode;
|
||||
bool _quickEditMode;
|
||||
SelectionInteractionMode _selectionMode;
|
||||
SelectionEndpoint _selectionEndpoint;
|
||||
#pragma endregion
|
||||
|
||||
|
||||
@@ -280,19 +280,14 @@ void Terminal::SetBlockSelection(const bool isEnabled) noexcept
|
||||
_blockSelection = isEnabled;
|
||||
}
|
||||
|
||||
const bool Terminal::IsInQuickEditMode() const noexcept
|
||||
Terminal::SelectionInteractionMode Terminal::SelectionMode() const noexcept
|
||||
{
|
||||
return _quickEditMode;
|
||||
}
|
||||
|
||||
bool Terminal::IsInMarkMode() const
|
||||
{
|
||||
return _markMode;
|
||||
return _selectionMode;
|
||||
}
|
||||
|
||||
void Terminal::ToggleMarkMode()
|
||||
{
|
||||
if (_markMode)
|
||||
if (_selectionMode == SelectionInteractionMode::Mark)
|
||||
{
|
||||
// Exit Mark Mode
|
||||
ClearSelection();
|
||||
@@ -307,8 +302,7 @@ void Terminal::ToggleMarkMode()
|
||||
_selection->start = cursorPos;
|
||||
_selection->end = cursorPos;
|
||||
_selection->pivot = cursorPos;
|
||||
_markMode = true;
|
||||
_quickEditMode = false;
|
||||
_selectionMode = SelectionInteractionMode::Mark;
|
||||
_blockSelection = false;
|
||||
WI_SetAllFlags(_selectionEndpoint, SelectionEndpoint::Start | SelectionEndpoint::End);
|
||||
}
|
||||
@@ -316,7 +310,7 @@ void Terminal::ToggleMarkMode()
|
||||
|
||||
Terminal::UpdateSelectionParams Terminal::ConvertKeyEventToUpdateSelectionParams(const ControlKeyStates mods, const WORD vkey) const
|
||||
{
|
||||
if ((_markMode || mods.IsShiftPressed()) && !mods.IsAltPressed())
|
||||
if ((_selectionMode == SelectionInteractionMode::Mark || mods.IsShiftPressed()) && !mods.IsAltPressed())
|
||||
{
|
||||
if (mods.IsCtrlPressed())
|
||||
{
|
||||
@@ -377,7 +371,7 @@ void Terminal::UpdateSelection(SelectionDirection direction, SelectionExpansion
|
||||
// [Quick Edit]
|
||||
// - just move "end" (or "start" if "pivot" == "end")
|
||||
_selectionEndpoint = static_cast<SelectionEndpoint>(0);
|
||||
if (_markMode && !mods.IsShiftPressed())
|
||||
if (_selectionMode == SelectionInteractionMode::Mark && !mods.IsShiftPressed())
|
||||
{
|
||||
WI_SetAllFlags(_selectionEndpoint, SelectionEndpoint::Start | SelectionEndpoint::End);
|
||||
}
|
||||
@@ -412,8 +406,8 @@ void Terminal::UpdateSelection(SelectionDirection direction, SelectionExpansion
|
||||
targetPos = std::min(targetPos, _GetMutableViewport().BottomRightInclusive());
|
||||
|
||||
// 3. Actually modify the selection state
|
||||
_quickEditMode = !_markMode;
|
||||
if (_markMode && !mods.IsShiftPressed())
|
||||
_selectionMode = std::max(_selectionMode, SelectionInteractionMode::Keyboard);
|
||||
if (_selectionMode == SelectionInteractionMode::Mark && !mods.IsShiftPressed())
|
||||
{
|
||||
// [Mark Mode] + shift unpressed --> move all three (i.e. just use arrow keys)
|
||||
_selection->start = targetPos;
|
||||
@@ -601,8 +595,7 @@ void Terminal::_MoveByBuffer(SelectionDirection direction, til::point& pos)
|
||||
void Terminal::ClearSelection()
|
||||
{
|
||||
_selection = std::nullopt;
|
||||
_markMode = false;
|
||||
_quickEditMode = false;
|
||||
_selectionMode = SelectionInteractionMode::Mouse;
|
||||
_selectionEndpoint = static_cast<SelectionEndpoint>(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user