New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let marks be cleared by clear
(and friends)
#15686
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ed51795
blindly move all marks to the TextBuffer
zadjii-msft 9b9c748
move a couple egregious helpers to TextBuffer
zadjii-msft e3eae2b
This actually fixes scrolling fairly elegantly
zadjii-msft b50f90f
rename to get rid of now useless namespace
zadjii-msft 10327de
hey now that the buffer owns these, we need to copy them over
zadjii-msft 500bbab
Merge branch 'main' into dev/migrie/b/clear-marks
zadjii-msft eea3f82
as from review
zadjii-msft 7c77ffb
austin mode
zadjii-msft 010cbdf
Merge remote-tracking branch 'origin/main' into dev/migrie/b/clear-marks
zadjii-msft f5ef592
these are nits if I've ever heard em
zadjii-msft 9e314e6
I agree this was dirty
zadjii-msft 2bc3dfc
MORE audit mode
zadjii-msft a871954
comments too
zadjii-msft 320c1f4
Speel cheek
DHowett File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1344,7 +1344,7 @@ void Terminal::_updateUrlDetection() | |
} | ||
|
||
// NOTE: This is the version of AddMark that comes from the UI. The VT api call into this too. | ||
void Terminal::AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark, | ||
void Terminal::AddMark(const ScrollMark& mark, | ||
const til::point& start, | ||
const til::point& end, | ||
const bool fromUi) | ||
|
@@ -1354,18 +1354,12 @@ void Terminal::AddMark(const Microsoft::Console::VirtualTerminal::DispatchTypes: | |
return; | ||
} | ||
|
||
DispatchTypes::ScrollMark m = mark; | ||
ScrollMark m = mark; | ||
m.start = start; | ||
m.end = end; | ||
|
||
if (fromUi) | ||
{ | ||
_scrollMarks.insert(_scrollMarks.begin(), m); | ||
} | ||
else | ||
{ | ||
_scrollMarks.push_back(m); | ||
} | ||
// If the mark came from the user adding a mark via the UI, don't make it the active prompt mark. | ||
fromUi ? _activeBuffer().AddMark(m) : _activeBuffer().StartPromptMark(m); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is very rare that using a ternary like this is the right thing to do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea that felt dirty to write |
||
|
||
// Tell the control that the scrollbar has somehow changed. Used as a | ||
// workaround to force the control to redraw any scrollbar marks | ||
|
@@ -1389,39 +1383,30 @@ void Terminal::ClearMark() | |
start = til::point{ GetSelectionAnchor() }; | ||
end = til::point{ GetSelectionEnd() }; | ||
} | ||
auto inSelection = [&start, &end](const DispatchTypes::ScrollMark& m) { | ||
return (m.start >= start && m.start <= end) || | ||
(m.end >= start && m.end <= end); | ||
}; | ||
|
||
_scrollMarks.erase(std::remove_if(_scrollMarks.begin(), | ||
_scrollMarks.end(), | ||
inSelection), | ||
_scrollMarks.end()); | ||
_activeBuffer().ClearMarksInRange(start, end); | ||
|
||
// Tell the control that the scrollbar has somehow changed. Used as a | ||
// workaround to force the control to redraw any scrollbar marks | ||
_NotifyScrollEvent(); | ||
} | ||
void Terminal::ClearAllMarks() noexcept | ||
{ | ||
_scrollMarks.clear(); | ||
_activeBuffer().ClearAllMarks(); | ||
// Tell the control that the scrollbar has somehow changed. Used as a | ||
// workaround to force the control to redraw any scrollbar marks | ||
_NotifyScrollEvent(); | ||
} | ||
|
||
const std::vector<DispatchTypes::ScrollMark>& Terminal::GetScrollMarks() const noexcept | ||
const std::vector<ScrollMark>& Terminal::GetScrollMarks() const noexcept | ||
{ | ||
// TODO: GH#11000 - when the marks are stored per-buffer, get rid of this. | ||
// We want to return _no_ marks when we're in the alt buffer, to effectively | ||
// hide them. We need to return a reference, so we can't just ctor an empty | ||
// list here just for when we're in the alt buffer. | ||
static const std::vector<DispatchTypes::ScrollMark> _altBufferMarks{}; | ||
return _inAltBuffer() ? _altBufferMarks : _scrollMarks; | ||
return _activeBuffer().GetMarks(); | ||
} | ||
|
||
til::color Terminal::GetColorForMark(const Microsoft::Console::VirtualTerminal::DispatchTypes::ScrollMark& mark) const | ||
til::color Terminal::GetColorForMark(const ScrollMark& mark) const | ||
{ | ||
if (mark.color.has_value()) | ||
{ | ||
|
@@ -1430,24 +1415,24 @@ til::color Terminal::GetColorForMark(const Microsoft::Console::VirtualTerminal:: | |
|
||
switch (mark.category) | ||
{ | ||
case Microsoft::Console::VirtualTerminal::DispatchTypes::MarkCategory::Prompt: | ||
case MarkCategory::Prompt: | ||
{ | ||
return _renderSettings.GetColorAlias(ColorAlias::DefaultForeground); | ||
} | ||
case Microsoft::Console::VirtualTerminal::DispatchTypes::MarkCategory::Error: | ||
case MarkCategory::Error: | ||
{ | ||
return _renderSettings.GetColorTableEntry(TextColor::BRIGHT_RED); | ||
} | ||
case Microsoft::Console::VirtualTerminal::DispatchTypes::MarkCategory::Warning: | ||
case MarkCategory::Warning: | ||
{ | ||
return _renderSettings.GetColorTableEntry(TextColor::BRIGHT_YELLOW); | ||
} | ||
case Microsoft::Console::VirtualTerminal::DispatchTypes::MarkCategory::Success: | ||
case MarkCategory::Success: | ||
{ | ||
return _renderSettings.GetColorTableEntry(TextColor::BRIGHT_GREEN); | ||
} | ||
default: | ||
case Microsoft::Console::VirtualTerminal::DispatchTypes::MarkCategory::Info: | ||
case MarkCategory::Info: | ||
{ | ||
return _renderSettings.GetColorAlias(ColorAlias::DefaultForeground); | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use
auto
here.