]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfind.C
Remove the inset and view member functions from PreviewedInset.
[lyx.git] / src / lyxfind.C
index afc50357e892dec4c9ee811468d2d25c3d59653d..dfa961eb181a8593628c0dbf2bff82e0f690c521 100644 (file)
@@ -1,27 +1,40 @@
+/**
+ * \file lyxfind.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ * \author John Levon
+ * \author Jürgen Vigna
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #include <config.h>
 
-#include "lyxtext.h"
 #include "lyxfind.h"
-#include "paragraph.h"
-#include "frontends/LyXView.h"
-#include "frontends/Alert.h"
-#include "support/textutils.h"
-#include "support/lstrings.h"
-#include "BufferView.h"
+
 #include "buffer.h"
-#include "debug.h"
+#include "BufferView.h"
 #include "gettext.h"
+#include "lyxtext.h"
+#include "paragraph.h"
+
+#include "frontends/Alert.h"
+
 #include "insets/insettext.h"
-#include "changes.h"
 
-using namespace lyx::support;
+#include "support/textutils.h"
+
+using lyx::support::lowercase;
+using lyx::support::uppercase;
 
-using lyx::pos_type;
-using std::endl;
+using std::string;
 
 namespace lyx {
 namespace find {
 
+
 namespace {
 
 // returns true if the specified string is at the specified position
@@ -32,7 +45,7 @@ bool isStringInText(Paragraph const & par, pos_type pos,
        string::size_type size = str.length();
        pos_type i = 0;
        pos_type parsize = par.size();
-       while (((pos + i) < parsize)
+       while ((pos + i < parsize)
               && (string::size_type(i) < size)
               && (cs ? (str[i] == par.getChar(pos + i))
                   : (uppercase(str[i]) == uppercase(par.getChar(pos + i))))) {
@@ -58,7 +71,7 @@ bool isStringInText(Paragraph const & par, pos_type pos,
 SearchResult searchForward(BufferView * bv, LyXText * text, string const & str,
                           bool const & cs, bool const & mw)
 {
-       ParagraphList::iterator pit = text->cursor.par();
+       ParagraphList::iterator pit = text->cursorPar();
        ParagraphList::iterator pend = text->ownerParagraphs().end();
        pos_type pos = text->cursor.pos();
        UpdatableInset * inset;
@@ -80,8 +93,8 @@ SearchResult searchForward(BufferView * bv, LyXText * text, string const & str,
        if (pit != pend) {
                text->setCursor(pit, pos);
                return SR_FOUND;
-       } else
-               return SR_NOT_FOUND;
+       }
+       return SR_NOT_FOUND;
 }
 
 
@@ -92,7 +105,7 @@ SearchResult searchBackward(BufferView * bv, LyXText * text,
                            string const & str,
                            bool const & cs, bool const & mw)
 {
-       ParagraphList::iterator pit = text->cursor.par();
+       ParagraphList::iterator pit = text->cursorPar();
        ParagraphList::iterator pbegin = text->ownerParagraphs().begin();
        pos_type pos = text->cursor.pos();
 
@@ -137,6 +150,7 @@ SearchResult searchBackward(BufferView * bv, LyXText * text,
 } // anon namespace
 
 
+
 int replace(BufferView * bv,
               string const & searchstr, string const & replacestr,
               bool forward, bool casesens, bool matchwrd, bool replaceall,
@@ -177,10 +191,10 @@ int replace(BufferView * bv,
        string str2;
        if (casesens) {
                str1 = searchstr;
-               str2 = text->selectionAsString(bv->buffer(), false);
+               str2 = text->selectionAsString(*bv->buffer(), false);
        } else {
                str1 = lowercase(searchstr);
-               str2 = lowercase(text->selectionAsString(bv->buffer(), false));
+               str2 = lowercase(text->selectionAsString(*bv->buffer(), false));
        }
        if (str1 != str2) {
                if (!find(bv, searchstr, fw, casesens, matchwrd) ||
@@ -208,7 +222,6 @@ int replace(BufferView * bv,
 
        // FIXME: should be called via an LFUN
        bv->buffer()->markDirty();
-       bv->fitCursor();
        bv->update();
 
        return replace_count;
@@ -263,7 +276,6 @@ bool find(BufferView * bv,
                bv->unlockInset(bv->theLockingInset());
                found = false;
        }
-       bv->fitCursor();
        bv->update();
 
        return found;
@@ -292,7 +304,7 @@ SearchResult find(BufferView * bv, LyXText * text,
 
 SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length)
 {
-       ParagraphList::iterator pit = text->cursor.par();
+       ParagraphList::iterator pit = text->cursorPar();
        ParagraphList::iterator pend = text->ownerParagraphs().end();
        pos_type pos = text->cursor.pos();
 
@@ -397,7 +409,6 @@ bool findNextChange(BufferView * bv)
                found = false;
        }
 
-       bv->fitCursor();
        bv->update();
 
        return found;