Rename UndoStack to TextUndoStack.

This commit is contained in:
Martín Lucas Golini
2024-02-08 22:42:01 -03:00
parent 2541dccfc9
commit 5271e2fd2e
5 changed files with 35 additions and 36 deletions

View File

@@ -16,7 +16,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 <functional>
#include <vector>
@@ -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<Uint8, 16> mHash;

View File

@@ -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 <deque>
#include <eepp/config.hpp>
@@ -80,11 +80,11 @@ class EE_API TextUndoCommandSelection : public TextUndoCommand {
using UndoStackContainer = std::deque<TextUndoCommand*>;
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();

View File

@@ -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

View File

@@ -1,6 +1,6 @@
#include <eepp/core/core.hpp>
#include <eepp/ui/doc/textdocument.hpp>
#include <eepp/ui/doc/undostack.hpp>
#include <eepp/ui/doc/textundostack.hpp>
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;
}

View File

@@ -9,7 +9,6 @@
#include <eepp/network/tcpsocket.hpp>
#include <eepp/system/process.hpp>
#include <eepp/ui/doc/textdocument.hpp>
#include <eepp/ui/doc/undostack.hpp>
#include <eepp/ui/uicodeeditor.hpp>
#include <eepp/ui/uipopupmenu.hpp>
#include <memory>