From 8eda9e25e00effe8eec6adef8244fc81b888c78f Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Tue, 18 Jul 2023 13:09:55 +0200 Subject: [PATCH] Acount for all non-negative spaces used by lyx 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 | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index df5752f942..13159b5737 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -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); -- 2.39.5