]> git.lyx.org Git - features.git/commitdiff
Change how some of the updating stuff is handled in lyxfind. I had no
authorRichard Heck <rgheck@comcast.net>
Wed, 13 Oct 2010 18:53:41 +0000 (18:53 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 13 Oct 2010 18:53:41 +0000 (18:53 +0000)
idea what a mess this was.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35639 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.cpp
src/lyxfind.cpp
src/lyxfind.h

index 55366c6b36651d324efcffc6f906388aecca5cfd..e7efc64c6f85eb8a7fa2a9c945afb49cf2704663 100644 (file)
@@ -1484,7 +1484,9 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                bool const fw = act == LFUN_WORD_FIND_FORWARD;
                docstring const data =
                        find2string(searched_string, true, false, fw);
-               find(this, FuncRequest(LFUN_WORD_FIND, data));
+               bool found = lyxfind(this, FuncRequest(LFUN_WORD_FIND, data));
+               if (found)
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
        }
 
@@ -1496,8 +1498,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "findreplace"));
                        break;
                }
-               if (find(this, req))
-                       showCursor();
+               if (lyxfind(this, req))
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
                else
                        message(_("String not found!"));
                d->search_request_cache_ = req;
@@ -1517,8 +1519,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                }
                        }
                }
-               replace(this, cmd, has_deleted);
-               dr.forceBufferUpdate();
+               if (lyxreplace(this, cmd, has_deleted)) {
+                       dr.forceBufferUpdate();
+                       dr.screenUpdate(Update::Force | Update::FitCursor);
+               }
                break;
        }
 
index a9cfa223c9043ef4d8feedfccc165bf0af19cf5c..63500a83254c1cbe68b8090cecf20af301f960f0 100644 (file)
@@ -247,8 +247,6 @@ int replaceOne(BufferView * bv, docstring & searchstr,
        cap::replaceSelectionWithString(cur, replacestr, forward);
        bv->buffer().markDirty();
        findOne(bv, searchstr, case_sens, whole, forward, false);
-       bv->buffer().updateMacros();
-       bv->processUpdateFlags(Update::Force | Update::FitCursor);
 
        return 1;
 }
@@ -283,7 +281,7 @@ docstring const replace2string(docstring const & replace,
 }
 
 
-bool find(BufferView * bv, FuncRequest const & ev)
+bool lyxfind(BufferView * bv, FuncRequest const & ev)
 {
        if (!bv || ev.action() != LFUN_WORD_FIND)
                return false;
@@ -304,11 +302,14 @@ bool find(BufferView * bv, FuncRequest const & ev)
 }
 
 
-void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
+bool lyxreplace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
 {
        if (!bv || ev.action() != LFUN_WORD_REPLACE)
-               return;
+               return false;
 
+       // assume we didn't do anything
+       bool retval = false;
+       
        // data is of the form
        // "<search>
        //  <replace>
@@ -333,12 +334,12 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
                        // emit message signal.
                        buf.message(_("String not found!"));
                } else {
+                       retval = true;
                        if (replace_count == 1) {
                                // emit message signal.
                                buf.message(_("String has been replaced."));
                        } else {
-                               docstring str = convert<docstring>(replace_count);
-                               str += _(" strings have been replaced.");
+                               docstring str = bformat(_("%1$d strings have been replaced."), replace_count);
                                // emit message signal.
                                buf.message(str);
                        }
@@ -347,10 +348,11 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
                // if we have deleted characters, we do not replace at all, but
                // rather search for the next occurence
                if (findOne(bv, search, casesensitive, matchword, forward))
-                       bv->showCursor();
+                       retval = true;
                else
                        bv->message(_("String not found!"));
        }
+       return retval;
 }
 
 
index 711bf8ee25aeae8ffc84ed7b336f096c1b61f8fd..e32d9a947ff0d62c0768947f8570505d1fa3148e 100644 (file)
@@ -55,13 +55,14 @@ docstring const replace2string(docstring const & replace,
  * The string is encoded by \c find2string.
  * \return true if the string was found.
  */
-bool find(BufferView * bv, FuncRequest const & ev);
+bool lyxfind(BufferView * bv, FuncRequest const & ev);
 
 /** Parse the string encoding of the replace request that is found in
  *  \c ev.argument and act on it.
  * The string is encoded by \c replace2string.
+ * \return whether we did anything
  */
-void replace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
+bool lyxreplace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
 
 /// find the next change in the buffer
 bool findNextChange(BufferView * bv);