[LyX/master] Acount for all non-negative spaces used by lyx
Kornel Benko
kornel at lyx.org
Tue Jul 18 10:03:19 UTC 2023
commit 8eda9e25e00effe8eec6adef8244fc81b888c78f
Author: Kornel Benko <kornel at lyx.org>
Date: Tue Jul 18 13:09:55 2023 +0200
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 files changed, 38 insertions(+), 4 deletions(-)
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index df5752f..13159b5 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);
More information about the lyx-cvs
mailing list