#include "math_cursor.h"
#include "math_macro.h"
#include "math_root.h"
-#include "error.h"
+#include "support/lstrings.h"
+#include "debug.h"
extern void mathed_set_font(short type, int style);
!(token==LM_TK_SYM && id<255));
}
-// Yes, mathed isn't using LString yet.
+// Yes, mathed isn't using string yet.
inline char *strnew(char const* s)
{
char *s1 = new char[strlen(s)+1];
}
MathedXIter* Item(int idx) {
- return (idx+1 <= i) ? &item[i-idx-1]: (MathedXIter*)NULL;
+ return (idx+1 <= i) ? &item[i-idx-1]: (MathedXIter*)0;
}
void Reset() {
anchor = 0;
lastcode = LM_TC_MIN;
SetPar(p);
-// selarray = NULL;
+// selarray = 0;
if (!MathMacroTable::built)
MathMacroTable::mathMTable.builtinMacros();
}
void MathedCursor::Draw(long unsigned pm, int x, int y)
{
-// fprintf(stderr, "Cursor[%d %d] ", x, y);
+// lyxerr << "Cursor[" << x << " " << y << "] ";
win = pm; // win = (mathedCanvas) ? mathedCanvas: pm;
par->Metrics();
int w = par->Width()+2, a = par->Ascent()+1, h = par->Height()+1;
void MathedCursor::Redraw()
{
- lyxerr.debug("Mathed: Redrawing!", Error::MATHED);
+ lyxerr[Debug::MATHED] << "Mathed: Redrawing!" << endl;
par->Metrics();
int w = par->Width(), h = par->Height();
int x, y;
if (!selection) {
MathParInset *p = cursor->GetActiveInset();
if (!p) {
- fprintf(stderr, "Math error: Inset expected.\n");
+ lyxerr << "Math error: Inset expected." << endl;
return cursor->Next();
}
p->setArgumentIdx(0);
}
} else
- fprintf(stderr, "Math error: Full stack.\n");
+ lyxerr << "Math error: Full stack." << endl;
}
void MathedCursor::Delete()
void MathedCursor::setLabel(char const* label)
{ // ugly hack and possible bug
if (!cursor->setLabel(strnew(label)))
- fprintf(stderr, "MathErr: Bad place to set labels.");
+ lyxerr << "MathErr: Bad place to set labels." << endl;
}
if (!l) {
p = MathMacroTable::mathMTable.getMacro(s);
if (!p) {
- lyxerr.debug(LString("Macro2 ") + s + ' '
- + (long)tcode, Error::MATHED);
+ lyxerr[Debug::MATHED] << "Macro2 " << s << ' ' << tcode << endl;
if (strcmp("root", s)==0) {
p = new MathRootInset();
tcode = LM_TC_ACTIVE_INSET;
p = new MathFuncInset(s, LM_OT_UNDEF);
} else {
tcode = ((MathMacro*)p)->getTCode();
- fprintf(stderr, "Macro2 %s %d ", s, tcode);
+ lyxerr << "Macro2 " << s << ' ' << tcode << " " ;
}
} else {
MathedInsetTypes fractype = LM_OT_FRAC;
}
case LM_TK_STACK:
fractype = LM_OT_STACKREL;
- lyxerr.debug(" i:stackrel ", Error::MATHED);
+ lyxerr[Debug::MATHED] << " i:stackrel " << endl;
case LM_TK_FRAC:
{
p = new MathFracInset(fractype);
case LM_TK_MACRO:
p = MathMacroTable::mathMTable.getMacro(s);
tcode = ((MathMacro*)p)->getTCode();
- lyxerr.debug(LString("Macro ") + s + ' '
- + (long)tcode, Error::MATHED);
+ lyxerr[Debug::MATHED] << "Macro " << s << ' ' << tcode << endl;
break;
default:
{
Insert (imacro);
macro_mode = true;
} else
- fprintf(stderr, "Mathed Warning: Already in macro mode\n");
+ lyxerr << "Mathed Warning: Already in macro mode" << endl;
}
void MathedCursor::MacroModeClose()
imacro->SetName(l->name);
} else {
Left();
- imacro->SetName(NULL);
+ imacro->SetName(0);
if (cursor->GetInset()->GetType()==LM_OT_ACCENT) {
setAccent(((MathAccentInset*)cursor->GetInset())->getAccentCode());
}
Interpret(macrobf);
}
}
- imacro = NULL;
+ imacro = 0;
}
}
} else
MacroModeClose();
} else
- fprintf(stderr, "Mathed Warning: we are not in macro mode\n");
+ lyxerr << "Mathed Warning: we are not in macro mode" << endl;
}
void MathedCursor::MacroModeInsert(char c)
macrobf[macroln++] = c;
imacro->Metrics();
} else
- fprintf(stderr, "Mathed Warning: we are not in macro mode\n");
+ lyxerr << "Mathed Warning: we are not in macro mode" << endl;
}
void MathedCursor::SelCopy()
void MathedCursor::SelDel()
{
-// fprintf(stderr, "Deleting sel ");
+// lyxerr << "Deleting sel "
if (selection) {
if (cursor->pos==selpos) return;
cursor->Clean(selpos);
void MathedCursor::SelPaste()
{
-// fprintf(stderr, "paste %p %d ", selarray, cursor->pos);
+// lyxerr << "paste " << selarray << " " << curor->pos;
if (selection) SelDel();
if (selarray) {
cursor->Merge(selarray);
void MathedCursor::SelStart()
{
- lyxerr.debug("Starting sel ",Error::MATHED);
+ lyxerr[Debug::MATHED] << "Starting sel " << endl;
if (!anchor) {
selpos = cursor->pos;
selstk = new MathStackXIter(mathstk);
void MathedCursor::SelClear()
{
- lyxerr.debug("Clearing sel ", Error::MATHED);
+ lyxerr[Debug::MATHED] << "Clearing sel " << endl;
selection = false;
delete selstk;
selstk = 0;
// If unbalanced, balance them
while (d != 0) {
if (d<0) {
-// fprintf(stderr, "b[%d %d %d %d]", mathstk.Level(), selstk->Level(), anchor->GetX(), cursor->GetX());
+// lyxerr << "b[" << mathstk.Level() << " " << selstk->Level << " " << anchor->GetX() << " " << cursor->GetX() << "]";
anchor = selstk->pop();
if (anchor->GetX() >= cursor->GetX())
anchor->Next();
} else {
-// fprintf(stderr, "a[%d %d]", mathstk.Level(), selstk->Level());
+// lyxerr <<"a[" << mathstk.Level() << " " << selstk->Level() <<"]";
Pop();
}
d = mathstk.Level() - selstk->Level();
point[i].x = point[0].x;
point[i++].y = point[0].y;
np = i;
-// fprintf(stderr, "AN[%d %d %d %d] ", x, y, x1, y1);
-// fprintf(stderr, "MT[%d %d %d %d] ", a, d, a1, d1);
+// lyxerr << "AN[" << x << " " << y << " " << x1 << " " << y1 << "] ";
+// lyxerr << "MT[" << a << " " << d << " " << a1 << " " << d1 << "] ";
// for (i=0; i<np; i++)
-// fprintf(stderr, "XY[%d %d] ", point[i].x, point[i].y);
+// lyxerr << "XY[" << point[i].x << " " << point[i].y << "] ";
return &point[0];
}