From c5e13278e7f3ac42d170f44ece3bf2b6f99f6b2f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 2 Oct 2001 15:01:57 +0000 Subject: [PATCH] leave red backslash as visual clue in formula when typing macro names git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2833 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 8 ++++++++ src/mathed/math_cursor.C | 23 +++++++++-------------- src/mathed/math_macrotemplate.C | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 156d8d937f..02f040f10c 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,11 @@ + +2001-10-02 André Pönitz + + * 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 * math_cursor.C: diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index ef4472dda5..8918412562 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -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; } diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index 79e1894e1b..10ffb95ae4 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -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; } -- 2.39.2