Skip to content

Commit

Permalink
Viewport selection is now an option
Browse files Browse the repository at this point in the history
TODO: connect to setting
  • Loading branch information
carlos-zamora committed Jun 14, 2019
1 parent a12f727 commit 494658f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 494658f

Please sign in to comment.