mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 18:24:48 +00:00
Implement wrapping in next-change (#10388).
This commit is contained in:
parent
5c4fa40849
commit
0be77e2eb2
@ -417,21 +417,57 @@ bool lyxreplace(BufferView * bv,
|
||||
}
|
||||
|
||||
|
||||
bool findNextChange(DocIterator & cur)
|
||||
bool findNextChange(BufferView * bv, Cursor & cur, bool const check_wrap)
|
||||
{
|
||||
for (; cur; cur.forwardPos())
|
||||
if (cur.inTexted() && cur.paragraph().isChanged(cur.pos()))
|
||||
return true;
|
||||
|
||||
if (check_wrap) {
|
||||
DocIterator cur_orig(bv->cursor());
|
||||
docstring q = _("End of file reached while searching forward.\n"
|
||||
"Continue searching from the beginning?");
|
||||
int wrap_answer = frontend::Alert::prompt(_("Wrap search?"),
|
||||
q, 0, 1, _("&Yes"), _("&No"));
|
||||
if (wrap_answer == 0) {
|
||||
bv->cursor().clear();
|
||||
bv->cursor().push_back(CursorSlice(bv->buffer().inset()));
|
||||
bv->clearSelection();
|
||||
cur.setCursor(bv->cursor().selectionBegin());
|
||||
if (findNextChange(bv, cur, false))
|
||||
return true;
|
||||
}
|
||||
bv->cursor().setCursor(cur_orig);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool findPreviousChange(DocIterator & cur)
|
||||
bool findPreviousChange(BufferView * bv, Cursor & cur, bool const check_wrap)
|
||||
{
|
||||
for (cur.backwardPos(); cur; cur.backwardPos()) {
|
||||
if (cur.inTexted() && cur.paragraph().isChanged(cur.pos()))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (check_wrap) {
|
||||
DocIterator cur_orig(bv->cursor());
|
||||
docstring q = _("Beginning of file reached while searching backward.\n"
|
||||
"Continue searching from the end?");
|
||||
int wrap_answer = frontend::Alert::prompt(_("Wrap search?"),
|
||||
q, 0, 1, _("&Yes"), _("&No"));
|
||||
if (wrap_answer == 0) {
|
||||
bv->cursor().setCursor(doc_iterator_end(&bv->buffer()));
|
||||
bv->cursor().backwardPos();
|
||||
bv->clearSelection();
|
||||
cur.setCursor(bv->cursor().selectionBegin());
|
||||
if (findPreviousChange(bv, cur, false))
|
||||
return true;
|
||||
}
|
||||
bv->cursor().setCursor(cur_orig);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -476,7 +512,7 @@ bool findChange(BufferView * bv, bool forward)
|
||||
Cursor cur(*bv);
|
||||
cur.setCursor(forward ? bv->cursor().selectionEnd()
|
||||
: bv->cursor().selectionBegin());
|
||||
forward ? findNextChange(cur) : findPreviousChange(cur);
|
||||
forward ? findNextChange(bv, cur, true) : findPreviousChange(bv, cur, true);
|
||||
return selectChange(cur, forward);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,8 @@ What's new
|
||||
|
||||
- Improve cross-references dialog design.
|
||||
|
||||
- Implement wrap-around in change tracking's next-change function (bug 10388).
|
||||
|
||||
|
||||
* DOCUMENTATION AND LOCALIZATION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user