mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-06 14:19:45 +00:00
Be able to mark a selection via the action, because that's handy!
This commit is contained in:
@@ -1808,7 +1808,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
::Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark m{};
|
||||
m.color = til::color{ mark.Color };
|
||||
_terminal->AddMark(m);
|
||||
|
||||
if (HasSelection())
|
||||
{
|
||||
m.start = til::point{ _terminal->GetSelectionAnchor() };
|
||||
m.end = til::point{ _terminal->GetSelectionEnd() };
|
||||
}
|
||||
else
|
||||
{
|
||||
m.start = m.end = til::point{ _terminal->GetTextBuffer().GetCursor().GetPosition() };
|
||||
}
|
||||
|
||||
// The version of this that only accepts a ScrollMark is buffer2
|
||||
_terminal->AddMark(m, m.start, m.end);
|
||||
}
|
||||
void ControlCore::ClearMark() { _terminal->ClearMark(); }
|
||||
void ControlCore::ClearAllMarks() { _terminal->ClearAllMarks(); }
|
||||
|
||||
@@ -740,7 +740,6 @@ bool Terminal::SendCharEvent(const wchar_t ch, const WORD scanCode, const Contro
|
||||
vkey = _VirtualKeyFromCharacter(ch);
|
||||
}
|
||||
|
||||
|
||||
if (_autoMarkPrompts && vkey == VK_RETURN && !_inAltBuffer())
|
||||
{
|
||||
DispatchTypes::ScrollMark mark;
|
||||
@@ -1446,6 +1445,21 @@ const std::vector<Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark
|
||||
return _scrollMarks;
|
||||
}
|
||||
|
||||
void Terminal::AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark,
|
||||
const til::point& start,
|
||||
const til::point& end)
|
||||
{
|
||||
DispatchTypes::ScrollMark m = mark;
|
||||
m.start = start;
|
||||
m.end = end;
|
||||
// // m.timestamp = now()
|
||||
|
||||
_scrollMarks.push_back(m);
|
||||
|
||||
// Tell the control that the scrollbar has somehow changed. Used as a hack.
|
||||
_NotifyScrollEvent();
|
||||
}
|
||||
|
||||
void Terminal::ClearMark()
|
||||
{
|
||||
// TODO! just look for one where the cursor is, or where the selection is
|
||||
|
||||
@@ -95,6 +95,9 @@ public:
|
||||
const RenderSettings& GetRenderSettings() const noexcept { return _renderSettings; };
|
||||
const std::vector<Microsoft::Console::VirtualTerminal::DispatchTypes::MenuEntry>& GetMenu() const;
|
||||
const std::vector<Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark>& GetScrollMarks() const;
|
||||
void AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark,
|
||||
const til::point& start,
|
||||
const til::point& end);
|
||||
|
||||
#pragma region ITerminalApi
|
||||
// These methods are defined in TerminalApi.cpp
|
||||
|
||||
@@ -706,13 +706,6 @@ void Terminal::AddToMenu(const Microsoft::Console::VirtualTerminal::DispatchType
|
||||
|
||||
void Terminal::AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark)
|
||||
{
|
||||
DispatchTypes::ScrollMark m = mark;
|
||||
// m.timestamp = now()
|
||||
const til::point cursorPos{ _activeBuffer().GetCursor().GetPosition() };
|
||||
m.start = m.end = cursorPos;
|
||||
|
||||
_scrollMarks.push_back(m);
|
||||
|
||||
// Tell the control that the scrollbar has somehow changed. Used as a hack.
|
||||
_NotifyScrollEvent();
|
||||
AddMark(mark, cursorPos, cursorPos);
|
||||
}
|
||||
|
||||
@@ -561,6 +561,7 @@ bool TerminalDispatch::DoITerm2Action(const std::wstring_view string)
|
||||
DispatchTypes::ScrollMark mark;
|
||||
mark.category = DispatchTypes::MarkCategory::Prompt;
|
||||
mark.color = til::color(255, 255, 255); // should this be configurable?
|
||||
// mark.start = mark.end = til::point{ _terminalApi.GetCursorPosition() };
|
||||
_terminalApi.AddMark(mark);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user