Code cleanup.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32682 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2009-12-30 22:21:23 +00:00
parent fed94f72d5
commit 82e07a4185
2 changed files with 19 additions and 33 deletions

View File

@ -1011,15 +1011,8 @@ bool prev_document_buffer(Buffer * & p_buf) {
** Return true if restarted from first open buffer. ** Return true if restarted from first open buffer.
**/ **/
bool next_open_buffer(Buffer * & p_buf) { bool next_open_buffer(Buffer * & p_buf) {
BufferList::const_iterator it = find(theBufferList().begin(), theBufferList().end(), p_buf); p_buf = theBufferList().next(p_buf);
LASSERT(it != theBufferList().end(), /**/) return p_buf == *theBufferList().begin();
++it;
if (it == theBufferList().end()) {
p_buf = *theBufferList().begin();
return true;
}
p_buf = *it;
return false;
} }
@ -1028,17 +1021,8 @@ bool next_open_buffer(Buffer * & p_buf) {
** Return true if restarted from last open buffer. ** Return true if restarted from last open buffer.
**/ **/
bool prev_open_buffer(Buffer * & p_buf) { bool prev_open_buffer(Buffer * & p_buf) {
BufferList::const_iterator it = find(theBufferList().begin(), theBufferList().end(), p_buf); p_buf = theBufferList().previous(p_buf);
LASSERT(it != theBufferList().end(), /**/) return p_buf == *(theBufferList().end() - 1);
if (it == theBufferList().begin()) {
it = theBufferList().end();
--it;
p_buf = *it;
return true;
}
--it;
p_buf = *it;
return false;
} }
@ -1062,15 +1046,16 @@ int findForwardAdv(DocIterator & cur, MatchStringAdv & match)
} }
// No match has been found in current buffer // No match has been found in current buffer
bool prompt = false; bool prompt = false;
if (match.opt.scope == FindAndReplaceOptions::S_BUFFER) { switch (match.opt.scope) {
case FindAndReplaceOptions::S_BUFFER:
prompt = true; prompt = true;
} else if (match.opt.scope == FindAndReplaceOptions::S_DOCUMENT) { break;
case FindAndReplaceOptions::S_DOCUMENT:
prompt = next_document_buffer(match.p_buf); prompt = next_document_buffer(match.p_buf);
} else if (match.opt.scope == FindAndReplaceOptions::S_OPEN_BUFFERS) { break;
case FindAndReplaceOptions::S_OPEN_BUFFERS:
prompt = next_open_buffer(match.p_buf); prompt = next_open_buffer(match.p_buf);
} else { break;
/* Unimplemented scope */
LASSERT(false, /**/);
} }
if (prompt) { if (prompt) {
if (wrap_answer != -1) if (wrap_answer != -1)
@ -1177,15 +1162,16 @@ int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) {
} }
// No match has been found in current buffer // No match has been found in current buffer
bool prompt = false; bool prompt = false;
if (match.opt.scope == FindAndReplaceOptions::S_BUFFER) { switch (match.opt.scope) {
case FindAndReplaceOptions::S_BUFFER:
prompt = true; prompt = true;
} else if (match.opt.scope == FindAndReplaceOptions::S_DOCUMENT) { break;
case FindAndReplaceOptions::S_DOCUMENT:
prompt = prev_document_buffer(match.p_buf); prompt = prev_document_buffer(match.p_buf);
} else if (match.opt.scope == FindAndReplaceOptions::S_OPEN_BUFFERS) { break;
case FindAndReplaceOptions::S_OPEN_BUFFERS:
prompt = prev_open_buffer(match.p_buf); prompt = prev_open_buffer(match.p_buf);
} else { break;
/* Unimplemented scope */
LASSERT(false, /**/);
} }
if (prompt) { if (prompt) {
wrap_answer = frontend::Alert::prompt( wrap_answer = frontend::Alert::prompt(

View File

@ -82,7 +82,7 @@ public:
S_BUFFER, S_BUFFER,
S_DOCUMENT, S_DOCUMENT,
S_OPEN_BUFFERS, S_OPEN_BUFFERS,
S_ALL_MANUALS /*S_ALL_MANUALS*/
} SearchScope; } SearchScope;
FindAndReplaceOptions( FindAndReplaceOptions(
docstring const & search, docstring const & search,