From b21c8b214dce258a52969878f170b78ea4c41756 Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Sat, 2 Mar 2019 22:00:20 +0100 Subject: [PATCH] FindAdv: Expand the list for handled latin characters --- src/lyxfind.cpp | 62 ++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index d6391d549f..78579ee77c 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -1248,25 +1248,30 @@ void Intervall::addIntervall(int low, int upper) typedef map AccentsMap; static AccentsMap accents = map(); -static void buildaccent(string name, string param, string values) -{ - size_t start = 0; - for (size_t i = 0; i < param.size(); i++) { - string key = name + "{" + param[i] + "}"; - // get the corresponding utf8-value - if ((values[start] & 0xc0) != 0xc0) { - // should not happen, utf8 encoding starts at least with 11xxxxxx - start++; - continue; - } - for (int j = 1; ;j++) { - if (start + j >= values.size()) - break; - if ((values[start+j] & 0xc0) == 0xc0) { - // This is the first byte of following utf8 char - accents[key] = values.substr(start, j); - start += j; - break; +static void buildaccent(string n, string param, string values) +{ + stringstream s(n); + string name; + const char delim = '|'; + while (getline(s, name, delim)) { + size_t start = 0; + for (size_t i = 0; i < param.size(); i++) { + string key = name + "{" + param[i] + "}"; + // get the corresponding utf8-value + if ((values[start] & 0xc0) != 0xc0) { + // should not happen, utf8 encoding starts at least with 11xxxxxx + start++; + continue; + } + for (int j = 1; ;j++) { + if (start + j >= values.size()) + break; + if ((values[start+j] & 0xc0) == 0xc0) { + // This is the first byte of following utf8 char + accents[key] = values.substr(start, j); + start += j; + break; + } } } } @@ -1277,19 +1282,22 @@ static void buildAccentsMap() accents["imath"] = "ı"; accents["ddot{\\imath}"] = "ï"; accents["acute{\\imath}"] = "í"; + accents["tilde{\\imath}"] = "ĩ"; + accents["jmath"] = "ȷ"; + accents["hat{\\jmath}"] = "ĵ"; accents["lyxmathsym{ß}"] = "ß"; - buildaccent("ddot", "aeouyAEOUY", "äëöüÿÄËÖÜŸ"); + buildaccent("ddot", "aeouyAEOUY", "äëöüÿÄËÖÜŸ"); // umlaut buildaccent("dot", "aeoyzAEOYZ", "ȧėȯẏżȦĖȮẎŻ"); - buildaccent("acute", "aeouyAEOUY", "äëöüÿÄËÖÜŸ"); + buildaccent("acute", "aAcCeElLoOnNrRsSuUyYzZI", "áÁćĆéÉĺĹóÓńŃŕŔśŚúÚýÝźŹÍ"); /* buildaccent("dacute", "oOuU", "őŐűŰ"); buildaccent("H", "oOuU", "őŐűŰ"); // dacute in text */ - buildaccent("mathring", "uU", "ůŮ"); - buildaccent("r", "uU", "ůŮ"); //mathring in text - buildaccent("check", "cdnrszCDNRSZ", "čďřňšžČĎŘŇŠŽ"); - buildaccent("hat", "cCoOgGhHsS", "ĉĈôÔĝĜĥĤŝŜ"); - buildaccent("bar", "aAeE", "āĀēĒ"); + buildaccent("mathring|r", "uU", "ůŮ"); + buildaccent("check", "cCdDeElLnNrRsSTzZ", "čČďĎěĚľĽňŇřŘšŠŤžŽ"); // caron + buildaccent("hat", "cCgGhHJsSwWyYoOgG", "ĉĈĝĜĥĤĴŝŜŵŴŷŶôÔĝĜ"); // circ + buildaccent("bar|=", "aAeEoOuU", "āĀēĒōŌūŪ"); // macron + buildaccent("tilde", "I", "Ĩ"); // macron } /* @@ -1300,7 +1308,7 @@ void Intervall::removeAccents() { if (accents.empty()) buildAccentsMap(); - static regex const accre("\\\\((lyxmathsym|ddot|dot|acute|mathring|r|check|check|hat|bar)\\{[^\\{\\}]+\\}|imath)"); + static regex const accre("\\\\((lyxmathsym|ddot|dot|acute|mathring|r|check|check|hat|bar|=)\\{[^\\{\\}]+\\}|imath|jmath)"); smatch sub; for (sregex_iterator itacc(par.begin(), par.end(), accre), end; itacc != end; ++itacc) { sub = *itacc; -- 2.39.2