]> git.lyx.org Git - features.git/commitdiff
somewhat clearer logic
authorAndré Pönitz <poenitz@gmx.net>
Wed, 7 Jan 2004 14:07:46 +0000 (14:07 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 7 Jan 2004 14:07:46 +0000 (14:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8314 a592a061-630c-0410-9148-cb99ea01b6c8

src/lyxfind.C

index c308e9d00baa28e16f4a231e726b868115a5ccba..b5bd7fb7f4e1892118044fe6440f93bff84b9787 100644 (file)
@@ -27,8 +27,6 @@
 
 #include "frontends/Alert.h"
 
-#include "insets/insettext.h"
-
 #include "support/textutils.h"
 
 using lyx::support::lowercase;
@@ -47,8 +45,10 @@ class MatchString
 {
 public:
        MatchString(string const & str, bool cs, bool mw)
-               : str(str), cs(cs), mw(mw) {};
-// returns true if the specified string is at the specified position
+               : str(str), cs(cs), mw(mw)
+       {}
+
+       // returns true if the specified string is at the specified position
        bool operator()(Paragraph const & par, pos_type pos) const
        {                       
                string::size_type size = str.length();
@@ -60,22 +60,28 @@ public:
                           : (uppercase(str[i]) == uppercase(par.getChar(pos + i))))) {
                        ++i;
                }
-               if (size == string::size_type(i)) {
-                       // if necessary, check whether string matches word
-                       if (!mw)
-                               return true;
-                       if ((pos <= 0 || !IsLetterCharOrDigit(par.getChar(pos - 1)))
-                           && (pos + pos_type(size) >= parsize
-                               || !IsLetterCharOrDigit(par.getChar(pos + size)))) {
-                               return true;
-                       }
+
+               if (size != string::size_type(i))
+                       return false;
+
+               // if necessary, check whether string matches word
+               if (mw) {
+                       if (pos > 0     && IsLetterCharOrDigit(par.getChar(pos - 1)))
+                               return false;
+                       if (pos + pos_type(size) < parsize
+                                       && IsLetterCharOrDigit(par.getChar(pos + size)));
+                               return false;
                }
-               return false;
+
+               return true;
        }
        
 private:
+       // search string
        string str;
+       // case sensitive
        bool cs;
+       // match whole words only
        bool mw;
 };
 
@@ -127,8 +133,7 @@ bool searchAllowed(BufferView * bv, string const & str)
 
 
 
-bool find(BufferView * bv, string const & searchstr,
-         bool cs, bool mw, bool fw)
+bool find(BufferView * bv, string const & searchstr, bool cs, bool mw, bool fw)
 {
        if (!searchAllowed(bv, searchstr))
                return false;