-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
atlas: draw selection colors as background/foreground instead of alpha overlay #17725
Changes from 1 commit
42713b5
7060e82
c67220d
c105fdf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This lets us get rid of SelectionFrom/SelectionTo and the selection quad.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -311,6 +311,8 @@ CATCH_RETURN() | |
_api.searchHighlightFocused = { info.searchHighlightFocused, 1 }; | ||
} | ||
} | ||
|
||
_api.selectionSpans = til::point_span_subspan_within_rect(info.selectionSpans, dr); | ||
} | ||
|
||
return S_OK; | ||
|
@@ -411,9 +413,10 @@ try | |
const auto end = isFinalRow ? std::min(hiEnd.x + 1, x2) : x2; | ||
_fillColorBitmap(row, x1, end, fgColor, bgColor); | ||
|
||
// Return early if we couldn't paint the whole region. We will resume | ||
// from here in the next call. | ||
if (!isFinalRow || end == x2) | ||
// Return early if we couldn't paint the whole region (either this was not the last row, or | ||
// it was the last row but the highlight ends outside of our x range.) | ||
// We will resume from here in the next call. | ||
if (!isFinalRow || hiEnd.x /*inclusive*/ >= x2 /*exclusive*/) | ||
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. This is the thing it took hours to fix lol 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. Wait, Ahh, hmm. Thanks for fixing this 🥲😃 |
||
{ | ||
return S_OK; | ||
} | ||
|
@@ -497,6 +500,7 @@ try | |
// Apply the highlighting colors to the highlighted cells | ||
RETURN_IF_FAILED(_drawHighlighted(_api.searchHighlights, y, x, columnEnd, highlightFg, highlightBg)); | ||
RETURN_IF_FAILED(_drawHighlighted(_api.searchHighlightFocused, y, x, columnEnd, highlightFocusFg, highlightFocusBg)); | ||
RETURN_IF_FAILED(_drawHighlighted(_api.selectionSpans, y, x, columnEnd, _api.s->misc->selectionForeground, _api.s->misc->selectionColor)); | ||
|
||
_api.lastPaintBufferLineCoord = { x, y }; | ||
return S_OK; | ||
|
@@ -563,28 +567,9 @@ try | |
CATCH_RETURN() | ||
|
||
[[nodiscard]] HRESULT AtlasEngine::PaintSelection(const til::rect& rect) noexcept | ||
try | ||
{ | ||
// Unfortunately there's no step after Renderer::_PaintBufferOutput that | ||
// would inform us that it's done with the last AtlasEngine::PaintBufferLine. | ||
// As such we got to call _flushBufferLine() here just to be sure. | ||
_flushBufferLine(); | ||
|
||
const auto y = gsl::narrow_cast<u16>(clamp<til::CoordType>(rect.top, 0, _p.s->viewportCellCount.y - 1)); | ||
const auto from = gsl::narrow_cast<u16>(clamp<til::CoordType>(rect.left, 0, _p.s->viewportCellCount.x - 1)); | ||
const auto to = gsl::narrow_cast<u16>(clamp<til::CoordType>(rect.right, from, _p.s->viewportCellCount.x)); | ||
|
||
auto& row = *_p.rows[y]; | ||
row.selectionFrom = from; | ||
row.selectionTo = to; | ||
|
||
_p.dirtyRectInPx.left = std::min(_p.dirtyRectInPx.left, from * _p.s->font->cellSize.x); | ||
_p.dirtyRectInPx.top = std::min(_p.dirtyRectInPx.top, y * _p.s->font->cellSize.y); | ||
_p.dirtyRectInPx.right = std::max(_p.dirtyRectInPx.right, to * _p.s->font->cellSize.x); | ||
_p.dirtyRectInPx.bottom = std::max(_p.dirtyRectInPx.bottom, _p.dirtyRectInPx.top + _p.s->font->cellSize.y); | ||
return S_OK; | ||
} | ||
CATCH_RETURN() | ||
|
||
[[nodiscard]] HRESULT AtlasEngine::PaintCursor(const CursorOptions& options) noexcept | ||
try | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
#define SHADING_TYPE_CURLY_LINE 7 | ||
#define SHADING_TYPE_SOLID_LINE 8 | ||
#define SHADING_TYPE_CURSOR 9 | ||
#define SHADING_TYPE_SELECTION 10 | ||
#define SHADING_TYPE_FILLED_RECT 10 | ||
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. better name would be A-OK with me |
||
|
||
struct VSData | ||
{ | ||
|
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.
Hold up, this has
color
twice. (1st param is fg, 2nd param is bg.)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.
Oh, I see: I misread the code in BackendD3D for cursor colors. I thought it did pass the background twice, but it passes
background
andbg
(lol)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.
Oh, no, I didn't misread. I pulled this from BackendD3D
_drawCursorForegroundSlowPath
It uses a foreground and a background, whereas we don't have a foreground color to speak of yet.