#include "LyXView.h"
#include "Painter.h"
#include "font.h"
+#include "support/lyxlib.h"
using std::ostream;
using std::istream;
static LyXFont::FONT_SIZE lfont_size = LyXFont::SIZE_NORMAL;
-// local global
-static int sel_x, sel_y;
+// local global
+static int sel_x;
+static int sel_y;
static bool sel_flag;
+
MathedCursor * InsetFormula::mathcursor = 0;
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);
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)
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);
}
}
-Inset * InsetFormula::Clone() const
+Inset * InsetFormula::Clone(Buffer const &) const
{
InsetFormula * f = new InsetFormula(par);
f->label = label;
}
-int InsetFormula::Ascii(Buffer const *, ostream & os) const
+int InsetFormula::Ascii(Buffer const *, ostream & os, int) const
{
par->Write(os, false);
return 0;
int InsetFormula::Linuxdoc(Buffer const * buf, ostream & os) const
{
- return Ascii(buf, os);
+ return Ascii(buf, os, 0);
}
int InsetFormula::DocBook(Buffer const * buf, ostream & os) const
{
- return Ascii(buf, os);
+ return Ascii(buf, os, 0);
}
if (!mathcursor)
return;
- int x, y;
+ int x;
+ int y;
mathcursor->GetPos(x, y);
// x -= par->xo;
y -= par->yo;
}
-void InsetFormula::ShowInsetCursor(BufferView * bv)
+void InsetFormula::ShowInsetCursor(BufferView * bv, bool)
{
if (!cursor_visible) {
if (mathcursor) {
- int x, y;
+ int x;
+ int y;
mathcursor->GetPos(x, y);
// x -= par->xo;
y -= par->yo;
//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;
mathcursor->SelStart();
ShowInsetCursor(bv);
mathcursor->GetPos(sel_x, sel_y);
- } else
- if (sel_flag) {
+ } else if (sel_flag) {
HideInsetCursor(bv);
x += par->xo;
y += par->yo;
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;
}
case LFUN_DELETE:
- //current_view->lockedInsetStoreUndo(Undo::INSERT);
- bv->lockedInsetStoreUndo(Undo::DELETE);
+ bv->lockedInsetStoreUndo(Undo::DELETE);
mathcursor->Delete();
bv->updateInset(this, true);
break;
// break;
case LFUN_SETXY:
{
- int x, y, x1, y1;
+ int x;
+ int y;
+ int x1;
+ int y1;
istringstream ist(arg.c_str());
ist >> x >> y;
par->GetXY(x1, y1);
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';
}
case LFUN_MATH_DISPLAY:
- //current_view->lockedInsetStoreUndo(Undo::INSERT);
- bv->lockedInsetStoreUndo(Undo::EDIT);
+ bv->lockedInsetStoreUndo(Undo::EDIT);
display(!disp_flag);
UpdateLocal(bv);
break;
//------- dummy actions
case LFUN_EXEC_COMMAND:
- bv->owner()->getMiniBuffer()->ExecCommand();
+ bv->owner()->getMiniBuffer()->PrepareForCommand();
break;
default:
result = FINISHED;
}
} else
- if (c == '\'') {
+ if (c == '\'' || c == '@') {
mathcursor->Insert (c, LM_TC_VAR);
} else
if (c == '\\') {