diff --git a/bin/assets/ui/breeze.css b/bin/assets/ui/breeze.css index 88b2922fe..0f04cf5bf 100644 --- a/bin/assets/ui/breeze.css +++ b/bin/assets/ui/breeze.css @@ -1091,7 +1091,7 @@ TextInput.table_cell_edit { --primary: #3daee9; --back: #eff0f1; --font: #232627; - --font-highlight: #1a5676; + --font-highlight: #3daee9; --font-hint: #232627; --button-back: #fcfcfc; --button-border: #b3b4b5; diff --git a/include/eepp/ui/tools/uicodeeditorsplitter.hpp b/include/eepp/ui/tools/uicodeeditorsplitter.hpp index bc57dd1d6..764a26aea 100644 --- a/include/eepp/ui/tools/uicodeeditorsplitter.hpp +++ b/include/eepp/ui/tools/uicodeeditorsplitter.hpp @@ -23,7 +23,7 @@ class EE_API UICodeEditorSplitter { class EE_API Client { public: - virtual ~Client(){}; + virtual ~Client() {}; virtual void onTabCreated( UITab* tab, UIWidget* widget ) = 0; @@ -41,6 +41,8 @@ class EE_API UICodeEditorSplitter { virtual void onDocumentCursorPosChange( UICodeEditor* editor, TextDocument& doc ) = 0; + virtual void onDocumentUndoRedo( UICodeEditor* editor, TextDocument& doc ) = 0; + virtual void onColorSchemeChanged( const std::string& currentColorScheme ) = 0; virtual void onDocumentLoaded( UICodeEditor* codeEditor, const std::string& path ) = 0; diff --git a/src/eepp/ui/tools/uicodeeditorsplitter.cpp b/src/eepp/ui/tools/uicodeeditorsplitter.cpp index 27077746a..dd83bbc07 100644 --- a/src/eepp/ui/tools/uicodeeditorsplitter.cpp +++ b/src/eepp/ui/tools/uicodeeditorsplitter.cpp @@ -262,6 +262,10 @@ UICodeEditor* UICodeEditorSplitter::createCodeEditor() { event->getNode()->asType(), event->getNode()->asType()->getDocument() ); } ); + editor->addEventListener( Event::OnDocumentUndoRedo, [this]( const Event* event ) { + mClient->onDocumentUndoRedo( event->getNode()->asType(), + event->getNode()->asType()->getDocument() ); + } ); editor->addKeyBinds( getLocalDefaultKeybindings() ); editor->addUnlockedCommands( getUnlockedCommands() ); diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 09310e485..b33b9cbd2 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -27,8 +27,6 @@ using namespace EE::UI::Tools; namespace EE { namespace UI { -static const String notSpaceStr = "\t "; - UICodeEditor* UICodeEditor::New() { return eeNew( UICodeEditor, ( true, true ) ); } @@ -3346,6 +3344,7 @@ void UICodeEditor::drawMatchingBrackets( const Vector2f& startScroll, const Floa void UICodeEditor::drawSelectionMatch( const DocumentLineRange& lineRange, const Vector2f& startScroll, const Float& lineHeight ) { + static const String notSpaceStr = "\t "; if ( !mDoc->hasSelection() ) return; TextRange selection = mDoc->getSelection( true ); @@ -3927,7 +3926,7 @@ void UICodeEditor::drawWhitespaces( const DocumentLineRange& lineRange, const Ve mScreenPos.x && position.x <= mScreenPos.x + mScroll.x + mSize.getWidth() ) { if ( ' ' == text[i] ) { - cpoint->draw( Vector2f( position.x, position.y ) ); + cpoint->draw( position ); position.x += glyphW; } else if ( '\t' == text[i] ) { adv->draw( Vector2f( position.x + tabCenter, position.y ) ); @@ -3990,7 +3989,7 @@ void UICodeEditor::drawIndentationGuides( const DocumentLineRange& lineRange, } void UICodeEditor::drawLineEndings( const DocumentLineRange& lineRange, const Vector2f& startScroll, - const Float& lineHeight ) { + const Float& /*lineHeight*/ ) { Color color( Color( mWhitespaceColor ).blendAlpha( mAlpha ) ); auto fontSize = getCharacterSize(); GlyphDrawable* nl = mFont->getGlyphDrawable( 8628 /*'↴'*/, fontSize ); @@ -4001,8 +4000,9 @@ void UICodeEditor::drawLineEndings( const DocumentLineRange& lineRange, const Ve for ( auto index = lineRange.first; index <= lineRange.second; index++ ) { if ( !mDocView.isLineVisible( index ) ) continue; - Vector2f position( { startScroll.x + getLineWidth( index ) - getGlyphWidth(), - startScroll.y + mDocView.getLineYOffset( index, lineHeight ) } ); + auto offset = + getTextPositionOffset( { index, static_cast( mDoc->line( index ).size() ) } ); + Vector2f position( { startScroll.x + offset.x, startScroll.y + offset.y } ); nl->draw( Vector2f( position.x, position.y ) ); } } @@ -4426,6 +4426,7 @@ void UICodeEditor::drawMinimap( const Vector2f& start, const DocumentLineRange&, auto text( selectionLine.view().substr( selection.start().column(), selection.end().column() - selection.start().column() ) ); + static const String notSpaceStr = "\t "; if ( !text.empty() && text.find_first_not_of( notSpaceStr.view() ) != String::InvalidPos ) { selectionString = text; diff --git a/src/tools/ecode/applayout.xml.hpp b/src/tools/ecode/applayout.xml.hpp index b855132e2..aef3431e8 100644 --- a/src/tools/ecode/applayout.xml.hpp +++ b/src/tools/ecode/applayout.xml.hpp @@ -456,6 +456,29 @@ Anchor.error:hover { margin-right: 2dp; font-style: shadow; } + +#code_container Tab.tab_modified > tab::icon { + tint: var(--font-highlight); +} +#code_container Tab.tab_clear > tab::icon { + tint: var(--icon); +} +#code_container Tab.tab_clear:selected > tab::icon, +#code_container Tab.tab_clear:not(:selected):hover > tab::icon { + tint: var(--menu-font-active); +} + +@media (prefers-color-scheme: light) { + +#code_container Tab.tab_clear > tab::icon, +#code_container Tab.tab_clear:selected > tab::icon, { + tint: var(--icon); +} +#code_container Tab.tab_clear:not(:selected):hover > tab::icon { + tint: var(--menu-font-active); +} + +} ]]> )html" diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 83c92d82d..2a65bdec5 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -152,19 +152,21 @@ std::string App::titleFromEditor( UICodeEditor* editor ) { void App::updateEditorTabTitle( UICodeEditor* editor ) { if ( editor == nullptr ) return; - std::string title( titleFromEditor( editor ) ); if ( editor->getData() ) { UITab* tab = (UITab*)editor->getData(); - tab->setText( title ); + tab->setText( editor->getDocument().getFilename() ); + + bool dirty = editor->getDocument().isDirty(); + tab->removeClass( dirty ? "tab_clear" : "tab_modified" ); + tab->addClass( dirty ? "tab_modified" : "tab_clear" ); } } void App::updateEditorTitle( UICodeEditor* editor ) { if ( editor == nullptr ) return; - std::string title( titleFromEditor( editor ) ); updateEditorTabTitle( editor ); - setAppTitle( title ); + setAppTitle( titleFromEditor( editor ) ); } void App::setAppTitle( const std::string& title ) { @@ -195,12 +197,16 @@ void App::onDocumentModified( UICodeEditor* editor, TextDocument& ) { if ( isDirty != wasDirty ) setAppTitle( titleFromEditor( editor ) ); - bool tabDirty = ( (UITab*)editor->getData() )->getText().lastChar() == '*'; + bool tabDirty = ( (UITab*)editor->getData() )->hasClass( "tab_modified" ); if ( isDirty != tabDirty ) updateEditorTitle( editor ); } +void App::onDocumentUndoRedo( UICodeEditor* editor, TextDocument& doc ) { + onDocumentModified( editor, doc ); +} + void App::openFileDialog() { UIFileDialog* dialog = UIFileDialog::New( UIFileDialog::DefaultFlags, "*", diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index 3925bc366..630d9356b 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -592,6 +592,8 @@ class App : public UICodeEditorSplitter::Client { void onDocumentModified( UICodeEditor* editor, TextDocument& ); + void onDocumentUndoRedo( UICodeEditor* editor, TextDocument& ); + void onColorSchemeChanged( const std::string& ); void onRealDocumentLoaded( UICodeEditor* editor, const std::string& path ); diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp index a1d1da9d6..dbdec5325 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp @@ -18,13 +18,11 @@ LSPDocumentClient::LSPDocumentClient( LSPClientServer* server, TextDocument* doc notifyOpen(); requestSymbolsDelayed(); requestSemanticHighlightingDelayed(); - doc->getFoldRangeService().setProvider( [this]( auto, bool requestFolds ) -> bool { - bool ret = mServer->getCapabilities().foldingRangeProvider; - if ( ret && requestFolds ) - requestFoldRange(); - return ret; + mDoc->getFoldRangeService().setProvider( [this]( auto, bool requestFolds ) -> bool { + return tryRequestFoldRanges( requestFolds ); } ); - mDoc->getFoldRangeService().findRegions(); + if ( mDoc->getFoldRangeService().isEnabled() ) + tryRequestFoldRanges( true ); } LSPDocumentClient::~LSPDocumentClient() { @@ -40,6 +38,13 @@ LSPDocumentClient::~LSPDocumentClient() { Sys::sleep( Milliseconds( 0.1f ) ); } +bool LSPDocumentClient::tryRequestFoldRanges( bool requestFolds ) { + bool ret = mServer->getCapabilities().foldingRangeProvider; + if ( ret && requestFolds ) + requestFoldRange(); + return ret; +} + void LSPDocumentClient::onDocumentLoaded( TextDocument* ) { refreshTag(); requestSemanticHighlightingDelayed(); diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp index 3b75c81ad..95c8326b4 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.hpp @@ -66,6 +66,8 @@ class LSPDocumentClient : public TextDocument::Client { void requestCodeLens(); + bool tryRequestFoldRanges( bool requestFolds ); + protected: LSPClientServer* mServer{ nullptr }; LSPClientServerManager* mServerManager{ nullptr }; diff --git a/src/tools/uieditor/uieditor.cpp b/src/tools/uieditor/uieditor.cpp index 76b82a0ec..82e304cdf 100644 --- a/src/tools/uieditor/uieditor.cpp +++ b/src/tools/uieditor/uieditor.cpp @@ -1480,6 +1480,8 @@ void App::onDocumentModified( UICodeEditor* editor, TextDocument& doc ) { } } +void App::onDocumentUndoRedo( UICodeEditor*, TextDocument& ) {} + void App::onDocumentLoaded( UICodeEditor* editor, const std::string& path ) { mSplitter->removeUnusedTab( mSplitter->tabWidgetFromEditor( editor ) ); diff --git a/src/tools/uieditor/uieditor.hpp b/src/tools/uieditor/uieditor.hpp index ab080540e..3a4cbb506 100644 --- a/src/tools/uieditor/uieditor.hpp +++ b/src/tools/uieditor/uieditor.hpp @@ -34,6 +34,8 @@ class App : public UICodeEditorSplitter::Client { virtual void onDocumentModified( UICodeEditor*, TextDocument& ); + virtual void onDocumentUndoRedo( UICodeEditor*, TextDocument& ); + virtual void onDocumentSelectionChange( UICodeEditor*, TextDocument& ); virtual void onDocumentCursorPosChange( UICodeEditor*, TextDocument& ){};