MCPcopy Create free account
hub / github.com/SpartanJ/eepp / getTextRangeRectangles

Method getTextRangeRectangles

src/eepp/ui/uicodeeditor.cpp:4371–4476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4369}
4370
4371std::vector<Rectf> UICodeEditor::getTextRangeRectangles(
4372 const TextRange& range, const Vector2f& startScroll,
4373 std::optional<const DocumentLineRange> lineRange, std::optional<Float> lineHeight,
4374 std::optional<DocumentViewLineRange> visibleLineRange, bool visualizeNewLines ) {
4375 std::vector<Rectf> rects;
4376 Float lh = lineHeight ? *lineHeight : getLineHeight();
4377 Int64 startLine =
4378 eemax<Int64>( lineRange ? lineRange->first : range.start().line(), range.start().line() );
4379 Int64 endLine =
4380 eemin<Int64>( lineRange ? lineRange->second : range.end().line(), range.end().line() );
4381 for ( auto ln = startLine; ln <= endLine; ln++ ) {
4382 if ( !mDocView.isLineVisible( ln ) )
4383 continue;
4384 const String& line = mDoc->line( ln ).getText();
4385 Rectf selRect;
4386 if ( mDocView.isWrappedLine( ln ) ) {
4387 auto fromInfo = mDocView.getVisibleLineRange(
4388 ln == range.start().line() ? range.start() : mDoc->startOfLine( { ln, 0 } ) );
4389 auto toInfo = mDocView.getVisibleLineRange(
4390 ln == range.end().line() ? range.end() : mDoc->endOfLine( { ln, 0 } ) );
4391 auto realFromInfoVisibleIndex = fromInfo.visibleIndex;
4392 auto realToInfoVisibleIndex = toInfo.visibleIndex;
4393 if ( visibleLineRange ) {
4394 if ( fromInfo.visibleIndex < visibleLineRange->first )
4395 fromInfo.visibleIndex = visibleLineRange->first;
4396 if ( toInfo.visibleIndex > visibleLineRange->second )
4397 toInfo.visibleIndex = visibleLineRange->second;
4398 }
4399
4400 for ( Int64 visibleIdx = static_cast<Int64>( fromInfo.visibleIndex );
4401 visibleIdx <= static_cast<Int64>( toInfo.visibleIndex ); visibleIdx++ ) {
4402 auto info =
4403 mDocView.getVisibleIndexPosition( static_cast<VisibleIndex>( visibleIdx ) );
4404 Vector2d startOffset;
4405 Vector2d endOffset;
4406 if ( ln == range.start().line() && fromInfo.range.start().line() == ln &&
4407 realFromInfoVisibleIndex == static_cast<VisibleIndex>( visibleIdx ) ) {
4408 startOffset =
4409 getTextPositionOffset( range.start(), lh, false, visualizeNewLines );
4410 } else {
4411 startOffset = getTextPositionOffset( info, lh );
4412 }
4413 selRect.Top = startScroll.y + startOffset.y;
4414 selRect.Bottom = selRect.Top + lh;
4415 selRect.Left = startScroll.x + startOffset.x;
4416 if ( ln == range.end().line() && toInfo.range.end().line() == ln &&
4417 realToInfoVisibleIndex == static_cast<VisibleIndex>( visibleIdx ) ) {
4418 endOffset = getTextPositionOffset( range.end(), lh );
4419 } else {
4420 auto nextInfo = mDocView.getVisibleIndexPosition(
4421 static_cast<VisibleIndex>( visibleIdx + 1 ) );
4422 if ( nextInfo.line() == info.line() ) {
4423 endOffset = getTextPositionOffset( { info.line(), nextInfo.column() }, lh,
4424 true, visualizeNewLines );
4425 } else {
4426 endOffset = getTextPositionOffset( mDoc->endOfLine( { ln, 0 } ), lh, true,
4427 visualizeNewLines );
4428 }

Callers 3

drawAfterLineTextMethod · 0.80
drawBeforeLineTextMethod · 0.80
drawAfterLineTextMethod · 0.80

Calls 13

isLineVisibleMethod · 0.80
isWrappedLineMethod · 0.80
startOfLineMethod · 0.80
endOfLineMethod · 0.80
columnMethod · 0.80
push_backMethod · 0.80
startMethod · 0.45
endMethod · 0.45
getTextMethod · 0.45
getVisibleLineRangeMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected