]> git.lyx.org Git - features.git/commitdiff
Acount for all non-negative spaces used by lyx
authorKornel Benko <kornel@lyx.org>
Tue, 18 Jul 2023 11:09:55 +0000 (13:09 +0200)
committerKornel Benko <kornel@lyx.org>
Tue, 18 Jul 2023 11:09:55 +0000 (13:09 +0200)
The unicode representation in an ascii-string string is
\302\240                                Normal space
\342\200\257                            Non-breaking Thin (1/6 em)
\342\200\213\342\200\205\342\200\213    Medium(2/9 em)
\342\200\213\342\200\204\342\200\213    Thick (5/18 em)
\342\201\240\342\200\202\342\201\240    Half Quad(0.5 em)
\342\200\203                            Quad(1 em)
\342\200\203\342\200\203                Double Quad(2 em)
\342\220\243                            Visible space

'Double Quad' counts as 2 spaces, all others count as 1 space in the search regex

src/lyxfind.cpp

index df5752f9425aa48e6cc93a2435d87985e3a59b4c..13159b57373e08f396f17964f2b7442f2f3ab44e 100644 (file)
@@ -831,13 +831,47 @@ string string2regex(string in)
                        // normal blanks
                        blanks++;
                }
-               else if ((tempx[i] == '\302' && tempx[i+1] == '\240')
-                       || (tempx[i] == '\342' && tempx[i+1] == '\202')) {
-                       // protected space
-                       // thin space
+               else if (tempx[i] == '\302' && tempx[i+1] == '\240') {
+                       // Normal Space
                        blanks++;
                        i++;
                }
+               else if (tempx[i] == '\342') {
+                       if (tempx[i+1] == '\200') {
+                               if ((tempx[i+2] == '\257')
+                                  || (tempx[i+2] == '\203')
+                                  || (tempx[i+2] == '\202')) {
+                                       // Non-breaking Thin (1/6 em)
+                                       // Quad(1 em), (Double quad counts as 2 blanks)
+                                       // Half Quad
+                                       blanks++;
+                                       i += 2;
+                               }
+                               else if (tempx[i+2] == '\213') {
+                                       // Ignoring parts of Medium and Thick
+                                       i += 2;
+                                       continue;
+                               }
+                               else if ((tempx[i+2] == '\204') || (tempx[i+2] == '\205')) {
+                                       // Thick
+                                       // Medium
+                                       blanks++;
+                                       i += 2;
+                               }
+                       }
+                       else if (tempx[i+1] == '\201') {
+                               if (tempx[i+2] == '\240') {
+                                       // Ignoring parts of half quad
+                                       i += 2;
+                                       continue;
+                               }
+                       }
+                       else if ((tempx[i+1] == '\220') && (tempx[i+2] == '\243')) {
+                               // Visible space
+                               blanks++;
+                               i += 2;
+                       }
+               }
                else {
                        if (blanks > 0) {
                                temp += getRegexSpaceCount(blanks);