]> git.lyx.org Git - features.git/commitdiff
cosmetics
authorAndré Pönitz <poenitz@gmx.net>
Tue, 14 Aug 2001 09:35:44 +0000 (09:35 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 14 Aug 2001 09:35:44 +0000 (09:35 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2511 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/math_cursor.C
src/mathed/support.C
src/mathed/support.h

index 1ba6cbe72883b388884fee2a5989575e94d681e9..dd07554f61fe932e3356c49120e26eb65106efb2 100644 (file)
@@ -160,6 +160,7 @@ void InsetFormula::metrics() const
        par_->metrics(display() ? LM_ST_DISPLAY : LM_ST_TEXT);
 }
 
+
 vector<string> const InsetFormula::getLabelList() const
 {
        return par_->getLabelList();
index 04f41ccfe25de6c1503daf95a9a11d53f8a2bbf6..4fee6ab5d326dccab266e62525d75668ae13082c 100644 (file)
@@ -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
index 2970c29a6d66c724d52ffcfc94e5721b8b606c3b..aa4e86f18e0a12499cfa28857e1219491c9d16e6 100644 (file)
@@ -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));
index 333bae5f8719940ddec6dae94a71b5016b8c7897..2f4b1f9102a903ef8949de06c86b7d4294d7265c 100644 (file)
@@ -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)
index eb447cf0f5d7d5605ab2f53096c47d80035d363f..79248d90a7d946794943a90476482f312c8be86e 100644 (file)
@@ -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,