]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.C
fix static array
[lyx.git] / src / mathed / formula.C
index 6d7f75a58816dc32792a15f1ec35f1d66b8194fd..5b10679fb142b219f6d7a2125bc00f4a90453ebd 100644 (file)
@@ -37,6 +37,7 @@
 #include "LyXView.h"
 #include "Painter.h"
 #include "font.h"
+#include "support/lyxlib.h"
 
 using std::ostream;
 using std::istream;
@@ -69,14 +70,6 @@ int MathedInset::df_des;
 int MathedInset::df_width;
 
 
-inline
-bool IsMacro(short token, int id)
-{
-   return (token != LM_TK_FRAC && token != LM_TK_SQRT &&
-         !((token == LM_TK_SYM || token == LM_TC_BSYM) && id < 255));
-}
-
-
 static
 void mathedValidate(LaTeXFeatures & features, MathParInset * par);
 
@@ -198,21 +191,18 @@ LyXFont mathed_get_font(short type, int size)
 
 int mathed_string_width(short type, int size, byte const * s, int ls)
 {
-    LyXFont f = WhichFont(type, size);
-
-    byte sx[80];
-    if (MathIsBinary(type)) {
-       byte * ps = &sx[0];
-       for (int i = 0; i < ls && i < 75; ++i) {
-           *(ps++) = ' ';
-           *(ps++) = s[i];
-           *(ps++) = ' ';
-       }
-       *(ps++) = '\0';
-       ls *= 3;
-       s = &sx[0];
-    }
-    return lyxfont::width(reinterpret_cast<char const *>(s), ls, f);
+       string st;
+       if (MathIsBinary(type))
+               for (int i = 0; i < ls; ++i) {
+                       st += ' ';
+                       st += s[i];
+                       st += ' ';
+               }
+       else
+               st = string(reinterpret_cast<char const *>(s), ls);
+
+       LyXFont const f = WhichFont(type, size);
+       return lyxfont::width(st, f);
 }
 
 int mathed_string_width(short type, int size, string const & str)
@@ -265,13 +255,15 @@ void MathedInset::drawStr(Painter & pain, short type, int siz,
                          int x, int y, byte const * s, int ls)
 {
        string st;
-       if (MathIsBinary(type)) {
+       if (MathIsBinary(type))
                for (int i = 0; i < ls; ++i) {
-                       st += string(" ") + char(s[i]) + ' ';
+                       st += ' ';
+                       st += char(s[i]);
+                       st += ' ';
                }
-       } else {
+       else
                st = string(reinterpret_cast<char const *>(s), ls);
-       }
+
        LyXFont const mf = mathed_get_font(type, siz);
        pain.text(x, y, st, mf);
 }
@@ -308,7 +300,7 @@ InsetFormula::~InsetFormula()
 }
 
 
-Inset * InsetFormula::Clone() const
+Inset * InsetFormula::Clone(Buffer const &) const
 {
     InsetFormula * f = new InsetFormula(par);
     f->label = label;
@@ -555,7 +547,7 @@ void InsetFormula::ToggleInsetCursor(BufferView * bv)
 }
 
 
-void InsetFormula::ShowInsetCursor(BufferView * bv)
+void InsetFormula::ShowInsetCursor(BufferView * bv, bool)
 {
   if (!cursor_visible) {
     if (mathcursor) {
@@ -590,7 +582,7 @@ void InsetFormula::ToggleInsetSelection(BufferView * bv)
     //int n;
     //XPoint * p = 
     //mathcursor->SelGetArea(n);
-//    XFillPolygon(fl_display, pm, LyXGetSelectionGC(), p, n, Nonconvex, CoordModeOrigin);
+//    XFillPolygon(fl_get_display(), pm, LyXGetSelectionGC(), p, n, Nonconvex, CoordModeOrigin);
 //    x -= par->xo; 
 //    y -= par->yo;
 
@@ -788,8 +780,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
       result = DISPATCHED_NOUPDATE;
       break;
     case LFUN_DELETE_LINE_FORWARD:
-           //current_view->lockedInsetStoreUndo(Undo::INSERT);
-           bv->lockedInsetStoreUndo(Undo::DELETE);
+      bv->lockedInsetStoreUndo(Undo::DELETE);
       mathcursor->DelLine();
       UpdateLocal(bv);
       break;
@@ -819,8 +810,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
        }
       
     case LFUN_DELETE:
-           //current_view->lockedInsetStoreUndo(Undo::INSERT);
-           bv->lockedInsetStoreUndo(Undo::DELETE);
+      bv->lockedInsetStoreUndo(Undo::DELETE);
       mathcursor->Delete();       
       bv->updateInset(this, true);
       break;    
@@ -1002,7 +992,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
        
        if (arg.empty())
               break;
-       strncpy(arg2, arg.c_str(), 40); arg2[39]= '\0';
+       ::strncpy(arg2, arg.c_str(), 40); arg2[39]= '\0';
        int n = sscanf(arg2, "%s %s", lf, rg);
        lf[39] = '\0'; rg[39] = '\0';
 
@@ -1076,8 +1066,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
     }
     
     case LFUN_MATH_DISPLAY:
-           //current_view->lockedInsetStoreUndo(Undo::INSERT);
-           bv->lockedInsetStoreUndo(Undo::EDIT);
+      bv->lockedInsetStoreUndo(Undo::EDIT);
       display(!disp_flag);
       UpdateLocal(bv);
       break;
@@ -1100,7 +1089,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
 
     //------- dummy actions
     case LFUN_EXEC_COMMAND:
-       bv->owner()->getMiniBuffer()->ExecCommand(); 
+       bv->owner()->getMiniBuffer()->PrepareForCommand(); 
        break;
        
     default:
@@ -1209,7 +1198,7 @@ InsetFormula::LocalDispatch(BufferView * bv,
                    result = FINISHED;
              }
           } else
-          if (c == '\'') {
+          if (c == '\'' || c == '@') {
              mathcursor->Insert (c, LM_TC_VAR);
           } else
           if (c == '\\') {