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

Method drawLineNumbers

src/eepp/ui/uicodeeditor.cpp:4493–4621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4491}
4492
4493void UICodeEditor::drawLineNumbers( const DocumentLineRange& lineRange, const Vector2f& startScroll,
4494 const Vector2f& screenStart, const Float& lineHeight,
4495 const Float& lineNumberWidth, const int& lineNumberDigits,
4496 const Float& fontSize ) {
4497 Primitives primitives;
4498 primitives.setColor( Color( mLineNumberBackgroundColor ).blendAlpha( mAlpha ) );
4499 Float w = 0.f;
4500 if ( mShowLineNumber )
4501 w += lineNumberWidth;
4502 bool foldVisible = mShowFoldingRegion && mDoc->getFoldRangeService().canFold();
4503 if ( foldVisible )
4504 w += mFoldRegionWidth;
4505 primitives.drawRectangle( Rectf( { screenStart.x, screenStart.y + mPluginsTopSpace },
4506 Sizef( w, editorHeight() - mPluginsTopSpace ) ) );
4507 TextRange selection = mDoc->getSelection( true );
4508 Float lineOffset = getLineOffset();
4509
4510 for ( auto plugin : mPlugins ) {
4511 plugin->drawLineNumbersBefore( this, lineRange, startScroll, screenStart, lineHeight,
4512 lineNumberWidth, lineNumberDigits, fontSize );
4513 }
4514
4515 for ( int i = lineRange.first; i <= lineRange.second; i++ ) {
4516 if ( !mDocView.isLineVisible( i ) )
4517 continue;
4518 String::StringBaseType pos[16];
4519
4520 if ( mShowLinesRelativePosition && selection.start().line() != i ) {
4521 String::intToStrBuf<int, String::StringBaseType>( eeabs( i - selection.start().line() ),
4522 pos, 16, lineNumberDigits, ' ' );
4523 } else {
4524 String::intToStrBuf<int, String::StringBaseType>( i + 1, pos, 16, lineNumberDigits,
4525 ' ' );
4526 }
4527
4528 auto lnPos(
4529 Vector2f( screenStart.x + mLineNumberPaddingLeft,
4530 startScroll.y + mDocView.getLineYOffset( i, lineHeight ) + lineOffset ) );
4531
4532 if ( mShowLineNumber ) {
4533 Text::draw( String::View{ pos }, lnPos, mFontStyleConfig.Font, fontSize,
4534 ( i >= selection.start().line() && i <= selection.end().line() )
4535 ? mLineNumberActiveFontColor
4536 : mLineNumberFontColor,
4537 mFontStyleConfig.Style, mFontStyleConfig.OutlineThickness,
4538 mFontStyleConfig.OutlineColor, mFontStyleConfig.ShadowColor,
4539 mFontStyleConfig.ShadowOffset, 4, TextHints::AllAscii );
4540 }
4541
4542 if ( foldVisible && mDoc->getFoldRangeService().isFoldingRegionInLine( i ) ) {
4543 bool isFolded = mDocView.isFolded( i );
4544 bool currentLineHasFold =
4545 std::find_if( mDoc->getSelections().begin(), mDoc->getSelections().end(),
4546 [i]( const TextRange& sel ) { return i == sel.start().line(); } ) !=
4547 mDoc->getSelections().end();
4548
4549 if ( mFoldsAlwaysVisible || mFoldsVisible || currentLineHasFold ) {
4550 if ( ( isFolded && mFoldedDrawable ) || ( !isFolded && mFoldedDrawable ) ) {

Callers

nothing calls this directly

Calls 15

eeabsFunction · 0.85
canFoldMethod · 0.80
isLineVisibleMethod · 0.80
getLineYOffsetMethod · 0.80
isFoldingRegionInLineMethod · 0.80
isFoldedMethod · 0.80
getDrawableTypeMethod · 0.80
setColorFilterMethod · 0.80
drawTriangleMethod · 0.80
getLineLengthMethod · 0.80
drawLineNumbersAfterMethod · 0.80
setColorMethod · 0.45

Tested by

no test coverage detected