-{
- if (selection) SelDel();
-
- if (t == LM_TC_MIN)
- t = lastcode;
-
- if (macro_mode && !(MathIsAlphaFont(t) || t == LM_TC_MIN))
- MacroModeClose();
-
- if (t == LM_TC_CR) {
- MathParInset *p= cursor->p;
- if (p == par && p->GetType()<LM_OT_MPAR && p->GetType()>LM_OT_MIN) {
- MathMatrixInset* mt = new MathMatrixInset(3, 0);
- mt->SetAlign(' ', "rcl");
- mt->SetStyle(LM_ST_DISPLAY);
- mt->SetType((p->GetType() == LM_OT_PARN) ? LM_OT_MPARN: LM_OT_MPAR);
- mt->SetData(p->GetData());
- p->SetData(0);//BUG duda
- delete p;
- par = mt;
- p = mt;
- p->Metrics();
- int pos = cursor->getPos();
- cursor->SetData(par);
- cursor->goPosAbs(pos);
- }
- if (p && p->Permit(LMPF_ALLOW_CR)) {
- cursor->addRow();
- }
- } else
- if (t == LM_TC_TAB) {
- MathParInset *p = cursor->p;
- if (p && p->Permit(LMPF_ALLOW_TAB)) {
- if (c) {
- cursor->Insert(c, t);
- cursor->checkTabs();
- } else
- cursor->goNextColumn();
- } else // Navigate between arguments
- if (p && p->GetType() == LM_OT_MACRO) {
- if (p->getArgumentIdx() < p->getMaxArgumentIdx()) {
- p->setArgumentIdx(p->getArgumentIdx()+1);
- cursor->SetData(p);
- return;
- }
- }
- } else {
- if (macro_mode) {
- if (MathIsAlphaFont(t) || t == LM_TC_MIN) {
- MacroModeInsert(c);
- return;
- }
- }
- if (accent) {
- doAccent(c, t);
- } else
- cursor->Insert(c, t);
- lastcode = t;
-
- return;
- }
- clearLastCode();
-}
-
-void MathedCursor::Insert(MathedInset* p, int t)
-{
- if (macro_mode) MacroModeClose();
- if (selection) {
- if (MathIsActive(t)) {
- SelCut();
- ((MathParInset*)p)->SetData(selarray);
- } else
- SelDel();
- }
-
- if (mathstk.i<MAX_STACK_ITEMS-1) {
-
- if (accent && !MathIsActive(t)) {
- doAccent(p);
- } else {
- cursor->Insert(p, t);
-
- if (MathIsActive(t)) {
- cursor->Prev();
- Push();
- }
- }
-
- } else
- lyxerr << "Math error: Full stack." << endl;
-}
-
-void MathedCursor::Delete()
-{
- if (macro_mode) return;
- if (selection) {
- SelDel();
- return;
- }
- if (cursor->Empty() && !mathstk.Empty()) {
- cursor = mathstk.pop();
- }
-// if (cursor->GetChar()!= LM_TC_TAB)
- cursor->Delete();
- cursor->checkTabs();
+{
+ if (selection)
+ SelDel();
+
+ if (t == LM_TC_MIN)
+ t = lastcode;
+
+ if (macro_mode && !(MathIsAlphaFont(t) || t == LM_TC_MIN))
+ MacroModeClose();
+
+ if (t == LM_TC_CR) {
+ MathParInset * p = cursor->getPar();
+ if (p == par && p->GetType() < LM_OT_MPAR && p->GetType() > LM_OT_MIN) {
+ short int type = LM_OT_MPAR;
+ int cols = 1;
+ if (c >= '1' && c <= '9') {
+ type = LM_OT_ALIGN;
+ cols = c - '1' + 1;
+ } else if (c >= 'A' && c <= 'I') {
+ type = LM_OT_ALIGNAT;
+ cols = c - 'A' + 1;
+ } else if (c == 'm')
+ type = LM_OT_MULTLINE;
+ else if (c == 'e')
+ type = LM_OT_MPAR;
+
+ if (p->GetType() == LM_OT_PARN)
+ ++type;
+ MathMatrixInset * mt =
+ new MathMatrixInset(create_multiline(type, cols));
+ mt->SetStyle(LM_ST_DISPLAY);
+ mt->SetType(type);
+ mt->setData(p->GetData());
+ delete p;
+ par = mt;
+ p = mt;
+ p->Metrics();
+ int pos = cursor->getPos();
+ SetCursorData(par);
+ cursor->goPosAbs(pos);
+ }
+ if (p && p->Permit(LMPF_ALLOW_CR)) {
+ cursor->addRow();
+ }
+ } else if (t == LM_TC_TAB) {
+ MathParInset * p = cursor->getPar();
+ if (p && p->Permit(LMPF_ALLOW_TAB)) {
+ if (c) {
+ cursor->insert(c, t);
+ cursor->checkTabs();
+ } else
+ cursor->goNextColumn();
+ } else {
+ // Navigate between arguments
+ if (p && p->GetType() == LM_OT_MACRO) {
+ if (p->getArgumentIdx() < p->getMaxArgumentIdx()) {
+ p->setArgumentIdx(p->getArgumentIdx() + 1);
+ SetCursorData(p);
+ return;
+ }
+ }
+ }
+ } else {
+ if (macro_mode) {
+ if (MathIsAlphaFont(t) || t == LM_TC_MIN) {
+ // was MacroModeInsert(c);
+ imacro->SetName(imacro->GetName() + static_cast<char>(c));
+ return;
+ }
+ }
+
+ if (accent)
+ doAccent(c, t);
+ else
+ cursor->insert(c, t);
+
+ lastcode = t;
+ return;
+ }
+ clearLastCode();
+}
+
+
+void MathedCursor::insertInset(MathedInset * p, int t)
+{
+ if (macro_mode)
+ MacroModeClose();
+
+ if (selection) {
+ if (MathIsActive(t)) {
+ SelCut();
+ static_cast<MathParInset*>(p)->setData(selarray);
+ } else
+ SelDel();
+ }
+
+ if (!mathstk.Full()) {
+ if (accent && !MathIsActive(t)) {
+ doAccent(p);
+ } else {
+ cursor->insertInset(p, t);
+ if (MathIsActive(t)) {
+ cursor->Prev();
+ Push();
+ }
+ }
+ } else
+ lyxerr << "Math error: Full stack." << endl;
+}
+
+
+void MathedCursor::Delete()
+{
+ if (macro_mode)
+ return;
+
+ if (selection) {
+ SelDel();
+ return;
+ }
+
+ if (cursor->Empty() && !mathstk.empty())
+ cursor = mathstk.pop();
+
+ // if (cursor->GetChar() != LM_TC_TAB)
+ cursor->Delete();
+ cursor->checkTabs();