mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
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:
parent
3b00f19cc2
commit
d3e4bfb124
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user