]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.cpp
Fix copy&paste bug.
[lyx.git] / src / lyxfind.cpp
index 92dcfa8a095d0622742c8c84e46b45e5352ded74..a7fe5a38a9cab0c37c7cab4ff76a17152ddcdb9e 100644 (file)
 #include "lyxfind.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
 #include "buffer_funcs.h"
 #include "BufferView.h"
+#include "Changes.h"
 #include "debug.h"
 #include "FuncRequest.h"
 #include "gettext.h"
 #include "Text.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
-#include "Undo.h"
 
 #include "frontends/alert.h"
 
@@ -144,7 +145,7 @@ bool searchAllowed(BufferView * bv, docstring const & str)
                                            _("Search string is empty"));
                return false;
        }
-       return bv->buffer();
+       return true;
 }
 
 
@@ -172,12 +173,12 @@ int replaceAll(BufferView * bv,
               docstring const & searchstr, docstring const & replacestr,
               bool cs, bool mw)
 {
-       Buffer & buf = *bv->buffer();
+       Buffer & buf = bv->buffer();
 
        if (!searchAllowed(bv, searchstr) || buf.isReadonly())
                return 0;
 
-       recordUndoFullDocument(bv);
+       bv->cursor().recordUndoFullDocument();
 
        MatchString const match(searchstr, cs, mw);
        int num = 0;
@@ -227,7 +228,7 @@ bool stringSelected(BufferView * bv, docstring const & searchstr,
 int replace(BufferView * bv, docstring const & searchstr,
            docstring const & replacestr, bool cs, bool mw, bool fw)
 {
-       if (!searchAllowed(bv, searchstr) || bv->buffer()->isReadonly())
+       if (!searchAllowed(bv, searchstr) || bv->buffer().isReadonly())
                return 0;
 
        if (!stringSelected(bv, searchstr, cs, mw, fw))
@@ -235,9 +236,9 @@ int replace(BufferView * bv, docstring const & searchstr,
 
        Cursor & cur = bv->cursor();
        cap::replaceSelectionWithString(cur, replacestr, fw);
-       bv->buffer()->markDirty();
+       bv->buffer().markDirty();
        find(bv, searchstr, cs, mw, fw, false);
-       bv->update();
+       bv->processUpdateFlags(Update::Force | Update::FitCursor);
 
        return 1;
 }
@@ -317,25 +318,24 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
        bool all           = parse_bool(howto);
        bool forward       = parse_bool(howto);
 
-       Buffer * buf = bv->buffer();
-
        if (!has_deleted) {
                int const replace_count = all
                        ? replaceAll(bv, search, rplc, casesensitive, matchword)
                        : replace(bv, search, rplc, casesensitive, matchword, forward);
        
+               Buffer & buf = bv->buffer();
                if (replace_count == 0) {
                        // emit message signal.
-                       buf->message(_("String not found!"));
+                       buf.message(_("String not found!"));
                } else {
                        if (replace_count == 1) {
                                // emit message signal.
-                               buf->message(_("String has been replaced."));
+                               buf.message(_("String has been replaced."));
                        } else {
                                docstring str = convert<docstring>(replace_count);
                                str += _(" strings have been replaced.");
                                // emit message signal.
-                               buf->message(str);
+                               buf.message(str);
                        }
                }
        } else {
@@ -353,9 +353,6 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
 
 bool findNextChange(BufferView * bv)
 {
-       if (!bv->buffer())
-               return false;
-
        DocIterator cur = bv->cursor();
 
        if (!findChange(cur))