From 49710a766f6d95525873bc6f220fa1e1bc6a6e7a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Tue, 11 Dec 2001 11:33:43 +0000 Subject: [PATCH] input support for \mathcal, \mathbb etc. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3186 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_cursor.C | 9 ++++++++- src/mathed/math_macro.C | 16 ++++++++++------ src/mathed/math_macro.h | 2 ++ src/mathed/math_macrotable.C | 1 + src/mathed/math_macrotemplate.C | 3 +-- src/mathed/math_mathmlstream.h | 1 - 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 2d7747052c..80cc2f918a 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -1266,6 +1266,12 @@ bool MathCursor::interpret(string const & s) return true; } + latexkeys const * l = in_word_set(s.substr(1)); + if (l && (l->token == LM_TK_FONT || l->token == LM_TK_OLDFONT)) { + lastcode_ = static_cast(l->id); + return true; + } + niceInsert(createMathInset(s.substr(1))); return true; } @@ -1403,7 +1409,8 @@ bool MathCursor::interpret(char c) } // no special circumstances, so insert the character without any fuss - insert(c, LM_TC_MIN); + insert(c, lastcode_); + lastcode_ = LM_TC_MIN; return true; } diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 8f413d47bd..7ac130d265 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -196,24 +196,21 @@ void MathMacro::validate(LaTeXFeatures & features) const void MathMacro::maplize(MapleStream & os) const { - expanded_ = tmplate_->xcell(0); - expanded_.data_.substitute(*this); + updateExpansion(); ::maplize(expanded_.data_, os); } void MathMacro::mathmlize(MathMLStream & os) const { - expanded_ = tmplate_->xcell(0); - expanded_.data_.substitute(*this); + updateExpansion(); ::mathmlize(expanded_.data_, os); } void MathMacro::octavize(OctaveStream & os) const { - expanded_ = tmplate_->xcell(0); - expanded_.data_.substitute(*this); + updateExpansion(); ::octavize(expanded_.data_, os); } @@ -235,3 +232,10 @@ void MathMacro::write(WriteStream & os) const if (nargs() == 0) os << ' '; } + + +void MathMacro::updateExpansion() const +{ + expanded_ = tmplate_->xcell(0); + expanded_.data_.substitute(*this); +} diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 5c5f4bc60e..4847d358a6 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -86,6 +86,8 @@ private: bool editing() const; /// bool defining() const; + /// + void updateExpansion() const; /// MathAtom & tmplate_; diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 2b70aaa9e6..a07cdb623e 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -55,6 +55,7 @@ void MathMacroTable::create(string const & name, int na, string const & text) } + void MathMacroTable::create(string const & name, int na, MathArray const & ar) { MathAtom t(new MathMacroTemplate(name, na)); diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index a12714b488..3fe31bc7b7 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -16,10 +16,9 @@ MathMacroTemplate::MathMacroTemplate() MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs) : MathNestInset(1), numargs_(numargs), name_(nm) { - if (numargs_ > 9) { + if (numargs_ > 9) lyxerr << "MathMacroTemplate::MathMacroTemplate: wrong # of arguments: " << numargs_ << std::endl; - } } diff --git a/src/mathed/math_mathmlstream.h b/src/mathed/math_mathmlstream.h index 7078efd82a..4efd2c95e8 100644 --- a/src/mathed/math_mathmlstream.h +++ b/src/mathed/math_mathmlstream.h @@ -193,5 +193,4 @@ WriteStream & operator<<(WriteStream &, int); /// WriteStream & operator<<(WriteStream &, unsigned int); - #endif -- 2.39.2