mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
#7564 make the move forward to next match after text replacement optional and suppress it when replace a word by selected suggestion
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38781 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4e922727e6
commit
cec318896c
@ -789,7 +789,7 @@ void MenuDefinition::expandSpellingSuggestions(BufferView const * bv)
|
|||||||
MenuItem w(MenuItem::Command, toqstr(suggestion),
|
MenuItem w(MenuItem::Command, toqstr(suggestion),
|
||||||
FuncRequest(LFUN_WORD_REPLACE,
|
FuncRequest(LFUN_WORD_REPLACE,
|
||||||
replace2string(suggestion,selection,
|
replace2string(suggestion,selection,
|
||||||
true, true, false, false)));
|
true, true, false, false, false)));
|
||||||
if (i < m)
|
if (i < m)
|
||||||
add(w);
|
add(w);
|
||||||
else
|
else
|
||||||
|
@ -229,7 +229,7 @@ int replaceAll(BufferView * bv,
|
|||||||
// whether anything at all was done.
|
// whether anything at all was done.
|
||||||
pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
||||||
docstring const & replacestr, bool case_sens,
|
docstring const & replacestr, bool case_sens,
|
||||||
bool whole, bool forward)
|
bool whole, bool forward, bool findnext)
|
||||||
{
|
{
|
||||||
Cursor & cur = bv->cursor();
|
Cursor & cur = bv->cursor();
|
||||||
if (!cur.selection()) {
|
if (!cur.selection()) {
|
||||||
@ -278,7 +278,8 @@ pair<bool, int> replaceOne(BufferView * bv, docstring searchstr,
|
|||||||
cur.pos() -= replacestr.length();
|
cur.pos() -= replacestr.length();
|
||||||
LASSERT(cur.pos() >= 0, /* */);
|
LASSERT(cur.pos() >= 0, /* */);
|
||||||
}
|
}
|
||||||
findOne(bv, searchstr, case_sens, whole, forward, false);
|
if (findnext)
|
||||||
|
findOne(bv, searchstr, case_sens, whole, forward, false);
|
||||||
|
|
||||||
return pair<bool, int>(true, 1);
|
return pair<bool, int>(true, 1);
|
||||||
}
|
}
|
||||||
@ -300,7 +301,7 @@ docstring const find2string(docstring const & search,
|
|||||||
|
|
||||||
docstring const replace2string(docstring const & replace,
|
docstring const replace2string(docstring const & replace,
|
||||||
docstring const & search, bool casesensitive, bool matchword,
|
docstring const & search, bool casesensitive, bool matchword,
|
||||||
bool all, bool forward)
|
bool all, bool forward, bool findnext)
|
||||||
{
|
{
|
||||||
odocstringstream ss;
|
odocstringstream ss;
|
||||||
ss << replace << '\n'
|
ss << replace << '\n'
|
||||||
@ -308,7 +309,8 @@ docstring const replace2string(docstring const & replace,
|
|||||||
<< int(casesensitive) << ' '
|
<< int(casesensitive) << ' '
|
||||||
<< int(matchword) << ' '
|
<< int(matchword) << ' '
|
||||||
<< int(all) << ' '
|
<< int(all) << ' '
|
||||||
<< int(forward);
|
<< int(forward) << ' '
|
||||||
|
<< int(findnext);
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,7 +345,7 @@ bool lyxreplace(BufferView * bv,
|
|||||||
// data is of the form
|
// data is of the form
|
||||||
// "<search>
|
// "<search>
|
||||||
// <replace>
|
// <replace>
|
||||||
// <casesensitive> <matchword> <all> <forward>"
|
// <casesensitive> <matchword> <all> <forward> <findnext>"
|
||||||
docstring search;
|
docstring search;
|
||||||
docstring rplc;
|
docstring rplc;
|
||||||
docstring howto = split(ev.argument(), rplc, '\n');
|
docstring howto = split(ev.argument(), rplc, '\n');
|
||||||
@ -353,6 +355,7 @@ bool lyxreplace(BufferView * bv,
|
|||||||
bool matchword = parse_bool(howto);
|
bool matchword = parse_bool(howto);
|
||||||
bool all = parse_bool(howto);
|
bool all = parse_bool(howto);
|
||||||
bool forward = parse_bool(howto);
|
bool forward = parse_bool(howto);
|
||||||
|
bool findnext = parse_bool(howto);
|
||||||
|
|
||||||
int replace_count = 0;
|
int replace_count = 0;
|
||||||
bool update = false;
|
bool update = false;
|
||||||
@ -363,7 +366,7 @@ bool lyxreplace(BufferView * bv,
|
|||||||
update = replace_count > 0;
|
update = replace_count > 0;
|
||||||
} else {
|
} else {
|
||||||
pair<bool, int> rv =
|
pair<bool, int> rv =
|
||||||
replaceOne(bv, search, rplc, casesensitive, matchword, forward);
|
replaceOne(bv, search, rplc, casesensitive, matchword, forward, findnext);
|
||||||
update = rv.first;
|
update = rv.first;
|
||||||
replace_count = rv.second;
|
replace_count = rv.second;
|
||||||
}
|
}
|
||||||
@ -383,7 +386,7 @@ bool lyxreplace(BufferView * bv,
|
|||||||
buf.message(str);
|
buf.message(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (findnext) {
|
||||||
// if we have deleted characters, we do not replace at all, but
|
// if we have deleted characters, we do not replace at all, but
|
||||||
// rather search for the next occurence
|
// rather search for the next occurence
|
||||||
if (findOne(bv, search, casesensitive, matchword, forward))
|
if (findOne(bv, search, casesensitive, matchword, forward))
|
||||||
|
@ -48,7 +48,8 @@ docstring const replace2string(docstring const & replace,
|
|||||||
bool casesensitive,
|
bool casesensitive,
|
||||||
bool matchword,
|
bool matchword,
|
||||||
bool all,
|
bool all,
|
||||||
bool forward);
|
bool forward,
|
||||||
|
bool findnext = true);
|
||||||
|
|
||||||
/** Parse the string encoding of the find request that is found in
|
/** Parse the string encoding of the find request that is found in
|
||||||
* \c ev.argument and act on it.
|
* \c ev.argument and act on it.
|
||||||
|
Loading…
Reference in New Issue
Block a user