Edwin Leuven <[EMAIL PROTECTED]> writes:
| Hi,
|
| I attach the patch that moves find/replace to frontends. It also moves some
| stuff out ouf LyXText. The files src/lyxfr1.[Ch] and src/lyxfr0.[Ch] can be
| removed. Could someone check and/or apply it?
+
+ bool found;
+ do {
+ bv->hideCursor();
You have to initialize found.
I am not overly found of these constructs:
+ if (forward
+ ? SearchForward(bv, searchstr, casesens, matchwrd)
+ : SearchBackward(bv, searchstr, casesens, matchwrd)) {
+ bv->update(bv->text, BufferView::SELECT|BufferView::FITCUR);
+ bv->toggleSelection();
+ bv->text->ClearSelection(bv);
+ bv->text->SetSelectionOverString(bv, searchstr);
+ bv->toggleSelection(false);
+ found = true;
+ };
+
I'd rather see you split forward and backward searching into different
functions. Or move the ?: out of the if:
bool ret = (forward ? SearchForward(...) : SearchBackward(...));
if (ret) {
...
}
&& cs ? str[i] == par->GetChar(pos + i)
+ : toupper(str[i]) == toupper(par->GetChar(pos + i))) {
I find stuff like that hard to read. And it complicates while
conditions a lot.
Ad Jürgen's segfault report, I think there is a mistake in the code
somewhere, but I can't see it offhand. I belive the reason Jürgen sees
this and you don't is a lyxstring vs. std::string matter. Lyxstring
has explicit Asserts in several places to ensure that we stay within
array bounds, std::string do not have these asserts. (And often it is
safe to overstep arraybounds by one, even if it is not correct).
Using iterators can be a boon in such cases.
Lgb