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

Method drawLineText

src/eepp/ui/uicodeeditor.cpp:4037–4369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4035}
4036
4037void UICodeEditor::drawLineText( const Int64& line, Vector2f position, const Float& fontSize,
4038 const Float& lineHeight,
4039 const DocumentViewLineRange& visibleLineRange ) {
4040 Vector2f originalPosition( position );
4041 // const auto& tokens = mDoc->getHighlighter()->getLine( line );
4042 mDoc->getHighlighter()->copyLineToBuffer( line, mTokens );
4043 const auto& tokens = mTokens;
4044 const auto& docLine = mDoc->line( line );
4045 const String& strLine = docLine.getText();
4046 Primitives primitives;
4047 Int64 curChar = 0;
4048 Int64 maxWidth = eeceil( mSize.getWidth() / getGlyphWidth() + 1 );
4049 bool isMonospace = isMonospaceLine( line );
4050 bool isFallbackFont = false;
4051 bool isEmojiFallbackFont = false;
4052 bool ended = false;
4053 Float lineOffset = getLineOffset();
4054 size_t pos = 0;
4055 Float initX = position.x;
4056 Uint32 drawHints = docLine.getTextHints() | getWidgetTextDrawHints();
4057 if ( mDoc->mightBeBinary() && mFont->getType() == FontType::TTF ) {
4058 FontTrueType* ttf = static_cast<FontTrueType*>( mFont );
4059 isFallbackFont = ttf->isFallbackFontEnabled();
4060 isEmojiFallbackFont = ttf->isEmojiFallbackEnabled();
4061 ttf->setEnableFallbackFont( false );
4062 ttf->setEnableEmojiFallback( false );
4063 }
4064
4065 const std::vector<ColorBoxData>* colorBoxesPtr = nullptr;
4066 size_t colorBoxIdx = 0;
4067 if ( mEnableInlineColorBoxes ) {
4068 auto it = mColorBoxesCache.find( line );
4069 if ( it == mColorBoxesCache.end() || it->second.first != mDoc->getLineHash( line ) ) {
4070 std::vector<ColorBoxData> colorBoxes;
4071 size_t cachePos = 0;
4072 for ( const auto& token : tokens ) {
4073 if ( token.type == "string"_sst || token.type == "number"_sst ||
4074 token.type == "literal"_sst ) {
4075 String::View text = strLine.view().substr( cachePos, token.len );
4076 String::View str = String::trim( text );
4077 if ( str.size() >= 4 ) {
4078 if ( str[0] == '"' || str[0] == '\'' )
4079 str = str.substr( 1 );
4080 if ( !str.empty() && ( str.back() == '"' || str.back() == '\'' ) )
4081 str = str.substr( 0, str.size() - 1 );
4082 if ( Color::isColorString( str, false ) ) {
4083 ColorBoxData data;
4084 data.startColumn = cachePos;
4085 data.endColumn = cachePos + token.len;
4086 data.color = Color::fromString( String( str ).toUtf8() );
4087 colorBoxes.push_back( data );
4088 }
4089 }
4090 }
4091 cachePos += token.len;
4092 }
4093 mColorBoxesCache[line] = { mDoc->getLineHash( line ), std::move( colorBoxes ) };
4094 it = mColorBoxesCache.find( line );

Callers

nothing calls this directly

Calls 15

getWidgetTextDrawHintsFunction · 0.85
fromStringFunction · 0.85
visibleIndexOffsetFunction · 0.85
getTextWidthFunction · 0.85
eemaxFunction · 0.85
eeminFunction · 0.85
copyLineToBufferMethod · 0.80
getHighlighterMethod · 0.80
mightBeBinaryMethod · 0.80
isFallbackFontEnabledMethod · 0.80
setEnableFallbackFontMethod · 0.80

Tested by

no test coverage detected