From c740d233cc823e1f881452cdfb13491402229dd9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 12 Sep 2001 14:31:18 +0000 Subject: [PATCH] interpret a typed \#1 as math-macro-arg 0 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2744 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 11 ++++++++--- src/mathed/math_factory.C | 4 ++++ src/mathed/math_macroarg.h | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index e0138f54bb..454d2d4169 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -1283,18 +1283,23 @@ void MathCursor::interpret(string const & s) if (lastcode_ == LM_TC_TEX) { if (macroName().empty()) { - if (strchr("#$%{}", c)) { + if (strchr("$%{}", c)) { insert(new MathCharInset(c, LM_TC_TEX)); lastcode_ = LM_TC_VAR; return; } insert(c, LM_TC_TEX); - if (!isalpha(c)) { + if (!isalpha(c) && c != '#') { macroModeClose(); lastcode_ = LM_TC_VAR; } } else { - if (isalpha(c)) + if ('1' <= c && c <= '9' && macroName() == "#") { + insert(c, LM_TC_TEX); + macroModeClose(); + lastcode_ = LM_TC_VAR; + } + else if (isalpha(c)) insert(c, LM_TC_TEX); else { macroModeClose(); diff --git a/src/mathed/math_factory.C b/src/mathed/math_factory.C index f18c1afcb3..34b0ba5d36 100644 --- a/src/mathed/math_factory.C +++ b/src/mathed/math_factory.C @@ -10,6 +10,7 @@ #include "math_kerninset.h" #include "math_macro.h" #include "math_macrotable.h" +#include "math_macroarg.h" #include "math_notinset.h" #include "math_rootinset.h" #include "math_spaceinset.h" @@ -66,6 +67,9 @@ MathInset * createMathInset(latexkeys const * l) MathInset * createMathInset(string const & s) { //cerr << "creating inset with name: '" << s << "'\n"; + if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9') + return new MathMacroArgument(s[1] - '0'); + latexkeys const * l = in_word_set(s); if (l) return createMathInset(l); diff --git a/src/mathed/math_macroarg.h b/src/mathed/math_macroarg.h index 3bf884684e..0982ada0d1 100644 --- a/src/mathed/math_macroarg.h +++ b/src/mathed/math_macroarg.h @@ -27,6 +27,8 @@ public: void writeNormal(std::ostream &) const; /// void substitute(MathMacro const & macro); + /// + bool isActive() const { return false; } private: /// A number between 1 and 9 -- 2.39.2