X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flyxfind.cpp;h=00bc9d51def3f9f1de0699839ef86cdf9979c61a;hb=03ec50ac4d06ef2b000d87a175d7a149c9abb2bf;hp=4186fa8f1eac0be183d29fb20ce72c44ee7072d5;hpb=f625dd7ea0770f0f1151401ed90d0ef2146595d7;p=lyx.git diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 4186fa8f1e..00bc9d51de 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -22,9 +22,7 @@ #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" @@ -32,17 +30,15 @@ #include "frontends/alert.h" #include "support/convert.h" +#include "support/debug.h" #include "support/docstream.h" +#include "support/gettext.h" #include "support/lstrings.h" -namespace lyx { - -using support::compare_no_case; -using support::uppercase; -using support::split; - -using std::advance; +using namespace std; +using namespace lyx::support; +namespace lyx { namespace { @@ -56,7 +52,7 @@ bool parse_bool(docstring & howto) } -class MatchString : public std::binary_function +class MatchString : public binary_function { public: MatchString(docstring const & str, bool cs, bool mw) @@ -152,19 +148,19 @@ int replaceAll(BufferView * bv, if (!searchAllowed(bv, searchstr) || buf.isReadonly()) return 0; - bv->cursor().recordUndoFullDocument(); - MatchString const match(searchstr, cs, mw); int num = 0; int const rsize = replacestr.size(); int const ssize = searchstr.size(); - DocIterator cur = doc_iterator_begin(buf.inset()); + Cursor cur(*bv); + cur.setCursor(doc_iterator_begin(buf.inset())); while (findForward(cur, match, false)) { pos_type pos = cur.pos(); Font const font = cur.paragraph().getFontSettings(buf.params(), pos); + cur.recordUndo(); int striked = ssize - cur.paragraph().eraseChars(pos, pos + ssize, buf.params().trackChanges); cur.paragraph().insert(pos, replacestr, font, @@ -212,6 +208,7 @@ int replace(BufferView * bv, docstring const & searchstr, cap::replaceSelectionWithString(cur, replacestr, fw); bv->buffer().markDirty(); find(bv, searchstr, cs, mw, fw, false); + bv->buffer().updateMacros(); bv->processUpdateFlags(Update::Force | Update::FitCursor); return 1; @@ -247,12 +244,12 @@ docstring const replace2string(docstring const & search, docstring const & repla } -void find(BufferView * bv, FuncRequest const & ev) +bool find(BufferView * bv, FuncRequest const & ev) { if (!bv || ev.action != LFUN_WORD_FIND) - return; + return false; - //lyxerr << "find called, cmd: " << ev << std::endl; + //lyxerr << "find called, cmd: " << ev << endl; // data is of the form // " @@ -264,12 +261,7 @@ void find(BufferView * bv, FuncRequest const & ev) bool matchword = parse_bool(howto); bool forward = parse_bool(howto); - bool const found = find(bv, search, - casesensitive, matchword, forward); - - if (!found) - // emit message signal. - bv->message(_("String not found!")); + return find(bv, search, casesensitive, matchword, forward); } @@ -315,11 +307,9 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted) } else { // if we have deleted characters, we do not replace at all, but // rather search for the next occurence - bool const found = find(bv, search, - casesensitive, matchword, forward); - - if (!found) - // emit message signal. + if (find(bv, search, casesensitive, matchword, forward)) + bv->showCursor(); + else bv->message(_("String not found!")); } }