using lyx::support::uppercase;
using lyx::support::split;
+using std::advance;
using std::ostringstream;
using std::string;
namespace find {
string const find2string(string const & search,
- bool casesensitive, bool matchword, bool forward)
+ bool casesensitive, bool matchword, bool forward)
{
ostringstream ss;
ss << search << '\n'
return ss.str();
}
-
+
string const replace2string(string const & search, string const & replace,
bool casesensitive, bool matchword,
bool forward = parse_bool(howto);
bool const found = ::find(bv, search,
- forward, casesensitive, matchword);
+ casesensitive, matchword, forward);
if (!found)
bv->owner()->message(_("String not found!"));
casesensitive, matchword) :
::replace(bv, search, replace,
casesensitive, matchword, forward);
-
+
if (replace_count == 0) {
lv->message(_("String not found!"));
} else {
if (!findChange(cur, endit))
return false;
-
+
ParagraphList::iterator pit = cur.pit();
pos_type pos = cur.pos();
-
+
Change orig_change = pit->lookupChangeFull(pos);
pos_type parsize = pit->size();
pos_type end = pos;
namespace {
-class MatchString
+class MatchString : public std::binary_function<Paragraph, lyx::pos_type, bool>
{
public:
MatchString(string const & str, bool cs, bool mw)
return true;
}
-
+
private:
// search string
string str;
bool findChange(PosIterator & cur, PosIterator const & end)
{
for (; cur != end; ++cur) {
- if ((!cur.pit()->size() || !cur.at_end())
+ if ((cur.pit()->empty() || !cur.at_end())
&& cur.pit()->lookupChange(cur.pos()) != Change::UNCHANGED)
return true;
}
if (!searchAllowed(bv, searchstr) || buf.isReadonly())
return 0;
-
- recordUndo(Undo::ATOMIC, bv->text(), 0, buf.paragraphs().size() - 1);
-
+
+ recordUndoFullDocument(bv->cursor());
+
PosIterator cur = buf.pos_iterator_begin();
PosIterator const end = buf.pos_iterator_end();
MatchString const match(searchstr, cs, mw);
bool stringSelected(BufferView * bv,
- string const & searchstr,
+ string const & searchstr,
bool cs, bool mw, bool fw)
{
LyXText * text = bv->getLyXText();
text->replaceSelectionWithString(replacestr);
text->setSelectionRange(replacestr.length());
- bv->cursor().current() = fw ? bv->cursor().selEnd() : bv->cursor().selStart();
+ bv->cursor().current() = fw ? bv->cursor().selEnd() : bv->cursor().selBegin();
bv->buffer()->markDirty();
find(bv, searchstr, cs, mw, fw);
bv->update();
-
+
return 1;
}