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

Method displayTooltip

src/tools/ecode/plugins/git/gitplugin.cpp:550–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548}
549
550void GitPlugin::displayTooltip( UICodeEditor* editor, const Git::Blame& blame,
551 const Vector2f& position ) {
552 // HACK: Gets the old font style to restore it when the tooltip is hidden
553 UITooltip* tooltip = editor->createTooltip();
554 if ( tooltip == nullptr )
555 return;
556
557 String str( blame.error.empty()
558 ? String::format( "%s: %s (%s)\n%s: %s (%s)\n%s: %s\n\n%s",
559 i18n( "commit", "Commit" ).toUtf8().c_str(),
560 blame.commitHash.c_str(), blame.commitShortHash.c_str(),
561 i18n( "author", "Author" ).toUtf8().c_str(),
562 blame.author.c_str(), blame.authorEmail.c_str(),
563 i18n( "date", "Date" ).toUtf8().c_str(), blame.date.c_str(),
564 blame.commitMessage.c_str() )
565 : blame.error );
566
567 Text::hardWrapText( str, PixelDensity::dpToPx( 400 ), tooltip->getFontStyleConfig(),
568 editor->getTabWidth() );
569
570 editor->setTooltipText( str );
571
572 mTooltipInfoShowing = true;
573 mOldBackgroundColor = tooltip->getBackgroundColor();
574 if ( Color::Transparent == mOldBackgroundColor ) {
575 tooltip->reloadStyle( true, true, true, true );
576 mOldBackgroundColor = tooltip->getBackgroundColor();
577 }
578 mOldTextStyle = tooltip->getFontStyle();
579 mOldTextAlign = tooltip->getHorizontalAlign();
580 mOldDontAutoHideOnMouseMove = tooltip->dontAutoHideOnMouseMove();
581 mOldUsingCustomStyling = tooltip->getUsingCustomStyling();
582 tooltip->setHorizontalAlign( UI_HALIGN_LEFT );
583 tooltip->setPixelsPosition( tooltip->getTooltipPosition( position ) );
584 tooltip->setDontAutoHideOnMouseMove( true );
585 tooltip->setUsingCustomStyling( true );
586 tooltip->setData( String::hash( "git" ) );
587 tooltip->setBackgroundColor( editor->getColorScheme().getEditorColor( "background"_sst ) );
588 tooltip->getUIStyle()->setStyleSheetProperty( StyleSheetProperty(
589 "background-color",
590 editor->getColorScheme().getEditorColor( "background"_sst ).toHexString(), true,
591 StyleSheetSelectorRule::SpecificityImportant ) );
592
593 if ( !mTooltipCustomSyntaxDef.has_value() ) {
594 static std::vector<SyntaxPattern> patterns;
595
596 patterns.emplace_back( SyntaxPattern( { "([%w:]+)%s(%x+)%s%((%x+)%)" },
597 { "normal", "keyword", "number", "number" } ) );
598 patterns.emplace_back( SyntaxPattern( { "([%w:]+)%s(.*)%(([%w%+%.-]+@[%w%.-]+%.%w+)%)" },
599 { "normal", "keyword", "function", "link" } ) );
600 patterns.emplace_back( SyntaxPattern( { "([%w:]+)%s(%d%d%d%d%-%d%d%-%d%d[%s%d%-+:]+)" },
601 { "normal", "keyword", "warning" } ) );
602 SyntaxDefinition syntaxDef( "custom_build", {}, std::move( patterns ) );
603 mTooltipCustomSyntaxDef = std::move( syntaxDef );
604 }
605
606 SyntaxTokenizer::tokenizeText( *mTooltipCustomSyntaxDef, editor->getColorScheme(),
607 tooltip->getTextCache() );

Callers

nothing calls this directly

Calls 15

formatFunction · 0.85
hashFunction · 0.85
SyntaxPatternClass · 0.85
createTooltipMethod · 0.80
c_strMethod · 0.80
toUtf8Method · 0.80
setTooltipTextMethod · 0.80
getFontStyleMethod · 0.80
getHorizontalAlignMethod · 0.80
setHorizontalAlignMethod · 0.80
setPixelsPositionMethod · 0.80

Tested by

no test coverage detected