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
<< ", 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);
}
<x>0</x>
<y>0</y>
<width>276</width>
- <height>291</height>
+ <height>421</height>
</rect>
</property>
<property name="sizePolicy">
</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>
</property>
</widget>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QCheckBox" name="expandMacrosCB">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
- <item row="4" column="0">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="OnlyMaths">
+ <property name="text">
+ <string>Search only in mat&hs</string>
</property>
- </spacer>
+ </widget>
</item>
</layout>
</item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <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>
</widget>
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);
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)
{
}
<< 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());
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;
}
S_OPEN_BUFFERS,
S_ALL_MANUALS
} SearchScope;
+ typedef enum {
+ R_EVERYTHING,
+ R_ONLY_MATHS
+ } SearchRestriction;
FindAndReplaceOptions(
docstring const & find_buf_name,
bool casesensitive,
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;
docstring repl_buf_name;
bool keep_case;
SearchScope scope;
+ SearchRestriction restr;
};
/// Write a FindAdvOptions instance to a stringstream