#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "lyxtext.h"
#include "lyxfind.h"
#include "paragraph.h"
text->clearSelection();
bv->unlockInset(bv->theLockingInset());
text = bv->text;
- text->cursorTop(bv);
+ text->cursorTop();
// override search direction because we search top to bottom
fw = true;
}
(text->inset_owner == text->inset_owner->getLockingInset())))
{
bv->hideCursor();
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT);
bv->toggleSelection(false);
- text->replaceSelectionWithString(bv, replacestr);
- text->setSelectionRange(bv, replacestr.length());
- bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
+ text->replaceSelectionWithString(replacestr);
+ text->setSelectionRange(replacestr.length());
+ bv->update(text, BufferView::SELECT);
++replace_count;
}
if (!once)
found = LyXFind(bv, searchstr, fw, casesens, matchwrd);
} while (!once && replaceall && found);
+ // FIXME: should be called via an LFUN
+ bv->buffer()->markDirty();
+ bv->fitCursor();
+
return replace_count;
}
return false;
bv->hideCursor();
- bv->update(bv->getLyXText(), BufferView::SELECT|BufferView::FITCUR);
+ bv->update(bv->getLyXText(), BufferView::SELECT);
if (bv->theLockingInset()) {
bool found = forward ?
// We now are in the main text but if we did a forward
// search we have to put the cursor behind the inset.
if (forward) {
- bv->text->cursorRight(bv, true);
+ bv->text->cursorRight(true);
}
}
// If we arrive here we are in the main text again so we
// inset did it already.
if (result == SR_FOUND) {
bv->unlockInset(bv->theLockingInset());
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
- text->setSelectionRange(bv, searchstr.length());
+ bv->update(text, BufferView::SELECT);
+ text->setSelectionRange(searchstr.length());
bv->toggleSelection(false);
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT);
} else if (result == SR_NOT_FOUND) {
bv->unlockInset(bv->theLockingInset());
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT);
found = false;
}
+ bv->fitCursor();
+
return found;
}
}
if (par) {
- text->setCursor(bv, par, pos);
+ text->setCursor(par, pos);
return SR_FOUND;
} else {
// make sure we end up at the end of the text,
// not the start point of the last search
- text->setCursor(bv, prev_par, prev_par->size());
+ text->setCursor(prev_par, prev_par->size());
return SR_NOT_FOUND;
}
}
} while (par && !IsStringInText(par, pos, str, cs, mw));
if (par) {
- text->setCursor(bv, par, pos);
+ text->setCursor(par, pos);
return SR_FOUND;
} else {
// go to the last part of the unsuccessful search
- text->setCursor(bv, prev_par, 0);
+ text->setCursor(prev_par, 0);
return SR_NOT_FOUND;
}
}
-
+
SearchResult nextChange(BufferView * bv, LyXText * text, pos_type & length)
{
Paragraph * par = text->cursor.par();
}
if (par) {
- text->setCursor(bv, par, pos);
+ text->setCursor(par, pos);
Change orig_change = par->lookupChangeFull(pos);
pos_type end = pos;
} else {
// make sure we end up at the end of the text,
// not the start point of the last search
- text->setCursor(bv, prev_par, prev_par->size());
+ text->setCursor(prev_par, prev_par->size());
return SR_NOT_FOUND;
}
}
-
-
+
+
SearchResult findNextChange(BufferView * bv, LyXText * text, pos_type & length)
{
if (text->selection.set())
return false;
bv->hideCursor();
- bv->update(bv->getLyXText(), BufferView::SELECT | BufferView::FITCUR);
+ bv->update(bv->getLyXText(), BufferView::SELECT);
pos_type length;
-
+
if (bv->theLockingInset()) {
bool found = bv->theLockingInset()->nextChange(bv, length);
-
+
// We found the stuff inside the inset so we don't have to
// do anything as the inset did all the update for us!
if (found)
return true;
-
+
// We now are in the main text but if we did a forward
// search we have to put the cursor behind the inset.
- bv->text->cursorRight(bv, true);
+ bv->text->cursorRight(true);
}
// If we arrive here we are in the main text again so we
// just start searching from the root LyXText at the position
bv->toggleSelection();
text->clearSelection();
-
+
SearchResult result = nextChange(bv, text, length);
lyxerr << "Result is " << result << endl;
-
+
bool found = true;
-
+
// If we found the cursor inside an inset we will get back
// SR_FOUND_NOUPDATE and we don't have to do anything as the
// inset did it already.
if (result == SR_FOUND) {
bv->unlockInset(bv->theLockingInset());
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
- text->setSelectionRange(bv, length);
+ bv->update(text, BufferView::SELECT);
+ text->setSelectionRange(length);
bv->toggleSelection(false);
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT);
} else if (result == SR_NOT_FOUND) {
bv->unlockInset(bv->theLockingInset());
- bv->update(text, BufferView::SELECT|BufferView::FITCUR);
+ bv->update(text, BufferView::SELECT);
found = false;
}
+ bv->fitCursor();
+
return found;
}
-
+
} // end lyxfind namespace