mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Added restrict-search-to-maths-only checkbox to advanced pane of Advanced F&R.
This commit is contained in:
parent
561c5bfd50
commit
b93f2c20d3
@ -439,6 +439,12 @@ bool FindAndReplaceWidget::findAndReplace(
|
||||
scope = FindAndReplaceOptions::S_ALL_MANUALS;
|
||||
else
|
||||
LATTEST(false);
|
||||
|
||||
FindAndReplaceOptions::SearchRestriction restr =
|
||||
OnlyMaths->isChecked()
|
||||
? FindAndReplaceOptions::R_ONLY_MATHS
|
||||
: FindAndReplaceOptions::R_EVERYTHING;
|
||||
|
||||
LYXERR(Debug::FIND, "FindAndReplaceOptions: "
|
||||
<< "find_buf_name=" << find_buf_name
|
||||
<< ", casesensitiv=" << casesensitive
|
||||
@ -448,10 +454,12 @@ bool FindAndReplaceWidget::findAndReplace(
|
||||
<< ", ignoreformat=" << ignoreformat
|
||||
<< ", repl_buf_name" << repl_buf_name
|
||||
<< ", keep_case=" << keep_case
|
||||
<< ", scope=" << scope);
|
||||
<< ", scope=" << scope
|
||||
<< ", restr=" << restr);
|
||||
|
||||
FindAndReplaceOptions opt(find_buf_name, casesensitive, matchword,
|
||||
!backwards, expandmacros, ignoreformat,
|
||||
repl_buf_name, keep_case, scope);
|
||||
repl_buf_name, keep_case, scope, restr);
|
||||
return findAndReplaceScope(opt, replace_all);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>276</width>
|
||||
<height>291</height>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -264,19 +264,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -311,7 +298,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="expandMacrosCB">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -321,7 +308,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="OnlyMaths">
|
||||
<property name="text">
|
||||
<string>Search only in mat&hs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -335,8 +331,6 @@
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -904,6 +904,9 @@ MatchStringAdv::MatchStringAdv(lyx::Buffer & buf, FindAndReplaceOptions const &
|
||||
|
||||
int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) const
|
||||
{
|
||||
if (at_begin &&
|
||||
(opt.restr == FindAndReplaceOptions::R_ONLY_MATHS && !cur.inMathed()) )
|
||||
return 0;
|
||||
docstring docstr = stringifyFromForSearch(opt, cur, len);
|
||||
LYXERR(Debug::FIND, "Matching against '" << lyx::to_utf8(docstr) << "'");
|
||||
string str = normalize(docstr, true);
|
||||
@ -1296,10 +1299,10 @@ FindAndReplaceOptions::FindAndReplaceOptions(
|
||||
docstring const & find_buf_name, bool casesensitive,
|
||||
bool matchword, bool forward, bool expandmacros, bool ignoreformat,
|
||||
docstring const & repl_buf_name, bool keep_case,
|
||||
SearchScope scope)
|
||||
SearchScope scope, SearchRestriction restr)
|
||||
: find_buf_name(find_buf_name), casesensitive(casesensitive), matchword(matchword),
|
||||
forward(forward), expandmacros(expandmacros), ignoreformat(ignoreformat),
|
||||
repl_buf_name(repl_buf_name), keep_case(keep_case), scope(scope)
|
||||
repl_buf_name(repl_buf_name), keep_case(keep_case), scope(scope), restr(restr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1492,7 +1495,8 @@ ostringstream & operator<<(ostringstream & os, FindAndReplaceOptions const & opt
|
||||
<< opt.ignoreformat << ' '
|
||||
<< to_utf8(opt.repl_buf_name) << "\nEOSS\n"
|
||||
<< opt.keep_case << ' '
|
||||
<< int(opt.scope);
|
||||
<< int(opt.scope) << ' '
|
||||
<< int(opt.restr);
|
||||
|
||||
LYXERR(Debug::FIND, "built: " << os.str());
|
||||
|
||||
@ -1534,8 +1538,12 @@ istringstream & operator>>(istringstream & is, FindAndReplaceOptions & opt)
|
||||
int i;
|
||||
is >> i;
|
||||
opt.scope = FindAndReplaceOptions::SearchScope(i);
|
||||
is >> i;
|
||||
opt.restr = FindAndReplaceOptions::SearchRestriction(i);
|
||||
|
||||
LYXERR(Debug::FIND, "parsed: " << opt.casesensitive << ' ' << opt.matchword << ' ' << opt.forward << ' '
|
||||
<< opt.expandmacros << ' ' << opt.ignoreformat << ' ' << opt.keep_case);
|
||||
<< opt.expandmacros << ' ' << opt.ignoreformat << ' ' << opt.keep_case << ' '
|
||||
<< opt.scope << ' ' << opt.restr);
|
||||
return is;
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,10 @@ public:
|
||||
S_OPEN_BUFFERS,
|
||||
S_ALL_MANUALS
|
||||
} SearchScope;
|
||||
typedef enum {
|
||||
R_EVERYTHING,
|
||||
R_ONLY_MATHS
|
||||
} SearchRestriction;
|
||||
FindAndReplaceOptions(
|
||||
docstring const & find_buf_name,
|
||||
bool casesensitive,
|
||||
@ -89,7 +93,8 @@ public:
|
||||
bool ignoreformat,
|
||||
docstring const & repl_buf_name,
|
||||
bool keep_case,
|
||||
SearchScope scope = S_BUFFER
|
||||
SearchScope scope = S_BUFFER,
|
||||
SearchRestriction restr = R_EVERYTHING
|
||||
);
|
||||
FindAndReplaceOptions() { }
|
||||
docstring find_buf_name;
|
||||
@ -102,6 +107,7 @@ public:
|
||||
docstring repl_buf_name;
|
||||
bool keep_case;
|
||||
SearchScope scope;
|
||||
SearchRestriction restr;
|
||||
};
|
||||
|
||||
/// Write a FindAdvOptions instance to a stringstream
|
||||
|
Loading…
Reference in New Issue
Block a user