diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index b9e22af58e2..09a7f4f9926 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -133,6 +133,9 @@ void Terminal::UpdateSettings(winrt::Microsoft::Terminal::Settings::ICoreSetting _snapOnInput = settings.SnapOnInput(); + // TODO: import tripleClickSelection setting from Settings + _tripleClickMode = TripleClickSelectionMode::Line; + // TODO:MSFT:21327402 - if HistorySize has changed, resize the buffer so we // have a smaller scrollback. We should do this carefully - if the new buffer // size is smaller than where the mutable viewport currently is, we'll want @@ -645,15 +648,44 @@ void Terminal::DoubleClickSelection(const COORD position) } // Method Description: -// - Select the entire row of the position clicked +// - Performs a triple click selection based on the setting // Arguments: // - position: the (x,y) coordinate on the visible viewport void Terminal::TripleClickSelection(const COORD position) +{ + switch (_tripleClickMode) + { + case TripleClickSelectionMode::VisibleViewport: + _SelectViewport(); + break; + case TripleClickSelectionMode::Line: + _SelectRow(position); + break; + case TripleClickSelectionMode::Disabled: + default: + SetSelectionAnchor(position); + break; + } +} + +// Method Description: +// - Create a selection of the entire row of the position clicked +// Arguments: +// - position: the (x,y) coordinate on the visible viewport +void Terminal::_SelectRow(const COORD position) { SetSelectionAnchor({ 0, position.Y }); SetEndSelectionPosition({ _buffer->GetSize().RightInclusive(), position.Y }); } +// Method Description: +// - Create a selection of the entire visible viewport present +void Terminal::_SelectViewport() +{ + SetSelectionAnchor({ 0, 0 }); + SetEndSelectionPosition(_mutableViewport.Dimensions()); +} + // Method Description: // - expand the double click selection to the left (stopped by delimiter) // Arguments: diff --git a/src/cascadia/TerminalCore/Terminal.hpp b/src/cascadia/TerminalCore/Terminal.hpp index d75e68e0c24..a0f3995a736 100644 --- a/src/cascadia/TerminalCore/Terminal.hpp +++ b/src/cascadia/TerminalCore/Terminal.hpp @@ -147,15 +147,24 @@ class Microsoft::Terminal::Core::Terminal final : bool _snapOnInput; // Text Selection + enum TripleClickSelectionMode + { + Disabled = 0, + Line, + VisibleViewport + }; COORD _selectionAnchor; COORD _endSelectionPosition; bool _boxSelection; bool _selectionActive; SHORT _selectionAnchor_YOffset; SHORT _endSelectionPosition_YOffset; + TripleClickSelectionMode _tripleClickMode; void _ExpandDoubleClickSelectionLeft(const COORD position); void _ExpandDoubleClickSelectionRight(const COORD position); const bool _DoubleClickDelimiterCheck(std::wstring_view cellChar) const; + void _SelectRow(const COORD position); + void _SelectViewport(); const COORD _ConvertToBufferCell(const COORD viewportPos) const; std::shared_mutex _readWriteLock;