From 336afe90d7c4cec457a64aa8c3cd3dffaced4ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 4 May 2026 19:30:56 -0300 Subject: [PATCH] Fixed a rendering bug in the terminal emulator when updated line only updated spaces. Added an optimization for scene loading. Do not allow the spell checker renderer to try to render on too long lines. --- .ecode/project_build.json | 2 +- include/eepp/ui/uiscenenode.hpp | 3 +++ src/eepp/ui/uiscenenode.cpp | 27 ++++++++++++++----- src/eepp/ui/uiwidgetcreator.cpp | 1 + .../src/eterm/terminal/terminaldisplay.cpp | 12 ++++++--- .../src/eterm/terminal/terminalemulator.cpp | 1 + .../spellchecker/spellcheckerplugin.cpp | 3 ++- 7 files changed, 38 insertions(+), 11 deletions(-) diff --git a/.ecode/project_build.json b/.ecode/project_build.json index 674aff317..a6aadfa91 100644 --- a/.ecode/project_build.json +++ b/.ecode/project_build.json @@ -476,7 +476,7 @@ "eepp-linux-ninja": { "build": [ { - "args": "--disable-static-build --with-debug-symbols --with-backend=SDL3 ninja", + "args": "--disable-static-build --with-debug-symbols --with-backend=SDL3 ninja", "command": "premake5", "working_dir": "${project_root}" }, diff --git a/include/eepp/ui/uiscenenode.hpp b/include/eepp/ui/uiscenenode.hpp index 6bf27f7ff..2733982ee 100644 --- a/include/eepp/ui/uiscenenode.hpp +++ b/include/eepp/ui/uiscenenode.hpp @@ -748,6 +748,7 @@ class EE_API UISceneNode : public SceneNode { CSS::StyleSheet mStyleSheet; bool mIsLoading{ false }; bool mUpdatingLayouts{ false }; + bool mStyleDuringLoad{ false }; UIThemeManager* mUIThemeManager{ nullptr }; UIIconThemeManager* mUIIconThemeManager{ nullptr }; std::vector mFontFaces; @@ -984,6 +985,8 @@ class EE_API UISceneNode : public SceneNode { /** @return The document / scene URI used to resolve paths from a complete URI (with * path+query+fragment+etc) */ URI getURIFromURL( const URI& url ) const; + + void updateStyleSheet( bool forceReloadStyle = true ); }; }} // namespace EE::UI diff --git a/src/eepp/ui/uiscenenode.cpp b/src/eepp/ui/uiscenenode.cpp index a902cabb3..3c7e52df5 100644 --- a/src/eepp/ui/uiscenenode.cpp +++ b/src/eepp/ui/uiscenenode.cpp @@ -371,6 +371,11 @@ UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent, const innerClock.getElapsedTimeAndReset().asMilliseconds() ); } + if ( mStyleDuringLoad ) { + updateStyleSheet( false ); + mStyleDuringLoad = false; + } + for ( auto& widget : widgets ) widget->reloadStyle( true, true, true ); @@ -380,6 +385,7 @@ UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent, const } mIsLoading = false; + SceneManager::instance()->setCurrentUISceneNode( prevUISceneNode ); if ( mVerbose ) { @@ -406,18 +412,13 @@ void UISceneNode::setStyleSheet( const std::string& inlineStyleSheet ) { setStyleSheet( parser.getStyleSheet() ); } -void UISceneNode::combineStyleSheet( const CSS::StyleSheet& styleSheet, bool forceReloadStyle, - URI baseURI ) { - mStyleSheet.combineStyleSheet( styleSheet ); - +void UISceneNode::updateStyleSheet( bool forceReloadStyle ) { bool mediaChanged = false; if ( !mStyleSheet.isMediaQueryListEmpty() && mStyleSheet.updateMediaLists( getMediaFeatures() ) ) { mediaChanged = true; } - processStyleSheetAtRules( styleSheet, baseURI ); - if ( mRoot && mRoot->getUIStyle() ) mRoot->getUIStyle()->resetGlobalDefinition(); @@ -428,6 +429,20 @@ void UISceneNode::combineStyleSheet( const CSS::StyleSheet& styleSheet, bool for reloadStyle(); } +void UISceneNode::combineStyleSheet( const CSS::StyleSheet& styleSheet, bool forceReloadStyle, + URI baseURI ) { + mStyleSheet.combineStyleSheet( styleSheet ); + + processStyleSheetAtRules( styleSheet, baseURI ); + + if ( mIsLoading ) { + mStyleDuringLoad = true; + return; + } + + updateStyleSheet( forceReloadStyle ); +} + void UISceneNode::combineStyleSheet( const std::string& inlineStyleSheet, bool forceReloadStyle, const Uint32& marker, URI baseURI ) { CSS::StyleSheetParser parser; diff --git a/src/eepp/ui/uiwidgetcreator.cpp b/src/eepp/ui/uiwidgetcreator.cpp index ed83504e2..7c0e54505 100644 --- a/src/eepp/ui/uiwidgetcreator.cpp +++ b/src/eepp/ui/uiwidgetcreator.cpp @@ -149,6 +149,7 @@ void UIWidgetCreator::createBaseWidgetList() { registeredWidget["del"] = UITextSpan::NewStrikethrough; registeredWidget["font"] = UITextSpan::NewFont; registeredWidget["code"] = UITextSpan::NewCode; + registeredWidget["tt"] = [] { return UITextSpan::NewWithTag( "tt" ); }; registeredWidget["mark"] = UITextSpan::NewMark; registeredWidget["div"] = UIRichText::NewDiv; registeredWidget["p"] = UIRichText::NewParagraph; diff --git a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp index 771835fdc..b7553e162 100644 --- a/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp +++ b/src/modules/eterm/src/eterm/terminal/terminaldisplay.cpp @@ -1359,23 +1359,29 @@ void TerminalDisplay::drawGrid( const Vector2f& pos ) { auto advanceX = spaceCharAdvanceX * ( isWide ? 2.0f : 1.0f ); if ( glyph.mode & ATTR_WDUMMY ) { - if ( mVBForeground ) + if ( mVBForeground ) { mVBForeground->setQuadColor( mCurGridPos, Color::Transparent ); + dirtyFG = true; + } continue; } if ( glyph.u == 32 && !( glyph.mode & ( ATTR_UNDERLINE | ATTR_STRUCK ) ) ) { x += advanceX; - if ( mVBForeground ) + if ( mVBForeground ) { mVBForeground->setQuadColor( mCurGridPos, Color::Transparent ); + dirtyFG = true; + } continue; } if ( glyph.mode & ATTR_BOXDRAW ) { auto bd = TerminalEmulator::boxdrawindex( &glyph ); drawbox( x, y, advanceX, lineHeight, fg, bg, bd ); - if ( mVBForeground ) + if ( mVBForeground ) { mVBForeground->setQuadColor( mCurGridPos, Color::Transparent ); + dirtyFG = true; + } } else { auto* gd = mFont->getGlyphDrawable( glyph.u, mFontSize, glyph.mode & ATTR_BOLD, glyph.mode & ATTR_ITALIC, 0 ); diff --git a/src/modules/eterm/src/eterm/terminal/terminalemulator.cpp b/src/modules/eterm/src/eterm/terminal/terminalemulator.cpp index fe633c99e..7bc0966f6 100644 --- a/src/modules/eterm/src/eterm/terminal/terminalemulator.cpp +++ b/src/modules/eterm/src/eterm/terminal/terminalemulator.cpp @@ -2740,6 +2740,7 @@ int TerminalEmulator::twrite( const char* buf, int buflen, int show_ctrl ) { u = buf[n] & 0xFF; charsize = 1; } + if ( show_ctrl && ISCONTROL( u ) ) { if ( u & 0x80 ) { u &= 0x7f; diff --git a/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp b/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp index c27eab15e..dccc38b29 100644 --- a/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp +++ b/src/tools/ecode/plugins/spellchecker/spellcheckerplugin.cpp @@ -424,7 +424,8 @@ void SpellCheckerPlugin::drawAfterLineText( UICodeEditor* editor, const Int64& i for ( size_t i = 0; i < matches.size(); ++i ) { auto& match = matches[i]; - if ( match.lineHash != doc->getLineHash( index ) ) + if ( match.lineHash != doc->getLineHash( index ) || + doc->getLineLength( index ) > ( EE_1KB * 10 ) ) return; Text line( "", editor->getFont(), editor->getFontSize() );