+/**
+ * \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
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))))) {
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;
if (pit != pend) {
text->setCursor(pit, pos);
return SR_FOUND;
- } else
- return SR_NOT_FOUND;
+ }
+ return SR_NOT_FOUND;
}
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();
} // anon namespace
+
int replace(BufferView * bv,
string const & searchstr, string const & replacestr,
bool forward, bool casesens, bool matchwrd, bool replaceall,
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) ||
// FIXME: should be called via an LFUN
bv->buffer()->markDirty();
- bv->fitCursor();
bv->update();
return replace_count;
bv->unlockInset(bv->theLockingInset());
found = false;
}
- bv->fitCursor();
bv->update();
return found;
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();
found = false;
}
- bv->fitCursor();
bv->update();
return found;