Change how some of the updating stuff is handled in lyxfind. I had no

idea what a mess this was.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35639 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2010-10-13 18:53:41 +00:00
parent 3b00f19cc2
commit d3e4bfb124
3 changed files with 22 additions and 15 deletions

View File

@ -1484,7 +1484,9 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
bool const fw = act == LFUN_WORD_FIND_FORWARD;
docstring const data =
find2string(searched_string, true, false, fw);
find(this, FuncRequest(LFUN_WORD_FIND, data));
bool found = lyxfind(this, FuncRequest(LFUN_WORD_FIND, data));
if (found)
dr.screenUpdate(Update::Force | Update::FitCursor);
break;
}
@ -1496,8 +1498,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "findreplace"));
break;
}
if (find(this, req))
showCursor();
if (lyxfind(this, req))
dr.screenUpdate(Update::Force | Update::FitCursor);
else
message(_("String not found!"));
d->search_request_cache_ = req;
@ -1517,8 +1519,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
}
}
}
replace(this, cmd, has_deleted);
dr.forceBufferUpdate();
if (lyxreplace(this, cmd, has_deleted)) {
dr.forceBufferUpdate();
dr.screenUpdate(Update::Force | Update::FitCursor);
}
break;
}

View File

@ -247,8 +247,6 @@ int replaceOne(BufferView * bv, docstring & searchstr,
cap::replaceSelectionWithString(cur, replacestr, forward);
bv->buffer().markDirty();
findOne(bv, searchstr, case_sens, whole, forward, false);
bv->buffer().updateMacros();
bv->processUpdateFlags(Update::Force | Update::FitCursor);
return 1;
}
@ -283,7 +281,7 @@ docstring const replace2string(docstring const & replace,
}
bool find(BufferView * bv, FuncRequest const & ev)
bool lyxfind(BufferView * bv, FuncRequest const & ev)
{
if (!bv || ev.action() != LFUN_WORD_FIND)
return false;
@ -304,11 +302,14 @@ bool find(BufferView * bv, FuncRequest const & ev)
}
void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
bool lyxreplace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
{
if (!bv || ev.action() != LFUN_WORD_REPLACE)
return;
return false;
// assume we didn't do anything
bool retval = false;
// data is of the form
// "<search>
// <replace>
@ -333,12 +334,12 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
// emit message signal.
buf.message(_("String not found!"));
} else {
retval = true;
if (replace_count == 1) {
// emit message signal.
buf.message(_("String has been replaced."));
} else {
docstring str = convert<docstring>(replace_count);
str += _(" strings have been replaced.");
docstring str = bformat(_("%1$d strings have been replaced."), replace_count);
// emit message signal.
buf.message(str);
}
@ -347,10 +348,11 @@ void replace(BufferView * bv, FuncRequest const & ev, bool has_deleted)
// if we have deleted characters, we do not replace at all, but
// rather search for the next occurence
if (findOne(bv, search, casesensitive, matchword, forward))
bv->showCursor();
retval = true;
else
bv->message(_("String not found!"));
}
return retval;
}

View File

@ -55,13 +55,14 @@ docstring const replace2string(docstring const & replace,
* The string is encoded by \c find2string.
* \return true if the string was found.
*/
bool find(BufferView * bv, FuncRequest const & ev);
bool lyxfind(BufferView * bv, FuncRequest const & ev);
/** Parse the string encoding of the replace request that is found in
* \c ev.argument and act on it.
* The string is encoded by \c replace2string.
* \return whether we did anything
*/
void replace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
bool lyxreplace(BufferView * bv, FuncRequest const &, bool has_deleted = false);
/// find the next change in the buffer
bool findNextChange(BufferView * bv);