From: André Pönitz Date: Mon, 9 Jul 2001 10:19:50 +0000 (+0000) Subject: Small bugfixes and cosmetic changes X-Git-Tag: 1.6.10~21113 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=b24b504cd296351e1109a6cd58b645567a8a68a3;p=features.git Small bugfixes and cosmetic changes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2208 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 98823926f2..81f989dad6 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,9 @@ +2001-07-04 André Pönitz + + * math_*inset.C: Change order of arguments in MathInset constructor + + * math_cursor.C: Remove broken "increase space" feature for a while + 2001-07-07 Dekel Tsur * formulabase.C (mathDispatchInsertMath): Create an inline formula. diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 66a7146698..b72eef4025 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -477,10 +477,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, MathTextCodes varcode = LM_TC_MIN; bool was_macro = mathcursor->InMacroMode(); bool sel = false; - bool space_on = false; bool was_selection = mathcursor->Selection(); RESULT result = DISPATCHED; - static MathSpaceInset * sp = 0; hideInsetCursor(bv); @@ -690,27 +688,18 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, } break; - case LFUN_INSERT_MATH: + case LFUN_INSERT_MATRIX: if (!arg.empty()) { bv->lockedInsetStoreUndo(Undo::INSERT); - mathcursor->Interpret(arg); + mathcursor->Interpret("matrix " + arg); updateLocal(bv); } break; - case LFUN_INSERT_MATRIX: - if (mathcursor) { + case LFUN_INSERT_MATH: + if (!arg.empty()) { bv->lockedInsetStoreUndo(Undo::INSERT); - int m = 1; - int n = 1; - string v_align; - string h_align; - istringstream is(arg.c_str()); - is >> m >> n >> v_align >> h_align; - MathArrayInset * p = new MathArrayInset(m, n); - p->valign(v_align[0]); - p->halign(h_align); - mathcursor->insert(p); + mathcursor->Interpret(arg); updateLocal(bv); } break; @@ -764,7 +753,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, case LFUN_PROTECTEDSPACE: bv->lockedInsetStoreUndo(Undo::INSERT); mathcursor->insert(new MathSpaceInset(1)); - space_on = true; updateLocal(bv); break; @@ -936,7 +924,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, if (code != LM_TC_TEXTRM) code = LM_TC_BOP; mathcursor->insert(c, code); - } else if (strchr(latex_special_chars, c) && c!= '_') { + } else if (strchr(latex_special_chars, c) && c != '_') { MathTextCodes code = mathcursor->getLastCode(); if (code != LM_TC_TEXTRM) code = LM_TC_SPECIAL; @@ -960,10 +948,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, mathcursor->insert(c, LM_TC_TEXTRM); } else if (was_macro) { mathcursor->MacroModeClose(); - } else if (sp) { - int isp = (sp->GetSpace()<5) ? sp->GetSpace()+1: 0; - sp->SetSpace(isp); - space_on = true; } else { if (!mathcursor->pop()) result = FINISHED; @@ -997,9 +981,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, //if (mathcursor) // updateLocal(bv); - if (sp && !space_on) - sp = 0; - if (mathcursor && (mathcursor->Selection() || was_selection)) toggleInsetSelection(bv); diff --git a/src/mathed/math_accentinset.C b/src/mathed/math_accentinset.C index e5c89351bb..32712c9f87 100644 --- a/src/mathed/math_accentinset.C +++ b/src/mathed/math_accentinset.C @@ -8,14 +8,12 @@ using std::ostream; MathAccentInset::MathAccentInset(byte cx, MathTextCodes f, int cd) - : MathInset("", LM_OT_ACCENT), - c(cx), fn(f), code(cd), inset(0) + : MathInset(1), c(cx), fn(f), code(cd), inset(0) {} MathAccentInset::MathAccentInset(MathInset * ins, int cd) - : MathInset("", LM_OT_ACCENT), - c(0), fn(LM_TC_MIN), code(cd), inset(ins) + : MathInset(0), c(0), fn(LM_TC_MIN), code(cd), inset(ins) {} diff --git a/src/mathed/math_accentinset.h b/src/mathed/math_accentinset.h index 4f2a2696a1..0888c1606e 100644 --- a/src/mathed/math_accentinset.h +++ b/src/mathed/math_accentinset.h @@ -27,6 +27,8 @@ public: void Metrics(MathStyles st); /// int getAccentCode() const; + /// + bool isAccentInset() const { return true; } protected: /// byte c; diff --git a/src/mathed/math_bigopinset.C b/src/mathed/math_bigopinset.C index 50b56f5a59..b69206490d 100644 --- a/src/mathed/math_bigopinset.C +++ b/src/mathed/math_bigopinset.C @@ -11,7 +11,7 @@ using std::ostream; MathBigopInset::MathBigopInset(string const & name, int id) - : MathScriptInset(true, false), lims_(0), sym_(id) + : MathScriptInset(false, true), lims_(0), sym_(id) { SetName(name); } @@ -101,9 +101,12 @@ void MathBigopInset::draw(Painter & pain, int x, int y) t = LM_TC_TEXTRM; } if (sym_ == LM_oint) { - pain.arc(x, y - 5 * width_ / 4, width_, width_, 0, 360 * 64, - LColor::mathline); - ++x; + int wid; + int asc; + int des; + mathed_char_dim(t, size(), LM_int, asc, des, wid); + wid += 2; + pain.arc(x - 1, y - (asc - des) / 2, wid, wid, 0, 360 * 64, LColor::mathline); } int asc, des, wid; diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index cad3c861f6..6a1fcfe578 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -23,6 +23,7 @@ #include #include "math_inset.h" +#include "math_arrayinset.h" #include "math_parser.h" #include "math_cursor.h" #include "math_macro.h" @@ -560,7 +561,8 @@ void MathCursor::SetSize(MathStyles size) void MathCursor::Interpret(string const & s) { - lyxerr << "Interpret: '" << s << "'\n"; + lyxerr << "Interpret: '" << s << "' ('" << s.substr(0, 7) << "' " << +in_word_set(s) << " \n"; if (s[0] == '^') { MathScriptInset * p = nearbyScriptInset(); @@ -604,6 +606,20 @@ void MathCursor::Interpret(string const & s) p = new MathRootInset; else if (MathMacroTable::hasTemplate(s)) p = new MathMacro(MathMacroTable::provideTemplate(s)); + else if (s.size() > 7 && s.substr(0, 7) == "matrix ") { + int m = 1; + int n = 1; + string v_align; + string h_align; + std::istringstream is(s.substr(7).c_str()); + is >> m >> n >> v_align >> h_align; + m = std::max(1, m); + n = std::max(1, n); + MathArrayInset * pp = new MathArrayInset(m, n); + pp->valign(v_align[0]); + pp->halign(h_align); + p = pp; + } else p = new MathFuncInset(s, LM_OT_UNDEF); } else { @@ -624,11 +640,11 @@ void MathCursor::Interpret(string const & s) break; case LM_TK_STACK: - p = new MathFracInset(LM_OT_STACKREL); + p = new MathFracInset("stackrel"); break; case LM_TK_FRAC: - p = new MathFracInset(LM_OT_FRAC); + p = new MathFracInset("frac"); break; case LM_TK_SQRT: @@ -709,7 +725,7 @@ void MathCursor::MacroModeClose() imacro->SetName(l->name); } else { Left(); - if (nextInset()->GetType() == LM_OT_ACCENT) + if (nextInset()->isAccentInset()) setAccent( static_cast(nextInset())->getAccentCode()); array().erase(cursor_); diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index de582f6f90..c8c799c796 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -15,7 +15,7 @@ using std::ostream; MathDecorationInset::MathDecorationInset(int d) - : MathInset("", LM_OT_DECO, 1), deco_(d) + : MathInset(1), deco_(d) { upper_ = deco_ != LM_underline && deco_ != LM_underbrace; } diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index b1790c87f2..5ff51edf87 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -134,26 +134,6 @@ enum MathInsetTypes { /// LM_OT_FUNCLIM, /// - LM_OT_SCRIPT, - /// - LM_OT_SPACE, - /// - LM_OT_DOTS, - /// A fraction - LM_OT_FRAC, - /// - LM_OT_ATOP, - /// - LM_OT_STACKREL, - /// A radical - LM_OT_SQRT, - /// A delimiter - LM_OT_DELIM, - /// A decoration - LM_OT_DECO, - /// An accent - LM_OT_ACCENT, - /// LM_OT_MACRO, /// LM_OT_MAX diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index cb4788e9ba..bea4755336 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -13,7 +13,7 @@ MathDelimInset::MathDelimInset(int l, int r) - : MathInset("", LM_OT_DELIM, 1), left_(l), right_(r) + : MathInset(1), left_(l), right_(r) {} diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index 20964b3d0a..d173a3bb71 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -12,7 +12,7 @@ using std::ostream; MathDotsInset::MathDotsInset(string const & name, int id) - : MathInset(name, LM_OT_DOTS), code_(id) + : MathInset(0, name), code_(id) {} diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 856e3b664b..6376eeab4d 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -13,12 +13,9 @@ #include "support/LOstream.h" -MathFracInset::MathFracInset(MathInsetTypes ot) - : MathInset("frac", ot, 2) -{ - if (objtype == LM_OT_STACKREL) - SetName("stackrel"); -} +MathFracInset::MathFracInset(string const & name) + : MathInset(2, name) +{} MathInset * MathFracInset::clone() const @@ -46,7 +43,7 @@ void MathFracInset::draw(Painter & pain, int x, int y) xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5); xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5); - if (objtype == LM_OT_FRAC) + if (name() == "frac") pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline); } diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index bf03ffc10a..4a3e7ab8e8 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -14,7 +14,7 @@ class MathFracInset : public MathInset { public: /// - explicit MathFracInset(MathInsetTypes ot = LM_OT_FRAC); + explicit MathFracInset(const string & name); /// virtual MathInset * clone() const; /// diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index 8af9361d01..22ba821089 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -18,7 +18,7 @@ extern LyXFont WhichFont(short type, int size); MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot) - : MathInset(nm, ot) + : MathInset(0, nm, ot) { lims_ = (GetType() == LM_OT_FUNCLIM); } diff --git a/src/mathed/math_grid.C b/src/mathed/math_grid.C index 111e9b3f9f..9c3fa1a1a9 100644 --- a/src/mathed/math_grid.C +++ b/src/mathed/math_grid.C @@ -33,7 +33,7 @@ MathGridInset::ColInfo::ColInfo() MathGridInset::MathGridInset(int m, int n, string const & nm, MathInsetTypes ot) - : MathInset(nm, ot, m * n), rowinfo_(n), colinfo_(m), v_align_('c') + : MathInset(m * n, nm, ot), rowinfo_(n), colinfo_(m), v_align_('c') { if (m <= 0) lyxerr << "positve number of columns expected\n"; diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index 8685048ebe..82760011ad 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -30,7 +30,7 @@ int MathInset::workwidth; -MathInset::MathInset(string const & name, MathInsetTypes ot, int nargs) +MathInset::MathInset(int nargs, string const & name, MathInsetTypes ot) : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0), size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0) {} diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 0b89e90460..7b86dc3c2d 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -43,8 +43,9 @@ public: type and font-size */ /// - explicit - MathInset (string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE, int na = 0); + explicit MathInset + (int na = 0, string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE); + /// The virtual base destructor virtual ~MathInset() {} @@ -173,6 +174,8 @@ public: bool covers(int x, int y) const; /// Identifies ScriptInsets virtual bool isScriptInset() const { return false; } + /// Identifies AccentInsets + virtual bool isAccentInset() const { return false; } /// virtual bool isActive() const { return nargs() > 0; } diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 44752e60d7..fae542145c 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -34,7 +34,7 @@ using std::endl; MathMacro::MathMacro(MathMacroTemplate const & t) - : MathInset(t.name(), LM_OT_MACRO, t.numargs()), tmplate_(&t) + : MathInset(t.numargs(), t.name(), LM_OT_MACRO), tmplate_(&t) {} diff --git a/src/mathed/math_macrotable.C b/src/mathed/math_macrotable.C index dba2b18e84..4eec360664 100644 --- a/src/mathed/math_macrotable.C +++ b/src/mathed/math_macrotable.C @@ -147,7 +147,7 @@ void MathMacroTable::builtinMacros() // binom has two arguments { - MathFracInset * frac = new MathFracInset(LM_OT_ATOP); + MathFracInset * frac = new MathFracInset("atop"); frac->cell(0).push_back(new MathMacroArgument(1)); frac->cell(1).push_back(new MathMacroArgument(2)); diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index 2b7c3ffde4..5277073473 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -10,12 +10,12 @@ MathMacroTemplate::MathMacroTemplate() : - MathInset("undefined", LM_OT_MACRO, 1), numargs_(0), users_() + MathInset(1, "undefined", LM_OT_MACRO), numargs_(0), users_() {} MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs) : - MathInset(nm, LM_OT_MACRO, 1), numargs_(numargs), users_() + MathInset(1, nm, LM_OT_MACRO), numargs_(numargs), users_() {} diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index e842542392..c185e874e3 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -475,10 +475,20 @@ void MathMatrixInset::mutate(short newtype) case LM_OT_EQNARRAY: switch (newtype) { case LM_OT_SIMPLE: - case LM_OT_EQUATION: + case LM_OT_EQUATION: { + string label; + bool allnonum = true; + for (int r = 0; r < nrows(); ++r) { + label += label_[r]; + if (!nonum_[r]) + allnonum = false; + } glueall(); mutate(newtype); + label_[0] = label; + nonum_[0] = allnonum; break; + } case LM_OT_ALIGN: default: diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index cd1cadf1a3..20e4c73276 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -392,9 +392,9 @@ void do_insert(MathArray & dat, unsigned char ch, MathTextCodes fcode) } -void handle_frac(MathArray & dat, MathInsetTypes t) +void handle_frac(MathArray & dat, string const & name) { - MathFracInset * p = new MathFracInset(t); + MathFracInset * p = new MathFracInset(name); mathed_parse(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST); mathed_parse(p->cell(1), FLAG_BRACE | FLAG_BRACE_LAST); dat.push_back(p); @@ -723,15 +723,15 @@ void mathed_parse(MathArray & array, unsigned flags) break; case LM_TK_CHOOSE: - handle_frac(array, LM_OT_ATOP); + handle_frac(array, "atop"); break; case LM_TK_STACK: - handle_frac(array, LM_OT_STACKREL); + handle_frac(array, "stackrel"); break; case LM_TK_FRAC: - handle_frac(array, LM_OT_FRAC); + handle_frac(array, "frac"); break; case LM_TK_SQRT: diff --git a/src/mathed/math_root.C b/src/mathed/math_root.C index f6ae3478f3..da68d2536e 100644 --- a/src/mathed/math_root.C +++ b/src/mathed/math_root.C @@ -24,7 +24,7 @@ #include "Painter.h" MathRootInset::MathRootInset() - : MathInset("sqrt", LM_OT_SQRT, 2) + : MathInset(2) {} diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 76ca5a0b94..f80a61262b 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -15,11 +15,11 @@ MathScriptInset::MathScriptInset() - : MathInset("script", LM_OT_SCRIPT, 2), up_(false), down_(false) + : MathInset(2), up_(false), down_(false) {} MathScriptInset::MathScriptInset(bool up, bool down) - : MathInset("script", LM_OT_SCRIPT, 2), up_(up), down_(down) + : MathInset(2), up_(up), down_(down) {} diff --git a/src/mathed/math_sizeinset.C b/src/mathed/math_sizeinset.C index 762632da33..707248a131 100644 --- a/src/mathed/math_sizeinset.C +++ b/src/mathed/math_sizeinset.C @@ -9,7 +9,7 @@ MathSizeInset::MathSizeInset(MathStyles st) - : MathInset("", LM_OT_SIMPLE, 1), style_(st) + : MathInset(1), style_(st) { name_ = verbose(); } diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index b53d0ed491..85cb731460 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -11,8 +11,8 @@ #include "support/LOstream.h" -MathSpaceInset::MathSpaceInset(int sp, MathInsetTypes ot) - : MathInset("", ot), space_(sp) +MathSpaceInset::MathSpaceInset(int sp) + : space_(sp) {} diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index 67062c5268..9983f4945b 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -13,9 +13,9 @@ class MathSpaceInset : public MathInset { public: /// - MathSpaceInset(int sp, MathInsetTypes ot = LM_OT_SPACE); + explicit MathSpaceInset(int sp); /// - MathInset * clone() const; + MathInset * clone() const; /// void draw(Painter &, int, int); /// diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index df36cf28ce..b201df0545 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -12,7 +12,7 @@ MathSqrtInset::MathSqrtInset() - : MathInset("sqrt", LM_OT_SQRT, 1) + : MathInset(1) {}