From: André Pönitz Date: Tue, 14 Aug 2001 09:35:44 +0000 (+0000) Subject: cosmetics X-Git-Tag: 1.6.10~20834 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=4310ee27935804c5b0986a57a477a6b2fd5b2f01;p=features.git cosmetics git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2511 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 1ba6cbe728..dd07554f61 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -160,6 +160,7 @@ void InsetFormula::metrics() const par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT); } + vector const InsetFormula::getLabelList() const { return par_->getLabelList(); diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 04f41ccfe2..4fee6ab5d3 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -177,7 +177,9 @@ void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int) lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl; metrics(); - //bv->updateInset(this, false); + // if that is removed, we won't get the magenta box when entering an + // inset for the first time + bv->updateInset(this, false); if (x == 0) mathcursor->first(); else diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 2970c29a6d..aa4e86f18e 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -399,15 +399,12 @@ void MathCursor::insert(char c, MathTextCodes t) if (t != LM_TC_VAR) lastcode_ = t; - if (imacro_ && !(MathIsAlphaFont(t) || t == LM_TC_VAR)) + if (imacro_ && t != LM_TC_TEX) macroModeClose(); if (imacro_) { - if (MathIsAlphaFont(t) || t == LM_TC_VAR) { - // was MacroModeinsert(c); - imacro_->setName(imacro_->name() + c); - return; - } + imacro_->setName(imacro_->name() + c); + return; } array().insert(pos(), new MathCharInset(c, t)); diff --git a/src/mathed/support.C b/src/mathed/support.C index 333bae5f87..2f4b1f9102 100644 --- a/src/mathed/support.C +++ b/src/mathed/support.C @@ -16,12 +16,6 @@ using std::endl; using std::max; -bool MathIsAlphaFont(MathTextCodes x) -{ - return LM_TC_VAR <= x && x <= LM_TC_TEXTRM; -} - - /// class Matrix { public: @@ -457,35 +451,43 @@ math_deco_struct math_deco_table[] = { struct math_deco_compare { /// for use by sort and lower_bound - inline - int operator()(math_deco_struct const & a, - math_deco_struct const & b) const { + int operator()(math_deco_struct const & a, math_deco_struct const & b) const + { return a.code < b.code; } }; int const math_deco_table_size = -sizeof(math_deco_table) /sizeof(math_deco_struct); + sizeof(math_deco_table) / sizeof(math_deco_struct); -class init_deco_table { -public: +// sort the table on startup +struct init_deco_table { init_deco_table() { - if (!init) { - sort(math_deco_table, + std::sort(math_deco_table, math_deco_table + math_deco_table_size, math_deco_compare()); - init_deco_table::init = true; - } } -private: - static bool init; }; +static init_deco_table dummy; + + +math_deco_struct const * search_deco(int code) +{ + static const math_deco_struct search_elem = { code, 0, 0 }; + + math_deco_struct const * res = + lower_bound(math_deco_table, + math_deco_table + math_deco_table_size, + search_elem, math_deco_compare()); + if (res != math_deco_table + math_deco_table_size && + res->code == code) + return res; + return 0; +} -bool init_deco_table::init = false; -static init_deco_table idt; } // namespace anon @@ -529,8 +531,6 @@ int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c) return lyxfont::descent(c, font); } - - int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c) { LyXFont const font = WhichFont(type, size); @@ -560,31 +560,12 @@ int mathed_string_height(MathTextCodes type, MathStyles size, string const & s, return asc + des; } - int mathed_string_width(MathTextCodes type, MathStyles size, string const & s) { return lyxfont::width(s, WhichFont(type, size)); } -namespace { - -math_deco_struct const * search_deco(int code) -{ - math_deco_struct search_elem = { code, 0, 0 }; - - math_deco_struct const * res = - lower_bound(math_deco_table, - math_deco_table + math_deco_table_size, - search_elem, math_deco_compare()); - if (res != math_deco_table + math_deco_table_size && - res->code == code) - return res; - return 0; -} - -} - void mathed_draw_deco(Painter & pain, int x, int y, int w, int h, latexkeys const * l) { @@ -674,6 +655,7 @@ bool isBinaryOp(char c) return true; } + // In a near future maybe we use a better fonts renderer void drawStr(Painter & pain, MathTextCodes type, MathStyles siz, int x, int y, string const & s) diff --git a/src/mathed/support.h b/src/mathed/support.h index eb447cf0f5..79248d90a7 100644 --- a/src/mathed/support.h +++ b/src/mathed/support.h @@ -32,8 +32,6 @@ int mathed_string_width(MathTextCodes type, MathStyles size, string const & s); 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); - void drawStr(Painter & pain, MathTextCodes type, MathStyles siz, int x, int y, string const & s); void drawChar(Painter & pain, MathTextCodes type, MathStyles siz,