+
+docstring const replace2string(docstring const & search, docstring const & replace,
+ bool casesensitive, bool matchword,
+ bool all, bool forward)
+{
+ odocstringstream ss;
+ ss << search << '\n'
+ << replace << '\n'
+ << int(casesensitive) << ' '
+ << int(matchword) << ' '
+ << int(all) << ' '
+ << int(forward);
+ return ss.str();
+}
+
+
+void find(BufferView * bv, FuncRequest const & ev)
+{
+ if (!bv || ev.action != LFUN_WORD_FIND)
+ return;
+
+ //lyxerr << "find called, cmd: " << ev << std::endl;
+
+ // data is of the form
+ // "<search>
+ // <casesensitive> <matchword> <forward>"
+ docstring search;
+ docstring howto = split(ev.argument(), search, '\n');
+
+ bool casesensitive = parse_bool(howto);
+ 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!"));
+}
+
+
+void replace(BufferView * bv, FuncRequest const & ev)
+{
+ if (!bv || ev.action != LFUN_WORD_REPLACE)
+ return;
+
+ // data is of the form
+ // "<search>
+ // <replace>
+ // <casesensitive> <matchword> <all> <forward>"
+ docstring search;
+ docstring rplc;
+ docstring howto = split(ev.argument(), search, '\n');
+ howto = split(howto, rplc, '\n');
+
+ bool casesensitive = parse_bool(howto);
+ bool matchword = parse_bool(howto);
+ bool all = parse_bool(howto);
+ bool forward = parse_bool(howto);
+
+ Buffer * buf = bv->buffer();
+
+ int const replace_count = all
+ ? replaceAll(bv, search, rplc, casesensitive, matchword)
+ : replace(bv, search, rplc, casesensitive, matchword, forward);
+
+ if (replace_count == 0) {
+ // emit message signal.
+ buf->message(_("String not found!"));