From 5271e2fd2e92c45de160468f70f91ea9ce21d2c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 8 Feb 2024 22:42:01 -0300 Subject: [PATCH] Rename UndoStack to TextUndoStack. --- include/eepp/ui/doc/textdocument.hpp | 6 +-- .../doc/{undostack.hpp => textundostack.hpp} | 10 ++-- projects/linux/ee.files | 4 +- .../doc/{undostack.cpp => textundostack.cpp} | 50 +++++++++---------- .../ecode/plugins/lsp/lspclientserver.hpp | 1 - 5 files changed, 35 insertions(+), 36 deletions(-) rename include/eepp/ui/doc/{undostack.hpp => textundostack.hpp} (93%) rename src/eepp/ui/doc/{undostack.cpp => textundostack.cpp} (75%) diff --git a/include/eepp/ui/doc/textdocument.hpp b/include/eepp/ui/doc/textdocument.hpp index 74d68a0ae..733dedabe 100644 --- a/include/eepp/ui/doc/textdocument.hpp +++ b/include/eepp/ui/doc/textdocument.hpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include @@ -596,10 +596,10 @@ class EE_API TextDocument { void resetUndoRedo(); protected: - friend class UndoStack; + friend class TextUndoStack; Uint64 mModificationId{ 0 }; - UndoStack mUndoStack; + TextUndoStack mUndoStack; std::string mFilePath; std::string mLoadingFilePath; std::array mHash; diff --git a/include/eepp/ui/doc/undostack.hpp b/include/eepp/ui/doc/textundostack.hpp similarity index 93% rename from include/eepp/ui/doc/undostack.hpp rename to include/eepp/ui/doc/textundostack.hpp index 0969a6261..60b4b4310 100644 --- a/include/eepp/ui/doc/undostack.hpp +++ b/include/eepp/ui/doc/textundostack.hpp @@ -1,5 +1,5 @@ -#ifndef EE_UI_DOC_UNDOSTACK_HPP -#define EE_UI_DOC_UNDOSTACK_HPP +#ifndef EE_UI_DOC_TEXTUNDOSTACK_HPP +#define EE_UI_DOC_TEXTUNDOSTACK_HPP #include #include @@ -80,11 +80,11 @@ class EE_API TextUndoCommandSelection : public TextUndoCommand { using UndoStackContainer = std::deque; -class EE_API UndoStack { +class EE_API TextUndoStack { public: - UndoStack( TextDocument* owner, const Uint32& maxStackSize = 10000 ); + TextUndoStack( TextDocument* owner, const Uint32& maxStackSize = 10000 ); - ~UndoStack(); + ~TextUndoStack(); void clear(); diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 8e9509cc5..e71b0552c 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -343,7 +343,7 @@ ../../include/eepp/ui/doc/textdocumentline.hpp ../../include/eepp/ui/doc/textposition.hpp ../../include/eepp/ui/doc/textrange.hpp -../../include/eepp/ui/doc/undostack.hpp +../../include/eepp/ui/doc/textundostack.hpp ../../include/eepp/ui/keyboardshortcut.hpp ../../include/eepp/ui/marginmove/scale.hpp ../../include/eepp/ui/models/csspropertiesmodel.hpp @@ -951,7 +951,7 @@ ../../src/eepp/ui/doc/syntaxhighlighter.cpp ../../src/eepp/ui/doc/syntaxtokenizer.cpp ../../src/eepp/ui/doc/textdocument.cpp -../../src/eepp/ui/doc/undostack.cpp +../../src/eepp/ui/doc/textundostack.cpp ../../src/eepp/ui/keyboardshortcut.cpp ../../src/eepp/ui/models/filesystemmodel.cpp ../../src/eepp/ui/models/model.cpp diff --git a/src/eepp/ui/doc/undostack.cpp b/src/eepp/ui/doc/textundostack.cpp similarity index 75% rename from src/eepp/ui/doc/undostack.cpp rename to src/eepp/ui/doc/textundostack.cpp index 500bdc8a9..4602b1476 100644 --- a/src/eepp/ui/doc/undostack.cpp +++ b/src/eepp/ui/doc/textundostack.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include using namespace EE::System; @@ -73,36 +73,36 @@ size_t TextUndoCommandSelection::getCursorIdx() const { return mCursorIdx; } -UndoStack::UndoStack( TextDocument* owner, const Uint32& maxStackSize ) : +TextUndoStack::TextUndoStack( TextDocument* owner, const Uint32& maxStackSize ) : mDoc( owner ), mMaxStackSize( maxStackSize ), mChangeIdCounter( 0 ), mMergeTimeout( Milliseconds( 300.f ) ) {} -UndoStack::~UndoStack() { +TextUndoStack::~TextUndoStack() { clear(); } -void UndoStack::clear() { +void TextUndoStack::clear() { clearUndoStack(); clearRedoStack(); } -void UndoStack::clearUndoStack() { +void TextUndoStack::clearUndoStack() { for ( TextUndoCommand* cmd : mUndoStack ) { eeDelete( cmd ); } mUndoStack.clear(); } -void UndoStack::clearRedoStack() { +void TextUndoStack::clearRedoStack() { for ( TextUndoCommand* cmd : mRedoStack ) { eeDelete( cmd ); } mRedoStack.clear(); } -void UndoStack::pushUndo( UndoStackContainer& undoStack, TextUndoCommand* cmd ) { +void TextUndoStack::pushUndo( UndoStackContainer& undoStack, TextUndoCommand* cmd ) { undoStack.push_back( cmd ); while ( undoStack.size() > mMaxStackSize ) { eeDelete( undoStack.front() ); @@ -110,26 +110,26 @@ void UndoStack::pushUndo( UndoStackContainer& undoStack, TextUndoCommand* cmd ) } } -void UndoStack::pushInsert( UndoStackContainer& undoStack, const String& string, - const size_t& cursorIdx, const TextPosition& position, - const Time& time ) { +void TextUndoStack::pushInsert( UndoStackContainer& undoStack, const String& string, + const size_t& cursorIdx, const TextPosition& position, + const Time& time ) { pushUndo( undoStack, eeNew( TextUndoCommandInsert, ( ++mChangeIdCounter, cursorIdx, string, position, time ) ) ); } -void UndoStack::pushRemove( UndoStackContainer& undoStack, const size_t& cursorIdx, - const TextRange& range, const Time& time ) { +void TextUndoStack::pushRemove( UndoStackContainer& undoStack, const size_t& cursorIdx, + const TextRange& range, const Time& time ) { pushUndo( undoStack, eeNew( TextUndoCommandRemove, ( ++mChangeIdCounter, cursorIdx, range, time ) ) ); } -void UndoStack::pushSelection( UndoStackContainer& undoStack, const size_t& cursorIdx, - const TextRanges& selection, const Time& time ) { +void TextUndoStack::pushSelection( UndoStackContainer& undoStack, const size_t& cursorIdx, + const TextRanges& selection, const Time& time ) { pushUndo( undoStack, eeNew( TextUndoCommandSelection, ( ++mChangeIdCounter, cursorIdx, selection, time ) ) ); } -void UndoStack::popUndo( UndoStackContainer& undoStack, UndoStackContainer& redoStack ) { +void TextUndoStack::popUndo( UndoStackContainer& undoStack, UndoStackContainer& redoStack ) { if ( undoStack.empty() ) return; @@ -166,45 +166,45 @@ void UndoStack::popUndo( UndoStackContainer& undoStack, UndoStackContainer& redo } } -void UndoStack::undo() { +void TextUndoStack::undo() { popUndo( mUndoStack, mRedoStack ); } -void UndoStack::redo() { +void TextUndoStack::redo() { popUndo( mRedoStack, mUndoStack ); } -bool UndoStack::hasUndo() const { +bool TextUndoStack::hasUndo() const { return !mUndoStack.empty(); } -bool UndoStack::hasRedo() const { +bool TextUndoStack::hasRedo() const { return !mRedoStack.empty(); } -const Uint32& UndoStack::getMaxStackSize() const { +const Uint32& TextUndoStack::getMaxStackSize() const { return mMaxStackSize; } -const Time& UndoStack::getMergeTimeout() const { +const Time& TextUndoStack::getMergeTimeout() const { return mMergeTimeout; } -void UndoStack::setMergeTimeout( const Time& mergeTimeout ) { +void TextUndoStack::setMergeTimeout( const Time& mergeTimeout ) { mMergeTimeout = mergeTimeout; } -Uint64 UndoStack::getCurrentChangeId() const { +Uint64 TextUndoStack::getCurrentChangeId() const { if ( mUndoStack.empty() ) return 0; return mUndoStack.back()->getId(); } -UndoStackContainer& UndoStack::getUndoStackContainer() { +UndoStackContainer& TextUndoStack::getUndoStackContainer() { return mUndoStack; } -UndoStackContainer& UndoStack::getRedoStackContainer() { +UndoStackContainer& TextUndoStack::getRedoStackContainer() { return mRedoStack; } diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.hpp b/src/tools/ecode/plugins/lsp/lspclientserver.hpp index cc3085de1..25ea55acc 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.hpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.hpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include