if (!searchAllowed(searchstr))
return false;
- DocIterator cur = bv->cursor();
+ DocIterator cur = forward
+ ? bv->cursor().selectionEnd()
+ : bv->cursor().selectionBegin();
MatchString const match(searchstr, case_sens, whole);
return s;
}
+
/// Wrapper for lyx::regex_replace with simpler interface
bool regex_replace(string const & s, string & t, string const & searchstr,
string const & replacestr)
return rv;
}
+
/** Checks if supplied string segment is well-formed from the standpoint of matching open-closed braces.
**
** Verify that closed braces exactly match open braces. This avoids that, for example,
return true;
}
+
/** The class performing a match between a position in the document and the FindAdvOptions.
**/
class MatchStringAdv {
}
-static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions const & opt) {
+static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions const & opt)
+{
docstring str;
if (!opt.ignoreformat) {
str = buffer_to_latex(buffer);
/// Return separation pos between the leading material and the rest
-static size_t identifyLeading(string const & s) {
+static size_t identifyLeading(string const & s)
+{
string t = s;
// @TODO Support \item[text]
while (regex_replace(t, t, "^\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)\\*?\\{", "")
// Remove trailing closure of math, macros and environments, so to catch parts of them.
-static int identifyClosing(string & t) {
+static int identifyClosing(string & t)
+{
int open_braces = 0;
do {
LYXERR(Debug::FIND, "identifyClosing(): t now is '" << t << "'");
/// Finds backwards
-int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match) {
+int findBackwardsAdv(DocIterator & cur, MatchStringAdv & match)
+{
if (! cur)
return 0;
// Backup of original position
/** Check if 'len' letters following cursor are all non-lowercase */
-static bool allNonLowercase(DocIterator const & cur, int len) {
+static bool allNonLowercase(DocIterator const & cur, int len)
+{
pos_type end_pos = cur.pos() + len;
for (pos_type pos = cur.pos(); pos != end_pos; ++pos)
if (isLowerCase(cur.paragraph().getChar(pos)))
/** Check if first letter is upper case and second one is lower case */
-static bool firstUppercase(DocIterator const & cur) {
+static bool firstUppercase(DocIterator const & cur)
+{
char_type ch1, ch2;
if (cur.pos() >= cur.lastpos() - 1) {
LYXERR(Debug::FIND, "No upper-case at cur: " << cur);
**
** \fixme What to do with possible further paragraphs in replace buffer ?
**/
-static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case) {
+static void changeFirstCase(Buffer & buffer, TextCase first_case, TextCase others_case)
+{
ParagraphList::iterator pit = buffer.paragraphs().begin();
pos_type right = pos_type(1);
pit->changeCase(buffer.params(), pos_type(0), right, first_case);
right = pit->size() + 1;
pit->changeCase(buffer.params(), right, right, others_case);
}
+
} // anon namespace
///