From d6f2a2313ab2e58a0c9dcf5de88e8ad89732560e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 9 Aug 2001 15:19:31 +0000 Subject: [PATCH] fix broken ^ stuff; break delimiters... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2466 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/Makefile.am | 2 + src/mathed/README | 2 +- src/mathed/formulabase.C | 54 +++------- src/mathed/math_bigopinset.C | 15 +-- src/mathed/math_bigopinset.h | 3 - src/mathed/math_cursor.C | 8 +- src/mathed/math_cursor.h | 3 +- src/mathed/math_decorationinset.C | 2 +- src/mathed/math_deliminset.C | 55 +++++----- src/mathed/math_deliminset.h | 18 +++- src/mathed/math_dotsinset.C | 4 +- src/mathed/math_hash.C | 161 +++++++++++++++--------------- src/mathed/math_macrotable.C | 30 +----- src/mathed/math_noglyphinset.C | 44 ++++++++ src/mathed/math_noglyphinset.h | 31 ++++++ src/mathed/math_parser.C | 66 +++++++----- src/mathed/math_parser.h | 4 + src/mathed/math_symbolinset.C | 14 +-- src/mathed/math_symbolinset.h | 3 - src/mathed/support.C | 37 +++---- src/mathed/support.h | 5 +- src/mathed/symbol_def.h | 89 ++--------------- 22 files changed, 307 insertions(+), 343 deletions(-) create mode 100644 src/mathed/math_noglyphinset.C create mode 100644 src/mathed/math_noglyphinset.h diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index fada409d2e..7022a48748 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -62,6 +62,8 @@ libmathed_la_SOURCES = \ math_matrixinset.h \ math_nestinset.C \ math_nestinset.h \ + math_noglyphinset.C \ + math_noglyphinset.h \ math_parser.C \ math_parser.h \ math_rootinset.C \ diff --git a/src/mathed/README b/src/mathed/README index 8f6b5afe6d..caf9498e1e 100644 --- a/src/mathed/README +++ b/src/mathed/README @@ -16,7 +16,7 @@ Inset hierarchy: / \ - Nest Dots Func Space Symbol + Nest Dots Func Space Symbol Bigop Noglyph (for thing with nested content) diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index d871cef4d3..be8dbaa617 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -74,17 +74,13 @@ void handleFont(BufferView * bv, MathTextCodes t) mathcursor->handleFont(t); } + void handleAccent(BufferView * bv, string const & name) { bv->lockedInsetStoreUndo(Undo::EDIT); mathcursor->handleAccent(name); } -void handleDelim(BufferView * bv, int l, int r) -{ - bv->lockedInsetStoreUndo(Undo::EDIT); - mathcursor->handleDelim(l, r); -} bool openNewInset(BufferView * bv, UpdatableInset * new_inset) { @@ -590,45 +586,19 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_MATH_DELIM: { bv->lockedInsetStoreUndo(Undo::INSERT); - static const string vdelim("(){}[]./|"); //lyxerr << "formulabase::LFUN_MATH_DELIM, arg: '" << arg << "'\n"; - - if (arg.empty()) - break; - - // try to read integers first - int ilt = '('; - int irt = '.'; + string ls; + string rs; istringstream is(arg.c_str()); - is >> ilt >> irt; - - if (!is) { // ok, the beasties are no integers... try something else - ilt = '('; - irt = '.'; - - istringstream is(arg.c_str()); - string lt; - string rt; - is >> lt >> rt; - //lyxerr << "formulabase::LFUN_MATH_DELIM, lt: '" << lt << "'\n"; - //lyxerr << "formulabase::LFUN_MATH_DELIM, rt: '" << rt << "'\n"; - - if (lt.size() > 1) { - latexkeys const * l = in_word_set(lt); - if (l) - ilt = l->id; - } else if (vdelim.find(lt[0]) != string::npos) - ilt = lt[0]; - - if (rt.size() > 1) { - latexkeys const * l = in_word_set(rt); - if (l) - irt = l->id; - } else if (vdelim.find(rt[0]) != string::npos) - irt = rt[0]; + is >> ls >> rs; + latexkeys const * l = in_word_set(ls); + latexkeys const * r = in_word_set(rs); + if (!is || !l || !r) { + lyxerr << "can't parse delimeters from '" << arg << "'\n"; + break; } - - handleDelim(bv, ilt, irt); + bv->lockedInsetStoreUndo(Undo::EDIT); + mathcursor->handleDelim(l, r); updateLocal(bv, true); break; } @@ -804,7 +774,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, if (code != LM_TC_TEXTRM) code = LM_TC_BOP; mathcursor->insert(c, code); - } else if (strchr("#$%^{|}", c)) { + } else if (strchr("#$%{|}", c)) { MathTextCodes code = mathcursor->getLastCode(); if (code != LM_TC_TEXTRM) code = LM_TC_SPECIAL; diff --git a/src/mathed/math_bigopinset.C b/src/mathed/math_bigopinset.C index 5426095297..e71494399f 100644 --- a/src/mathed/math_bigopinset.C +++ b/src/mathed/math_bigopinset.C @@ -32,17 +32,7 @@ void MathBigopInset::writeNormal(ostream & os) const void MathBigopInset::metrics(MathStyles st) const { size_ = st; - - if (sym_->id > 0 && sym_->id < 256) { - ssym_ = string(); - ssym_ += sym_->id; - code_ = (sym_->token == LM_TK_BIGSYM) ? LM_TC_BSYM : LM_TC_SYMB; - } else { - ssym_ = sym_->name; - code_ = LM_TC_TEXTRM; - } - - mathed_string_dim(code_, size(), ssym_, ascent_, descent_, width_); + mathed_char_dim(LM_TC_BSYM, st, sym_->id, ascent_, descent_, width_); } @@ -50,6 +40,5 @@ void MathBigopInset::draw(Painter & pain, int x, int y) const { xo(x); yo(y); - - drawStr(pain, code_, size_, x, y, ssym_); + drawChar(pain, LM_TC_BSYM, size_, x, y, sym_->id); } diff --git a/src/mathed/math_bigopinset.h b/src/mathed/math_bigopinset.h index 896c1969f6..66f30e2c57 100644 --- a/src/mathed/math_bigopinset.h +++ b/src/mathed/math_bigopinset.h @@ -6,7 +6,6 @@ // larger in displayed formulae and take limits #include "math_diminset.h" -#include "LString.h" struct latexkeys; @@ -31,7 +30,5 @@ public: private: /// latexkeys const * sym_; - /// - mutable string ssym_; }; #endif diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 6f3562a52c..61889f7569 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -45,6 +45,7 @@ #include "math_macrotable.h" #include "math_macrotemplate.h" #include "math_matrixinset.h" +#include "math_noglyphinset.h" #include "math_rootinset.h" #include "math_spaceinset.h" #include "math_sqrtinset.h" @@ -675,6 +676,11 @@ void MathCursor::interpret(string const & s) p = new MathFuncInset(s); } else { switch (l->token) { + case LM_TK_NOGLYPH: + case LM_TK_NOGLYPHB: + p = new MathNoglyphInset(l); + break; + case LM_TK_BIGSYM: p = new MathBigopInset(l); break; @@ -897,7 +903,7 @@ void MathCursor::handleAccent(string const & name) } -void MathCursor::handleDelim(int l, int r) +void MathCursor::handleDelim(latexkeys const * l, latexkeys const * r) { handleNest(new MathDelimInset(l, r)); } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 3bdc37080f..836c43ee00 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -33,6 +33,7 @@ class InsetFormulaBase; class MathArray; class MathXArray; class Painter; +class latexkeys; /// Description of a position struct MathCursorPos { @@ -171,7 +172,7 @@ public: /// void handleAccent(string const & name); /// - void handleDelim(int l, int r); + void handleDelim(latexkeys const * l, latexkeys const * r); /// void handleNest(MathInset * p); /// Splits cells and shifts right part to the next cell diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index aec0bb25f2..469a288837 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -56,7 +56,7 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const xo(x); yo(x); xcell(0).draw(pain, x, y); - mathed_draw_deco(pain, x, y + dy_, width_, dh_, key_->id); + mathed_draw_deco(pain, x, y + dy_, width_, dh_, key_); } diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 5e2d30bf35..f5cbc7b2f4 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -9,7 +9,7 @@ #include "support/LOstream.h" -MathDelimInset::MathDelimInset(int l, int r) +MathDelimInset::MathDelimInset(latexkeys const * l, latexkeys const * r) : MathNestInset(1), left_(l), right_(r) {} @@ -20,34 +20,33 @@ MathInset * MathDelimInset::clone() const } +string MathDelimInset::latexName(latexkeys const * l) +{ + //static const string vdelim("(){}[]./|"); + string name = l->name; + if (name == "(") + return name; + if (name == "[") + return name; + if (name == ".") + return name; + if (name == ")") + return name; + if (name == "]") + return name; + if (name == "/") + return name; + if (name == "|") + return name; + return "\\" + name + " "; +} + + void MathDelimInset::write(std::ostream & os, bool fragile) const { - latexkeys const * l = (left_ != '|') ? - lm_get_key_by_id(left_, LM_TK_SYM) : 0; - latexkeys const * r = (right_ != '|') ? - lm_get_key_by_id(right_, LM_TK_SYM) : 0; - - os << "\\left"; - if (l) - os << '\\' << l->name << ' '; - else { - if (left_ == '{' || left_ == '}') - os << '\\' << char(left_) << ' '; - else - os << char(left_) << ' '; - } - + os << "\\left" << latexName(left_); cell(0).write(os, fragile); - - os << "\\right"; - if (r) - os << '\\' << r->name << ' '; - else { - if (right_ == '{' || right_ == '}') - os << '\\' << char(right_) << ' '; - else - os << char(right_) << ' '; - } + os << "\\right" << latexName(right_); } @@ -59,7 +58,7 @@ void MathDelimInset::draw(Painter & pain, int x, int y) const int w = dw(); xcell(0).draw(pain, x + w, y); - if (left_ == '.') { + if (latexName(left_) == ".") { pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_, LColor::mathcursor, Painter::line_onoffdash); } else @@ -67,7 +66,7 @@ void MathDelimInset::draw(Painter & pain, int x, int y) const x += width() - w - 2; - if (right_ == '.') { + if (latexName(right_) == ".") { pain.line(x + 4, yo() - ascent_, x + 4, yo() + descent_, LColor::mathcursor, Painter::line_onoffdash); } else diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index 712148bb84..af60d64837 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -3,6 +3,7 @@ #define MATH_DELIMINSET_H #include "math_nestinset.h" +#include "LString.h" #ifdef __GNUG__ #pragma interface @@ -11,10 +12,18 @@ /** A delimiter \author Alejandro Aguilar Sierra */ + +class latexkeys; + class MathDelimInset : public MathNestInset { public: /// - MathDelimInset(int, int); + MathDelimInset(latexkeys const *, latexkeys const *); + +#warning Remove this ass soon the Math panel patch is applied + /// + ///MathDelimInset(int, int) : MathNestInset(2) {} + /// MathInset * clone() const; /// @@ -24,10 +33,13 @@ public: /// void metrics(MathStyles st) const; private: + /// + static string latexName(latexkeys const *); + /// int dw() const; /// - int left_; + latexkeys const * left_; /// - int right_; + latexkeys const * right_; }; #endif diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index 1391970bc0..04478bd0ed 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -23,12 +23,12 @@ MathInset * MathDotsInset::clone() const void MathDotsInset::draw(Painter & pain, int x, int y) const { - mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, key_->id); + mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, key_); if (key_->id == LM_vdots || key_->id == LM_ddots) ++x; if (key_->id != LM_vdots) --y; - mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, key_->id); + mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, key_); } diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 325984df69..d011174516 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -24,6 +24,7 @@ latexkeys const wordlist[] = {"(", LM_TK_BEGIN, LM_OT_SIMPLE, LMB_NONE}, {")", LM_TK_END, LM_OT_SIMPLE, LMB_NONE}, {",", LM_TK_SPACE, 1, LMB_NONE}, + {".", LM_TK_SPECIAL, '.', LMB_NONE}, {":", LM_TK_SPACE, 2, LMB_NONE}, {";", LM_TK_SPACE, 3, LMB_NONE}, {"Delta", LM_TK_SYM, LM_Delta, LMB_NONE}, @@ -33,9 +34,9 @@ latexkeys const wordlist[] = {"Lambda", LM_TK_SYM, LM_Lambda, LMB_NONE}, {"Leftarrow", LM_TK_SYM, LM_Leftarrow, LMB_NONE}, {"Leftrightarrow", LM_TK_SYM, LM_Leftrightarrow, LMB_NONE}, - {"Longleftarrow", LM_TK_SYM, LM_Longleftarrow, LMB_NONE}, - {"Longleftrightarrow", LM_TK_SYM, LM_Longleftrightarrow, LMB_NONE}, - {"Longrightarrow", LM_TK_SYM, LM_Longrightarrow, LMB_NONE}, + {"Longleftarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"Longleftrightarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"Longrightarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, {"Omega", LM_TK_SYM, LM_Omega, LMB_NONE}, {"Phi", LM_TK_SYM, LM_Phi, LMB_NONE}, {"Pi", LM_TK_SYM, LM_Pi, LMB_NONE}, @@ -46,9 +47,9 @@ latexkeys const wordlist[] = {"Sigma", LM_TK_SYM, LM_Sigma, LMB_NONE}, {"Theta", LM_TK_SYM, LM_Theta, LMB_NONE}, {"Uparrow", LM_TK_SYM, LM_Uparrow, LMB_NONE}, - {"Updownarrow", LM_TK_SYM, LM_Updownarrow, LMB_NONE}, + {"Updownarrow", LM_TK_NOGLYPH, LM_Updownarrow, LMB_NONE}, {"Upsilon", LM_TK_SYM, LM_Upsilon, LMB_NONE}, - {"Vert", LM_TK_SYM, LM_Vert, LMB_NONE}, + {"Vert", LM_TK_NOGLYPH, LM_Vert, LMB_NONE}, {"Xi", LM_TK_SYM, LM_Xi, LMB_NONE}, {"[", LM_TK_BEGIN, LM_OT_EQUATION, LMB_NONE}, {"\\", LM_TK_NEWLINE, static_cast(-1), LMB_NONE}, @@ -57,33 +58,33 @@ latexkeys const wordlist[] = {"acute", LM_TK_DECORATION, LM_acute, LMB_NONE}, {"aleph", LM_TK_SYM, LM_aleph, LMB_NONE}, {"alpha", LM_TK_SYM, LM_alpha, LMB_NONE}, - {"amalg", LM_TK_SYM, LM_amalg, LMB_OPERATOR}, + {"amalg", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"angle", LM_TK_SYM, LM_angle, LMB_NONE}, {"approx", LM_TK_SYM, LM_approx, LMB_RELATION}, {"arccos", LM_TK_FUNC, 0, LMB_NONE}, {"arcsin", LM_TK_FUNC, 0, LMB_NONE}, {"arctan", LM_TK_FUNC, 0, LMB_NONE}, {"arg", LM_TK_FUNC, 0, LMB_NONE}, - {"asymp", LM_TK_SYM, LM_asymp, LMB_RELATION}, - {"backslash", LM_TK_SYM, LM_backslash, LMB_NONE}, + {"asymp", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"backslash", LM_TK_SPECIAL, '\\', LMB_NONE}, {"bar", LM_TK_DECORATION, LM_bar, LMB_NONE}, {"begin", LM_TK_BEGIN, 0, LMB_NONE}, {"beta", LM_TK_SYM, LM_beta, LMB_NONE}, - {"bigcap", LM_TK_BIGSYM, LM_cap, LMB_NONE}, - {"bigcirc", LM_TK_SYM, LM_bigcirc, LMB_OPERATOR}, - {"bigcup", LM_TK_BIGSYM, LM_cup, LMB_NONE}, - {"bigodot", LM_TK_BIGSYM, LM_bigodot, LMB_NONE}, - {"bigoplus", LM_TK_BIGSYM, LM_oplus, LMB_NONE}, - {"bigotimes", LM_TK_BIGSYM, LM_otimes, LMB_NONE}, - {"bigsqcup", LM_TK_BIGSYM, LM_bigsqcup, LMB_NONE}, - {"bigtriangledown", LM_TK_SYM, LM_bigtriangledown, LMB_OPERATOR}, - {"bigtriangleup", LM_TK_SYM, LM_bigtriangleup, LMB_OPERATOR}, - {"biguplus", LM_TK_BIGSYM, LM_biguplus, LMB_NONE}, - {"bigvee", LM_TK_BIGSYM, LM_vee, LMB_NONE}, - {"bigwedge", LM_TK_BIGSYM, LM_wedge, LMB_NONE}, + {"bigcap", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigcirc", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, + {"bigcup", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigodot", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigoplus", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigotimes", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigsqcup", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigtriangledown", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, + {"bigtriangleup", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, + {"biguplus", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigvee", LM_TK_NOGLYPHB, 0, LMB_NONE}, + {"bigwedge", LM_TK_NOGLYPHB, 0, LMB_NONE}, {"bmod", LM_TK_FUNC, 0, LMB_NONE}, {"bot", LM_TK_SYM, LM_bot, LMB_NONE}, - {"bowtie", LM_TK_SYM, LM_bowtie, LMB_RELATION}, + {"bowtie", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"breve", LM_TK_DECORATION, LM_breve, LMB_NONE}, {"bullet", LM_TK_SYM, LM_bullet, LMB_OPERATOR}, {"cap", LM_TK_SYM, LM_cap, LMB_OPERATOR}, @@ -91,19 +92,19 @@ latexkeys const wordlist[] = {"cdots", LM_TK_DOTS, LM_cdots, LMB_NONE}, {"check", LM_TK_DECORATION, LM_check, LMB_NONE}, {"chi", LM_TK_SYM, LM_chi, LMB_NONE}, - {"circ", LM_TK_SYM, LM_circ, LMB_OPERATOR}, + {"circ", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"clubsuit", LM_TK_SYM, LM_clubsuit, LMB_NONE}, {"cong", LM_TK_SYM, LM_cong, LMB_RELATION}, - {"coprod", LM_TK_BIGSYM, LM_coprod, LMB_NONE}, + {"coprod", LM_TK_NOGLYPHB, 0, LMB_NONE}, {"cos", LM_TK_FUNC, 0, LMB_NONE}, {"cosh", LM_TK_FUNC, 0, LMB_NONE}, {"cot", LM_TK_FUNC, 0, LMB_NONE}, {"coth", LM_TK_FUNC, 0, LMB_NONE}, {"csc", LM_TK_FUNC, 0, LMB_NONE}, {"cup", LM_TK_SYM, LM_cup, LMB_OPERATOR}, - {"dagger", LM_TK_SYM, LM_dagger, LMB_OPERATOR}, - {"dashv", LM_TK_SYM, LM_dashv, LMB_RELATION}, - {"ddagger", LM_TK_SYM, LM_ddagger, LMB_OPERATOR}, + {"dagger", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, + {"dashv", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"ddagger", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"ddot", LM_TK_DECORATION, LM_ddot, LMB_NONE}, {"ddots", LM_TK_DOTS, LM_ddots, LMB_NONE}, {"deg", LM_TK_FUNC, 0, LMB_NONE}, @@ -114,38 +115,38 @@ latexkeys const wordlist[] = {"dim", LM_TK_FUNC, 0, LMB_NONE}, {"div", LM_TK_SYM, LM_div, LMB_OPERATOR}, {"dot", LM_TK_DECORATION, LM_dot, LMB_NONE}, - {"doteq", LM_TK_SYM, LM_doteq, LMB_RELATION}, + {"doteq", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"downarrow", LM_TK_SYM, LM_downarrow, LMB_NONE}, - {"ell", LM_TK_SYM, LM_ell, LMB_NONE}, + {"ell", LM_TK_NOGLYPH, 0, LMB_NONE}, {"emptyset", LM_TK_MACRO, LM_emptyset, LMB_NONE}, {"end", LM_TK_END, 0, LMB_NONE}, - {"epsilon", LM_TK_SYM, LM_epsilon, LMB_NONE}, + {"epsilon", LM_TK_NOGLYPH, 0, LMB_NONE}, {"equiv", LM_TK_SYM, LM_equiv, LMB_RELATION}, {"eta", LM_TK_SYM, LM_eta, LMB_NONE}, {"exists", LM_TK_SYM, LM_exists, LMB_NONE}, {"exp", LM_TK_FUNC, 0, LMB_NONE}, - {"flat", LM_TK_SYM, LM_flat, LMB_NONE}, + {"flat", LM_TK_NOGLYPH, 0, LMB_NONE}, {"forall", LM_TK_SYM, LM_forall, LMB_NONE}, {"frac", LM_TK_FRAC, 0, LMB_NONE}, - {"frown", LM_TK_SYM, LM_frown, LMB_RELATION}, + {"frown", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"gamma", LM_TK_SYM, LM_gamma, LMB_NONE}, {"gcd", LM_TK_FUNCLIM, 0, LMB_NONE}, {"geq", LM_TK_SYM, LM_geq, LMB_RELATION}, - {"gg", LM_TK_SYM, LM_gg, LMB_RELATION}, + {"gg", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"grave", LM_TK_DECORATION, LM_grave, LMB_NONE}, {"hat", LM_TK_DECORATION, LM_hat, LMB_NONE}, - {"hbar", LM_TK_SYM, LM_hbar, LMB_NONE}, + {"hbar", LM_TK_NOGLYPH, 0, LMB_NONE}, {"heartsuit", LM_TK_SYM, LM_heartsuit, LMB_NONE}, {"hom", LM_TK_FUNC, 0, LMB_NONE}, - {"hookleftarrow", LM_TK_SYM, LM_hookleftarrow, LMB_NONE}, - {"hookrightarrow", LM_TK_SYM, LM_hookrightarrow, LMB_NONE}, - {"imath", LM_TK_SYM, LM_imath, LMB_NONE}, + {"hookleftarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"hookrightarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"imath", LM_TK_NOGLYPH, 0, LMB_NONE}, {"in", LM_TK_SYM, LM_in, LMB_RELATION}, {"inf", LM_TK_FUNCLIM, 0, LMB_NONE}, {"infty", LM_TK_SYM, LM_infty, LMB_NONE}, {"int", LM_TK_BIGSYM, LM_int, LMB_NONE}, {"iota", LM_TK_SYM, LM_iota, LMB_NONE}, - {"jmath", LM_TK_SYM, LM_jmath, LMB_NONE}, + {"jmath", LM_TK_NOGLYPH, 0, LMB_NONE}, {"kappa", LM_TK_SYM, LM_kappa, LMB_NONE}, {"ker", LM_TK_FUNC, 0, LMB_NONE}, {"label", LM_TK_LABEL, 0, LMB_NONE}, @@ -155,8 +156,8 @@ latexkeys const wordlist[] = {"ldots", LM_TK_DOTS, LM_ldots, LMB_NONE}, {"left", LM_TK_LEFT, 0, LMB_NONE}, {"leftarrow", LM_TK_SYM, LM_leftarrow, LMB_NONE}, - {"leftharpoondown", LM_TK_SYM, LM_leftharpoondown, LMB_NONE}, - {"leftharpoonup", LM_TK_SYM, LM_leftharpoonup, LMB_NONE}, + {"leftharpoondown", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"leftharpoonup", LM_TK_NOGLYPH, 0, LMB_NONE}, {"leftrightarrow", LM_TK_SYM, LM_leftrightarrow, LMB_NONE}, {"leq", LM_TK_SYM, LM_leq, LMB_RELATION}, {"lfloor", LM_TK_SYM, LM_lfloor, LMB_NONE}, @@ -165,14 +166,14 @@ latexkeys const wordlist[] = {"liminf", LM_TK_FUNCLIM, 0, LMB_NONE}, {"limits", LM_TK_LIMIT, 1 , LMB_NONE}, {"limsup", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"ll", LM_TK_SYM, LM_ll, LMB_RELATION}, + {"ll", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"ln", LM_TK_FUNC, 0, LMB_NONE}, {"log", LM_TK_FUNC, 0, LMB_NONE}, - {"longleftarrow", LM_TK_SYM, LM_longleftarrow, LMB_NONE}, - {"longleftrightarrow", LM_TK_SYM, LM_longleftrightarrow, LMB_NONE}, - {"longmapsto", LM_TK_SYM, LM_longmapsto, LMB_NONE}, - {"longrightarrow", LM_TK_SYM, LM_longrightarrow, LMB_NONE}, - {"mapsto", LM_TK_SYM, LM_mapsto, LMB_NONE}, + {"longleftarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"longleftrightarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"longmapsto", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"longrightarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"mapsto", LM_TK_NOGLYPH, 0, LMB_NONE}, {"mathbf", LM_TK_FONT, LM_TC_BF, LMB_NONE}, {"mathcal", LM_TK_FONT, LM_TC_CAL, LMB_NONE}, {"mathit", LM_TK_FONT, LM_TC_IT, LMB_NONE}, @@ -183,25 +184,25 @@ latexkeys const wordlist[] = {"max", LM_TK_FUNCLIM, 0, LMB_NONE}, {"mid", LM_TK_SYM, LM_mid, LMB_RELATION}, {"min", LM_TK_FUNCLIM, 0, LMB_NONE}, - {"models", LM_TK_SYM, LM_models, LMB_RELATION}, - {"mp", LM_TK_SYM, LM_mp, LMB_OPERATOR}, + {"models", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"mp", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"mu", LM_TK_SYM, LM_mu, LMB_NONE}, {"nabla", LM_TK_SYM, LM_nabla, LMB_NONE}, - {"natural", LM_TK_SYM, LM_natural, LMB_NONE}, - {"nearrow", LM_TK_SYM, LM_nearrow, LMB_NONE}, + {"natural", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"nearrow", LM_TK_NOGLYPH, 0, LMB_NONE}, {"neg", LM_TK_SYM, LM_neg, LMB_NONE}, {"neq", LM_TK_SYM, LM_neq, LMB_RELATION}, {"newcommand", LM_TK_NEWCOMMAND, 0 , LMB_NONE}, - {"ni", LM_TK_SYM, LM_ni, LMB_RELATION}, + {"ni", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"nolimits", LM_TK_LIMIT, static_cast(-1), LMB_NONE}, {"nonumber", LM_TK_NONUM, 0, LMB_NONE}, {"not", LM_TK_DECORATION, LM_not, LMB_NONE}, {"notin", LM_TK_MACRO, LM_notin, LMB_RELATION}, {"nu", LM_TK_SYM, LM_nu, LMB_NONE}, - {"nwarrow", LM_TK_SYM, LM_nwarrow, LMB_NONE}, - {"odot", LM_TK_SYM, LM_odot, LMB_OPERATOR}, + {"nwarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"odot", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"omega", LM_TK_SYM, LM_omega, LMB_NONE}, - {"ominus", LM_TK_SYM, LM_ominus, LMB_OPERATOR}, + {"ominus", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"oplus", LM_TK_SYM, LM_oplus, LMB_OPERATOR}, {"oslash", LM_TK_SYM, LM_oslash, LMB_OPERATOR}, {"otimes", LM_TK_SYM, LM_otimes, LMB_OPERATOR}, @@ -209,14 +210,14 @@ latexkeys const wordlist[] = {"overleftarrow", LM_TK_DECORATION, LM_overleftarrow, LMB_NONE}, {"overline", LM_TK_DECORATION, LM_overline, LMB_NONE}, {"overrightarrow", LM_TK_DECORATION, LM_overightarrow, LMB_NONE}, - {"parallel", LM_TK_SYM, LM_parallel, LMB_RELATION}, + {"parallel", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"partial", LM_TK_SYM, LM_partial, LMB_NONE}, {"perp", LM_TK_MACRO, LM_perp, LMB_RELATION}, {"phi", LM_TK_SYM, LM_phi, LMB_NONE}, {"pi", LM_TK_SYM, LM_pi, LMB_NONE}, {"pm", LM_TK_SYM, LM_pm, LMB_OPERATOR}, - {"prec", LM_TK_SYM, LM_prec, LMB_RELATION}, - {"preceq", LM_TK_SYM, LM_preceq, LMB_RELATION}, + {"prec", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"preceq", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"prime", LM_TK_SYM, LM_prime, LMB_NONE}, {"prod", LM_TK_BIGSYM, LM_prod, LMB_NONE}, {"propto", LM_TK_SYM, LM_propto, LMB_RELATION}, @@ -230,37 +231,37 @@ latexkeys const wordlist[] = {"rho", LM_TK_SYM, LM_rho, LMB_NONE}, {"right", LM_TK_RIGHT, 0, LMB_NONE}, {"rightarrow", LM_TK_SYM, LM_rightarrow, LMB_NONE}, - {"rightharpoondown", LM_TK_SYM, LM_rightharpoondown, LMB_NONE}, - {"rightharpoonup", LM_TK_SYM, LM_rightharpoonup, LMB_NONE}, - {"rightleftharpoons", LM_TK_SYM, LM_rightleftharpoons, LMB_NONE}, - {"searrow", LM_TK_SYM, LM_searrow, LMB_NONE}, + {"rightharpoondown", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"rightharpoonup", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"rightleftharpoons", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"searrow", LM_TK_NOGLYPH, 0, LMB_NONE}, {"sec", LM_TK_FUNC, 0, LMB_NONE}, - {"setminus", LM_TK_SYM, LM_setminus, LMB_OPERATOR}, + {"setminus", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"sharp", LM_TK_SYM, LM_sharp, LMB_NONE}, {"sigma", LM_TK_SYM, LM_sigma, LMB_NONE}, - {"sim", LM_TK_SYM, LM_sim, LMB_RELATION}, - {"simeq", LM_TK_SYM, LM_simeq, LMB_RELATION}, + {"sim", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"simeq", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"sin", LM_TK_FUNC, 0, LMB_NONE}, {"sinh", LM_TK_FUNC, 0, LMB_NONE}, - {"smile", LM_TK_SYM, LM_smile, LMB_RELATION}, + {"smile", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"spadesuit", LM_TK_SYM, LM_spadesuit, LMB_NONE}, - {"sqcap", LM_TK_SYM, LM_sqcap, LMB_OPERATOR}, - {"sqcup", LM_TK_SYM, LM_sqcup, LMB_OPERATOR}, + {"sqcap", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, + {"sqcup", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"sqrt", LM_TK_SQRT, 0, LMB_NONE}, - {"sqsubseteq", LM_TK_SYM, LM_sqsubseteq, LMB_RELATION}, - {"sqsupseteq", LM_TK_SYM, LM_sqsupseteq, LMB_RELATION}, + {"sqsubseteq", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"sqsupseteq", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"stackrel", LM_TK_STACK, 0, LMB_NONE}, - {"star", LM_TK_SYM, LM_star, LMB_OPERATOR}, + {"star", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"subset", LM_TK_SYM, LM_subset, LMB_RELATION}, {"subseteq", LM_TK_SYM, LM_subseteq, LMB_RELATION}, - {"succ", LM_TK_SYM, LM_succ, LMB_RELATION}, - {"succeq", LM_TK_SYM, LM_succeq, LMB_RELATION}, + {"succ", LM_TK_NOGLYPH, 0, LMB_RELATION}, + {"succeq", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"sum", LM_TK_BIGSYM, LM_sum, LMB_NONE}, {"sup", LM_TK_FUNCLIM, 0, LMB_NONE}, {"supset", LM_TK_SYM, LM_supset, LMB_RELATION}, {"supseteq", LM_TK_SYM, LM_supseteq, LMB_RELATION}, {"surd", LM_TK_SYM, LM_surd, LMB_NONE}, - {"swarrow", LM_TK_SYM, LM_swarrow, LMB_NONE}, + {"swarrow", LM_TK_NOGLYPH, 0, LMB_NONE}, {"tan", LM_TK_FUNC, 0, LMB_NONE}, {"tanh", LM_TK_FUNC, 0, LMB_NONE}, {"tau", LM_TK_SYM, LM_tau, LMB_NONE}, @@ -268,22 +269,22 @@ latexkeys const wordlist[] = {"theta", LM_TK_SYM, LM_theta, LMB_NONE}, {"tilde", LM_TK_DECORATION, LM_tilde, LMB_NONE}, {"times", LM_TK_SYM, LM_times, LMB_OPERATOR}, - {"top", LM_TK_SYM, LM_top, LMB_NONE}, - {"triangle", LM_TK_SYM, LM_triangle, LMB_NONE}, - {"triangleleft", LM_TK_SYM, LM_triangleleft, LMB_OPERATOR}, - {"triangleright", LM_TK_SYM, LM_triangleright, LMB_OPERATOR}, + {"top", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"triangle", LM_TK_NOGLYPH, 0, LMB_NONE}, + {"triangleleft", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, + {"triangleright", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"underbrace", LM_TK_DECORATION, LM_underbrace, LMB_NONE}, {"underline", LM_TK_DECORATION, LM_underline, LMB_NONE}, {"uparrow", LM_TK_SYM, LM_uparrow, LMB_NONE}, - {"updownarrow", LM_TK_SYM, LM_updownarrow, LMB_NONE}, - {"uplus", LM_TK_SYM, LM_uplus, LMB_OPERATOR}, + {"updownarrow", LM_TK_NOGLYPH, LM_updownarrow, LMB_NONE}, + {"uplus", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"upsilon", LM_TK_SYM, LM_upsilon, LMB_NONE}, {"varepsilon", LM_TK_SYM, LM_varepsilon, LMB_NONE}, {"varphi", LM_TK_SYM, LM_varphi, LMB_NONE}, {"varpi", LM_TK_SYM, LM_varpi, LMB_NONE}, {"varsigma", LM_TK_SYM, LM_varsigma, LMB_NONE}, {"vartheta", LM_TK_SYM, LM_vartheta, LMB_NONE}, - {"vdash", LM_TK_SYM, LM_vdash, LMB_RELATION}, + {"vdash", LM_TK_NOGLYPH, 0, LMB_RELATION}, {"vdots", LM_TK_DOTS, LM_vdots, LMB_NONE}, {"vec", LM_TK_DECORATION, LM_vec, LMB_NONE}, {"vee", LM_TK_SYM, LM_vee, LMB_OPERATOR}, @@ -291,7 +292,7 @@ latexkeys const wordlist[] = {"widehat", LM_TK_DECORATION, LM_widehat, LMB_NONE}, {"widetilde", LM_TK_DECORATION, LM_widetilde, LMB_NONE}, {"wp", LM_TK_SYM, LM_wp, LMB_NONE}, - {"wr", LM_TK_SYM, LM_wr, LMB_OPERATOR}, + {"wr", LM_TK_NOGLYPH, 0, LMB_OPERATOR}, {"xi", LM_TK_SYM, LM_xi, LMB_NONE}, {"zeta", LM_TK_SYM, LM_zeta, LMB_NONE}, {"{", LM_TK_SPECIAL, '{', LMB_NONE}, diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index 72a83a633f..c50033d581 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -10,7 +10,6 @@ #include "math_macro.h" #include "math_macrotemplate.h" #include "math_parser.h" -#include "math_deliminset.h" #include "math_fracinset.h" #include "debug.h" @@ -98,32 +97,5 @@ void MathMacroTable::builtinMacros() createTemplate("to", 0, "\\rightarrow"); //createTemplate("lint", 4, "\\int_{#1}^{#2}#3 d#4"); //createTemplate("silentmult", 0, "\\cdot"); - //createTemplate("binomi", 2, "\\left(\\frac{#1}{#2}\\right)"); - - // binom has two arguments - { - MathFracInset * frac = new MathFracInset; - frac->cell(0).push_back(new MathMacroArgument(1)); - frac->cell(1).push_back(new MathMacroArgument(2)); - - MathInset * inset = new MathDelimInset('(', ')'); - inset->push_back(frac); - - MathMacroTemplate t("binom", 2); - t.push_back(inset); - insertTemplate(t); - } - -/* - { - MathFracInset * frac = new MathFracInset(LM_OT_ATOP); - frac->cell(0)->push_back(new MathMacroArgument(1)); - frac->cell(1)->push_back(new MathMacroArgument(2)); - - MathMacroTemplate * t = new MathMacroTemplate("choose", 2); - t->push_back(frac); - - insertTemplate(t); - } -*/ + createTemplate("binom", 2, "\\left(\\frac{#1}{#2}\\right)"); } diff --git a/src/mathed/math_noglyphinset.C b/src/mathed/math_noglyphinset.C new file mode 100644 index 0000000000..a62dc9477f --- /dev/null +++ b/src/mathed/math_noglyphinset.C @@ -0,0 +1,44 @@ +#include "math_noglyphinset.h" +#include "math_parser.h" +#include "support.h" +#include "support/LOstream.h" + + +using std::ostream; + +MathNoglyphInset::MathNoglyphInset(const latexkeys * l) + : sym_(l) +{} + + +MathInset * MathNoglyphInset::clone() const +{ + return new MathNoglyphInset(*this); +} + + +void MathNoglyphInset::write(ostream & os, bool /* fragile */) const +{ + os << '\\' << sym_->name << ' '; +} + + +void MathNoglyphInset::writeNormal(ostream & os) const +{ + os << "[bigop " << sym_->name << "] "; +} + + +void MathNoglyphInset::metrics(MathStyles st) const +{ + size(st); + mathed_string_dim(LM_TC_TEX, st, sym_->name, ascent_, descent_, width_); +} + + +void MathNoglyphInset::draw(Painter & pain, int x, int y) const +{ + xo(x); + yo(y); + drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name); +} diff --git a/src/mathed/math_noglyphinset.h b/src/mathed/math_noglyphinset.h new file mode 100644 index 0000000000..70ec34bef7 --- /dev/null +++ b/src/mathed/math_noglyphinset.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +#ifndef MATH_NOGLYPHINSET_H +#define MATH_NOGLYPHINSET_H + +#include "math_diminset.h" + +struct latexkeys; + +// "normal" symbols for which we don't have a glyph aailable to display +// them properly + +class MathNoglyphInset : public MathDimInset { +public: + /// + explicit MathNoglyphInset(latexkeys const *); + /// + MathInset * clone() const; + /// + void write(std::ostream &, bool fragile) const; + /// + void writeNormal(std::ostream &) const; + /// + void metrics(MathStyles st) const; + /// + void draw(Painter &, int x, int y) const; + +private: + /// + latexkeys const * sym_; +}; +#endif diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index ffa08802ac..2def6913c6 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -41,6 +41,7 @@ #include "math_macrotable.h" #include "math_macrotemplate.h" #include "math_matrixinset.h" +#include "math_noglyphinset.h" #include "math_rootinset.h" #include "math_scriptinset.h" #include "math_sizeinset.h" @@ -65,7 +66,6 @@ enum lexcode_enum { LexAlpha, LexDigit, LexBOP, // Binary operators or relations - LexMathSpace, LexOpen, LexClose, LexComment, @@ -112,7 +112,7 @@ enum { }; /// -union { +struct { /// int i; /// @@ -180,9 +180,6 @@ void lexInit() lexcode['+'] = lexcode['-'] = lexcode['*'] = lexcode['/'] = lexcode['<'] = lexcode['>'] = lexcode['='] = LexBOP; - lexcode['!'] = lexcode[','] = lexcode[':'] - = lexcode[';'] = LexMathSpace; - lexcode['('] = lexcode[')'] = lexcode['|'] = lexcode['.'] = lexcode['?'] = LexOther; @@ -257,9 +254,7 @@ int yylex() do { c = getuchar(yyis); } while (c != '\n' && yyis->good()); // eat comments - } else if (lexcode[c] == LexDigit - || lexcode[c] == LexOther - || lexcode[c] == LexMathSpace) { + } else if (lexcode[c] == LexDigit || lexcode[c] == LexOther) { yylval.i = c; return LM_TK_STR; } else if (lexcode[c] == LexAlpha || lexcode[c] == LexSpace) { @@ -283,12 +278,15 @@ int yylex() return LM_TK_CLOSE; } else if (lexcode[c] == LexESC) { c = getuchar(yyis); + //lyxerr << "reading second byte: '" << c << "' code: " << lexcode[c] << endl; string s; s += c; latexkeys const * l = in_word_set(s); if (l) { - //lyxerr << "found special token for '" << l->name - // << "' : " << l->id << " \n"; + //lyxerr << "found key: " << l << endl; + //lyxerr << "found key name: " << l->name << endl; + //lyxerr << "found key token: " << l->token << endl; + yylval.l = l; yylval.i = l->id; return l->token; } @@ -304,6 +302,7 @@ int yylex() yyis->putback(c); //lyxerr[Debug::MATHED] << "reading: text '" << yytext << "'\n"; + //lyxerr << "reading: text '" << yytext << "'\n"; latexkeys const * l = in_word_set(yytext); if (!l) return LM_TK_UNDEF; @@ -484,6 +483,30 @@ MathMatrixInset * mathed_parse_normal() } +latexkeys const * read_delim() +{ + int ld = yylex(); + lyxerr << "found symbol: " << ld << "\n"; + latexkeys const * l = in_word_set("."); + switch (ld) { + case LM_TK_SYM: + case LM_TK_NOGLYPH: + case LM_TK_SPECIAL: + case LM_TK_BEGIN: + l = yylval.l; + lyxerr << "found key 1: '" << l << "'\n"; + lyxerr << "found key 1: '" << l->name << "'\n"; + break; + case LM_TK_STR: + string s; + s += yylval.i; + l = in_word_set(s); + lyxerr << "found key 2: '" << l->name << "'\n"; + } + return l; +} + + void mathed_parse_into(MathArray & array, unsigned flags) { static int plevel = -1; @@ -620,6 +643,12 @@ void mathed_parse_into(MathArray & array, unsigned flags) case LM_TK_PROTECT: break; + case LM_TK_NOGLYPH: + case LM_TK_NOGLYPHB: + limits = 0; + array.push_back(new MathNoglyphInset(yylval.l)); + break; + case LM_TK_BIGSYM: limits = 0; array.push_back(new MathBigopInset(yylval.l)); @@ -683,22 +712,11 @@ void mathed_parse_into(MathArray & array, unsigned flags) case LM_TK_LEFT: { - int ld = yylex(); - if (ld == LM_TK_SYM) - ld = yylval.l->id; - else if (ld == LM_TK_STR || ld == LM_TK_BOP || ld == LM_TK_SPECIAL) - ld = yylval.i; - + latexkeys const * l = read_delim(); MathArray ar; mathed_parse_into(ar, FLAG_RIGHT); - - int rd = yylex(); - if (rd == LM_TK_SYM) - rd = yylval.l->id; - else if (rd == LM_TK_STR || rd == LM_TK_BOP || rd == LM_TK_SPECIAL) - rd = yylval.i; - - MathDelimInset * dl = new MathDelimInset(ld, rd); + latexkeys const * r = read_delim(); + MathDelimInset * dl = new MathDelimInset(l, r); dl->cell(0) = ar; array.push_back(dl); break; diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index 7ebf014707..1e9144a93a 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -71,6 +71,10 @@ enum MathTokenEnum /// LM_TK_BIGSYM, /// + LM_TK_NOGLYPH, + /// + LM_TK_NOGLYPHB, + /// LM_TK_LABEL, /// LM_TK_NONUM, diff --git a/src/mathed/math_symbolinset.C b/src/mathed/math_symbolinset.C index d93776f05a..1ca489bd5b 100644 --- a/src/mathed/math_symbolinset.C +++ b/src/mathed/math_symbolinset.C @@ -32,17 +32,7 @@ void MathSymbolInset::writeNormal(ostream & os) const void MathSymbolInset::metrics(MathStyles st) const { size(st); - - if (sym_->id > 0 && sym_->id < 256) { - ssym_ = string(); - ssym_ += sym_->id; - code_ = (sym_->token == LM_TK_BIGSYM) ? LM_TC_BSYM : LM_TC_SYMB; - } else { - ssym_ = sym_->name; - code_ = LM_TC_TEX; - } - - mathed_string_dim(code_, size(), ssym_, ascent_, descent_, width_); + mathed_char_dim(LM_TC_SYMB, size_, sym_->id, ascent_, descent_, width_); } @@ -51,7 +41,7 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const xo(x); yo(y); - drawStr(pain, code_, size_, x, y, ssym_); + drawChar(pain, LM_TC_SYMB, size_, x, y, sym_->id); } diff --git a/src/mathed/math_symbolinset.h b/src/mathed/math_symbolinset.h index 679d2efb82..29254c7b0f 100644 --- a/src/mathed/math_symbolinset.h +++ b/src/mathed/math_symbolinset.h @@ -3,7 +3,6 @@ #define MATH_SYMBOLINSET_H #include "math_diminset.h" -#include "LString.h" struct latexkeys; @@ -30,7 +29,5 @@ public: private: /// latexkeys const * sym_; - /// cache for the symbol's onscreen string representation - mutable string ssym_; }; #endif diff --git a/src/mathed/support.C b/src/mathed/support.C index d751a76632..a4013d0337 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -28,13 +28,6 @@ bool MathIsBinary(MathTextCodes x) } -bool MathIsSymbol(MathTextCodes x) -{ - return x == LM_TC_SYMB || x == LM_TC_BSYM; -} - - - /// class Matrix { public: @@ -433,7 +426,7 @@ math_deco_struct math_deco_table[] = { { '|', &vert[0], 0 }, { '/', &slash[0], 0 }, { LM_Vert, &Vert[0], 0 }, - { LM_backslash, &slash[0], 1 }, + { '\\', &slash[0], 1 }, { LM_langle, &angle[0], 0 }, { LM_lceil, &corner[0], 0 }, { LM_lfloor, &corner[0], 1 }, @@ -608,20 +601,19 @@ math_deco_struct const * search_deco(int code) } -void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code) +void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, + latexkeys const * l) { Matrix mt; Matrix sqmt; - float xx; - float yy; - float x2; - float y2; int i = 0; + string name = l->name; + int code = (name.size() > 1) ? l->id : name[0]; math_deco_struct const * mds = search_deco(code); if (!mds) { - // Should this ever happen? - lyxerr << "Deco was not found. Programming error?" << endl; + lyxerr << "Deco was not found. Programming error?\n"; + lyxerr << "name: '" << l->name << "', code: " << code << "\n"; return; } @@ -635,11 +627,22 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code) mt.escalate(w, h); int const n = (w < h) ? w : h; + sqmt.rotate(r); sqmt.escalate(n, n); - if (r > 0 && r < 3) y += h; - if (r >= 2) x += w; + + if (r > 0 && r < 3) + y += h; + + if (r >= 2) + x += w; + do { + float xx; + float yy; + float x2; + float y2; + code = int(d[i++]); switch (code) { case 0: break; diff --git a/src/mathed/support.h b/src/mathed/support.h index e32e7683c3..eb447cf0f5 100644 --- a/src/mathed/support.h +++ b/src/mathed/support.h @@ -7,6 +7,7 @@ #include "LString.h" class Painter; +class latexkeys; extern char const * math_font_name[]; extern char const * latex_mathspace[]; @@ -19,7 +20,8 @@ int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c); int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c); int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c); -void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, int code); +void mathed_draw_deco + (Painter & pain, int x, int y, int w, int h, latexkeys const * l); void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s, int & asc, int & des, int & wid); @@ -31,7 +33,6 @@ int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s); int mathed_string_descent(MathTextCodes type, MathStyles size, string const & s); bool MathIsAlphaFont(MathTextCodes x); -bool MathIsSymbol(MathTextCodes x); void drawStr(Painter & pain, MathTextCodes type, MathStyles siz, int x, int y, string const & s); diff --git a/src/mathed/symbol_def.h b/src/mathed/symbol_def.h index 4f22d506d9..1a92c4fc4c 100644 --- a/src/mathed/symbol_def.h +++ b/src/mathed/symbol_def.h @@ -122,92 +122,18 @@ enum Math_Symbols_enum { LM_mid = 0x7c, LM_angle = 0xd0, LM_vee = 0xda, - //LM_backslash '\\' /// Symbols that don't exist in X11 symbol font LM_NoFont = 256, - LM_epsilon, - LM_hookleftarrow, - LM_hookrightarrow, - LM_updownarrow, - LM_leftharpoonup, - LM_rightharpoonup, - LM_rightleftharpoons, - LM_Updownarrow, - LM_leftharpoondown, - LM_rightharpoondown, - LM_mapsto, - LM_Longleftarrow, - LM_Longrightarrow, - LM_Longleftrightarrow, - LM_longleftrightarrow, - LM_longleftarrow, - LM_longrightarrow, - LM_longmapsto, - LM_nwarrow, - LM_nearrow, - LM_swarrow, - LM_searrow, - LM_models, - LM_prec, - LM_succ, - LM_sim, LM_perp, - LM_preceq, - LM_succeq, - LM_simeq, - LM_ll, - LM_gg, - LM_asymp, - LM_parallel, - LM_smile, - LM_frown, - LM_sqsubseteq, - LM_sqsupseteq, - LM_doteq, - LM_ni, LM_notin, - LM_vdash, - LM_dashv, - LM_bowtie, - LM_mp, - LM_bigtriangleup, - LM_ominus, - LM_uplus, - LM_bigtriangledown, - LM_sqcap, - LM_triangleright, - LM_sqcup, - LM_triangleleft, - LM_odot, - LM_star, - LM_amalg, - LM_bigcirc, - LM_setminus, - LM_dagger, - LM_circ, - LM_wr, - LM_ddagger, - LM_oint, - LM_coprod, - LM_bigsqcup, - LM_bigotimes, - LM_bigodot, - LM_bigoplus, - LM_bigcap, - LM_bigcup, - LM_biguplus, - LM_bigvee, - LM_bigwedge, - LM_ell, - LM_imath, - LM_jmath, - LM_hbar, - LM_top, + +/// needed as decoration LM_Vert, - LM_flat, - LM_natural, - LM_triangle, + LM_updownarrow, + LM_Updownarrow, + +/// decorations LM_widehat, LM_widetilde, LM_underline, @@ -216,11 +142,12 @@ enum Math_Symbols_enum { LM_overbrace, LM_overleftarrow, LM_overightarrow, + +/// dots LM_ldots, LM_cdots, LM_vdots, LM_ddots, - LM_backslash, LM_emptyset, /// Accents that don't exist in X11 symbol font