mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-26 14:15:32 +00:00
Fix bug #2213 (part 1): GuiChanges lacks "Previous Change" button.
*lyxfind: Add findPreviousChange(). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29108 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b5880744c9
commit
5a1dc72483
@ -115,11 +115,19 @@ bool findBackwards(DocIterator & cur, MatchString const & match,
|
||||
}
|
||||
|
||||
|
||||
bool findChange(DocIterator & cur)
|
||||
bool findChange(DocIterator & cur, bool next)
|
||||
{
|
||||
for (; cur; cur.forwardPos())
|
||||
if (cur.inTexted() && !cur.paragraph().isUnchanged(cur.pos()))
|
||||
if (!next)
|
||||
cur.backwardPos();
|
||||
for (; cur; next ? cur.forwardPos() : cur.backwardPos())
|
||||
if (cur.inTexted() && !cur.paragraph().isUnchanged(cur.pos())) {
|
||||
if (!next)
|
||||
// if we search backwards, take a step forward
|
||||
// to correctly set the anchor
|
||||
cur.forwardPos();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -332,21 +340,47 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
|
||||
|
||||
bool findNextChange(BufferView * bv)
|
||||
{
|
||||
DocIterator cur = bv->cursor();
|
||||
return findChange(bv, true);
|
||||
}
|
||||
|
||||
if (!findChange(cur))
|
||||
|
||||
bool findPreviousChange(BufferView * bv)
|
||||
{
|
||||
return findChange(bv, false);
|
||||
}
|
||||
|
||||
|
||||
bool findChange(BufferView * bv, bool next)
|
||||
{
|
||||
DocIterator cur = bv->cursor();
|
||||
if (!findChange(cur, next))
|
||||
return false;
|
||||
|
||||
bv->cursor().setCursor(cur);
|
||||
bv->cursor().resetAnchor();
|
||||
|
||||
if (!next)
|
||||
// take a step into the change
|
||||
cur.backwardPos();
|
||||
|
||||
Change orig_change = cur.paragraph().lookupChange(cur.pos());
|
||||
|
||||
CursorSlice & tip = cur.top();
|
||||
for (; !tip.at_end(); tip.forwardPos()) {
|
||||
Change change = tip.paragraph().lookupChange(tip.pos());
|
||||
if (change != orig_change)
|
||||
break;
|
||||
if (next) {
|
||||
for (; !tip.at_end(); tip.forwardPos()) {
|
||||
Change change = tip.paragraph().lookupChange(tip.pos());
|
||||
if (change != orig_change)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
for (; !tip.at_begin(); tip.backwardPos()) {
|
||||
Change change = tip.paragraph().lookupChange(tip.pos());
|
||||
if (change != orig_change) {
|
||||
// take a step forward to correctly set the selection
|
||||
tip.forwardPos();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now put cursor to end of selection:
|
||||
|
@ -66,6 +66,13 @@ void replace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
|
||||
/// find the next change in the buffer
|
||||
bool findNextChange(BufferView * bv);
|
||||
|
||||
/// find the previous change in the buffer
|
||||
bool findPreviousChange(BufferView * bv);
|
||||
|
||||
/// find the change in the buffer
|
||||
/// \param next true to find the next change, otherwise the previous
|
||||
bool findChange(BufferView * bv, bool next);
|
||||
|
||||
// Hopefully, nobody will ever replace with something like this
|
||||
#define LYX_FR_NULL_STRING "__LYX__F&R__NULL__STRING__"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user