]> git.lyx.org Git - features.git/commitdiff
interpret a typed \#1 as math-macro-arg 0
authorAndré Pönitz <poenitz@gmx.net>
Wed, 12 Sep 2001 14:31:18 +0000 (14:31 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 12 Sep 2001 14:31:18 +0000 (14:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2744 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_cursor.C
src/mathed/math_factory.C
src/mathed/math_macroarg.h

index e0138f54bbef202efa3ccacdfc9b5053c48d2e28..454d2d416952948d677351aea9bcdbbcbc0e6dcc 100644 (file)
@@ -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();
index f18c1afcb3931b76fe8fef1661d8e92b5fbe531c..34b0ba5d3642f731d311c2dbc1e2a00f0670437f 100644 (file)
@@ -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);
index 3bf884684e8d4f388e0c5489a5bae54510d5ba82..0982ada0d12c440b571b1b37a5a753f5b1f32347 100644 (file)
@@ -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