| 548 | } |
| 549 | |
| 550 | void 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() ); |
nothing calls this directly
no test coverage detected