From: Thibaut Cuvelier Date: Mon, 11 Mar 2024 00:22:12 +0000 (+0100) Subject: Extract vert, langle, rangle in MathExtern like parentheses and brackets. X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9e6b810b37f28499a5573468ae61d68be0bb2e75;p=features.git Extract vert, langle, rangle in MathExtern like parentheses and brackets. This patch is part of a series that aims at solving https://www.lyx.org/trac/ticket/12891. It is an excerpt of the patch that lynx published at https://www.lyx.org/trac/ticket/12270. --- diff --git a/src/mathed/MathExtern.cpp b/src/mathed/MathExtern.cpp index b07c08b56e..e273aac791 100644 --- a/src/mathed/MathExtern.cpp +++ b/src/mathed/MathExtern.cpp @@ -292,6 +292,19 @@ bool testString(MathAtom const & at, char const * const str) return testString(at, from_ascii(str)); } + +bool testSymbol(MathAtom const & at, docstring const & name) +{ + return at->asSymbolInset() && at->asSymbolInset()->name() == name; +} + + +bool testSymbol(MathAtom const & at, char const * const name) +{ + return testSymbol(at, from_ascii(name)); +} + + // search end of nested sequence MathData::iterator endNestSearch( MathData::iterator it, @@ -523,12 +536,52 @@ MathAtom replaceBracketDelims(const MathData & ar) } -// replace '('...')' and '['...']' sequences by a real InsetMathDelim +bool testOpenVert(MathAtom const & at) +{ + return testSymbol(at, "lvert"); +} + + +bool testCloseVert(MathAtom const & at) +{ + return testSymbol(at, "rvert"); +} + + +MathAtom replaceVertDelims(const MathData & ar) +{ + return MathAtom(new InsetMathDelim(const_cast(ar.buffer()), + from_ascii("lvert"), from_ascii("rvert"), ar, true)); +} + + +bool testOpenAngled(MathAtom const & at) +{ + return testSymbol(at, "langle"); +} + + +bool testCloseAngled(MathAtom const & at) +{ + return testSymbol(at, "rangle"); +} + + +MathAtom replaceAngledDelims(const MathData & ar) +{ + return MathAtom(new InsetMathDelim(const_cast(ar.buffer()), + from_ascii("langle"), from_ascii("rangle"), ar, true)); +} + + +// replace '('...')', '['...']', '|'...'|', and '<'...'>' sequences by a real InsetMathDelim void extractDelims(MathData & ar) { //lyxerr << "\nDelims from: " << ar << endl; replaceNested(ar, testOpenParen, testCloseParen, replaceParenDelims); replaceNested(ar, testOpenBracket, testCloseBracket, replaceBracketDelims); + replaceNested(ar, testOpenVert, testCloseVert, replaceVertDelims); + replaceNested(ar, testOpenAngled, testCloseAngled, replaceAngledDelims); //lyxerr << "\nDelims to: " << ar << endl; } @@ -622,18 +675,6 @@ void extractFunctions(MathData & ar, ExternalMath kind) // search integrals // -bool testSymbol(MathAtom const & at, docstring const & name) -{ - return at->asSymbolInset() && at->asSymbolInset()->name() == name; -} - - -bool testSymbol(MathAtom const & at, char const * const name) -{ - return testSymbol(at, from_ascii(name)); -} - - bool testIntSymbol(MathAtom const & at) { return testSymbol(at, from_ascii("int"));