]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.C
small cleanup, doxygen, formatting changes
[lyx.git] / src / mathed / math_cursor.C
index 7eb3bc73caccbf27e8bd6887ca299eda63de34bc..4b747c80cf1546fd32421d63419563b43d80de0c 100644 (file)
@@ -138,8 +138,6 @@ MathedCursor::MathedCursor(MathParInset * p) // : par(p)
 
 void MathedCursor::SetPar(MathParInset * p)
 {
-       win        = 0;
-       is_visible = False;
        macro_mode = false;
        selection  = false; // not SelClear() ?
        mathstk.Reset();
@@ -191,7 +189,14 @@ void MathedCursor::Redraw(Painter & pain)
 bool MathedCursor::Left(bool sel)
 {
        if (macro_mode) {
-               MacroModeBack();
+               // was MacroModeBack()
+               if (!imacro->GetName().empty()) {
+                       imacro->SetName(imacro->GetName()
+                                       .substr(0, imacro->GetName()
+                                               .length() - 1));
+                       imacro->Metrics();
+               } else
+                       MacroModeClose();
                return true;
        }
 
@@ -211,8 +216,7 @@ bool MathedCursor::Left(bool sel)
                result = true;
                if (selection)
                        SelClear();
-       } else
-       if (result && cursor->IsActive()) {
+       } else if (result && cursor->IsActive()) {
                if (cursor->IsScript()) {
                        cursor->Prev();
                        if (!cursor->IsScript())
@@ -448,8 +452,8 @@ void MathedCursor::Insert(byte c, MathedTextCodes t)
                        MathMatrixInset * mt = create_multiline(type, cols);
                        mt->SetStyle(LM_ST_DISPLAY);
                        mt->SetType(type);
-                       mt->SetData(p->GetData());
-                       p->SetData(0);                          // BUG duda
+                       mt->setData(p->GetData());
+                       p->setData(0);                          // BUG duda
                        delete p;
                        par = mt;
                        p = mt;
@@ -480,7 +484,8 @@ void MathedCursor::Insert(byte c, MathedTextCodes t)
        } else {
                if (macro_mode) {
                        if (MathIsAlphaFont(t) || t == LM_TC_MIN) {
-                               MacroModeInsert(c);
+                               // was MacroModeInsert(c);
+                               imacro->SetName(imacro->GetName() + static_cast<char>(c));
                                return;
                        }
                }
@@ -505,7 +510,7 @@ void MathedCursor::Insert(MathedInset * p, int t)
        if (selection) {
                if (MathIsActive(t)) {
                        SelCut();
-                       static_cast<MathParInset*>(p)->SetData(selarray);
+                       static_cast<MathParInset*>(p)->setData(selarray);
                } else
                        SelDel();
        }
@@ -715,7 +720,7 @@ void MathedCursor::setNumbered()
 void MathedCursor::Interpret(string const & s)
 {
        MathedInset * p = 0;
-       latexkeys * l = 0;
+       latexkeys const * l = 0;
        MathedTextCodes tcode = LM_TC_INSET;
 
        if (s[0] == '^' || s[0] == '_') {
@@ -753,7 +758,7 @@ void MathedCursor::Interpret(string const & s)
                if (!p) {
                lyxerr[Debug::MATHED] << "Macro2 " << s << ' ' << tcode << endl;
                if (s == "root") {
-                       p = new MathRootInset();
+                       p = new MathRootInset;
                        tcode = LM_TC_ACTIVE_INSET;
                } else
                        p = new MathFuncInset(s, LM_OT_UNDEF);
@@ -839,7 +844,7 @@ bool MathedCursor::pullArg()
                        return false;
                
                MathedArray * a = p->GetData();
-               p->SetData(0);
+               p->setData(0);
                Delete();
                if (a) {
                        cursor->Merge(a);
@@ -867,7 +872,7 @@ void MathedCursor::MacroModeClose()
 {
        if (macro_mode)  {
                macro_mode = false;
-               latexkeys * l = in_word_set(imacro->GetName());
+               latexkeys const * l = in_word_set(imacro->GetName());
                if (!imacro->GetName().empty()
                && (!l || (l && IsMacro(l->token, l->id))) &&
                !MathMacroTable::mathMTable.getMacro(imacro->GetName())) {
@@ -894,30 +899,6 @@ void MathedCursor::MacroModeClose()
 }
 
 
-void MathedCursor::MacroModeBack()
-{
-       if (macro_mode) {
-               if (!imacro->GetName().empty()) {
-                       imacro->SetName(
-                                       imacro->GetName().substr(0, imacro->GetName().length() - 1));
-                       imacro->Metrics();
-               } else
-                       MacroModeClose();
-       } else
-               lyxerr << "Mathed Warning: we are not in macro mode" << endl;
-}
-
-
-void MathedCursor::MacroModeInsert(char c)
-{
-       if (macro_mode) {
-               imacro->SetName(imacro->GetName() + c);
-               imacro->Metrics();
-       } else
-               lyxerr << "Mathed Warning: we are not in macro mode" << endl;
-}
-
-
 void MathedCursor::SelCopy()
 {
        if (selection) {