Permalink
Browse files

Fixed: Replace all now counts as a single Undo/Redo action

  • Loading branch information...
1 parent f3d7ef1 commit ebe685805218b6d1ce6eb290fcd78457919aa1d3 @Mezomish committed Feb 20, 2012
Showing with 36 additions and 1 deletion.
  1. +12 −0 include/Document.h
  2. +1 −1 include/JuffPlugin.h
  3. +8 −0 src/app/SearchEngine.cpp
  4. +13 −0 src/app/qsci/SciDoc.cpp
  5. +2 −0 src/app/qsci/SciDoc.h
View
@@ -207,6 +207,18 @@ Q_OBJECT
virtual void insertText(const QString&) {}
/**
+ * Begins an undo action
+ * Used when you want to group several changes into one undo/redo operation.
+ */
+ virtual void beginUndoAction() {}
+
+ /**
+ * Ends an undo action.
+ * Used when you want to group several changes into one undo/redo operation.
+ */
+ virtual void endUndoAction() {}
+
+ /**
* Sets params loaded from saved session.
*/
virtual void setSessionParams(const Juff::SessionParams&) {}
View
@@ -148,6 +148,6 @@ class LIBJUFF_EXPORT JuffPlugin {
JuffAPI* api_;
};
-Q_DECLARE_INTERFACE(JuffPlugin, "JuffEd.JuffPlugin/2.693")
+Q_DECLARE_INTERFACE(JuffPlugin, "JuffEd.JuffPlugin/2.70")
#endif // __JUFF_PLUGIN_H__
View
@@ -397,6 +397,10 @@ void SearchEngine::onReplaceAll() {
curDoc_->setCursorPos(0, 0);
int replacesMade = 0;
int count = results->count();
+
+ // we want all replaces to be a single undo action - mark the beginning of this action
+ curDoc_->beginUndoAction();
+
for ( int i = count - 1; i >= 0; --i ) {
const Juff::SearchOccurence& occ = results->occurence(i);
curDoc_->setSelection(occ.startRow, occ.startCol, occ.endRow, occ.endCol);
@@ -411,6 +415,10 @@ void SearchEngine::onReplaceAll() {
curDoc_->replaceSelectedText(replaceWith);
replacesMade++;
}
+
+ // mark the end of a single undo action for replacements
+ curDoc_->endUndoAction();
+
searchPopup_->setFocusOnReplace();
mw_->message(QIcon(), tr("Replace"), tr("Replacement finished (%1 replacements were made)").arg(replacesMade), Qt::AlignBottom | Qt::AlignLeft, 5);
View
@@ -517,6 +517,19 @@ void SciDoc::setSyntax(const QString& lexName) {
// notify plugins
emit syntaxChanged(oldSyntax);
}
+
+void SciDoc::beginUndoAction() {
+ if ( int_->curEdit_ == NULL ) return;
+
+ int_->curEdit_->beginUndoAction();
+}
+
+void SciDoc::endUndoAction() {
+ if ( int_->curEdit_ == NULL ) return;
+
+ int_->curEdit_->endUndoAction();
+}
+
// End of Document API implementation
////////////////////////////////////////////////////////////////////////////////
View
@@ -57,6 +57,8 @@ Q_OBJECT
virtual void setSyntax(const QString& lexName);
virtual void highlightSearchResults();
virtual void clearHighlighting();
+ virtual void beginUndoAction();
+ virtual void endUndoAction();
virtual void setSessionParams(const Juff::SessionParams&);
virtual Juff::SessionParams sessionParams() const;

0 comments on commit ebe6858

Please sign in to comment.