#include "lyxfind.h"
#include "Buffer.h"
-#include "BufferList.h"
#include "buffer_funcs.h"
+#include "BufferList.h"
#include "BufferParams.h"
#include "BufferView.h"
#include "Changes.h"
#include "Cursor.h"
#include "CutAndPaste.h"
#include "FuncRequest.h"
-#include "OutputParams.h"
+#include "LyXFunc.h"
#include "output_latex.h"
+#include "OutputParams.h"
#include "Paragraph.h"
#include "ParIterator.h"
#include "TexRow.h"
#include "Text.h"
-#include "FuncRequest.h"
-#include "LyXFunc.h"
+
+#include "frontends/alert.h"
#include "mathed/InsetMath.h"
#include "mathed/InsetMathGrid.h"
#include "mathed/InsetMathHull.h"
#include "mathed/MathStream.h"
-#include "frontends/alert.h"
-
#include "support/convert.h"
#include "support/debug.h"
#include "support/docstream.h"
#include "support/gettext.h"
-#include "support/lstrings.h"
#include "support/lassert.h"
-
-#include "frontends/Application.h"
-#include "frontends/LyXView.h"
+#include "support/lstrings.h"
#include <boost/regex.hpp>
#include <boost/next_prior.hpp>
FindAndReplaceOptions const & opt;
private:
+ /// Auxiliary find method (does not account for opt.matchword)
+ int findAux(DocIterator const & cur, int len = -1, bool at_begin = true) const;
+
/** Normalize a stringified or latexified LyX paragraph.
**
** Normalize means:
}
-int MatchStringAdv::operator()(DocIterator const & cur, int len, bool at_begin) const
+int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) const
{
docstring docstr = stringifyFromForSearch(opt, cur, len);
LYXERR(Debug::FIND, "Matching against '" << lyx::to_utf8(docstr) << "'");
}
+int MatchStringAdv::operator()(DocIterator const & cur, int len, bool at_begin) const
+{
+ int res = findAux(cur, len, at_begin);
+ if (res == 0 || !at_begin || !opt.matchword || !cur.inTexted())
+ return res;
+ Paragraph const & par = cur.paragraph();
+ bool ws_left = cur.pos() > 0 ?
+ par.isWordSeparator(cur.pos() - 1) : true;
+ bool ws_right = cur.pos() + res < par.size() ?
+ par.isWordSeparator(cur.pos() + res) : true;
+ LYXERR(Debug::FIND,
+ "cur.pos()=" << cur.pos() << ", res=" << res
+ << ", separ: " << ws_left << ", " << ws_right
+ << endl);
+ if (ws_left && ws_right)
+ return res;
+ return 0;
+}
+
+
string MatchStringAdv::normalize(docstring const & s) const
{
string t;
}
-ostringstream & operator<<(ostringstream & os, lyx::FindAndReplaceOptions const & opt)
+ostringstream & operator<<(ostringstream & os, FindAndReplaceOptions const & opt)
{
os << to_utf8(opt.search) << "\nEOSS\n"
<< opt.casesensitive << ' '
return os;
}
-istringstream & operator>>(istringstream & is, lyx::FindAndReplaceOptions & opt)
+istringstream & operator>>(istringstream & is, FindAndReplaceOptions & opt)
{
LYXERR(Debug::FIND, "parsing");
string s;