Adv-Search: Use some free unicodes as replacement for searched spaces

Without this, it is difficult to find backslashed macros if in regexp-mode.
This commit is contained in:
Kornel Benko 2020-12-10 11:32:59 +01:00
parent 286db9361f
commit 2d2e2f1c6d
2 changed files with 38 additions and 23 deletions

View File

@ -579,78 +579,85 @@ void InsetSpace::latex(otexstream & os, OutputParams const & runparams) const
{ {
switch (params_.kind) { switch (params_.kind) {
case InsetSpaceParams::NORMAL: case InsetSpaceParams::NORMAL:
os << (runparams.free_spacing ? " " : "\\ "); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\ ");
break; break;
case InsetSpaceParams::PROTECTED: case InsetSpaceParams::PROTECTED:
if (runparams.local_font && if (runparams.local_font &&
runparams.local_font->language()->lang() == "polutonikogreek") runparams.local_font->language()->lang() == "polutonikogreek")
// in babel's polutonikogreek, ~ is active // in babel's polutonikogreek, ~ is active
os << (runparams.free_spacing ? " " : "\\nobreakspace{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\nobreakspace{}");
else else
os << (runparams.free_spacing ? ' ' : '~'); os << (runparams.free_spacing && !runparams.for_search ? ' ' : '~');
break; break;
case InsetSpaceParams::VISIBLE: case InsetSpaceParams::VISIBLE:
os << (runparams.free_spacing ? " " : "\\textvisiblespace{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\textvisiblespace{}");
break; break;
case InsetSpaceParams::THIN: case InsetSpaceParams::THIN:
os << (runparams.free_spacing ? " " : "\\,"); if (runparams.for_search)
os << "\\thinspace{}";
else
os << (runparams.free_spacing ? " " : "\\,");
break; break;
case InsetSpaceParams::MEDIUM: case InsetSpaceParams::MEDIUM:
if (params_.math) if (runparams.for_search)
os << "\\medspace{}";
else if (params_.math)
os << (runparams.free_spacing ? " " : "\\:"); os << (runparams.free_spacing ? " " : "\\:");
else else
os << (runparams.free_spacing ? " " : "\\medspace{}"); os << (runparams.free_spacing ? " " : "\\medspace{}");
break; break;
case InsetSpaceParams::THICK: case InsetSpaceParams::THICK:
if (params_.math) if (runparams.for_search)
os << "\\thickspace{}";
else if (params_.math)
os << (runparams.free_spacing ? " " : "\\;"); os << (runparams.free_spacing ? " " : "\\;");
else else
os << (runparams.free_spacing ? " " : "\\thickspace{}"); os << (runparams.free_spacing ? " " : "\\thickspace{}");
break; break;
case InsetSpaceParams::QUAD: case InsetSpaceParams::QUAD:
os << (runparams.free_spacing ? " " : "\\quad{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\quad{}");
break; break;
case InsetSpaceParams::QQUAD: case InsetSpaceParams::QQUAD:
os << (runparams.free_spacing ? " " : "\\qquad{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\qquad{}");
break; break;
case InsetSpaceParams::ENSPACE: case InsetSpaceParams::ENSPACE:
os << (runparams.free_spacing ? " " : "\\enspace{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\enspace{}");
break; break;
case InsetSpaceParams::ENSKIP: case InsetSpaceParams::ENSKIP:
os << (runparams.free_spacing ? " " : "\\enskip{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\enskip{}");
break; break;
case InsetSpaceParams::NEGTHIN: case InsetSpaceParams::NEGTHIN:
os << (runparams.free_spacing ? " " : "\\negthinspace{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\negthinspace{}");
break; break;
case InsetSpaceParams::NEGMEDIUM: case InsetSpaceParams::NEGMEDIUM:
os << (runparams.free_spacing ? " " : "\\negmedspace{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\negmedspace{}");
break; break;
case InsetSpaceParams::NEGTHICK: case InsetSpaceParams::NEGTHICK:
os << (runparams.free_spacing ? " " : "\\negthickspace{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\negthickspace{}");
break; break;
case InsetSpaceParams::HFILL: case InsetSpaceParams::HFILL:
os << (runparams.free_spacing ? " " : "\\hfill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\hfill{}");
break; break;
case InsetSpaceParams::HFILL_PROTECTED: case InsetSpaceParams::HFILL_PROTECTED:
os << (runparams.free_spacing ? " " : "\\hspace*{\\fill}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\hspace*{\\fill}");
break; break;
case InsetSpaceParams::DOTFILL: case InsetSpaceParams::DOTFILL:
os << (runparams.free_spacing ? " " : "\\dotfill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\dotfill{}");
break; break;
case InsetSpaceParams::HRULEFILL: case InsetSpaceParams::HRULEFILL:
os << (runparams.free_spacing ? " " : "\\hrulefill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\hrulefill{}");
break; break;
case InsetSpaceParams::LEFTARROWFILL: case InsetSpaceParams::LEFTARROWFILL:
os << (runparams.free_spacing ? " " : "\\leftarrowfill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\leftarrowfill{}");
break; break;
case InsetSpaceParams::RIGHTARROWFILL: case InsetSpaceParams::RIGHTARROWFILL:
os << (runparams.free_spacing ? " " : "\\rightarrowfill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\rightarrowfill{}");
break; break;
case InsetSpaceParams::UPBRACEFILL: case InsetSpaceParams::UPBRACEFILL:
os << (runparams.free_spacing ? " " : "\\upbracefill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\upbracefill{}");
break; break;
case InsetSpaceParams::DOWNBRACEFILL: case InsetSpaceParams::DOWNBRACEFILL:
os << (runparams.free_spacing ? " " : "\\downbracefill{}"); os << (runparams.free_spacing && !runparams.for_search ? " " : "\\downbracefill{}");
break; break;
case InsetSpaceParams::CUSTOM: case InsetSpaceParams::CUSTOM:
if (runparams.free_spacing) if (runparams.free_spacing)

View File

@ -1296,6 +1296,13 @@ static void buildAccentsMap()
accents["i"] = "ı"; accents["i"] = "ı";
accents["jmath"] = "ȷ"; accents["jmath"] = "ȷ";
accents["cdot"] = "·"; accents["cdot"] = "·";
accents["hairspace"] = u8"\uf0000"; // select from free unicode plane 15
accents["thinspace"] = u8"\uf0002"; // and used _only_ by findadv
accents["negthinspace"] = u8"\uf0003"; // to omit backslashed latex macros
accents["medspace"] = u8"\uf0004"; // See https://en.wikipedia.org/wiki/Private_Use_Areas
accents["negmedspace"] = u8"\uf0005";
accents["thickspace"] = u8"\uf0006";
accents["negthickspace"] = u8"\uf0007";
accents["lyxmathsym{ß}"] = "ß"; accents["lyxmathsym{ß}"] = "ß";
accents["text{ß}"] = "ß"; accents["text{ß}"] = "ß";
accents["ddot{\\imath}"] = "ï"; accents["ddot{\\imath}"] = "ï";
@ -1361,7 +1368,7 @@ void Intervall::removeAccents()
{ {
if (accents.empty()) if (accents.empty())
buildAccentsMap(); buildAccentsMap();
static regex const accre("\\\\(([\\S]|grave|breve|lyxmathsym|text|ddot|dot|acute|dacute|mathring|check|hat|bar|tilde|subdot|ogonek|cedilla|subring|textsubring|subhat|textsubcircum|subtilde|textsubtilde|dgrave|textdoublegrave|rcap|textroundcap|slashed)\\{[^\\{\\}]+\\}|(i|imath|jmath|cdot)(?![a-zA-Z]))"); static regex const accre("\\\\(([\\S]|grave|breve|lyxmathsym|text|ddot|dot|acute|dacute|mathring|check|hat|bar|tilde|subdot|ogonek|cedilla|subring|textsubring|subhat|textsubcircum|subtilde|textsubtilde|dgrave|textdoublegrave|rcap|textroundcap|slashed)\\{[^\\{\\}]+\\}|(i|imath|jmath|cdot|[a-z]+space)(?![a-zA-Z]))");
smatch sub; smatch sub;
for (sregex_iterator itacc(par.begin(), par.end(), accre), end; itacc != end; ++itacc) { for (sregex_iterator itacc(par.begin(), par.end(), accre), end; itacc != end; ++itacc) {
sub = *itacc; sub = *itacc;
@ -2007,6 +2014,7 @@ void LatexInfo::buildKeys(bool isPatternString)
makeKey("quad|qquad|hfill|dotfill", KeyInfo(KeyInfo::isChar, 0, false), isPatternString); makeKey("quad|qquad|hfill|dotfill", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
makeKey("textvisiblespace|nobreakspace", KeyInfo(KeyInfo::isChar, 0, false), isPatternString); makeKey("textvisiblespace|nobreakspace", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
makeKey("negthickspace|negmedspace|negthinspace", KeyInfo(KeyInfo::isChar, 0, false), isPatternString); makeKey("negthickspace|negmedspace|negthinspace", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
makeKey("thickspace|medspace|thinspace", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
// Skip // Skip
// makeKey("enskip|smallskip|medskip|bigskip|vfill", KeyInfo(KeyInfo::isChar, 0, false), isPatternString); // makeKey("enskip|smallskip|medskip|bigskip|vfill", KeyInfo(KeyInfo::isChar, 0, false), isPatternString);
// Custom space/skip, remove the content (== length value) // Custom space/skip, remove the content (== length value)