int LyXReplace(BufferView * bv,
string const & searchstr, string const & replacestr,
bool forward, bool casesens, bool matchwrd, bool replaceall,
- bool once)
+ bool once)
{
if (!bv->available() || bv->buffer()->isReadonly())
return 0;
// if nothing selected or selection does not equal search string
// search and select next occurance and return if no replaceall
- if (searchstr!=text->selectionAsString(bv->buffer())) {
+ string str1;
+ string str2;
+ if (casesens) {
+ str1 = searchstr;
+ str2 = text->selectionAsString(bv->buffer());
+ } else {
+ str1 = lowercase(searchstr);
+ str2 = lowercase(text->selectionAsString(bv->buffer()));
+ }
+ if (str1 != str2) {
if (!LyXFind(bv, searchstr, fw, false, casesens, matchwrd) ||
!replaceall)
{
return 0;
}
}
-
+
bool found = false;
int replace_count = 0;
do {
bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
++replace_count;
if (!once)
- found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
+ found = LyXFind(bv, searchstr, fw, false, casesens, matchwrd);
} while (!once && replaceall && found);
if (bv->focus())
bool LyXFind(BufferView * bv,
string const & searchstr, bool forward,
- bool frominset, bool casesens, bool matchwrd)
+ bool frominset, bool casesens, bool matchwrd)
{
if (!bv->available() || searchstr.empty())
return false;
if (par) {
text->setCursor(bv, par, pos);
return SR_FOUND;
+#if 0
} else if (text->inset_owner) {
// test if we're inside an inset if yes unlock the inset
// and recall us with the outside LyXText!
} else {
return SR_NOT_FOUND;
}
+#endif
} else
return SR_NOT_FOUND;
}
if (par) {
text->setCursor(bv, par, pos);
return SR_FOUND;
- } else if (text->inset_owner) {
+ }
+#if 0
+ else if (text->inset_owner) {
// test if we're inside an inset if yes unlock the inset
// and recall us with the outside LyXText!
bv->unlockInset((UpdatableInset *)text->inset_owner);
return SearchBackward(bv, bv->getLyXText(), str, cs, mw);
}
}
+#endif
return SR_NOT_FOUND;
}