]> git.lyx.org Git - features.git/commitdiff
leave red backslash as visual clue in formula when typing macro names
authorAndré Pönitz <poenitz@gmx.net>
Tue, 2 Oct 2001 15:01:57 +0000 (15:01 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 2 Oct 2001 15:01:57 +0000 (15:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2833 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_cursor.C
src/mathed/math_macrotemplate.C

index 156d8d937fb54e75ffcb9271b8e17a907be6f86c..02f040f10ccbceccbdba90862214bff4bc86c844 100644 (file)
@@ -1,3 +1,11 @@
+
+2001-10-02  André Pönitz  <poenitz@gmx.net>
+
+       * math_cursor.C: leave red backslash as visual clue
+       in formula when typing macro names
+
+       *       math_macrotemplate.C: sanity check
+
 2001-10-01  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * math_cursor.C:
index ef4472dda5168e901294819a9d193fec6772520b..89184125627a7ef14696f9382bd6e79d502b85ba 100644 (file)
@@ -635,8 +635,8 @@ void MathCursor::macroModeClose()
 {
        string s = macroName();
        if (s.size()) {
-               pos() = pos() - s.size();
-               for (unsigned i = 0; i < s.size(); ++i)
+               pos() = pos() - s.size() - 1;
+               for (unsigned i = 0; i <= s.size(); ++i)
                        plainErase();
                lastcode_ = LM_TC_VAR;
                interpret("\\" + s);
@@ -649,10 +649,9 @@ string MathCursor::macroName() const
        string s;
        for (int i = pos() - 1; i >= 0; --i) {
                MathInset * p = array().at(i)->nucleus();
-               if (p && p->code() == LM_TC_TEX)
-                       s = p->getChar() + s;
-               else
+               if (!p || p->code() != LM_TC_TEX || p->getChar() == '\\')
                        break;
+               s = p->getChar() + s;
        }
        return s;
 }
@@ -1333,11 +1332,6 @@ void MathCursor::interpret(string const & s)
 
        if (lastcode_ == LM_TC_TEX) {
                if (macroName().empty()) {
-                       if (strchr("$%{}", c)) {
-                               insert(new MathCharInset(c, LM_TC_TEX));        
-                               lastcode_ = LM_TC_VAR;
-                               return;
-                       }
                        insert(c, LM_TC_TEX);
                        if (!isalpha(c) && c != '#') {
                                macroModeClose();
@@ -1362,14 +1356,14 @@ void MathCursor::interpret(string const & s)
        if (isalpha(c) && (lastcode_ == LM_TC_GREEK || lastcode_ == LM_TC_GREEK1)) {
                static char const greekl[][26] =
                        {"alpha", "beta", "chi", "delta", "epsilon", "phi",
-                        "gamma", "eta", "iota", "", "kappa", "lambda", "mu",
+                        "gamma", "eta", "iota", "iota", "kappa", "lambda", "mu",
                         "nu", "omikron", "pi", "omega", "rho", "sigma",
-                        "tau", "upsilon", "theta", "", "xi", "upsilon", "zeta"};
+                        "tau", "upsilon", "theta", "omega", "xi", "upsilon", "zeta"};
                static char const greeku[][26] =
                        {"Alpha", "Beta", "Chi", "Delta", "Epsilon", "Phi",
-                        "Gamma", "Eta", "Iota", "", "Kappa", "Lambda", "Mu",
+                        "Gamma", "Eta", "Iota", "Iota", "Kappa", "Lambda", "Mu",
                         "Nu", "Omikron", "Pi", "Omega", "Rho", "Sigma", "Tau",
-                        "Upsilon", "Theta", "", "xi", "Upsilon", "Zeta"};
+                        "Upsilon", "Theta", "Omega", "xi", "Upsilon", "Zeta"};
        
                latexkeys const * l = 0;        
                if ('a' <= c && c <= 'z')
@@ -1390,6 +1384,7 @@ void MathCursor::interpret(string const & s)
 
        if (c == '\\') {
                lastcode_ = LM_TC_TEX;
+               insert(c, LM_TC_TEX);
                //bv->owner()->message(_("TeX mode"));
                return; 
        }
index 79e1894e1bfa8c53a096a05c935bbb8d3dd582d1..10ffb95ae4a44a7a64ca1055afb3d9727243207e 100644 (file)
@@ -15,7 +15,7 @@ MathMacroTemplate::MathMacroTemplate()
 MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs)
        : MathNestInset(1), numargs_(numargs), name_(nm)
 {
-       if (numargs_ < 1 || numargs_ > 9) {
+       if (numargs_ > 9) {
                lyxerr << "MathMacroTemplate::MathMacroTemplate: wrong # of arguments: "
                        << numargs_ << std::endl;
        }