};
///
- LyxArrayBase(int size=ARRAY_STEP);
+ LyxArrayBase(int size= ARRAY_STEP);
///
LyxArrayBase(const LyxArrayBase&);
///
///
- int Empty() { return (last==0); }
+ int Empty() { return (last == 0); }
///
int Last() { return last; }
byte operator[](const int);
/// Constructs a new array with dx elements starting at pos
- LyxArrayBase& operator=(const LyxArrayBase&);
+ LyxArrayBase& operator= (const LyxArrayBase&);
protected:
///
}
inline
-LyxArrayBase& LyxArrayBase::operator=(const LyxArrayBase& a)
+LyxArrayBase& LyxArrayBase::operator= (const LyxArrayBase& a)
{
if (this != &a) {
Resize(a.maxsize);
bool LyxArrayBase::Move(int p, int shift)
{
bool result = false;
- if (p<=last) {
- if (last+shift>=maxsize) {
+ if (p<= last) {
+ if (last+shift>= maxsize) {
Resize(last + shift);
}
memmove(&bf[p+shift], &bf[p], last-p);
void LyxArrayBase::Insert(int pos, byte c)
{
if (pos<0) pos = last;
- if (pos>=maxsize)
+ if (pos>= maxsize)
Resize(maxsize+ARRAY_STEP);
bf[pos] = c;
- if (pos>=last)
+ if (pos>= last)
last = pos+1;
}
// wrong name on this one should be called "IsAscii"
inline bool IsAlpha(char c)
{
- return ('A' <= c && c<='Z' || 'a' <= c && c<='z');
+ return ('A' <= c && c<= 'Z' || 'a' <= c && c<= 'z');
}
inline bool IsDigit(char c)
{
- return ('0' <= c && c <='9');
+ return ('0' <= c && c <= '9');
}
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));
+ return (token!= LM_TK_FRAC && token!= LM_TK_SQRT &&
+ !((token == LM_TK_SYM || token == LM_TC_BSYM) && id<255));
}
void mathedValidate(LaTeXFeatures &features, MathParInset *par);
switch (size) {
case LM_ST_DISPLAY:
- if (type==LM_TC_BSYM) {
+ if (type == LM_TC_BSYM) {
f.incSize();
f.incSize();
}
break;
}
- if (type!=LM_TC_TEXTRM)
+ if (type!= LM_TC_TEXTRM)
f.setColor(LyXFont::MATH);
return f;
}
Math_Fonts = new LyXFont[8]; //DEC cxx cannot initialize all fonts
//at once (JMarc) rc
- for (int i=0 ; i<8 ; i++){
+ for (int i= 0 ; i<8 ; i++){
Math_Fonts[i] = LyXFont::ALL_SANE;
}
Math_Fonts[0].setShape(LyXFont::ITALIC_SHAPE);
mathFrameGC = getGC(gc_math_frame);
}
LyXFont f = WhichFont(type, size);
- if (type==LM_TC_TEX) {
+ if (type == LM_TC_TEX) {
f.setLatex(LyXFont::ON);
latexGC = f.getGC();
} else
byte sx[80];
if (MathIsBinary(type)) {
byte *ps = &sx[0];
- for (int i=0; i<ls && i<75; i++) {
+ for (int i= 0; i<ls && i<75; i++) {
*(ps++) = ' ';
*(ps++) = s[i];
*(ps++) = ' ';
{
LyXFont font = WhichFont(type, size);
asc = des = 0;
- for (int i=0; i<ls; i++) {
+ for (int i= 0; i<ls; i++) {
if (font.descent(s[i]) > des)
des = font.descent(s[i]);
if (font.ascent(s[i]) > asc)
byte sx[80];
if (MathIsBinary(type)) {
byte *ps = &sx[0];
- for (int i=0; i<ls && i < 75; i++) {
+ for (int i= 0; i<ls && i < 75; i++) {
*(ps++) = ' ';
*(ps++) = s[i];
*(ps++) = ' ';
ls = 3*ls;
s = &sx[0];
}
- GC gc = (type==LM_TC_TEX) ? latexGC: mathGC;
+ GC gc = (type == LM_TC_TEX) ? latexGC: mathGC;
XDrawString(fl_display, pm, gc, x, y, reinterpret_cast<char*>(s), ls);
XFlush(fl_display);
}
InsetFormula::InsetFormula(MathParInset *p)
{
- par = (p->GetType()>=LM_OT_MPAR) ?
+ par = (p->GetType()>= LM_OT_MPAR) ?
new MathMatrixInset((MathMatrixInset*)p):
new MathParInset(p);
// mathcursor = 0;
lfont_size = f.size();
mathed_set_font(LM_TC_TEXTRM, LM_ST_TEXT); // otherwise a segfault could occur
// in some XDrawRectangles (i.e. matrix) (Matthias)
- if (mathcursor && mathcursor->GetPar()==par) {
+ if (mathcursor && mathcursor->GetPar() == par) {
if (mathcursor->Selection()) {
int n;
XPoint * p = mathcursor->SelGetArea(n);
}
x += (float)Width(f);
- if (par->GetType()==LM_OT_PARN || par->GetType()==LM_OT_MPARN) {
+ if (par->GetType() == LM_OT_PARN || par->GetType() == LM_OT_MPARN) {
char s[80];
LyXFont font = WhichFont(LM_TC_BF, par->size);
font.setLatex(LyXFont::OFF);
- if (par->GetType()==LM_OT_PARN) {
+ if (par->GetType() == LM_OT_PARN) {
if (!label.empty())
sprintf(s, "(%s)", label.c_str());
else
sprintf(s, "(#)");
font.drawString(s, pm, baseline, int(x+20));
} else
- if (par->GetType()==LM_OT_MPARN) {
+ if (par->GetType() == LM_OT_MPARN) {
MathMatrixInset *mt = (MathMatrixInset*)par;
- //int i=0;
+ //int i= 0;
int y;
MathedRowSt const* crow = mt->getRowSt();
while (crow) {
void InsetFormula::SetDisplay(bool dspf)
{
- if (dspf!=disp_flag) {
+ if (dspf!= disp_flag) {
if (dspf) {
par->SetType(LM_OT_PAR);
par->SetStyle(LM_ST_DISPLAY);
} else {
- if (par->GetType()>=LM_OT_MPAR) {
+ if (par->GetType()>= LM_OT_MPAR) {
MathParInset *p = new MathParInset(par);
delete par;
par = p;
}
par->SetType(LM_OT_MIN);
par->SetStyle(LM_ST_TEXT);
- if (!label.empty() && par->GetType()!=LM_OT_MPARN) {
+ if (!label.empty() && par->GetType()!= LM_OT_MPARN) {
label.clear();
}
}
int InsetFormula::GetNumberOfLabels() const
{
// This is dirty, I know. I'll clean it at 0.13
- if (par->GetType()==LM_OT_MPARN) {
+ if (par->GetType() == LM_OT_MPARN) {
MathMatrixInset *mt = (MathMatrixInset*)par;
- int nl=0;
+ int nl= 0;
MathedRowSt const* crow = mt->getRowSt();
while (crow) {
if (crow->getLabel()) nl++;
{
//#warning This is dirty, I know. Ill clean it at 0.11
// Correction, the only way to clean this is with a new kernel: 0.13.
- if (par->GetType()==LM_OT_MPARN) {
+ if (par->GetType() == LM_OT_MPARN) {
string lab;
MathMatrixInset * mt = (MathMatrixInset*)par;
- int nl=0;
+ int nl= 0;
MathedRowSt const * crow = mt->getRowSt();
while (crow) {
if (crow->getLabel()) {
- if (nl==il) {
+ if (nl == il) {
lab = crow->getLabel();
break;
}
if (sel_flag) {
sel_flag = false;
sel_x = sel_y = 0;
- UpdateInset(this,false);
+ UpdateInset(this, false);
}
}
mathcursor->SetPos(x, y);
ShowInsetCursor();
mathcursor->GetPos(x, y);
- if (sel_x!=x || sel_y!=y)
+ if (sel_x!= x || sel_y!= y)
UpdateInset(this, false);
sel_x = x; sel_y = y;
}
{
if (disp_flag) {
short type = par->GetType();
- bool oldf = (type==LM_OT_PARN || type==LM_OT_MPARN);
+ bool oldf = (type == LM_OT_PARN || type == LM_OT_MPARN);
if (numbf && !oldf) type++;
if (!numbf && oldf) type--;
par->SetType(type);
// extern char *dispatch_result;
MathedTextCodes varcode = LM_TC_MIN;
bool was_macro = mathcursor->InMacroMode();
- bool sel=false;
+ bool sel= false;
bool space_on = false;
bool was_selection = mathcursor->Selection();
bool result = true;
- static MathSpaceInset* sp=0;
+ static MathSpaceInset* sp= 0;
HideInsetCursor();
if (mathcursor->Selection() && (fast_selection || mono_video)) ToggleInsetSelection();
- if (mathcursor->getLastCode()==LM_TC_TEX) {
+ if (mathcursor->getLastCode() == LM_TC_TEX) {
varcode = LM_TC_TEX;
}
switch (action) {
LockedInsetStoreUndo(Undo::INSERT);
if (disp_flag) {
short type = par->GetType();
- bool oldf = (type==LM_OT_PARN || type==LM_OT_MPARN);
+ bool oldf = (type == LM_OT_PARN || type == LM_OT_MPARN);
if (oldf) {
type--;
if (!label.empty()) {
case LFUN_MATH_NONUMBER:
{
- if (par->GetType()==LM_OT_MPARN) {
+ if (par->GetType() == LM_OT_MPARN) {
// MathMatrixInset *mt = (MathMatrixInset*)par;
//BUG
// mt->SetNumbered(!mt->IsNumbered());
int k, m, n;
char s[80], arg2[80];
// This is just so that too long args won't ooze out of s.
- strncpy(arg2,arg,80); arg2[79]=(char)0;
+ strncpy(arg2, arg, 80); arg2[79]= (char)0;
k = sscanf(arg2, "%d %d %s", &m, &n, s);
s[79] = (char)0;
if (k<1) {
m = n = 1;
- } else if (k==1) {
+ } else if (k == 1) {
n = 1;
}
string vdelim("(){}[]./|");
if (!arg) break;
- strncpy(arg2,arg,40); arg2[39]=(char)0;
+ strncpy(arg2, arg, 40); arg2[39]= (char)0;
int n = sscanf(arg2, "%s %s", lf, rg);
lf[39] = (char)0; rg[39] = (char)0;
else
if (lf[1]) {
l = in_word_set(lf, strlen(lf));
- // Long words will cause l==0; so check.
+ // Long words will cause l == 0; so check.
if(l) ilf = l->id;
} else
if (vdelim.find(lf[0]) != string::npos)
lb = string(askForText(_("Enter new label to insert:")));
if (!lb.empty() && lb[0]> ' ') {
SetNumber(true);
- if (par->GetType()==LM_OT_MPARN) {
+ if (par->GetType() == LM_OT_MPARN) {
mathcursor->setLabel(lb.c_str());
// MathMatrixInset *mt = (MathMatrixInset*)par;
// mt->SetLabel(lb);
// Invalid actions under math mode
case LFUN_MATH_MODE:
{
- if (mathcursor->getLastCode()!=LM_TC_TEXTRM) {
+ if (mathcursor->getLastCode()!= LM_TC_TEXTRM) {
minibuffer->Set(_("math text mode"));
varcode = LM_TC_TEXTRM;
} else {
break;
default:
- if ((action==-1 || action==LFUN_SELFINSERT) && arg) {
+ if ((action == -1 || action == LFUN_SELFINSERT) && arg) {
unsigned char c = arg[0];
LockedInsetStoreUndo(Undo::INSERT);
- if (c==' ' && mathcursor->getAccent()==LM_hat) {
+ if (c == ' ' && mathcursor->getAccent() == LM_hat) {
c = '^';
mathcursor->setAccent(0);
}
- if (c==0) { // Dead key, do nothing
+ if (c == 0) { // Dead key, do nothing
//lyxerr << "deadkey" << endl;
break;
}
if (isalpha(c)) {
- if (mathcursor->getLastCode()==LM_TC_TEX) {
+ if (mathcursor->getLastCode() == LM_TC_TEX) {
mathcursor->MacroModeOpen();
mathcursor->clearLastCode();
varcode = LM_TC_MIN;
varcode = LM_TC_MIN;
if (greek_kb_flag<2) greek_kb_flag = 0;
} else
- if (strchr("!,:;{}", c) && (varcode==LM_TC_TEX||was_macro)) {
+ if (strchr("!,:;{}", c) && (varcode == LM_TC_TEX||was_macro)) {
mathcursor->Insert(c, LM_TC_TEX);
- if (c=='{') {
+ if (c == '{') {
mathcursor->Insert('}', LM_TC_TEX);
mathcursor->Left();
}
mathcursor->clearLastCode();
// varcode = LM_TC_MIN;
} else
- if (c=='_' && varcode==LM_TC_TEX) {
+ if (c == '_' && varcode == LM_TC_TEX) {
mathcursor->Insert(c, LM_TC_SPECIAL);
mathcursor->clearLastCode();
// varcode = LM_TC_MIN;
} else
- if (('0'<=c && c<='9') && (varcode==LM_TC_TEX||was_macro)) {
+ if (('0'<= c && c<= '9') && (varcode == LM_TC_TEX||was_macro)) {
mathcursor->MacroModeOpen();
mathcursor->clearLastCode();
mathcursor->Insert(c, LM_TC_MIN);
}
else
- if (('0'<=c && c<='9') || strchr(";:!|[]().,?", c))
+ if (('0'<= c && c<= '9') || strchr(";:!|[]().,?", c))
mathcursor->Insert(c, LM_TC_CONST);
else
- if (strchr("+/-*<>=", c))
+ if (strchr("+/-*<>= ", c))
mathcursor->Insert(c, LM_TC_BOP);
else
- if (strchr(latex_special_chars, c) && c!='_')
+ if (strchr(latex_special_chars, c) && c!= '_')
mathcursor->Insert(c, LM_TC_SPECIAL);
else
- if (c=='_' || c=='^') {
+ if (c == '_' || c == '^') {
char s[2];
s[0] = c;
s[1] = 0;
mathcursor->Interpret (s);
} else
- if (c==' ') {
+ if (c == ' ') {
if (!varcode) {
short f = (mathcursor->getLastCode()) ?
mathcursor->getLastCode():
(MathedTextCodes)mathcursor->GetFCode();
varcode = MathIsAlphaFont(f) ? (MathedTextCodes)f:LM_TC_VAR;
}
- if (varcode==LM_TC_TEXTRM) {
+ if (varcode == LM_TC_TEXTRM) {
mathcursor->Insert(c, LM_TC_TEXTRM);
} else
if (was_macro)
result = false;
}
} else
- if (c=='\'') {
+ if (c == '\'') {
mathcursor->Insert (c, LM_TC_VAR);
} else
- if (c=='\\') {
+ if (c == '\\') {
if (was_macro)
mathcursor->MacroModeClose();
minibuffer->Set(_("TeX mode"));
result = false;
}
}
- if (was_macro!=mathcursor->InMacroMode()&&action>=0&&action!=LFUN_BACKSPACE)
+ if (was_macro!= mathcursor->InMacroMode()&&action>= 0&&action!= LFUN_BACKSPACE)
UpdateLocal();
if (sp && !space_on) sp = 0;
if (mathcursor->Selection() || (was_selection && !(fast_selection || mono_video)))
font.setLatex(LyXFont::ON);
x += (font.textWidth("I", 1)+3)/4;
if (mono_video) {
- int a=font.maxAscent(), d=font.maxDescent();
+ int a= font.maxAscent(), d= font.maxDescent();
XFillRectangle (fl_display, pm, getGC(gc_copy),
x, y-a,
font.textWidth(name, strlen(name)), a+d);
if (it.IsInset()) {
if(it.IsActive()) {
MathParInset *p = it.GetActiveInset();
- if (!features.binom && p->GetType()==LM_OT_MACRO &&
- strcmp(p->GetName(), "binom")==0) {
+ if (!features.binom && p->GetType() == LM_OT_MACRO &&
+ strcmp(p->GetName(), "binom") == 0) {
features.binom = true;
} else {
- for (int i=0; i<=p->getMaxArgumentIdx(); i++) {
+ for (int i= 0; i<= p->getMaxArgumentIdx(); i++) {
p->setArgumentIdx(i);
mathedValidate(features, p);
}
} else {
MathedInset* p = it.GetInset();
if (!features.boldsymbol && p->GetName() &&
- strcmp(p->GetName(), "boldsymbol")==0) {
+ strcmp(p->GetName(), "boldsymbol") == 0) {
features.boldsymbol = true;
}
}
* the GNU General Public Licence version 2 or later.
*/
-#ifndef _INSET_FORMULA_H
-#define _INSET_FORMULA_H
+#ifndef INSET_FORMULA_H
+#define INSET_FORMULA_H
#ifdef __GNUG__
#pragma interface
#endif
-#include "definitions.h"
#include "insets/lyxinset.h"
class InsetFormula: public UpdatableInset {
public:
///
- InsetFormula(bool display=false);
+ InsetFormula(bool display = false);
///
- InsetFormula(MathParInset*);
+ InsetFormula(MathParInset *);
///
~InsetFormula();
///
- int Ascent(LyXFont const &font) const;
+ int Ascent(LyXFont const & font) const;
///
- int Descent(LyXFont const &font) const;
+ int Descent(LyXFont const & font) const;
///
- int Width(LyXFont const &font) const;
+ int Width(LyXFont const & font) const;
///
- void Draw(LyXFont font, LyXScreen &scr, int baseline, float &x);
+ void Draw(LyXFont font, LyXScreen & scr, int baseline, float & x);
///
- void Write(FILE *file);
+ void Write(FILE * file);
///
- void Read(LyXLex &lex);
+ void Read(LyXLex & lex);
///
- int Latex(FILE *file, signed char fragile);
+ int Latex(FILE * file, signed char fragile);
///
- int Latex(string &file, signed char fragile);
+ int Latex(string & file, signed char fragile);
///
- int Linuxdoc(string &file);
+ int Linuxdoc(string & file);
///
- int DocBook(string &file);
+ int DocBook(string & file);
///
void Validate(LaTeXFeatures &) const;
///
- Inset* Clone();
+ Inset * Clone();
///
Inset::Code LyxCode() const { return Inset::MATH_CODE; }
///
}
/// what appears in the minibuffer when opening
- char const* EditMessage() {return _("Math editor mode");}
+ char const * EditMessage() {return _("Math editor mode");}
///
void Edit(int x, int y);
///
///
void HideInsetCursor();
///
- void GetCursorPos(int&, int&);
+ void GetCursorPos(int &, int &);
///
void ToggleInsetSelection();
///
///
void InsetButtonRelease(int x, int y, int button);
///
- void InsetKeyPress(XKeyEvent *ev);
+ void InsetKeyPress(XKeyEvent * ev);
///
void InsetMotionNotify(int x, int y, int state);
///
void InsetUnlock();
/// To allow transparent use of math editing functions
- virtual bool LocalDispatch(int, char const*);
+ virtual bool LocalDispatch(int, char const *);
///
- void InsertSymbol(char const*);
+ void InsertSymbol(char const *);
///
bool SetNumber(bool);
///
protected:
void UpdateLocal();
- MathParInset* par;
+ MathParInset * par;
static MathedCursor* mathcursor;
private:
bool disp_flag;
- //char *label;
string label;
};
bool OpenMathInset(Buffer *);
#endif
-
} else {
font.setColor(LyXFont::MATH);
- int y=baseline - Ascent(font)+1;
- int w=Width(font) - 2, h=(Ascent(font)+Descent(font)-2);
+ int y= baseline - Ascent(font)+1;
+ int w= Width(font) - 2, h= (Ascent(font)+Descent(font)-2);
scr.fillRectangle(gc_lighted, int(x), y, w, h);
bool InsetFormulaMacro::LocalDispatch(int action, char const *arg)
{
- if (action==LFUN_MATH_MACROARG) {
+ if (action == LFUN_MATH_MACROARG) {
int i = atoi(arg) - 1;
- if (i>=0 && i<tmacro->getNoArgs()) {
+ if (i>= 0 && i<tmacro->getNoArgs()) {
mathcursor->Insert(tmacro->getMacroPar(i), LM_TC_INSET);
InsetFormula::UpdateLocal();
}
* the GNU General Public Licence version 2 or later.
*/
-#ifndef _INSET_FORMULA_MACRO_H
-#define _INSET_FORMULA_MACRO_H
+#ifndef INSET_FORMULA_MACRO_H
+#define INSET_FORMULA_MACRO_H
#ifdef __GNUG__
#pragma interface
///
InsetFormulaMacro();
///
- InsetFormulaMacro(string name, int na=0, bool env=false);
+ InsetFormulaMacro(string name, int na= 0, bool env= false);
///
~InsetFormulaMacro();
///
extern GC canvasGC, mathGC, latexGC, cursorGC, mathFrameGC;
-static LyxArrayBase *selarray=0;
+static LyxArrayBase *selarray= 0;
inline bool IsAlpha(char c)
{
- return ('A' <= c && c<='Z' || 'a' <= c && c<='z');
+ return ('A' <= c && c<= 'Z' || 'a' <= c && c<= 'z');
}
// This was very smaller, I'll change it later
int i, imax;
MathedXIter *item;
- MathStackXIter(int n=MAX_STACK_ITEMS): imax(n) {
+ MathStackXIter(int n= MAX_STACK_ITEMS): imax(n) {
item = new MathedXIter[imax];
i = 0;
}
}
int Full() {
- return (i>=MAX_STACK_ITEMS);
+ return (i>= MAX_STACK_ITEMS);
}
int Empty() {
- return (i<=1);
+ return (i<= 1);
}
int Level() { return i; }
-} mathstk, *selstk=0;
+} mathstk, *selstk= 0;
MathStackXIter::MathStackXIter(MathStackXIter &stk) {
imax = stk.imax;
item = new MathedXIter[imax];
i = stk.i;
- for (int k=0; k<i; k++) {
+ for (int k= 0; k<i; k++) {
item[k].SetData(stk.item[k].getPar());
item[k].GoBegin();
item[k].goPosAbs(stk.item[k].getPos());
if (par->GetType()>LM_OT_PAR) { a += 4; h += 8; }
if (!canvasGC) mathed_set_font(LM_TC_VAR, 1);
- // XFillRectangle(fl_display,pm, canvasGC, x, y-a, w, h);
- XDrawRectangle(fl_display,pm, mathFrameGC, x-1, y-a, w, h);
+ // XFillRectangle(fl_display, pm, canvasGC, x, y-a, w, h);
+ XDrawRectangle(fl_display, pm, mathFrameGC, x-1, y-a, w, h);
XFlush(fl_display);
MathParInset::pm = pm;
par->Draw(x, y);
int x, y;
par->GetXY(x, y);
mathed_set_font(LM_TC_VAR, 1);
- XFillRectangle(fl_display, win,canvasGC,x, y-par->Ascent(), w, h);
+ XFillRectangle(fl_display, win, canvasGC, x, y-par->Ascent(), w, h);
XFlush(fl_display);
MathParInset::pm = win;
par->Draw(x, y);
} else
result = cursor->Next();
} else {
- if (cursor->GetChar()!=LM_TC_CR)
+ if (cursor->GetChar()!= LM_TC_CR)
result = cursor->Next();
if (!result && !mathstk.Empty()) {
cursor = mathstk.pop();
{
if (selection) SelDel();
- if (t==LM_TC_MIN)
+ if (t == LM_TC_MIN)
t = lastcode;
- if (macro_mode && !(MathIsAlphaFont(t) || t==LM_TC_MIN))
+ if (macro_mode && !(MathIsAlphaFont(t) || t == LM_TC_MIN))
MacroModeClose();
- if (t==LM_TC_CR) {
+ if (t == LM_TC_CR) {
MathParInset *p= cursor->p;
- if (p==par && p->GetType()<LM_OT_MPAR && p->GetType()>LM_OT_MIN) {
+ 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->SetType((p->GetType() == LM_OT_PARN) ? LM_OT_MPARN: LM_OT_MPAR);
mt->SetData(p->GetData());
p->SetData(0);//BUG duda
delete p;
cursor->addRow();
}
} else
- if (t==LM_TC_TAB) {
+ if (t == LM_TC_TAB) {
MathParInset *p = cursor->p;
if (p && p->Permit(LMPF_ALLOW_TAB)) {
if (c) {
} else
cursor->goNextColumn();
} else // Navigate between arguments
- if (p && p->GetType()==LM_OT_MACRO) {
+ if (p && p->GetType() == LM_OT_MACRO) {
if (p->getArgumentIdx() < p->getMaxArgumentIdx()) {
p->setArgumentIdx(p->getArgumentIdx()+1);
cursor->SetData(p);
}
} else {
if (macro_mode) {
- if (MathIsAlphaFont(t) || t==LM_TC_MIN) {
+ if (MathIsAlphaFont(t) || t == LM_TC_MIN) {
MacroModeInsert(c);
return;
}
if (cursor->Empty() && !mathstk.Empty()) {
cursor = mathstk.pop();
}
-// if (cursor->GetChar()!=LM_TC_TAB)
+// if (cursor->GetChar()!= LM_TC_TAB)
cursor->Delete();
cursor->checkTabs();
}
return;
}
MathParInset *p= cursor->p;
- if (p && (p->GetType()<=LM_OT_MATRIX && p->GetType()>=LM_OT_MPAR)) {
+ if (p && (p->GetType()<= LM_OT_MATRIX && p->GetType()>= LM_OT_MPAR)) {
cursor->delRow();
}
}
if (!result && cursor->p) {
p = cursor->p;
- if (p->GetType()==LM_OT_SCRIPT) {
+ if (p->GetType() == LM_OT_SCRIPT) {
MathedXIter *cx = mathstk.Item(1);
- bool is_down = (cx->GetChar()==LM_TC_DOWN);
+ bool is_down = (cx->GetChar() == LM_TC_DOWN);
cursor = mathstk.pop();
cursor->Next();
result = (is_down) ? true: Up();
result = cursor->Down();
if (!result && cursor->p) {
p= cursor->p;
- if (p->GetType()==LM_OT_SCRIPT) {
+ if (p->GetType() == LM_OT_SCRIPT) {
MathedXIter *cx = mathstk.Item(1);
- bool is_up = (cx->GetChar()==LM_TC_UP);
+ bool is_up = (cx->GetChar() == LM_TC_UP);
cursor = mathstk.pop();
cursor->Next();
result = (is_up) ? true: Down();
MathedInset *p = cursor->GetInset();
bool ol = p->GetLimits();
p->SetLimits(!ol);
- return (ol!=p->GetLimits());
+ return (ol!= p->GetLimits());
}
return false;
}
latexkeys *l = 0;
MathedTextCodes tcode = LM_TC_INSET;
- if (s[0]=='^' || s[0]=='_') {
+ if (s[0] == '^' || s[0] == '_') {
char c = cursor->GetChar();
- if (MathIsUp(c) && s[0]=='^' || MathIsDown(c) && s[0]=='_') {
+ if (MathIsUp(c) && s[0] == '^' || MathIsDown(c) && s[0] == '_') {
Push();
return;
} else // A script may be followed by a script
cursor->ipush();
cursor->Next();
c = cursor->GetChar();
- if (MathIsUp(c) && s[0]=='^' || MathIsDown(c) && s[0]=='_') {
+ if (MathIsUp(c) && s[0] == '^' || MathIsDown(c) && s[0] == '_') {
Push();
return;
} else
cursor->ipop();
}
p = new MathParInset(LM_ST_SCRIPT, "", LM_OT_SCRIPT);
- Insert (p, (s[0]=='_') ? LM_TC_DOWN: LM_TC_UP);
+ Insert (p, (s[0] == '_') ? LM_TC_DOWN: LM_TC_UP);
return;
} else
- if (s[0]=='!' || s[0]==',' || s[0]==':' || s[0]==';') {
- int sp = ((s[0]==',') ? 1:((s[0]==':') ? 2:((s[0]==';') ? 3: 0)));
+ if (s[0] == '!' || s[0] == ',' || s[0] == ':' || s[0] == ';') {
+ int sp = ((s[0] == ',') ? 1:((s[0] == ':') ? 2:((s[0] == ';') ? 3: 0)));
p = new MathSpaceInset(sp);
Insert(p);
return;
p = MathMacroTable::mathMTable.getMacro(s);
if (!p) {
lyxerr[Debug::MATHED] << "Macro2 " << s << ' ' << tcode << endl;
- if (strcmp("root", s)==0) {
+ if (strcmp("root", s) == 0) {
p = new MathRootInset();
tcode = LM_TC_ACTIVE_INSET;
} else
} else {
Left();
imacro->SetName(0);
- if (cursor->GetInset()->GetType()==LM_OT_ACCENT) {
+ if (cursor->GetInset()->GetType() == LM_OT_ACCENT) {
setAccent(((MathAccentInset*)cursor->GetInset())->getAccentCode());
}
cursor->Delete();
void MathedCursor::SelCut()
{
if (selection) {
- if (cursor->pos==selpos) return;
+ if (cursor->pos == selpos) return;
int p1, p2;
p1 = (cursor->pos < selpos) ? cursor->pos: selpos;
{
// lyxerr << "Deleting sel "
if (selection) {
- if (cursor->pos==selpos) return;
+ if (cursor->pos == selpos) return;
cursor->Clean(selpos);
cursor->Adjust();
SelClear();
point[i].x = x;
point[i++].y = y-a;
- if (y!=y1) {
+ if (y!= y1) {
point[i].x = xo + w;
point[i++].y = y-a;
if (x1<xo+w) {
point[i].x = x1;
point[i++].y = y1+d;
- if (y!=y1) {
+ if (y!= y1) {
point[i].x = xo;
point[i++].y = y1+d;
if (x>xo) {
np = i;
// lyxerr << "AN[" << x << " " << y << " " << x1 << " " << y1 << "] ";
// lyxerr << "MT[" << a << " " << d << " " << a1 << " " << d1 << "] ";
-// for (i=0; i<np; i++)
+// for (i= 0; i<np; i++)
// lyxerr << "XY[" << point[i].x << " " << point[i].y << "] ";
return &point[0];
{
MathedInset *ac = 0;
- for (int i=accent-1; i>=0; i--) {
- if (i==accent-1)
+ for (int i= accent-1; i>= 0; i--) {
+ if (i == accent-1)
ac = new MathAccentInset(c, t, nestaccent[i]);
else
ac = new MathAccentInset(ac, nestaccent[i]);
{
MathedInset *ac = 0;
- for (int i=accent-1; i>=0; i--) {
- if (i==accent-1)
+ for (int i= accent-1; i>= 0; i--) {
+ if (i == accent-1)
ac = new MathAccentInset(p, nestaccent[i]);
else
ac = new MathAccentInset(ac, nestaccent[i]);
* the GNU General Public Licence version 2 or later.
*/
-#ifndef __MATH_CURSOR__
-#define __MATH_CURSOR__
+#ifndef MATH_CURSOR
+#define MATH_CURSOR
#ifdef __GNUG__
#pragma interface
class MathedCursor {
public:
///
- MathedCursor(MathParInset *p);
+ MathedCursor(MathParInset * p);
///
~MathedCursor() { };
///
- void Insert(byte, MathedTextCodes t=LM_TC_MIN);
+ void Insert(byte, MathedTextCodes t = LM_TC_MIN);
///
- void Insert(MathedInset*, int t=LM_TC_INSET);
+ void Insert(MathedInset*, int t = LM_TC_INSET);
///
void Home();
///
void End();
///
- bool Right(bool sel=false);
+ bool Right(bool sel = false);
///
- bool Left(bool sel=false);
+ bool Left(bool sel = false);
///
- bool Up(bool sel=false);
+ bool Up(bool sel = false);
///
- bool Down(bool sel=false);
+ bool Down(bool sel = false);
///
bool Pop();
///
///
void SetPos(int, int);
///
- void GetPos(int& x, int& y) { cursor->GetPos(x, y); }
+ void GetPos(int & x, int & y) { cursor->GetPos(x, y); }
///
short GetFCode() { return cursor->FCode(); }
///
- MathParInset *GetPar() { return par; }
+ MathParInset * GetPar() { return par; }
///
- MathParInset *getCurrentPar() const { return cursor->p; }
+ MathParInset * getCurrentPar() const { return cursor->p; }
///
- void SetPar(MathParInset*);
+ void SetPar(MathParInset *);
///
- void Interpret(char const*);
+ void Interpret(char const *);
///
void SetSize(short);
///
void setNumbered();
- void setLabel(char const*);
+ void setLabel(char const *);
///
bool Limits();
- /// Set accent: if argument=0 it's considered consumed
- void setAccent(int ac=0);
+ /// Set accent: if argument = 0 it's considered consumed
+ void setAccent(int ac = 0);
/// Returns last accent
int getAccent() const;
///
///
void SelBalance();
///
- XPoint *SelGetArea(int&);
+ XPoint * SelGetArea(int &);
///
void clearLastCode() { lastcode = LM_TC_MIN; }
///
///
int selpos;
///
- MathedXIter cursel, *anchor;
+ MathedXIter cursel, * anchor;
///
// LyxArrayBase *selarray;
///
///
long unsigned win;
///
- MathParInset *par;
+ MathParInset * par;
///
- MathedXIter *cursor;
+ MathedXIter * cursor;
///
int xc, yc;
///
void doAccent(byte c, MathedTextCodes t);
///
- void doAccent(MathedInset *p);
+ void doAccent(MathedInset * p);
///
int accent;
///
///
int macroln;
///
- MathFuncInset* imacro;
+ MathFuncInset * imacro;
};
#endif
-
/// Standard Math Sizes (Math mode styles)
enum MathedStyles {
///
- LM_ST_DISPLAY=0,
+ LM_ST_DISPLAY= 0,
///
LM_ST_TEXT,
///
/// Standard LaTeX Math Environments
enum MathedEnvironment {
///
- LM_EN_INTEXT=0,
+ LM_EN_INTEXT= 0,
///
LM_EN_DISPLAY,
///
virtual ~MathedInset() { };
/// Draw the object
- virtual void Draw(int x, int baseline)=0;
+ virtual void Draw(int x, int baseline)= 0;
/// Write LaTeX and Lyx code
- virtual void Write(FILE *file)=0;
+ virtual void Write(FILE *file)= 0;
/// Write LaTeX and Lyx code
- virtual void Write(string & file)=0;
+ virtual void Write(string & file)= 0;
/// Reproduces itself
- virtual MathedInset *Clone()=0;
+ virtual MathedInset *Clone()= 0;
/// Compute the size of the object
- virtual void Metrics()=0;
+ virtual void Metrics()= 0;
///
virtual int Ascent() const { return ascent; }
///
class MathParInset: public MathedInset {
public:
///
- MathParInset(short st=LM_ST_TEXT, char const *nm=0, short ot=LM_OT_MIN);
+ MathParInset(short st= LM_ST_TEXT, char const *nm= 0, short ot= LM_OT_MIN);
///
MathParInset(MathParInset*);
///
/// Paragraph position
virtual void GetXY(int&, int&) const;
///
- virtual void setXY(int x, int y) { xo =x; yo = y; }
+ virtual void setXY(int x, int y) { xo = x; yo = y; }
///
- virtual void SetFocus(int,int) { };
+ virtual void SetFocus(int, int) { };
///
virtual bool Inside(int, int);
// Vertical switching
///
- virtual bool setArgumentIdx(int i) { return (i==0); }
+ virtual bool setArgumentIdx(int i) { return (i == 0); }
///
virtual bool setNextArgIdx() { return false; }
///
///
friend class MathedCursor;
///
- friend LyxArrayBase *mathed_parse(unsigned flags = 0, LyxArrayBase*a=0, MathParInset**p=0);
+ friend LyxArrayBase *mathed_parse(unsigned flags = 0, LyxArrayBase*a= 0, MathParInset**p= 0);
};
class MathMatrixInset: public MathParInset {
public:
///
- MathMatrixInset(int m=1, int n=1, short st=LM_ST_TEXT);
+ MathMatrixInset(int m= 1, int n= 1, short st= LM_ST_TEXT);
///
MathMatrixInset(MathMatrixInset*);
///
///
LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *data, MathParInset **mt);
///
-void mathed_write(MathParInset*, FILE *, int*, char fragile, char const* label=0);
+void mathed_write(MathParInset*, FILE *, int*, char fragile, char const* label= 0);
///
-void mathed_write(MathParInset*, string&, int*, char fragile, char const* label=0);
+void mathed_write(MathParInset*, string &, int*, char fragile, char const* label= 0);
///
void mathed_parser_file(FILE*, int);
///
/************************ Inline functions ********************************/
///
-#define MathIsInset(x) (LM_TC_INSET<=(x) && (x)<=LM_TC_ACTIVE_INSET)
+#define MathIsInset(x) (LM_TC_INSET<= (x) && (x)<= LM_TC_ACTIVE_INSET)
///
-#define MathIsFont(x) (LM_TC_CONST<=(x) && (x)<=LM_TC_BSYM)
+#define MathIsFont(x) (LM_TC_CONST<= (x) && (x)<= LM_TC_BSYM)
///
-#define MathIsAlphaFont(x) (LM_TC_VAR<=(x) && (x)<=LM_TC_TEXTRM)
+#define MathIsAlphaFont(x) (LM_TC_VAR<= (x) && (x)<= LM_TC_TEXTRM)
///
-#define MathIsActive(x) (LM_TC_INSET<(x) && (x)<=LM_TC_ACTIVE_INSET)
+#define MathIsActive(x) (LM_TC_INSET<(x) && (x)<= LM_TC_ACTIVE_INSET)
///
-#define MathIsUp(x) ((x)==LM_TC_UP)
+#define MathIsUp(x) ((x) == LM_TC_UP)
///
-#define MathIsDown(x) ((x)==LM_TC_DOWN)
+#define MathIsDown(x) ((x) == LM_TC_DOWN)
///
-#define MathIsScript(x) ((x)==LM_TC_DOWN || (x)==LM_TC_UP)
+#define MathIsScript(x) ((x) == LM_TC_DOWN || (x) == LM_TC_UP)
///
#define MathIsBOPS(x) (MathedLookupBOP(x)>LMB_NONE)
///
inline bool MathIsBinary(short x)
{
- return (x==LM_TC_BOP || x==LM_TC_BOPS);
+ return (x == LM_TC_BOP || x == LM_TC_BOPS);
}
///
inline bool MathIsSymbol(short x) {
- return (LM_TC_SYMB<=x && x<=LM_TC_BSYM);
+ return (LM_TC_SYMB<= x && x<= LM_TC_BSYM);
}
inline
bool MathParInset::Inside(int x, int y)
{
- return (x>=xo && x<=xo+width && y<=yo+descent && y>=yo-ascent);
+ return (x>= xo && x<= xo+width && y<= yo+descent && y>= yo-ascent);
}
inline
void MathParInset::UserSetSize(short sz)
{
- if (sz>=0) {
+ if (sz>= 0) {
size = sz;
flag = flag & ~LMPF_FIXED_SIZE;
}
typedef float matriz_data[2][2];
-const matriz_data MATIDEN={ {1,0}, {0,1}};
+const matriz_data MATIDEN= { {1, 0}, {0, 1}};
extern void mathed_set_font(short type, int style);
extern int mathed_char_width(short type, int style, byte c);
extern int mathed_char_height(short, int, byte, int&, int&);
-#define mateq(m1,m2) memcpy(m1,m2,sizeof(matriz_data))
+#define mateq(m1, m2) memcpy(m1, m2, sizeof(matriz_data))
class Matriz {
public:
- Matriz() { mateq(m,MATIDEN); }
+ Matriz() { mateq(m, MATIDEN); }
void rota(int);
void escala(float, float);
void transf(float, float, float&, float&);
float cs, sn;
matriz_data r;
- mateq(r,MATIDEN);
+ mateq(r, MATIDEN);
cs = (odd(code)) ? 0: 1 - code;
sn = (odd(code)) ? 2 - code: 0;
r[0][0] = cs; r[0][1] = sn;
void Matriz::escala(float x, float y)
{
matriz_data s;
- mateq(s,MATIDEN);
+ mateq(s, MATIDEN);
s[0][0] = x; s[1][1] = y;
matmat(s);
}
{
int i;
matriz_data c;
- for (i=0;i<2; i++) {
+ for (i= 0;i<2; i++) {
c[0][i] = a[0][0]*m[0][i] + a[0][1]*m[1][i];
c[1][i] = a[1][0]*m[0][i] + a[1][1]*m[1][i];
}
static int search_deco(int code)
{
- int i=0;
+ int i= 0;
- while (math_deco_table[i].code && math_deco_table[i].code!=code) i++;
+ while (math_deco_table[i].code && math_deco_table[i].code!= code) i++;
if (!math_deco_table[i].code) i = -1;
return i;
}
Matriz mt, sqmt;
XPoint p[32];
float *d, xx, yy, x2, y2;
- int i=0,j, n, r;
+ int i= 0, j, n, r;
j = search_deco(code);
if (j<0) return;
sqmt.rota(r);
sqmt.escala(n, n);
if (r> 0 && r< 3) y += h;
- if (r>=2) x += w;
+ if (r>= 2) x += w;
do {
code = (int)d[i++];
switch (code) {
{
xx = d[i++]; yy = d[i++];
x2 = d[i++]; y2 = d[i++];
- if (code==3)
+ if (code == 3)
sqmt.transf(xx, yy, xx, yy);
else
mt.transf(xx, yy, xx, yy);
case 4:
{
n = (int)d[i++];
- for (j=0; j<n; j++) {
+ for (j= 0; j<n; j++) {
xx = d[i++]; yy = d[i++];
// lyxerr << " " << xx << " " << yy << " ";
- if (code==4)
+ if (code == 4)
sqmt.transf(xx, yy, xx, yy);
else
mt.transf(xx, yy, xx, yy);
{
xo = x; yo = y;
MathParInset::Draw(x+dw+2, y-dh);
- //int h=Height(), hg=descent-1;
+ //int h= Height(), hg= descent-1;
- if (left=='.') {
+ if (left == '.') {
XDrawLine(fl_display, pm, cursorGC, x+4, yo-ascent, x+4, yo+descent);
XFlush(fl_display);
}
else
mathed_draw_deco(pm, x, y-ascent, dw, Height(), left);
x += Width()-dw-2;
- if (right=='.') {
+ if (right == '.') {
XDrawLine(fl_display, pm, cursorGC, x+4, yo-ascent, x+4, yo+descent);
XFlush(fl_display);
}
drawStr(fn, size, x, y, &c, 1);
XFlush(fl_display);
}
- x += (code==LM_not) ? (width-dw)/2: 2;
+ x += (code == LM_not) ? (width-dw)/2: 2;
mathed_draw_deco(pm, x, y-dy, dw, dh, code);
}
width = mathed_char_width(fn, size, c);
dh = (width-2)/2;
}
- if (code==LM_not) {
+ if (code == LM_not) {
ascent += dh;
descent += dh;
dh = Height();
MathDotsInset::Draw(int x, int y)
{
mathed_draw_deco(pm, x+2, y-dh, width-2, ascent, code);
- if (code==LM_vdots||code==LM_ddots) x++;
- if (code!=LM_vdots) y--;
+ if (code == LM_vdots||code == LM_ddots) x++;
+ if (code!= LM_vdots) y--;
mathed_draw_deco(pm, x+2, y-dh, width-2, ascent, code);
}
switch (code) {
case LM_ldots: dh = 0; break;
case LM_cdots: dh = ascent/2; break;
- case LM_vdots: width /=2;
+ case LM_vdots: width /= 2;
case LM_ddots: dh = ascent; break;
}
}
extern int mathed_string_height(short, int, byte const*, int, int&, int&);
extern int mathed_char_height(short, int, byte, int&, int&);
-GC canvasGC=0, mathGC=0, mathLineGC=0, latexGC=0, cursorGC=0, mathFrameGC=0;
+GC canvasGC= 0, mathGC= 0, mathLineGC= 0, latexGC= 0, cursorGC= 0, mathFrameGC= 0;
long unsigned int MathedInset::pm;
p[2].x = x+width-2; p[2].y = y;
p[3].x = x+width-2; p[3].y = y-3;
- XDrawLines(fl_display,pm,(space) ? latexGC: mathGC,p,4,CoordModeOrigin);
+ XDrawLines(fl_display, pm,(space) ? latexGC: mathGC, p, 4, CoordModeOrigin);
XFlush(fl_display);
}
void
MathParInset::Draw(int x, int y)
{
- byte cx, cxp=0;
- int xp=0, ls;
- int asc=df_asc, des=0;
+ byte cx, cxp= 0;
+ int xp= 0, ls;
+ int asc= df_asc, des= 0;
bool limits = false;
xo = x; yo = y;
MathedXIter data(this);
data.GetPos(x, y);
}
- XDrawRectangle(fl_display,pm,mathLineGC,x,y-df_asc, df_width, df_asc);
+ XDrawRectangle(fl_display, pm, mathLineGC, x, y-df_asc, df_width, df_asc);
XFlush(fl_display);
return;
}
mathed_char_height(data.FCode(), size, s[ls-1], asc, des);
limits = false;
} else {
- if (cx==0) break;
+ if (cx == 0) break;
if (MathIsInset(cx)) {
int yy = y;
MathedInset *p = data.GetInset();
- if (cx==LM_TC_UP) {
+ if (cx == LM_TC_UP) {
if (limits) {
x -= (xp>p->Width()) ? p->Width()+(xp-p->Width())/2: xp;
yy -= (asc + p->Descent()+4);
} else
yy -= (p->Descent()>asc) ? p->Descent()+4: asc;
} else
- if (cx==LM_TC_DOWN) {
+ if (cx == LM_TC_DOWN) {
if (limits) {
x -= (xp>p->Width()) ? p->Width()+(xp-p->Width())/2: xp;
yy += des + p->Ascent() + 2;
des = p->Descent();
}
p->Draw(x, yy);
- if (cx!=LM_TC_UP && cx!=LM_TC_DOWN) {
+ if (cx!= LM_TC_UP && cx!= LM_TC_DOWN) {
limits = p->GetLimits();
if (limits) xp = p->Width();
}
data.Next();
} else
- if (cx==LM_TC_TAB) {
- if ((cxp==cx || cxp==LM_TC_CR || data.IsFirst())) { // && objtype==L
- XDrawRectangle(fl_display,pm,mathLineGC,
- x,y-df_asc, df_width, df_asc);
+ if (cx == LM_TC_TAB) {
+ if ((cxp == cx || cxp == LM_TC_CR || data.IsFirst())) { // && objtype == L
+ XDrawRectangle(fl_display, pm, mathLineGC,
+ x, y-df_asc, df_width, df_asc);
}
XFlush(fl_display);
data.Next();
limits = false;
} else
- if (cx==LM_TC_CR) {
- if (cxp==LM_TC_TAB || cxp==LM_TC_CR || data.IsFirst()) { // && objtype==LM_OT_MATRIX) {
- XDrawRectangle(fl_display,pm,mathLineGC,x,y-df_asc, df_width, df_asc);
+ if (cx == LM_TC_CR) {
+ if (cxp == LM_TC_TAB || cxp == LM_TC_CR || data.IsFirst()) { // && objtype == LM_OT_MATRIX) {
+ XDrawRectangle(fl_display, pm, mathLineGC, x, y-df_asc, df_width, df_asc);
}
data.Next();
limits = false;
}
cxp = cx;
}
- if (cxp==LM_TC_TAB || cxp==LM_TC_CR) { // && objtype==LM_OT_MATRIX) {
+ if (cxp == LM_TC_TAB || cxp == LM_TC_CR) { // && objtype == LM_OT_MATRIX) {
data.GetPos(x, y);
- XDrawRectangle(fl_display,pm,mathLineGC,x,y-df_asc, df_width, df_asc);
+ XDrawRectangle(fl_display, pm, mathLineGC, x, y-df_asc, df_width, df_asc);
XFlush(fl_display);
}
}
void
MathParInset::Metrics()
{
- byte cx, cxp=0, *s;
+ byte cx, cxp= 0, *s;
int ls;
- int asc=df_asc, des=0;
- int tb = 0, tab=0;
+ int asc= df_asc, des= 0;
+ int tb = 0, tab= 0;
bool limits = false;
MathedInset *p = data.GetInset();
p->SetStyle(size);
p->Metrics();
- if (cx==LM_TC_UP) {
+ if (cx == LM_TC_UP) {
asc += (limits) ? p->Height()+4: p->Ascent() +
((p->Descent()>asc) ? p->Descent()-asc+4: 0);
} else
- if (cx==LM_TC_DOWN) {
+ if (cx == LM_TC_DOWN) {
des += ((limits) ? p->Height()+4: p->Height()-p->Ascent()/2);
} else {
asc = p->Ascent();
}
if (asc > ascent) ascent = asc;
if (des > descent) descent = des;
- if (cx!=LM_TC_UP && cx!=LM_TC_DOWN)
+ if (cx!= LM_TC_UP && cx!= LM_TC_DOWN)
limits = p->GetLimits();
data.Next();
} else
- if (cx==LM_TC_TAB) {
+ if (cx == LM_TC_TAB) {
int x, y;
data.GetIncPos(x, y);
- if (data.IsFirst() || cxp==LM_TC_TAB || cxp==LM_TC_CR) {
+ if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) {
if (ascent<df_asc) ascent = df_asc;
tb = x;
}
limits = false;
data.Next();
} else
- if (cx==LM_TC_CR) {
+ if (cx == LM_TC_CR) {
if (tb>0) {
int x, y;
data.GetIncPos(x, y);
- if (data.IsFirst() || cxp==LM_TC_TAB || cxp==LM_TC_CR) {
+ if (data.IsFirst() || cxp == LM_TC_TAB || cxp == LM_TC_CR) {
if (ascent<df_asc) ascent = df_asc;
tb = x;
}
data.setTab(x-tb, tab);
- } else //if (GetColumns()==1)
+ } else //if (GetColumns() == 1)
{
int x, y;
data.GetIncPos(x, y);
data.setTab(x, tab);
if (ascent<df_asc) ascent = df_asc;
}
- tb=tab=0;
+ tb= tab= 0;
data.subMetrics(ascent, descent);
ascent = df_asc;
descent = 0;
// No matter how simple is a matrix, it is NOT a subparagraph
if (isMatrix()) {
- if (cxp==LM_TC_TAB) {
+ if (cxp == LM_TC_TAB) {
if (ascent<df_asc) ascent = df_asc;
data.setTab(0, tab);
} else {
MathSqrtInset::Draw(int x, int y)
{
MathParInset::Draw(x+hmax+2, y);
- int h=ascent, d=descent, h2=Height()/2, w2 = (Height()>4*hmax)?hmax:hmax/2;
+ int h= ascent, d= descent, h2= Height()/2, w2 = (Height()>4*hmax)?hmax:hmax/2;
XPoint p[4];
p[0].x = x + hmax + wbody, p[0].y = y-h;
p[1].x = x+hmax, p[1].y = y-h;
p[2].x = x+w2, p[2].y = y+d;
p[3].x = x, p[3].y = y+d-h2;
- XDrawLines(fl_display, pm, mathLineGC,p, 4, CoordModeOrigin);
+ XDrawLines(fl_display, pm, mathLineGC, p, 4, CoordModeOrigin);
XFlush(fl_display);
}
ascent += 4;
descent += 2;
int a, b;
- hmax = mathed_char_height(LM_TC_VAR, size, 'I',a, b);
+ hmax = mathed_char_height(LM_TC_VAR, size, 'I', a, b);
if (hmax<10) hmax = 10;
wbody = width + 4;
width += hmax + 4;
short sizex = size;
idx = 0;
- if (size==LM_ST_DISPLAY) size++;
+ if (size == LM_ST_DISPLAY) size++;
MathParInset::Draw(x+(width-w0)/2, y - des0);
den->Draw(x+(width-w1)/2, y + den->Ascent() + 2 - dh);
size = sizex;
- if (objtype==LM_OT_FRAC)
+ if (objtype == LM_OT_FRAC)
XDrawLine(fl_display, pm, mathLineGC, x+2, y-dh, x+width-4, y - dh);
XFlush(fl_display);
idx = idxp;
short idxp = idx;
short sizex = size;
idx = 0;
- if (size==LM_ST_DISPLAY) size++;
+ if (size == LM_ST_DISPLAY) size++;
MathParInset::Metrics();
size = sizex;
w0 = width;
char const *s;
short t;
- if (sym<256 || sym==LM_oint) {
+ if (sym<256 || sym == LM_oint) {
ls = 1;
- c = (sym==LM_oint) ? LM_int: sym;
+ c = (sym == LM_oint) ? LM_int: sym;
s = &c;
t = LM_TC_BSYM;
} else {
t = LM_TC_TEXTRM;
}
mathed_set_font(t, size);
- if (sym==LM_oint) {
- XDrawArc(fl_display, pm, mathLineGC, x,y-5*width/4,width,width,0,23040);
+ if (sym == LM_oint) {
+ XDrawArc(fl_display, pm, mathLineGC, x, y-5*width/4, width, width, 0, 23040);
XFlush(fl_display);
x++;
}
char const *s;
short t;
- if (sym<256 || sym==LM_oint) {
+ if (sym<256 || sym == LM_oint) {
ls = 1;
- c = (sym==LM_oint) ? LM_int: sym;
+ c = (sym == LM_oint) ? LM_int: sym;
s = &c;
t = LM_TC_BSYM;
} else {
mathed_set_font(t, size);
mathed_string_height(t, size, reinterpret_cast<const unsigned char*>(s), ls, ascent, descent);
width = mathed_string_width(t, size, reinterpret_cast<const unsigned char*>(s), ls);
- if (sym==LM_oint) width += 2;
+ if (sym == LM_oint) width += 2;
}
/* Form definition file generated with fdesign. */
#include FORMS_H_LOCATION
-#include <stdlib.h>
+#include <cstdlib>
#include "math_panel.h"
FD_panel *create_form_panel(void)
FD_panel *fdui = (FD_panel *) fl_calloc(1, sizeof(FD_panel));
fdui->panel = fl_bgn_form(FL_NO_BOX, 290, 172);
- obj = fl_add_box(FL_UP_BOX,0,0,290,172,"");
- obj = fl_add_button(FL_RETURN_BUTTON,80,14,80,30,_("Close "));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,button_cb,100);
- fdui->func_browse = obj = fl_add_browser(FL_SELECT_BROWSER,180,40,94,110,_("Functions"));
- fl_set_object_lalign(obj,FL_ALIGN_TOP);
- fl_set_object_callback(obj,button_cb,MM_FUNC);
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 290, 172, "");
+ obj = fl_add_button(FL_RETURN_BUTTON, 80, 14, 80, 30, _("Close "));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, button_cb, 100);
+ fdui->func_browse = obj = fl_add_browser(FL_SELECT_BROWSER, 180, 40, 94, 110, _("Functions"));
+ fl_set_object_lalign(obj, FL_ALIGN_TOP);
+ fl_set_object_callback(obj, button_cb, MM_FUNC);
#if FL_REVISION > 85
fl_set_browser_hscrollbar(obj, FL_OFF);
#endif
- fdui->greek = obj = fl_add_button(FL_NORMAL_BUTTON,10,90,50,30,_("Greek"));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lstyle(obj,15);
- fl_set_object_callback(obj,button_cb,MM_GREEK);
- fdui->arrow = obj = fl_add_button(FL_NORMAL_BUTTON,10,120,50,30,_(" Û"));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lstyle(obj,15);
- fl_set_object_callback(obj,button_cb,MM_ARROW);
- fdui->boperator = obj = fl_add_button(FL_NORMAL_BUTTON,60,90,50,30,_("± ´"));
- fl_set_object_lsize(obj,0);
- fl_set_object_lstyle(obj,15);
- fl_set_object_callback(obj,button_cb,MM_BOP);
- fdui->brelats = obj = fl_add_button(FL_NORMAL_BUTTON,110,90,50,30,_("£ @"));
- fl_set_object_lsize(obj,0);
- fl_set_object_lstyle(obj,15);
- fl_set_object_callback(obj,button_cb,MM_BRELATS);
- fdui->varsize = obj = fl_add_button(FL_NORMAL_BUTTON,60,120,50,30,_("S ò"));
- fl_set_object_lsize(obj,0);
- fl_set_object_lstyle(obj,15);
- fl_set_object_callback(obj,button_cb,MM_VARSIZE);
- fdui->misc = obj = fl_add_button(FL_NORMAL_BUTTON,110,120,50,30,_("Misc"));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lstyle(obj,FL_TIMESITALIC_STYLE);
- fl_set_object_callback(obj,button_cb,MM_MISC);
- fdui->equation = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,130,50,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_callback(obj,button_cb,MM_EQU);
- fdui->sqrt = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,10,15,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_callback(obj,button_cb,MM_SQRT);
- fdui->frac = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,40,15,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_lcol(obj,FL_COL1);
- fl_set_object_callback(obj,button_cb,MM_FRAC);
- fdui->delim = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,10,50,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_callback(obj,button_cb,MM_DELIM);
- fdui->matrix = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,100,50,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_callback(obj,button_cb,MM_MATRIX);
- fdui->deco = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,40,50,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_callback(obj,button_cb,MM_DECO);
- fdui->space = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,70,50,30,30,"");
- fl_set_object_color(obj,FL_MCOL,FL_BLUE);
- fl_set_object_callback(obj,button_cb,MM_SPACE);
+ fdui->greek = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 90, 50, 30, _("Greek"));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lstyle(obj, 15);
+ fl_set_object_callback(obj, button_cb, MM_GREEK);
+ fdui->arrow = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 120, 50, 30, _(" Û"));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lstyle(obj, 15);
+ fl_set_object_callback(obj, button_cb, MM_ARROW);
+ fdui->boperator = obj = fl_add_button(FL_NORMAL_BUTTON, 60, 90, 50, 30, _("± ´"));
+ fl_set_object_lsize(obj, 0);
+ fl_set_object_lstyle(obj, 15);
+ fl_set_object_callback(obj, button_cb, MM_BOP);
+ fdui->brelats = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 90, 50, 30, _("£ @"));
+ fl_set_object_lsize(obj, 0);
+ fl_set_object_lstyle(obj, 15);
+ fl_set_object_callback(obj, button_cb, MM_BRELATS);
+ fdui->varsize = obj = fl_add_button(FL_NORMAL_BUTTON, 60, 120, 50, 30, _("S ò"));
+ fl_set_object_lsize(obj, 0);
+ fl_set_object_lstyle(obj, 15);
+ fl_set_object_callback(obj, button_cb, MM_VARSIZE);
+ fdui->misc = obj = fl_add_button(FL_NORMAL_BUTTON, 110, 120, 50, 30, _("Misc"));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lstyle(obj, FL_TIMESITALIC_STYLE);
+ fl_set_object_callback(obj, button_cb, MM_MISC);
+ fdui->equation = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 130, 50, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_callback(obj, button_cb, MM_EQU);
+ fdui->sqrt = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 10, 15, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_callback(obj, button_cb, MM_SQRT);
+ fdui->frac = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 40, 15, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_lcol(obj, FL_COL1);
+ fl_set_object_callback(obj, button_cb, MM_FRAC);
+ fdui->delim = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 10, 50, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_callback(obj, button_cb, MM_DELIM);
+ fdui->matrix = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 100, 50, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_callback(obj, button_cb, MM_MATRIX);
+ fdui->deco = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 40, 50, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_callback(obj, button_cb, MM_DECO);
+ fdui->space = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 70, 50, 30, 30, "");
+ fl_set_object_color(obj, FL_MCOL, FL_BLUE);
+ fl_set_object_callback(obj, button_cb, MM_SPACE);
fl_end_form();
//fdui->panel->fdui = fdui;
FD_delim *fdui = (FD_delim *) fl_calloc(1, sizeof(FD_delim));
fdui->delim = fl_bgn_form(FL_NO_BOX, 250, 260);
- obj = fl_add_box(FL_UP_BOX,0,0,250,260,"");
- fdui->menu = obj = fl_add_bmtable(FL_PUSH_BUTTON,40,70,170,140,"");
- fl_set_object_lcol(obj,FL_BLUE);
- fl_set_object_callback(obj,delim_cb,2);
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 250, 260, "");
+ fdui->menu = obj = fl_add_bmtable(FL_PUSH_BUTTON, 40, 70, 170, 140, "");
+ fl_set_object_lcol(obj, FL_BLUE);
+ fl_set_object_callback(obj, delim_cb, 2);
fdui->lado = fl_bgn_group();
- fdui->right = obj = fl_add_checkbutton(FL_RADIO_BUTTON,40,40,80,30,idex(_("Right|#R")));fl_set_button_shortcut(obj,scex(_("Right|#R")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,delim_cb,4);
- fdui->left = obj = fl_add_checkbutton(FL_RADIO_BUTTON,40,10,80,30,idex(_("Left|#L")));fl_set_button_shortcut(obj,scex(_("Left|#L")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,delim_cb,3);
+ fdui->right = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 40, 40, 80, 30, idex(_("Right|#R")));fl_set_button_shortcut(obj, scex(_("Right|#R")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, delim_cb, 4);
+ fdui->left = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 40, 10, 80, 30, idex(_("Left|#L")));fl_set_button_shortcut(obj, scex(_("Left|#L")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, delim_cb, 3);
fl_end_group();
- obj = fl_add_button(FL_NORMAL_BUTTON,170,220,70,30,idex(_("Cancel|^[")));fl_set_button_shortcut(obj,scex(_("Cancel|^[")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,delim_cb,MM_CLOSE);
- fdui->pix = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON,130,20,50,40,"");
- fl_set_object_color(obj,FL_COL1,FL_COL1);
- fl_set_object_callback(obj,delim_cb,MM_APPLY);
- obj = fl_add_button(FL_NORMAL_BUTTON,90,220,70,30,idex(_("Apply|#A")));fl_set_button_shortcut(obj,scex(_("Apply|#A")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,delim_cb,MM_APPLY);
- obj = fl_add_button(FL_RETURN_BUTTON,10,220,70,30,_("OK"));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,delim_cb,MM_OK);
+ obj = fl_add_button(FL_NORMAL_BUTTON, 170, 220, 70, 30, idex(_("Cancel|^[")));fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, delim_cb, MM_CLOSE);
+ fdui->pix = obj = fl_add_pixmapbutton(FL_NORMAL_BUTTON, 130, 20, 50, 40, "");
+ fl_set_object_color(obj, FL_COL1, FL_COL1);
+ fl_set_object_callback(obj, delim_cb, MM_APPLY);
+ obj = fl_add_button(FL_NORMAL_BUTTON, 90, 220, 70, 30, idex(_("Apply|#A")));fl_set_button_shortcut(obj, scex(_("Apply|#A")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, delim_cb, MM_APPLY);
+ obj = fl_add_button(FL_RETURN_BUTTON, 10, 220, 70, 30, _("OK"));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, delim_cb, MM_OK);
fl_end_form();
//fdui->delim->fdui = fdui;
FD_matrix *fdui = (FD_matrix *) fl_calloc(1, sizeof(FD_matrix));
fdui->matrix = fl_bgn_form(FL_NO_BOX, 280, 170);
- obj = fl_add_box(FL_UP_BOX,0,0,280,170,"");
- obj = fl_add_button(FL_RETURN_BUTTON,10,130,80,30,_("OK "));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,matrix_cb,MM_OK);
- obj = fl_add_button(FL_NORMAL_BUTTON,190,130,80,30,idex(_("Cancel|^[")));fl_set_button_shortcut(obj,scex(_("Cancel|^[")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,matrix_cb,MM_CLOSE);
- fdui->rows = obj = fl_add_valslider(FL_HOR_NICE_SLIDER,10,30,160,30,_("Rows"));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lalign(obj,FL_ALIGN_TOP);
- fl_set_object_callback(obj,matrix_cb,-1);
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 280, 170, "");
+ obj = fl_add_button(FL_RETURN_BUTTON, 10, 130, 80, 30, _("OK "));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, matrix_cb, MM_OK);
+ obj = fl_add_button(FL_NORMAL_BUTTON, 190, 130, 80, 30, idex(_("Cancel|^[")));fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, matrix_cb, MM_CLOSE);
+ fdui->rows = obj = fl_add_valslider(FL_HOR_NICE_SLIDER, 10, 30, 160, 30, _("Rows"));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lalign(obj, FL_ALIGN_TOP);
+ fl_set_object_callback(obj, matrix_cb,-1);
fl_set_slider_precision(obj, 0);
fl_set_slider_bounds(obj, 1, 20);
fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
- fdui->columns = obj = fl_add_valslider(FL_HOR_NICE_SLIDER,10,90,160,30,_("Columns "));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lalign(obj,FL_ALIGN_TOP);
- fl_set_object_callback(obj,matrix_cb,2);
+ fdui->columns = obj = fl_add_valslider(FL_HOR_NICE_SLIDER, 10, 90, 160, 30, _("Columns "));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lalign(obj, FL_ALIGN_TOP);
+ fl_set_object_callback(obj, matrix_cb, 2);
fl_set_slider_precision(obj, 0);
fl_set_slider_bounds(obj, 1, 20);
fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
- fdui->valign = obj = fl_add_choice(FL_NORMAL_CHOICE,180,30,90,30,idex(_("Vertical align|#V")));fl_set_button_shortcut(obj,scex(_("Vertical align|#V")),1);
- fl_set_object_boxtype(obj,FL_FRAME_BOX);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lalign(obj,FL_ALIGN_TOP);
- fl_set_object_callback(obj,matrix_cb,-1);
- fdui->halign = obj = fl_add_input(FL_NORMAL_INPUT,180,90,90,30,idex(_("Horizontal align|#H")));fl_set_button_shortcut(obj,scex(_("Horizontal align|#H")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_lalign(obj,FL_ALIGN_TOP);
- fl_set_object_callback(obj,matrix_cb,2);
- obj = fl_add_button(FL_NORMAL_BUTTON,100,130,80,30,idex(_("Apply|#A")));fl_set_button_shortcut(obj,scex(_("Apply|#A")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,matrix_cb,MM_APPLY);
+ fdui->valign = obj = fl_add_choice(FL_NORMAL_CHOICE, 180, 30, 90, 30, idex(_("Vertical align|#V")));fl_set_button_shortcut(obj, scex(_("Vertical align|#V")), 1);
+ fl_set_object_boxtype(obj, FL_FRAME_BOX);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lalign(obj, FL_ALIGN_TOP);
+ fl_set_object_callback(obj, matrix_cb,-1);
+ fdui->halign = obj = fl_add_input(FL_NORMAL_INPUT, 180, 90, 90, 30, idex(_("Horizontal align|#H")));fl_set_button_shortcut(obj, scex(_("Horizontal align|#H")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_lalign(obj, FL_ALIGN_TOP);
+ fl_set_object_callback(obj, matrix_cb, 2);
+ obj = fl_add_button(FL_NORMAL_BUTTON, 100, 130, 80, 30, idex(_("Apply|#A")));fl_set_button_shortcut(obj, scex(_("Apply|#A")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, matrix_cb, MM_APPLY);
fl_end_form();
//fdui->matrix->fdui = fdui;
FD_deco *fdui = (FD_deco *) fl_calloc(1, sizeof(FD_deco));
fdui->deco = fl_bgn_form(FL_NO_BOX, 160, 150);
- obj = fl_add_box(FL_UP_BOX,0,0,160,150,"");
- fdui->menu = obj = fl_add_bmtable(FL_PUSH_BUTTON,10,10,140,90,"");
- fl_set_object_lcol(obj,FL_BLUE);
- fl_set_object_callback(obj,deco_cb,MM_APPLY);
- obj = fl_add_button(FL_RETURN_BUTTON,30,110,100,30,_("Close"));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,deco_cb,MM_CLOSE);
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 160, 150, "");
+ fdui->menu = obj = fl_add_bmtable(FL_PUSH_BUTTON, 10, 10, 140, 90, "");
+ fl_set_object_lcol(obj, FL_BLUE);
+ fl_set_object_callback(obj, deco_cb, MM_APPLY);
+ obj = fl_add_button(FL_RETURN_BUTTON, 30, 110, 100, 30, _("Close"));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, deco_cb, MM_CLOSE);
fl_end_form();
//fdui->deco->fdui = fdui;
FD_space *fdui = (FD_space *) fl_calloc(1, sizeof(FD_space));
fdui->space = fl_bgn_form(FL_NO_BOX, 280, 150);
- obj = fl_add_box(FL_UP_BOX,0,0,280,150,"");
- obj = fl_add_button(FL_RETURN_BUTTON,10,110,80,30,_("OK "));
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,MM_OK);
- obj = fl_add_button(FL_NORMAL_BUTTON,190,110,80,30,idex(_("Cancel|^[")));fl_set_button_shortcut(obj,scex(_("Cancel|^[")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,MM_CLOSE);
- obj = fl_add_button(FL_NORMAL_BUTTON,100,110,80,30,idex(_("Apply|#A")));fl_set_button_shortcut(obj,scex(_("Apply|#A")),1);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,MM_APPLY);
+ obj = fl_add_box(FL_UP_BOX, 0, 0, 280, 150, "");
+ obj = fl_add_button(FL_RETURN_BUTTON, 10, 110, 80, 30, _("OK "));
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, MM_OK);
+ obj = fl_add_button(FL_NORMAL_BUTTON, 190, 110, 80, 30, idex(_("Cancel|^[")));fl_set_button_shortcut(obj, scex(_("Cancel|^[")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, MM_CLOSE);
+ obj = fl_add_button(FL_NORMAL_BUTTON, 100, 110, 80, 30, idex(_("Apply|#A")));fl_set_button_shortcut(obj, scex(_("Apply|#A")), 1);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, MM_APPLY);
fdui->spaces = fl_bgn_group();
- obj = fl_add_checkbutton(FL_RADIO_BUTTON,20,10,120,30,idex(_("Thin|#T")));fl_set_button_shortcut(obj,scex(_("Thin|#T")),1);
- fl_set_object_color(obj,FL_MCOL,FL_YELLOW);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,1);
- obj = fl_add_checkbutton(FL_RADIO_BUTTON,20,40,120,30,idex(_("Medium|#M")));fl_set_button_shortcut(obj,scex(_("Medium|#M")),1);
- fl_set_object_color(obj,FL_MCOL,FL_YELLOW);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,2);
- obj = fl_add_checkbutton(FL_RADIO_BUTTON,20,70,120,30,idex(_("Thick|#H")));fl_set_button_shortcut(obj,scex(_("Thick|#H")),1);
- fl_set_object_color(obj,FL_MCOL,FL_YELLOW);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,3);
- obj = fl_add_checkbutton(FL_RADIO_BUTTON,140,10,120,30,idex(_("Negative|#N")));fl_set_button_shortcut(obj,scex(_("Negative|#N")),1);
- fl_set_object_color(obj,FL_MCOL,FL_YELLOW);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,0);
- obj = fl_add_checkbutton(FL_RADIO_BUTTON,140,40,120,30,idex(_("Quadratin|#Q")));fl_set_button_shortcut(obj,scex(_("Quadratin|#Q")),1);
- fl_set_object_color(obj,FL_MCOL,FL_YELLOW);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,4);
- obj = fl_add_checkbutton(FL_RADIO_BUTTON,140,70,120,30,idex(_("2Quadratin|#2")));fl_set_button_shortcut(obj,scex(_("2Quadratin|#2")),1);
- fl_set_object_color(obj,FL_MCOL,FL_YELLOW);
- fl_set_object_lsize(obj,FL_NORMAL_SIZE);
- fl_set_object_callback(obj,space_cb,5);
+ obj = fl_add_checkbutton(FL_RADIO_BUTTON, 20, 10, 120, 30, idex(_("Thin|#T")));fl_set_button_shortcut(obj, scex(_("Thin|#T")), 1);
+ fl_set_object_color(obj, FL_MCOL, FL_YELLOW);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, 1);
+ obj = fl_add_checkbutton(FL_RADIO_BUTTON, 20, 40, 120, 30, idex(_("Medium|#M")));fl_set_button_shortcut(obj, scex(_("Medium|#M")), 1);
+ fl_set_object_color(obj, FL_MCOL, FL_YELLOW);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, 2);
+ obj = fl_add_checkbutton(FL_RADIO_BUTTON, 20, 70, 120, 30, idex(_("Thick|#H")));fl_set_button_shortcut(obj, scex(_("Thick|#H")), 1);
+ fl_set_object_color(obj, FL_MCOL, FL_YELLOW);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, 3);
+ obj = fl_add_checkbutton(FL_RADIO_BUTTON, 140, 10, 120, 30, idex(_("Negative|#N")));fl_set_button_shortcut(obj, scex(_("Negative|#N")), 1);
+ fl_set_object_color(obj, FL_MCOL, FL_YELLOW);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, 0);
+ obj = fl_add_checkbutton(FL_RADIO_BUTTON, 140, 40, 120, 30, idex(_("Quadratin|#Q")));fl_set_button_shortcut(obj, scex(_("Quadratin|#Q")), 1);
+ fl_set_object_color(obj, FL_MCOL, FL_YELLOW);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, 4);
+ obj = fl_add_checkbutton(FL_RADIO_BUTTON, 140, 70, 120, 30, idex(_("2Quadratin|#2")));fl_set_button_shortcut(obj, scex(_("2Quadratin|#2")), 1);
+ fl_set_object_color(obj, FL_MCOL, FL_YELLOW);
+ fl_set_object_lsize(obj, FL_NORMAL_SIZE);
+ fl_set_object_callback(obj, space_cb, 5);
fl_end_group();
fl_end_form();
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: gperf -a -p -o -t -G -D keywords */
#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include "math_defs.h"
#include "math_parser.h"
/* maximum key range = 483, duplicates = 40 */
static unsigned int
-hash (register const char *str, register int len)
+hash (register char const *str, register int len)
{
- static unsigned short asso_values[] =
+ static unsigned short asso_values[] =
{
491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
return len + asso_values[str[len - 1]] + asso_values[str[0]];
}
-static struct latexkeys wordlist[] =
+static struct latexkeys wordlist[] =
{
{"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
{"setminus", LM_TK_SYM, LM_setminus},
{"vdash", LM_TK_SYM, LM_vdash},
};
-static short lookup[] =
+static short lookup[] =
{
-1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, -1, -1, -1,
-1, 9, 10, -1, 11, -1, -1, -1, 12, -1, -1, 491, -13, -2,
};
struct latexkeys *
-in_word_set (register const char *str, register int len)
+in_word_set (register char const *str, register int len)
{
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
latexkeys* l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS];
latexkeys* base = &wordlist[MIN_HASH_VALUE];
while (--l >= base) {
- if (t==l->id && tk==l->token)
+ if (t == l->id && tk == l->token)
return l;
}
return 0;
MathedInset("", ot, st)
{
ln = 0;
- lims = (GetType()==LM_OT_FUNCLIM);
- if (GetType()==LM_OT_UNDEF) {
+ lims = (GetType() == LM_OT_FUNCLIM);
+ if (GetType() == LM_OT_UNDEF) {
fname = strnew(nm);
SetName(fname);
} else {
width = 4;
descent = 0;
flag = 1;
- if (objtype==LM_OT_SCRIPT)
+ if (objtype == LM_OT_SCRIPT)
flag |= LMPF_SCRIPT;
}
MathedIter it(array);
while (it.OK()) {
char c = it.GetChar();
- if (c==LM_TC_TAB || c==LM_TC_CR)
+ if (c == LM_TC_TAB || c == LM_TC_CR)
it.Delete();
else
it.Next();
bool MathSqrtInset::Inside(int x, int y)
{
- return (x>=xo-hmax && x<=xo+width-hmax && y<=yo+descent && y>=yo-ascent);
+ return (x>= xo-hmax && x<= xo+width-hmax && y<= yo+descent && y>= yo-ascent);
}
MathDecorationInset::MathDecorationInset(int d, short st):
MathParInset(st, "", LM_OT_DECO), deco(d)
{
- upper = (deco!=LM_underline && deco!=LM_underbrace);
+ upper = (deco!= LM_underline && deco!= LM_underbrace);
}
MathedInset *MathDecorationInset::Clone()
den = new MathParInset(LM_ST_TEXT); // this leaks
dh = 0;
idx = 0;
- if (objtype==LM_OT_STACKREL) {
+ if (objtype == LM_OT_STACKREL) {
flag |= LMPF_SCRIPT;
SetName("stackrel");
}
bool MathFracInset::setArgumentIdx(int i)
{
- if (i==0 || i==1) {
+ if (i == 0 || i == 1) {
idx = i;
return true;
} else
{
MathParInset::SetStyle(st);
dh = 0;
- den->SetStyle((size==LM_ST_DISPLAY) ? (short)LM_ST_TEXT: size);
+ den->SetStyle((size == LM_ST_DISPLAY) ? (short)LM_ST_TEXT: size);
}
void MathFracInset::SetData(LyxArrayBase *n, LyxArrayBase *d)
void MathFracInset::SetData(LyxArrayBase *d)
{
- if (idx==0)
+ if (idx == 0)
MathParInset::SetData(d);
else {
den->SetData(d);
void MathFracInset::GetXY(int& x, int& y) const
{
- if (idx==0)
+ if (idx == 0)
MathParInset::GetXY(x, y);
else
den->GetXY(x, y);
LyxArrayBase *MathFracInset::GetData()
{
- if (idx==0)
+ if (idx == 0)
return array;
else
return den->GetData();
{
int xx = xo - (width-w0)/2;
- return (x>=xx && x<=xx+width && y<=yo+descent && y>=yo-ascent);
+ return (x>= xx && x<= xx+width && y<= yo+descent && y>= yo-ascent);
}
void MathFracInset::SetFocus(int /*x*/, int y)
ws = new int[nc];
v_align = 0;
h_align = new char[nc+1];
- for (int i =0; i < nc; i++) h_align[i] = 'c';
+ for (int i = 0; i < nc; i++) h_align[i] = 'c';
h_align[nc] = '\0';
nr = 0;
row = 0;
MathedXIter it(this);
for (int j = 1; j < n; j++) it.addRow();
nr = n;
- if (nr==1 && nc>1) {
+ if (nr == 1 && nc>1) {
for (int j = 0; j < nc - 1; j++)
it.Insert('T', LM_TC_TAB);
}
it.SetData(mt->GetData());
array = it.Copy();
if (mt->row != 0) {
- MathedRowSt *r, *ro=0, *mrow = mt->row;
+ MathedRowSt *r, *ro= 0, *mrow = mt->row;
mrow = mt->row;
while (mrow) {
r = new MathedRowSt(nc+1);
void MathMatrixInset::Metrics()
{
- int i, /*cy,*/ hl, h=0;
- MathedRowSt *cprow=0, *cxrow;
+ int i, /*cy,*/ hl, h= 0;
+ MathedRowSt *cprow= 0, *cxrow;
if (!row) {
// lyxerr << " MIDA ";
// Clean the arrays
cxrow = row;
while (cxrow) {
- for (i=0; i<=nc; i++) cxrow->w[i] = 0;
+ for (i= 0; i<= nc; i++) cxrow->w[i] = 0;
cxrow = cxrow->next;
}
// Basic metrics
MathParInset::Metrics();
- if (nc<=1 && !row->next) {
+ if (nc<= 1 && !row->next) {
row->asc = ascent;
row->desc = descent;
}
// Vertical positions of each row
cxrow = row;
while (cxrow) {
- for (i=0; i<nc; i++) {
- if (cxrow==row || ws[i]<cxrow->w[i]) ws[i]=cxrow->w[i];
- if (cxrow->next==0 && ws[i]==0) ws[i] = df_width;
+ for (i= 0; i<nc; i++) {
+ if (cxrow == row || ws[i]<cxrow->w[i]) ws[i]= cxrow->w[i];
+ if (cxrow->next == 0 && ws[i] == 0) ws[i] = df_width;
}
- cxrow->y = (cxrow==row) ? cxrow->asc:
+ cxrow->y = (cxrow == row) ? cxrow->asc:
cxrow->asc + cprow->desc + MATH_ROWSEP + cprow->y;
h += cxrow->asc + cxrow->desc + MATH_ROWSEP;
cprow = cxrow;
cxrow = row;
width = MATH_COLSEP;
while (cxrow) {
- int rg=MATH_COLSEP, ww, lf=0, *w = cxrow->w;
- for (i=0; i<nc; i++) {
+ int rg= MATH_COLSEP, ww, lf= 0, *w = cxrow->w;
+ for (i= 0; i<nc; i++) {
bool isvoid = false;
- if (w[i]<=0) {
+ if (w[i]<= 0) {
w[i] = df_width;
isvoid = true;
}
ww = (isvoid) ? lf: lf + w[i];
w[i] = lf + rg;
rg = ws[i] - ww + MATH_COLSEP;
- if (cxrow==row) width += ws[i] + MATH_COLSEP;
+ if (cxrow == row) width += ws[i] + MATH_COLSEP;
}
cxrow->y -= ascent;
cxrow = cxrow->next;
// Note: These math insets are internal to Mathed and are not derived
// from lyx inset.
-#ifndef __MATH_INSET__
-#define __MATH_INSET__
+#ifndef MATH_INSET
+#define MATH_INSET
#ifdef __GNUG__
#pragma interface
class MathFuncInset: public MathedInset {
public:
///
- MathFuncInset(char const *nm, short ot=LM_OT_FUNC, short st=LM_ST_TEXT);
+ MathFuncInset(char const *nm, short ot= LM_OT_FUNC, short st= LM_ST_TEXT);
///
~MathFuncInset();
///
class MathAccentInset: public MathedInset {
public:
///
- MathAccentInset(byte, MathedTextCodes, int, short st=LM_ST_TEXT);
+ MathAccentInset(byte, MathedTextCodes, int, short st= LM_ST_TEXT);
///
- MathAccentInset(MathedInset *, int, short st=LM_ST_TEXT);
+ MathAccentInset(MathedInset *, int, short st= LM_ST_TEXT);
///
~MathAccentInset();
///
class MathDotsInset: public MathedInset {
public:
///
- MathDotsInset(char const*,int,short st=LM_ST_TEXT);
+ MathDotsInset(char const*, int, short st= LM_ST_TEXT);
///
~MathDotsInset() { };
///
class MathSpaceInset: public MathedInset {
public:
///
- MathSpaceInset(int sp, short ot=LM_OT_SPACE, short st=LM_ST_TEXT);
+ MathSpaceInset(int sp, short ot= LM_OT_SPACE, short st= LM_ST_TEXT);
///
~MathSpaceInset() { };
///
class MathBigopInset: public MathedInset {
public:
///
- MathBigopInset(char const*, int, short st=LM_ST_TEXT);
+ MathBigopInset(char const*, int, short st= LM_ST_TEXT);
///
~MathBigopInset() { };
///
class MathSqrtInset: public MathParInset {
public:
///
- MathSqrtInset(short st=LM_ST_TEXT);
+ MathSqrtInset(short st= LM_ST_TEXT);
///
~MathSqrtInset() { };
///
class MathFracInset: public MathParInset {
public:
///
- MathFracInset(short ot=LM_OT_FRAC);
+ MathFracInset(short ot= LM_OT_FRAC);
///
~MathFracInset();
///
///
void GetXY(int& x, int& y) const;
///
- void SetFocus(int,int);
+ void SetFocus(int, int);
///
bool Inside(int, int);
///
class MathDelimInset: public MathParInset {
public:
///
- MathDelimInset(int, int, short st=LM_ST_TEXT);
+ MathDelimInset(int, int, short st= LM_ST_TEXT);
///
~MathDelimInset() { };
///
class MathDecorationInset: public MathParInset {
public:
///
- MathDecorationInset(int, short st=LM_ST_TEXT);
+ MathDecorationInset(int, short st= LM_ST_TEXT);
///
~MathDecorationInset() { };
///
inline
MathFuncInset::~MathFuncInset()
{
- if (fname && GetType()==LM_OT_UNDEF) delete[] fname;
+ if (fname && GetType() == LM_OT_UNDEF) delete[] fname;
}
inline
bool MathFuncInset::GetLimits() const
{
- return (bool)(lims && (GetStyle()==LM_ST_DISPLAY));
+ return (bool)(lims && (GetStyle() == LM_ST_DISPLAY));
}
inline
{
width = (space) ? space*2: 2;
if (space>3) width *= 2;
- if (space==5) width *= 2;
+ if (space == 5) width *= 2;
width += 4;
ascent = 4; descent = 0;
}
{
// Default case
if (lims<0) {
- return (bool)(sym!=LM_int && sym!=LM_oint && (GetStyle()==LM_ST_DISPLAY));
+ return (bool)(sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY));
}
// Custom
inline
bool MathDecorationInset::GetLimits() const
{
- return (bool)(deco==LM_underbrace||deco==LM_overbrace);
+ return (bool)(deco == LM_underbrace||deco == LM_overbrace);
}
}
byte *s = &array->bf[pos];
len = pos;
- while (array->bf[pos]>=' ' && pos<array->last) pos++;
+ while (array->bf[pos]>= ' ' && pos<array->last) pos++;
len = pos-len;
return s;
bool MathedIter::goNextCode(MathedTextCodes code)
{
while (Next()) {
- if (array->bf[pos]==code)
+ if (array->bf[pos] == code)
return true;
}
{
if (c<' ') return;
- if (t==LM_TC_TAB && col>=ncols-1)
+ if (t == LM_TC_TAB && col>= ncols-1)
return;
// Never more than one space // array->bf[pos-1] gives error from purify:
// Reading 1 byte from 0x47b857 in the heap.
// Address 0x47b857 is 1 byte before start of malloc'd block at 0x47b858 of 16 bytes.
- if (c==' ' && (array->bf[pos]==' ' || array->bf[pos-1]==' '))
+ if (c == ' ' && (array->bf[pos] == ' ' || array->bf[pos-1] == ' '))
return;
- if (IsFont() && array->bf[pos]==t) {
+ if (IsFont() && array->bf[pos] == t) {
fcode = t;
pos++;
} else
- if (t!=fcode && pos>0 && MathIsFont(array->bf[pos-1])) {
+ if (t!= fcode && pos>0 && MathIsFont(array->bf[pos-1])) {
pos--;
int k;
- for (k=pos-1; k>=0 && array->bf[k]>=' '; k--);
+ for (k= pos-1; k>= 0 && array->bf[k]>= ' '; k--);
fcode = (k >= 0 && MathIsFont(array->bf[k])) ? array->bf[k]: -1;
}
short f = (array->bf[pos]<' ') ? 0: fcode;
- int shift = (t==fcode) ? 1: ((f) ? 3: 2);
+ int shift = (t == fcode) ? 1: ((f) ? 3: 2);
- if (t==LM_TC_TAB || t==LM_TC_CR) {
+ if (t == LM_TC_TAB || t == LM_TC_CR) {
shift--;
c = t;
- if (t==LM_TC_CR) {
+ if (t == LM_TC_CR) {
row++;
col = 0;
} else
if (pos < array->last)
array->Move(pos, shift);
else {
- if (array->last+shift>=array->maxsize) {
+ if (array->last+shift>= array->maxsize) {
array->Resize(array->last+shift);
}
array->last += shift;
if (t != fcode) {
if (f)
array->bf[pos+shift-1] = fcode;
- if (c>=' ') {
+ if (c>= ' ') {
array->bf[pos++] = t;
fcode = t;
} else {
{
if (pos < array->last) {
bool fg = false;
- if (array->bf[pos]>=' ') {
+ if (array->bf[pos]>= ' ') {
if (pos> 0 && MathIsFont(array->bf[pos-1]))
pos--;
else {
array->Move(pos, shift);
if (fg) array->bf[pos+shift-1] = fcode;
} else {
- if (array->last+shift>=array->maxsize) {
+ if (array->last+shift>= array->maxsize) {
array->Resize(array->last+shift);
}
array->last += shift;
// I assume that both pos and pos2 are legal positions
void MathedIter::join(int pos2)
{
- if (!OK() || pos2<=pos)
+ if (!OK() || pos2<= pos)
return;
- short f=fcode;
- if (pos>0 && array->bf[pos]>=' ' && MathIsFont(array->bf[pos-1]))
+ short f= fcode;
+ if (pos>0 && array->bf[pos]>= ' ' && MathIsFont(array->bf[pos-1]))
pos--;
if (MathIsFont(array->bf[pos2-1]))
pos2--;
- if (array->bf[pos2]>=' ') {
- for (int p=pos2; p>0; p--)
+ if (array->bf[pos2]>= ' ') {
+ for (int p= pos2; p>0; p--)
if (MathIsFont(array->bf[p])) {
f = array->bf[p];
break;
int shift = 0;
byte c = GetChar();
- if (c>=' ') {
+ if (c>= ' ') {
if (MathIsFont(array->bf[pos-1]) && array->bf[pos+1]<' ') {
int i;
shift = 2;
pos--;
- for (i=pos-1; i>0 && !MathIsFont(array->bf[i]); i--);
+ for (i= pos-1; i>0 && !MathIsFont(array->bf[i]); i--);
if (i>0 && MathIsFont(array->bf[i]))
fcode = array->bf[i];
} else
if (MathIsInset(array->bf[pos]))
shift = sizeof(char*) + 2;
else
- if (c==LM_TC_TAB || c==LM_TC_CR) {
+ if (c == LM_TC_TAB || c == LM_TC_CR) {
shift++;
// lyxerr <<"Es un tab.";
}
}
}
- if (shift!=0) {
+ if (shift!= 0) {
array->Move(pos+shift, -shift);
- if (pos>=array->last)
+ if (pos>= array->last)
pos = (array->last>0) ? array->last: 0;
return true;
} else
// int posx = pos;
ipush();
- LyxArrayBase *t=array, *a;
+ LyxArrayBase *t= array, *a;
- if (pos1>0 || pos2<=array->last) {
- short fc=0;
+ if (pos1>0 || pos2<= array->last) {
+ short fc= 0;
if (pos1>0 && array->bf[pos1]>' ') {
- for (int p=pos1; p>=0; p--)
+ for (int p= pos1; p>= 0; p--)
if (MathIsFont(array->bf[p])) {
- if (p!=pos1-1)
+ if (p!= pos1-1)
fc = array->bf[p];
else
pos1--;
}
}
- if (pos2>0 && array->bf[pos2]>=' ' && MathIsFont(array->bf[pos2-1]))
+ if (pos2>0 && array->bf[pos2]>= ' ' && MathIsFont(array->bf[pos2-1]))
pos2--;
int dx = pos2 - pos1;
while (OK()) {
if (IsInset()) {
MathedInset* inset = GetInset();
- if (inset->GetType()!=LM_OT_MACRO_ARG)
+ if (inset->GetType()!= LM_OT_MACRO_ARG)
delete inset;
Delete();
} else
// MathedIter:Reset();
while (OK()) {
- if ((IsTab() && col>=ncols-1) || (IsCR() && !(MthIF_CR&flags))) {
+ if ((IsTab() && col>= ncols-1) || (IsCR() && !(MthIF_CR&flags))) {
Delete();
continue;
}
if (IsInset()) {
MathedInset* inset = GetInset();
Next();
- if (inset->GetType()!=LM_OT_MACRO_ARG)
+ if (inset->GetType()!= LM_OT_MACRO_ARG)
delete inset;
continue;
}
}
ipop();
- if (pos2<=array->Last()) {
+ if (pos2<= array->Last()) {
pos = pos1;
join(pos2);
checkTabs();
split(a->Last());
array->MergeF(a, pos, a->Last());
- int pos1=pos, pos2 = pos + a->Last(); // pos3=0;
+ int pos1= pos, pos2 = pos + a->Last(); // pos3= 0;
goPosAbs(pos1);
{
// lyxerr << "Ne[" << pos << "]";
if (!OK()) return false;
- int w=0;
+ int w= 0;
// lyxerr << "xt ";
if (IsInset()) {
MathedInset* px = GetInset();
w = px->Width();
- if (px->GetType()==LM_OT_SCRIPT) {
+ if (px->GetType() == LM_OT_SCRIPT) {
if (w>sw) sw = w;
w = 0;
} else
sx = (px->GetLimits()) ? w: 0;
} else {
byte c = GetChar();
- if (c>=' ') {
+ if (c>= ' ') {
// lyxerr << "WD[" << fcode << " " << size << " " << c << endl;
w = mathed_char_width(fcode, size, c);
} else
- if (c==LM_TC_TAB && p) {
+ if (c == LM_TC_TAB && p) {
// w = p->GetTab(col+1);
w = (crow) ? crow->getTab(col+1): 0;
//lyxerr << "WW[" << w << "]";
} else
- if (c==LM_TC_CR && p) {
+ if (c == LM_TC_CR && p) {
x = 0;
if (crow && crow->next) {
crow = crow->next;
}
if (MathedIter::Next()) {
// lyxerr <<"LNX " << pos << endl;
-// if (sw>0 && GetChar()!=LM_TC_UP && GetChar()!=LM_TC_DOWN) {
+// if (sw>0 && GetChar()!= LM_TC_UP && GetChar()!= LM_TC_DOWN) {
// w = (sx>sw) ? 0: sw-sx;
- if ((sw>0 || sx>0) && GetChar()!=LM_TC_UP && GetChar()!=LM_TC_DOWN) {
+ if ((sw>0 || sx>0) && GetChar()!= LM_TC_UP && GetChar()!= LM_TC_DOWN) {
if (sw>0)
w = (sx>sw) ? 0: sw-sx;
sx = sw = 0;
bool MathedXIter::Prev()
{
- if (pos==0 || (pos==1 && GetChar()>=' '))
+ if (pos == 0 || (pos == 1 && GetChar()>= ' '))
return false;
int pos2 = pos; // pos1
bool MathedXIter::goNextColumn()
{
- int rowp = row, colp=col;
- while (Next() && col==colp);
+ int rowp = row, colp= col;
+ while (Next() && col == colp);
- return (col!=colp+1 || rowp!=row);
+ return (col!= colp+1 || rowp!= row);
}
bool MathedXIter::Up()
{
- if (row==0) return false;
- int xp = x, rowp = row, colp=col;
+ if (row == 0) return false;
+ int xp = x, rowp = row, colp= col;
GoBegin();
while (row<rowp-1) Next();
while (x<xp && OK() && !IsCR()) {
ipush();
Next();
}
- if (col>colp) // || (stck.col==colp && stck.x<=xp && x>xp))
+ if (col>colp) // || (stck.col == colp && stck.x<= xp && x>xp))
ipop();
return true;
bool MathedXIter::Down()
{
- int xp = x, colp=col; // ,rowp = row
+ int xp = x, colp= col; // , rowp = row
bool res = (IsCR()) ? true: goNextCode(LM_TC_CR);
if (res) {
ipush();
Next();
}
- if (col>colp || (stck.col==colp && stck.x<=xp && x>xp))
+ if (col>colp || (stck.col == colp && stck.x<= xp && x>xp))
ipop();
return true;
}
if (p) {
crow = p->getRowSt();
if (crow)
- for (int i=0; i<row; i++)
+ for (int i= 0; i<row; i++)
crow = crow->next;
}
}
p->GetXY(xo, yo);
// first fit vertically
while (crow && OK()) {
- if (yy>=yo+y-crow->asc && yy<= yo+y+crow->desc)
+ if (yy>= yo+y-crow->asc && yy<= yo+y+crow->desc)
break;
goNextCode(LM_TC_CR);
Next();
void MathedXIter::setTab(int tx, int tab)
{
- if (crow && tab<=ncols) {
+ if (crow && tab<= ncols) {
crow->w[tab] = tx;
}
else
// This function is not recursive, as MathPar::Metrics is
void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent)
{
- byte cx, cxp=0;// *s;
+ byte cx, cxp= 0;// *s;
int x1;// ls;
- int asc=0, des=0;
+ int asc= 0, des= 0;
bool limit = false;
descent = ascent = width = 0;
} else
if (MathIsInset(cx)) {
MathedInset *pp = GetInset();
- if (cx==LM_TC_UP) {
+ if (cx == LM_TC_UP) {
if (!asc && p) {
int xx, yy;
p->GetXY(xx, yy);
}
asc += ((limits) ? pp->Height()+4: pp->Ascent());
} else
- if (cx==LM_TC_DOWN) {
+ if (cx == LM_TC_DOWN) {
if (!des && p) {
int xx, yy;
p->GetXY(xx, yy);
}
if (asc > ascent) ascent = asc;
if (des > descent) descent = des;
- if (cx!=LM_TC_UP && cx!=LM_TC_DOWN)
+ if (cx!= LM_TC_UP && cx!= LM_TC_DOWN)
limit = pp->GetLimits();
} else
- if (cx==LM_TC_TAB) {
+ if (cx == LM_TC_TAB) {
limit = false;
}
else {
MathedRowSt *mrow = crow;
while (OK()) {
if (IsCR()) {
- if (col>=ncols) ncols = col+1;
+ if (col>= ncols) ncols = col+1;
MathedRowSt *r = new MathedRowSt(ncols+1); // this leaks
// r->next = crow->next;
crow->next = r;
*
*/
-#ifndef __MATH_ITER__
-#define __MATH_ITER__
+#ifndef MATH_ITER
+#define MATH_ITER
#ifdef __GNUG__
#pragma interface
///
void goPosAbs(int);
///
- int Empty() { return array->last<=1; }
+ int Empty() { return array->last<= 1; }
///
int OK() { return array && (pos < array->last); }
///
- int IsFirst() { return (pos==0); }
+ int IsFirst() { return (pos == 0); }
///
byte GetChar();
///
///
virtual void Reset();
///
- virtual void Insert(byte, MathedTextCodes c=LM_TC_CONST);
+ virtual void Insert(byte, MathedTextCodes c= LM_TC_CONST);
///
- virtual void Insert(MathedInset*, int t=LM_TC_INSET);
+ virtual void Insert(MathedInset*, int t= LM_TC_INSET);
///
virtual bool Delete();
///
LyxArrayBase *GetData() { return array; }
/// Copy every object from position p1 to p2
- LyxArrayBase *Copy(int p1=0, int p2=10000);
+ LyxArrayBase *Copy(int p1= 0, int p2= 10000);
/// Delete every object from position p1 to p2
void Clear();
// Limits auxiliary variables
/// Position and max width of a script
int sx, sw;
- /// true=center, false=left align (default)
+ /// true= center, false= left align (default)
bool limits;
/// Type of previous script
short s_type;
inline
bool MathedIter::IsTab()
{
- return (array->bf[pos]==LM_TC_TAB);
+ return (array->bf[pos] == LM_TC_TAB);
}
inline
bool MathedIter::IsCR()
{
- return (array->bf[pos]==LM_TC_CR);
+ return (array->bf[pos] == LM_TC_CR);
}
}
enum MathedMacroFlag {
- MMF_Env=1,
- MMF_Exp=2,
- MMF_Edit=4
+ MMF_Env= 1,
+ MMF_Exp= 2,
+ MMF_Edit= 4
};
ostream & operator<<(ostream & o, MathedMacroFlag mmf)
nargs = tmplate->getNoArgs();
tcode = tmplate->getTCode();
args = new MacroArgumentBase[nargs];
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
// if (tmplate->getMacroPar(i)->Permit(LMPF_ALLOW_CR))
// args[i].row = new MathedRowSt(tmplate->getMacroPar(i)->GetColumns());
// else
/* int k = tmplate->getMacroPar(i)->GetColumns();
if (k>0) {
args[i].array = new LyxArrayBase;
- for (int j=0; j<k-1; j++) args[i].array->Insert(j, LM_TC_TAB);
+ for (int j= 0; j<k-1; j++) args[i].array->Insert(j, LM_TC_TAB);
}*/
}
idx = 0;
args = new MacroArgumentBase[nargs];
idx = 0;
SetName(tmplate->GetName());
- for (int i=0; i<tmplate->nargs; i++) {
+ for (int i= 0; i<tmplate->nargs; i++) {
m->setArgumentIdx(i);
MathedIter it(m->GetData());
args[i].row = m->args[i].row;
MathMacro::~MathMacro()
{
- for (idx=0; idx<nargs; idx++) {
+ for (idx= 0; idx<nargs; idx++) {
MathedIter it(args[idx].array);
it. Clear();
delete args[idx].row;
tmplate->SetStyle(size);
mathGC = latexGC;
tmplate->Draw(x, y);
- for (int i=0; i<nargs; i++)
+ for (int i= 0; i<nargs; i++)
tmplate->GetMacroXY(i, args[i].x, args[i].y);
}
if (!(tmplate->flags & MMF_Env) && nargs>0)
file += '{';
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
array = args[i].array;
MathParInset::Write(file);
if (i<nargs-1)
if (nargs>0) {
tcode = LM_TC_ACTIVE_INSET;
args = new MathMacroArgument[nargs];
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setNumber(i+1);
}
} else
MathMacroTemplate::~MathMacroTemplate()
{
// prevent to delete already deleted objects
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].SetData(0);
}
delete[] args;
{
if (ed) {
flags |= MMF_Edit;
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(false);
}
} else {
flags &= ~MMF_Edit;
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(true);
}
}
int x2, y2;
bool expnd = (nargs>0) ? args[0].getExpand(): false;
if (flags & MMF_Edit) {
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(false);
}
x2 = x; y2 = y;
} else {
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(true);
}
x2 = xo; y2 = yo;
MathParInset::Draw(x, y);
xo = x2; yo = y2;
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(expnd);
}
}
bool expnd = (nargs>0) ? args[0].getExpand(): false;
if (flags & MMF_Edit) {
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(false);
}
} else {
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(true);
}
}
MathParInset::Metrics();
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(expnd);
}
}
void MathMacroTemplate::update(MathMacro* macro)
{
int idx = (macro) ? macro->getArgumentIdx(): 0;
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
if (macro) {
macro->setArgumentIdx(i);
args[i].SetData(macro->GetData());
fprintf(file, "{");
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(false);
}
Write(file);
file += '{';
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
args[i].setExpand(false);
}
Write(file);
MathParInset *MathMacroTemplate::getMacroPar(int i) const
{
- return ((i>=0 && i<nargs) ? (MathParInset*)&args[i]: 0);
+ return ((i>= 0 && i<nargs) ? (MathParInset*)&args[i]: 0);
}
void MathMacroTemplate::SetMacroFocus(int &idx, int x, int y)
{
- for (int i=0; i<nargs; i++) {
+ for (int i= 0; i<nargs; i++) {
if (args[i].Inside(x, y)) {
idx = i;
break;
// The search is currently linear but will be binary or hash, later.
MathMacroTemplate *MathMacroTable::getTemplate(char const* name) const
{
- for (int i=0; i<num_macros; i++) {
- if (strcmp(name, macro_table[i]->GetName())==0)
+ for (int i= 0; i<num_macros; i++) {
+ if (strcmp(name, macro_table[i]->GetName()) == 0)
return macro_table[i];
}
addTemplate(m);
array = new LyxArrayBase; // this leaks
iter.SetData(array);
- arg = new MathMatrixInset(2,1); // this leaks
+ arg = new MathMatrixInset(2, 1); // this leaks
m->setArgument(arg);
- arg->SetAlign('c',"ll");
+ arg->SetAlign('c', "ll");
iter.Insert(arg, LM_TC_ACTIVE_INSET);
inset = new MathDelimInset('{', '.'); // this leaks
inset->SetData(array);
// the environment substack has 1 argument
m = new MathMacroTemplate("substack", 1, MMF_Env); // this leaks
addTemplate(m);
- arg = new MathMatrixInset(1,1); // this leaks
+ arg = new MathMatrixInset(1, 1); // this leaks
m->setArgument(arg);
arg->SetType(LM_OT_MACRO);
array = new LyxArrayBase; // this leaks
{
public:
/// A template constructor needs all the data
- MathMacroTemplate(char const*, int na=0, int f=0);
+ MathMacroTemplate(char const*, int na= 0, int f= 0);
///
~MathMacroTemplate();
///
///
MathedTextCodes getTCode() { return tcode; }
///
- void setArgument(LyxArrayBase *, int i=0);
+ void setArgument(LyxArrayBase *, int i= 0);
/// Number of arguments
int getNoArgs() { return nargs; }
///
void setEditMode(bool);
/// Replace the appropriate arguments with a specific macro's data
- void update(MathMacro* m=0);
+ void update(MathMacro* m= 0);
private:
///
inline
bool MathMacro::setArgumentIdx(int i)
{
- if (i>=0 && i<nargs) {
+ if (i>= 0 && i<nargs) {
idx = i;
return true;
} else
#include <config.h>
#include FORMS_H_LOCATION
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
#include "lyx_gui_misc.h"
#include "math_panel.h"
#include "matrix.xpm"
#include "equation.xpm"
-static LyXFunc *lyxfunc=0;
+static LyXFunc * lyxfunc= 0;
-//static FD_panel* symb_form=0;
+//static FD_panel* symb_form= 0;
-FD_panel *fd_panel;
-FD_delim *fd_delim;
-FD_deco *fd_deco;
-FD_space *fd_space;
-FD_matrix *fd_matrix;
+FD_panel * fd_panel;
+FD_delim * fd_delim;
+FD_deco * fd_deco;
+FD_space * fd_space;
+FD_matrix * fd_matrix;
int delim_code[] = {
'(', ')', LM_lceil, LM_rceil, LM_uparrow, LM_Uparrow,
LM_langle, LM_rangle, '|', LM_Vert, '.', 0
};
-static char const *deco_code[] = {
+
+static char const * deco_code[] = {
"widehat", "widetilde", "overbrace", "overleftarrow", "overrightarrow",
- "overline","underbrace", "underline"
+ "overline", "underbrace", "underline"
};
-static char const *func_code[] = {
+static char const * func_code[] = {
"arccos", "arcsin", "arctan", "arg", "bmod",
"cos", "cosh", "cot", "coth", "csc", "deg",
"det", "dim", "exp", "gcd", "hom", "inf", "ker",
static char h_align_str[80] = "c";
/* callbacks for form panel */
-void button_cb(FL_OBJECT *ob, long data)
+void button_cb(FL_OBJECT * ob, long data)
{
extern void free_symbols_form();
switch (data) {
case MM_BOP:
case MM_MISC:
{
- BitmapMenu *menu = (BitmapMenu *)ob->u_vdata;
+ BitmapMenu * menu = static_cast<BitmapMenu *>(ob->u_vdata);
menu->Show();
break;
}
lyxfunc->Dispatch(LFUN_INSERT_MATH, "sqrt");
break;
case MM_DELIM:
- fl_show_form(fd_delim->delim,FL_PLACE_MOUSE,FL_FULLBORDER, _("Delimiter"));
+ fl_show_form(fd_delim->delim, FL_PLACE_MOUSE, FL_FULLBORDER, _("Delimiter"));
fl_set_form_atclose(fd_delim->delim, CancelCloseBoxCB, 0);
break;
case MM_DECO:
- fl_show_form(fd_deco->deco,FL_PLACE_MOUSE,FL_FULLBORDER,_("Decoration"));
+ fl_show_form(fd_deco->deco, FL_PLACE_MOUSE, FL_FULLBORDER, _("Decoration"));
fl_set_form_atclose(fd_deco->deco, CancelCloseBoxCB, 0);
break;
case MM_SPACE:
- fl_show_form(fd_space->space,FL_PLACE_MOUSE,FL_FULLBORDER,_("Spacing"));
+ fl_show_form(fd_space->space, FL_PLACE_MOUSE, FL_FULLBORDER, _("Spacing"));
fl_set_form_atclose(fd_space->space, CancelCloseBoxCB, 0);
break;
case MM_MATRIX:
- fl_show_form(fd_matrix->matrix,FL_PLACE_MOUSE,FL_FULLBORDER,_("Matrix"));
+ fl_show_form(fd_matrix->matrix, FL_PLACE_MOUSE, FL_FULLBORDER, _("Matrix"));
fl_set_form_atclose(fd_matrix->matrix, CancelCloseBoxCB, 0);
break;
case MM_EQU:
/* callbacks for form delim */
void delim_cb(FL_OBJECT *, long data)
{
- int left=fd_delim->left->u_ldata, right=fd_delim->right->u_ldata;
- int side=(fl_get_button(fd_delim->right)!=0);
+ int left= fd_delim->left->u_ldata, right= fd_delim->right->u_ldata;
+ int side= (fl_get_button(fd_delim->right)!= 0);
Pixmap p1, p2;
switch (data) {
char s[80];
sprintf(s, "%d %d", delim_code[left], delim_code[right]);
lyxfunc->Dispatch(LFUN_MATH_DELIM, s);
- if (data==MM_APPLY) break;
+ if (data == MM_APPLY) break;
}
case MM_CLOSE: fl_hide_form(fd_delim->delim); break;
case 2:
{
int i = fl_get_bmtable(fd_delim->menu);
- if (i>=0) {
+ if (i>= 0) {
#if FL_REVISION > 85
- if (side || (fl_get_bmtable_numb(fd_delim->menu)!=FL_LEFT_MOUSE))
+ if (side || (fl_get_bmtable_numb(fd_delim->menu)!= FL_LEFT_MOUSE))
#else
if (side || (fl_get_bmtable_numb(fd_delim->menu)!= 1))
left = i;
}
p1 = fl_get_pixmap_pixmap(fd_delim->pix, &p1, &p2);
- fl_draw_bmtable_item(fd_delim->menu,left,p1,0,0);
- fl_draw_bmtable_item(fd_delim->menu,right,p1,16,0);
+ fl_draw_bmtable_item(fd_delim->menu, left, p1, 0, 0);
+ fl_draw_bmtable_item(fd_delim->menu, right, p1, 16, 0);
fl_redraw_object(fd_delim->pix);
fd_delim->left->u_ldata = left;
{
char s[80];
char c = v_align_c[fl_get_choice(fd_matrix->valign)-1];
- char const *sh = fl_get_input(fd_matrix->halign);
- nx = (int)(fl_get_slider_value(fd_matrix->columns)+0.5);
- ny = (int)(fl_get_slider_value(fd_matrix->rows)+0.5);
+ char const * sh = fl_get_input(fd_matrix->halign);
+ nx = int(fl_get_slider_value(fd_matrix->columns)+0.5);
+ ny = int(fl_get_slider_value(fd_matrix->rows)+0.5);
sprintf(s, "%d %d %c%s", nx, ny, c, sh);
- if (data==MM_OK) fl_hide_form(fd_matrix->matrix);
+ if (data == MM_OK) fl_hide_form(fd_matrix->matrix);
lyxfunc->Dispatch(LFUN_INSERT_MATRIX, s);
break;
}
case MM_CLOSE: fl_hide_form(fd_matrix->matrix); break;
case 2:
{
- nx = (int)(fl_get_slider_value(fd_matrix->columns)+0.5);
- for (int i=0; i<nx; i++) h_align_str[i] = 'c';
+ nx = int(fl_get_slider_value(fd_matrix->columns)+0.5);
+ for (int i= 0; i<nx; i++) h_align_str[i] = 'c';
//memset(h_align_str, 'c', nx);
h_align_str[nx] = '\0';
// fl_freeze_form(fd_form_main->form_main);
{
int i = fl_get_bmtable(fd_deco->menu);
lyxfunc->Dispatch(LFUN_INSERT_MATH, deco_code[i]);
- if (data==MM_APPLY) break;
+ if (data == MM_APPLY) break;
}
case MM_CLOSE: fl_hide_form(fd_deco->deco); break;
}
}
+
/* callbacks for form space */
void space_cb(FL_OBJECT *, long data)
{
- static short sp=-1;
- extern char *latex_mathspace[];
+ static short sp = -1;
+ extern char * latex_mathspace[];
- if (data>=0 && data<6)
- sp = (short)data;
+ if (data >= 0 && data < 6)
+ sp = short(data);
else
switch (data) {
case MM_APPLY:
case MM_OK:
{
- if (sp>=0)
+ if (sp>= 0)
lyxfunc->Dispatch(LFUN_INSERT_MATH, latex_mathspace[sp]);
- if (data==MM_APPLY) break;
+ if (data == MM_APPLY) break;
}
case MM_CLOSE: fl_hide_form(fd_space->space); break;
}
}
-extern "C" int align_filter(FL_OBJECT *, char const *, char const *cur, int c)
+
+extern "C" int align_filter(FL_OBJECT *, char const *, char const * cur, int c)
{
- int n = (int)(fl_get_slider_value(fd_matrix->columns)+0.5) - strlen(cur);
- return ((c=='c'||c=='l'||c=='r') && n>=0) ? FL_VALID: FL_INVALID;
+ int n = int(fl_get_slider_value(fd_matrix->columns)+0.5) - strlen(cur);
+ return ((c == 'c'||c == 'l'||c == 'r') && n>= 0) ? FL_VALID: FL_INVALID;
}
-char** mathed_get_pixmap_from_icon(int d)
+
+char ** mathed_get_pixmap_from_icon(int d)
{
switch (d) {
case MM_FRAC: return frac;
}
}
-FD_panel *create_math_panel( )
+
+FD_panel * create_math_panel( )
{
fd_panel = create_form_panel();
fd_delim = create_form_delim();
/* fill-in form initialization code */
fl_set_button(fd_delim->left, 1);
fl_set_pixmap_data(fd_delim->pix, delim0);
- fl_set_bmtable_data(fd_delim->menu,6,4,delim_width,delim_height,
+ fl_set_bmtable_data(fd_delim->menu, 6, 4, delim_width, delim_height,
delim_bits);
fl_set_bmtable_maxitems(fd_delim->menu, 23);
fl_set_pixmap_data(fd_panel->matrix, matrix);
fl_set_pixmap_data(fd_panel->equation, equation);
- for (int i=0; i<32; i++) {
+ for (int i= 0; i<32; i++) {
fl_add_browser_line(fd_panel->func_browse, func_code[i]);
}
fl_set_input(fd_matrix->halign, h_align_str);
fl_set_input_filter(fd_matrix->halign, align_filter);
- fl_set_bmtable_data(fd_deco->menu,3,3,deco_width,deco_height,
+ fl_set_bmtable_data(fd_deco->menu, 3, 3, deco_width, deco_height,
deco_bits);
fl_set_bmtable_maxitems(fd_deco->menu, 8);
extern BitmapMenu* sym_menu;
extern void create_symbol_menues(FD_panel *);
+
void free_symbols_form()
{
if (fd_panel) {
}
}
+
extern "C" int AtClose_symbols_form(FL_FORM *, void *)
{
free_symbols_form();
return FL_IGNORE;
}
-void show_symbols_form(LyXFunc *lf)
+
+void show_symbols_form(LyXFunc * lf)
{
lyxfunc = lf;
if (!fd_panel) {
};
///
-typedef FL_OBJECT* FL_OBJECTP;
+typedef FL_OBJECT * FL_OBJECTP;
/// Class to manage bitmap menu bars
class BitmapMenu {
///
- static BitmapMenu *active;
+ static BitmapMenu * active;
///
friend int peek_event(FL_FORM *, void *);
protected:
///
- BitmapMenu *next, *prev;
+ BitmapMenu * next, * prev;
///
int nb; // Number of bitmaps
///
///
int x, y, w, h;
///
- FL_FORM *form;
+ FL_FORM * form;
///
- FL_OBJECTP *bitmap;
+ FL_OBJECTP * bitmap;
///
- FL_OBJECT *button;
+ FL_OBJECT * button;
public:
///
- BitmapMenu(int n, FL_OBJECT* bt, BitmapMenu* prevx=0);
+ BitmapMenu(int n, FL_OBJECT * bt, BitmapMenu * prevx= 0);
///
~BitmapMenu();
///
- FL_OBJECT* AddBitmap(int id,
+ FL_OBJECT * AddBitmap(int id,
int nx, int ny, int bw, int bh,
- unsigned char* data, Bool vert=True); // Why Bool?
+ unsigned char * data, Bool vert= True); // Why Bool?
///
void Create();
///
///
void Next();
///
- int GetIndex(FL_OBJECT* ob);
+ int GetIndex(FL_OBJECT * ob);
};
// This is just a wrapper around peek_event()
-extern "C" int C_peek_event(FL_FORM *form, void *ptr);
+extern "C" int C_peek_event(FL_FORM * form, void * ptr);
inline
*/
#include <config.h>
-#include <stdlib.h>
-#include <ctype.h>
+#include <cstdlib>
+#include <cctype>
#ifdef __GNUG__
#pragma implementation "math_parser.h"
static short mathed_env = LM_EN_INTEXT;
-char *mathed_label = 0;
+char * mathed_label = 0;
-char const *latex_mathenv[] = {
+char const * latex_mathenv[] = {
"math",
"displaymath",
"equation",
};
-char const *latex_mathspace[] = {
+char const * latex_mathspace[] = {
"!", ",", ":", ";", "quad", "qquad"
};
-char const *latex_special_chars = "#$%&_{}";
+char const * latex_special_chars = "#$%&_{}";
// These are lexical codes, not semantic
enum lexcode_enum {
static lexcode_enum lexcode[256];
static char yytext[256];
static int yylineno;
-static FILE *yyin;
-static bool yy_mtextmode=false;
+static FILE * yyin;
+static bool yy_mtextmode= false;
inline
-char *strnew(char const* s)
+char * strnew(char const * s)
{
char *s1 = new char[strlen(s)+1]; // this leaks when not delete[]'ed
strcpy(s1, s);
}
-static void mathPrintError(char const *msg)
+static void mathPrintError(char const * msg)
{
lyxerr << "Line ~" << yylineno << ": Math parse error: "
<< msg << endl;
static void LexInitCodes()
{
- int i;
-
- for (i=0; i<=255; i++) {
+ for (int i = 0; i <= 255; ++i) {
if (isalpha(i)) lexcode[i] = LexAlpha;
else if (isdigit(i)) lexcode[i] = LexDigit;
else if (isspace(i)) lexcode[i] = LexSpace;
lexcode['%'] = LexComment;
lexcode['#'] = LexArgument;
lexcode['+'] = lexcode['-'] = lexcode['*'] = lexcode['/'] =
- lexcode['<'] = lexcode['>'] = lexcode['='] = LexBOP;
+ lexcode['<'] = lexcode['>'] = lexcode['= '] = LexBOP;
lexcode['!'] = lexcode[','] = lexcode[':'] = lexcode[';'] = LexMathSpace;
lexcode['('] = lexcode[')'] = lexcode['|'] = lexcode['.'] = lexcode['?'] = LexOther;
lexcode['}'] = LexClose;
}
-static char LexGetArg(char lf, bool accept_spaces=false)
+
+static char LexGetArg(char lf, bool accept_spaces= false)
{
- char c, rg, *p = &yytext[0];
- int bcnt =1;
+ char c, rg, * p = &yytext[0];
+ int bcnt = 1;
while (!feof(yyin)) {
c = getc(yyin);
if (c>' ') {
if (!lf) lf = c; else
- if (c!=lf)
+ if (c!= lf)
lyxerr << "Math parse error: unexpected '"
<< c << "'" << endl;
break;
}
}
- rg = (lf=='{') ? '}': ((lf=='[') ? ']': ((lf=='(') ? ')': 0));
+ rg = (lf == '{') ? '}': ((lf == '[') ? ']': ((lf == '(') ? ')': 0));
if (!rg) {
lyxerr << "Math parse error: unknown bracket '"
<< lf << "'" << endl;
}
do {
c = getc(yyin);
- if (c==lf) bcnt++;
- if (c==rg) bcnt--;
- if ((c>' ' || (c==' ' && accept_spaces)) && bcnt>0) *(p++) = c;
+ if (c == lf) bcnt++;
+ if (c == rg) bcnt--;
+ if ((c>' ' || (c == ' ' && accept_spaces)) && bcnt>0) *(p++) = c;
} while (bcnt>0 && !feof(yyin));
*p = '\0';
return rg;
}
+
static int yylex(void)
{
static int init_done = 0;
while (!feof(yyin)) {
c = getc(yyin);
- if (yy_mtextmode && c==' ') {
- yylval.i=' ';
+ if (yy_mtextmode && c == ' ') {
+ yylval.i= ' ';
return LM_TK_ALPHA;
}
- if (lexcode[c]==LexNewLine) {
+ if (lexcode[c] == LexNewLine) {
yylineno++;
continue;
}
- if (lexcode[c]==LexComment)
- do c = getc(yyin); while (c!='\n' % !feof(yyin)); // eat comments
+ if (lexcode[c] == LexComment)
+ do c = getc(yyin); while (c!= '\n' % !feof(yyin)); // eat comments
- if (lexcode[c]==LexDigit || lexcode[c]==LexOther || lexcode[c]==LexMathSpace)
+ if (lexcode[c] == LexDigit || lexcode[c] == LexOther || lexcode[c] == LexMathSpace)
{ yylval.i= c; return LM_TK_STR; }
- if (lexcode[c]==LexAlpha) { yylval.i=c; return LM_TK_ALPHA; }
- if (lexcode[c]==LexBOP) { yylval.i=c; return LM_TK_BOP; }
- if (lexcode[c]==LexSelf) { return c; }
- if (lexcode[c]==LexArgument) {
+ if (lexcode[c] == LexAlpha) { yylval.i= c; return LM_TK_ALPHA; }
+ if (lexcode[c] == LexBOP) { yylval.i= c; return LM_TK_BOP; }
+ if (lexcode[c] == LexSelf) { return c; }
+ if (lexcode[c] == LexArgument) {
c = getc(yyin);
yylval.i = c - '0';
return LM_TK_ARGUMENT;
}
- if (lexcode[c]==LexOpen) { return LM_TK_OPEN; }
- if (lexcode[c]==LexClose) { return LM_TK_CLOSE; }
+ if (lexcode[c] == LexOpen) { return LM_TK_OPEN; }
+ if (lexcode[c] == LexClose) { return LM_TK_CLOSE; }
- if (lexcode[c]==LexESC) {
+ if (lexcode[c] == LexESC) {
c = getc(yyin);
- if (c=='\\') { return LM_TK_NEWLINE; }
- if (c=='(') { yylval.i = LM_EN_INTEXT; return LM_TK_BEGIN; }
- if (c==')') { yylval.i = LM_EN_INTEXT; return LM_TK_END; }
- if (c=='[') { yylval.i = LM_EN_DISPLAY; return LM_TK_BEGIN; }
- if (c==']') { yylval.i = LM_EN_DISPLAY; return LM_TK_END; }
+ if (c == '\\') { return LM_TK_NEWLINE; }
+ if (c == '(') { yylval.i = LM_EN_INTEXT; return LM_TK_BEGIN; }
+ if (c == ')') { yylval.i = LM_EN_INTEXT; return LM_TK_END; }
+ if (c == '[') { yylval.i = LM_EN_DISPLAY; return LM_TK_BEGIN; }
+ if (c == ']') { yylval.i = LM_EN_DISPLAY; return LM_TK_END; }
if (strchr(latex_special_chars, c)) {
yylval.i = c;
return LM_TK_SPECIAL;
}
- if (lexcode[c]==LexMathSpace) {
+ if (lexcode[c] == LexMathSpace) {
int i;
- for (i=0; i<4 && c!=latex_mathspace[i][0]; i++);
+ for (i= 0; i<4 && c!= latex_mathspace[i][0]; i++);
yylval.i = (i<4) ? i: 0;
return LM_TK_SPACE;
}
- if (lexcode[c]==LexAlpha || lexcode[c]==LexDigit) {
+ if (lexcode[c] == LexAlpha || lexcode[c] == LexDigit) {
char* p = &yytext[0];
- while (lexcode[c]==LexAlpha || lexcode[c]==LexDigit) {
+ while (lexcode[c] == LexAlpha || lexcode[c] == LexDigit) {
*p = c;
c = getc(yyin);
p++;
if (!feof(yyin)) ungetc(c, yyin);
latexkeys *l = in_word_set (yytext, strlen(yytext));
if (l) {
- if (l->token==LM_TK_BEGIN || l->token==LM_TK_END) {
+ if (l->token == LM_TK_BEGIN || l->token == LM_TK_END) {
int i;
LexGetArg('{');
-// for (i=0; i<5 && strncmp(yytext, latex_mathenv[i],
+// for (i= 0; i<5 && strncmp(yytext, latex_mathenv[i],
// strlen(latex_mathenv[i])); i++);
- for (i=0; i<6 && strcmp(yytext, latex_mathenv[i]); i++);
+ for (i= 0; i<6 && strcmp(yytext, latex_mathenv[i]); i++);
yylval.i = i;
} else
- if (l->token==LM_TK_SPACE)
+ if (l->token == LM_TK_SPACE)
yylval.i = l->id;
else
yylval.l = l;
return 0;
}
-int parse_align(char *hor, char *)
-{
- char *c;
+int parse_align(char * hor, char *)
+{
int nc = 0;
- for (c=hor; c && *c>' '; c++) nc++;
+ for (char * c = hor; c && *c > ' '; ++c) nc++;
return nc;
}
+
// Accent hacks only for 0.12. Stolen from Cursor.
int accent = 0;
int nestaccent[8];
}
-MathedInset *doAccent(byte c, MathedTextCodes t)
+MathedInset * doAccent(byte c, MathedTextCodes t)
{
- MathedInset *ac = 0;
+ MathedInset * ac = 0;
- for (int i=accent-1; i>=0; i--) {
- if (i==accent-1)
+ for (int i= accent-1; i>= 0; i--) {
+ if (i == accent-1)
ac = new MathAccentInset(c, t, nestaccent[i]);
else
ac = new MathAccentInset(ac, nestaccent[i]);
}
-MathedInset *doAccent(MathedInset *p)
+MathedInset * doAccent(MathedInset * p)
{
- MathedInset *ac = 0;
+ MathedInset * ac = 0;
- for (int i=accent-1; i>=0; i--) {
- if (i==accent-1)
+ for (int i= accent-1; i>= 0; i--) {
+ if (i == accent-1)
ac = new MathAccentInset(p, nestaccent[i]);
else
ac = new MathAccentInset(ac, nestaccent[i]);
-LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **mtx)
+LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
+ MathParInset ** mtx)
{
int t = yylex(), tprev = 0;
bool panic = false;
static int size = LM_ST_TEXT;
MathedTextCodes varcode = LM_TC_VAR;
MathedInset* binset = 0;
- static MathMacroTemplate *macro=0;
+ static MathMacroTemplate *macro= 0;
int brace = 0;
int acc_brace = 0;
int acc_braces[8];
- MathParInset *mt = (mtx) ? *mtx: 0;//(MathParInset*)0;
- MathedRowSt *crow = (mt) ? mt->getRowSt(): 0;
+ MathParInset * mt = (mtx) ? *mtx: 0;//(MathParInset*)0;
+ MathedRowSt * crow = (mt) ? mt->getRowSt(): 0;
- plevel++;
+ ++plevel;
if (!array) array = new LyxArrayBase;
MathedIter data(array);
while (t) {
if ((flags & FLAG_BRACE) && t != LM_TK_OPEN) {
- if ((flags & FLAG_BRACK_ARG) && t=='[') {
+ if ((flags & FLAG_BRACK_ARG) && t == '[') {
}
else {
mathPrintError("Expected {. Maybe you forgot to enclose an argument in {}");
// ugly trick to be removed soon (lyx3)
char c = getc(yyin);
ungetc(c, yyin);
- if (c=='[') {
+ if (c == '[') {
LexGetArg('[');
na = atoi(yytext);
}
case LM_TK_OPEN:
{
brace++;
- if (accent && tprev==LM_TK_ACCENT) {
+ if (accent && tprev == LM_TK_ACCENT) {
acc_braces[acc_brace++] = brace;
break;
}
panic = true;
break;
}
- if (acc_brace && brace==acc_braces[acc_brace-1]-1) {
+ if (acc_brace && brace == acc_braces[acc_brace-1]-1) {
acc_brace--;
break;
}
{
if (flags & FLAG_BRACK_ARG) {
flags &= ~FLAG_BRACK_ARG;
- char rg=LexGetArg('[');
- if (rg!=']') {
+ char rg= LexGetArg('[');
+ if (rg!= ']') {
mathPrintError("Expected ']'");
panic = true;
break;
}
case '_':
{
- MathParInset *p = new MathParInset(size, "", LM_OT_SCRIPT);
+ MathParInset * p = new MathParInset(size, "", LM_OT_SCRIPT);
LyxArrayBase * ar = mathed_parse(FLAG_BRACE_OPT|FLAG_BRACE_LAST, 0);
p->SetData(ar);
data.Insert (p, LM_TC_DOWN);
}
case LM_TK_BIGSYM:
{
- binset = new MathBigopInset(yylval.l->name,yylval.l->id);
+ binset = new MathBigopInset(yylval.l->name, yylval.l->id);
data.Insert(binset);
break;
}
}
case LM_TK_SPACE:
{
- if (yylval.i>=0) {
- MathSpaceInset *sp = new MathSpaceInset(yylval.i);
+ if (yylval.i>= 0) {
+ MathSpaceInset * sp = new MathSpaceInset(yylval.i);
data.Insert(sp);
}
break;
}
case LM_TK_DOTS:
{
- MathDotsInset *p = new MathDotsInset(yylval.l->name, yylval.l->id);
+ MathDotsInset * p = new MathDotsInset(yylval.l->name, yylval.l->id);
data.Insert(p);
break;
}
fractype = LM_OT_STACKREL;
case LM_TK_FRAC:
{
- MathFracInset *fc = new MathFracInset(fractype);
- LyxArrayBase* num = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
- LyxArrayBase* den = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
+ MathFracInset * fc = new MathFracInset(fractype);
+ LyxArrayBase * num = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
+ LyxArrayBase * den = mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST);
fc->SetData(num, den);
data.Insert(fc, LM_TC_ACTIVE_INSET);
break;
}
case LM_TK_SQRT:
{
- MathParInset *rt;
+ MathParInset * rt;
char c = getc(yyin);
- if (c=='[') {
+ if (c == '[') {
rt = new MathRootInset(size);
rt->setArgumentIdx(0);
rt->SetData(mathed_parse(FLAG_BRACK_END, 0, &rt));
case LM_TK_LEFT:
{
int lfd, rgd;
- lfd=yylex();
- if (lfd==LM_TK_SYM || lfd==LM_TK_STR || lfd==LM_TK_BOP|| lfd==LM_TK_SPECIAL)
- lfd = (lfd==LM_TK_SYM) ? yylval.l->id: yylval.i;
+ lfd = yylex();
+ if (lfd == LM_TK_SYM || lfd == LM_TK_STR || lfd == LM_TK_BOP|| lfd == LM_TK_SPECIAL)
+ lfd = (lfd == LM_TK_SYM) ? yylval.l->id: yylval.i;
// lyxerr << "L[" << lfd << " " << lfd << "]";
- LyxArrayBase* a = mathed_parse(FLAG_RIGHT);
- rgd=yylex();
+ LyxArrayBase * a = mathed_parse(FLAG_RIGHT);
+ rgd = yylex();
// lyxerr << "R[" << rgd << "]";
- if (rgd==LM_TK_SYM || rgd==LM_TK_STR || rgd==LM_TK_BOP || rgd==LM_TK_SPECIAL)
- rgd = (rgd==LM_TK_SYM) ? yylval.l->id: yylval.i;
- MathDelimInset *dl = new MathDelimInset(lfd, rgd);
+ if (rgd == LM_TK_SYM || rgd == LM_TK_STR || rgd == LM_TK_BOP || rgd == LM_TK_SPECIAL)
+ rgd = (rgd == LM_TK_SYM) ? yylval.l->id: yylval.i;
+ MathDelimInset * dl = new MathDelimInset(lfd, rgd);
dl->SetData(a);
data.Insert(dl, LM_TC_ACTIVE_INSET);
// lyxerr << "RL[" << lfd << " " << rgd << "]";
case LM_TK_FONT:
{
varcode = (MathedTextCodes)yylval.l->id;
- yy_mtextmode = (bool)(varcode==LM_TC_TEXTRM);
+ yy_mtextmode = bool(varcode == LM_TC_TEXTRM);
flags |= (FLAG_BRACE|FLAG_BRACE_FONT);
break;
}
case LM_TK_WIDE:
{
- MathDecorationInset *sq = new MathDecorationInset(yylval.l->id, size);
+ MathDecorationInset * sq = new MathDecorationInset(yylval.l->id,
+ size);
sq->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
data.Insert(sq, LM_TC_ACTIVE_INSET);
break;
case LM_TK_PMOD:
case LM_TK_FUNC:
{
- MathedInset *bg = new MathFuncInset(yylval.l->name);
+ MathedInset * bg = new MathFuncInset(yylval.l->name);
if (accent) {
data.Insert(t);
} else
case LM_TK_UNDEF:
{
- MathMacro* p =
+ MathMacro * p =
MathMacroTable::mathMTable.getMacro(yylval.s);
if (p) {
if (accent)
data.Insert(doAccent(p), p->getTCode());
else
data.Insert(p, p->getTCode());
- for (int i=0; p->setArgumentIdx(i); i++)
+ for (int i= 0; p->setArgumentIdx(i); i++)
p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
}
else {
- MathedInset *q = new MathFuncInset(yylval.s, LM_OT_UNDEF);
+ MathedInset * q = new MathFuncInset(yylval.s, LM_OT_UNDEF);
if (accent) {
data.Insert(doAccent(q));
} else {
}
case LM_TK_END:
{
- if (mathed_env != yylval.i && yylval.i!=LM_EN_ARRAY)
+ if (mathed_env != yylval.i && yylval.i!= LM_EN_ARRAY)
mathPrintError("Unmatched environment");
// debug info [made that conditional -JMarc]
if (lyxerr.debugging(Debug::MATHED))
}
case LM_TK_BEGIN:
{
- if (yylval.i==LM_EN_ARRAY) {
+ if (yylval.i == LM_EN_ARRAY) {
char ar[120], ar2[8];
ar[0] = ar2[0] = '\0';
- char rg=LexGetArg(0);
- if (rg==']') {
+ char rg= LexGetArg(0);
+ if (rg == ']') {
strcpy(ar2, yytext);
rg = LexGetArg('{');
}
strcpy(ar, yytext);
int nc = parse_align(ar, ar2);
- MathParInset* mm = new MathMatrixInset(nc, 0);
+ MathParInset * mm = new MathMatrixInset(nc, 0);
mm->SetAlign(ar2[0], ar);
data.Insert(mm, LM_TC_ACTIVE_INSET);
mathed_parse(FLAG_END, mm->GetData(), &mm);
} else
- if (yylval.i>=LM_EN_INTEXT && yylval.i<=LM_EN_EQNARRAY) {
- if (plevel!=0) {
+ if (yylval.i>= LM_EN_INTEXT && yylval.i<= LM_EN_EQNARRAY) {
+ if (plevel!= 0) {
mathPrintError("Misplaced environment");
break;
}
}
mathed_env = yylval.i;
- if (mathed_env>=LM_EN_DISPLAY) {
+ if (mathed_env>= LM_EN_DISPLAY) {
size = LM_ST_DISPLAY;
if (mathed_env>LM_EN_EQUATION) {
mt = new MathMatrixInset(3, -1);
#endif
} else {
// lyxerr << "MATHCRO[" << yytext << "]";
- MathMacro* p =
+ MathMacro * p =
MathMacroTable::mathMTable.getMacro(yytext);
if (p) {
data.Insert(p, p->getTCode());
p->setArgumentIdx(0);
mathed_parse(FLAG_END, p->GetData(), (MathParInset**)&p);
-// for (int i=0; p->setArgumentIdx(i); i++)
+// for (int i= 0; p->setArgumentIdx(i); i++)
// p->SetData(mathed_parse(FLAG_BRACE|FLAG_BRACE_LAST));
} else
mathPrintError("Unrecognized environment");
case LM_TK_MACRO:
{
- MathedInset* p =
+ MathedInset * p =
MathMacroTable::mathMTable.getMacro(yylval.l->name);
if (p) {
} else
t = yylex ();
- if ((flags & FLAG_BRACE_OPT)/* && t!='^' && t!='_'*/) {
+ if ((flags & FLAG_BRACE_OPT)/* && t!= '^' && t!= '_'*/) {
flags &= ~FLAG_BRACE_OPT;
//data.Insert (LM_TC_CLOSE);
break;
}
-void mathed_parser_file(FILE* file, int lineno)
+void mathed_parser_file(FILE * file, int lineno)
{
yyin = file;
yylineno = lineno;
* the GNU General Public Licence version 2 or later.
*/
-#ifndef __MATH_PARSER__
-#define __MATH_PARSER__
+#ifndef MATH_PARSER
+#define MATH_PARSER
#ifdef __GNUG__
#pragma interface
};
///
-struct latexkeys { char const* name; short token; int id; };
+struct latexkeys { char const * name; short token; int id; };
///
struct latexkeys *
-in_word_set (register char const *str, register int len);
+in_word_set (register char const * str, register int len);
///
-struct latexkeys *lm_get_key(int index);
+struct latexkeys * lm_get_key(int index);
///
-struct latexkeys *lm_get_key_by_id(int id, short tc=LM_TK_SYM);
+struct latexkeys * lm_get_key_by_id(int id, short tc = LM_TK_SYM);
///
typedef union{
///
unsigned char c;
///
-char *s;
+char * s;
///
int i;
///
-latexkeys *l;
+latexkeys * l;
} YYSTYPE;
extern YYSTYPE yylval;
void MathRootInset::SetData(LyxArrayBase *d)
{
- if (idx==1)
+ if (idx == 1)
MathParInset::SetData(d);
else {
uroot->SetData(d);
bool MathRootInset::setArgumentIdx(int i)
{
- if (i==0 || i==1) {
+ if (i == 0 || i == 1) {
idx = i;
return true;
} else
void MathRootInset::GetXY(int& x, int& y) const
{
- if (idx==1)
+ if (idx == 1)
MathParInset::GetXY(x, y);
else
uroot->GetXY(x, y);
LyxArrayBase *MathRootInset::GetData()
{
- if (idx==1)
+ if (idx == 1)
return array;
else
return uroot->GetData();
* the GNU General Public Licence version 2 or later.
*/
-#ifndef __MATH_ROOT__
-#define __MATH_ROOT__
+#ifndef MATH_ROOT
+#define MATH_ROOT
#ifdef __GNUG__
#pragma interface
#endif
-#include <stdio.h>
+#include <cstdio>
#include "math_defs.h"
#include "math_inset.h"
#include "symbol_def.h"
class MathRootInset: public MathSqrtInset {
public:
///
- MathRootInset(short st=LM_ST_TEXT);
+ MathRootInset(short st = LM_ST_TEXT);
///
// MathRootInset(MathSqrtInset &);
///
~MathRootInset();
///
- MathedInset *Clone();
+ MathedInset * Clone();
///
void Draw(int x, int baseline);
///
- void Write(FILE *file);
+ void Write(FILE * file);
///
- void Write(string &file);
+ void Write(string & file);
///
void Metrics();
///
bool Inside(int, int);
///
- void SetFocus(int,int);
+ void SetFocus(int, int);
///
- void SetData(LyxArrayBase*);
+ void SetData(LyxArrayBase *);
///
void GetXY(int& x, int& y) const;
///
///
int idx;
///
- MathParInset *uroot;
+ MathParInset * uroot;
///
int wroot, dh;
};
-
-
#endif
static char const* latex_arrow[] = {
"downarrow", "leftarrow", "Downarrow", "Leftarrow",
"hookleftarrow", "rightarrow", "uparrow", "Rightarrow", "Uparrow",
- "hookrightarrow","updownarrow", "Leftrightarrow", "leftharpoonup",
+ "hookrightarrow", "updownarrow", "Leftrightarrow", "leftharpoonup",
"rightharpoonup", "rightleftharpoons", "leftrightarrow", "Updownarrow",
"leftharpoondown", "rightharpoondown", "mapsto",
"Longleftarrow", "Longrightarrow", "Longleftrightarrow",
FL_OBJECT*
BitmapMenu::AddBitmap(int id, int nx, int ny, int bw, int bh, unsigned char* data, Bool vert)
{
- if (i>=nb)
+ if (i>= nb)
return 0;
- int wx=bw+ww/2, wy=bh+ww/2;
+ int wx= bw+ww/2, wy= bh+ww/2;
wx += (wx % nx);
wy += (wy % ny);
FL_OBJECT *obj = fl_create_bmtable(1, x, y, wx, wy, "");
return;
}
form = fl_bgn_form(FL_UP_BOX, w, h);
- for (i=0; i<nb; i++) {
+ for (i= 0; i<nb; i++) {
fl_add_object(form, bitmap[i]);
bitmap[i]->u_vdata = this;
}
int BitmapMenu::GetIndex(FL_OBJECT* ob)
{
- if (active==this) {
+ if (active == this) {
int k = 0;
- for (i=0; i<nb; i++) {
- if (bitmap[i]==ob)
+ for (i= 0; i<nb; i++) {
+ if (bitmap[i] == ob)
return k+fl_get_bmtable(ob);
k += fl_get_bmtable_maxitems(bitmap[i]);
}
int peek_event(FL_FORM * /*form*/, void *xev)
{
- if (BitmapMenu::active==0)
+ if (BitmapMenu::active == 0)
return 0;
if(((XEvent *)xev)->type == ButtonPress)
char c[5];
KeySym keysym;
XLookupString(&((XEvent *)xev)->xkey, &c[0], 5, &keysym, 0);
- if (keysym==XK_Left)
+ if (keysym == XK_Left)
BitmapMenu::active->Prev(); else
- if (keysym==XK_Right)
+ if (keysym == XK_Right)
BitmapMenu::active->Next();
else
BitmapMenu::active->Hide();
// This is just a wrapper.
extern "C" int C_peek_event(FL_FORM *form, void *ptr) {
- return peek_event(form,ptr);
+ return peek_event(form, ptr);
}
char** get_pixmap_from_symbol(char const *arg, int wx, int hx)
{
- char** data=0;
+ char** data= 0;
latexkeys *l = in_word_set (arg, strlen(arg));
if (!l)
return 0;
Bool math_insert_greek(char const c)
{
int i;
- char const *s=0;
+ char const *s= 0;
- if ('A'<=c && c<='Z') {
- if ((i=Latin2Greek[c - 'A'])>=0)
+ if ('A'<= c && c<= 'Z') {
+ if ((i= Latin2Greek[c - 'A'])>= 0)
s = latex_greek[i];
}
- if ('a'<=c && c<='z') {
- if ((i=latin2greek[c - 'a'])>=0)
+ if ('a'<= c && c<= 'z') {
+ if ((i= latin2greek[c - 'a'])>= 0)
s = latex_greek[i+11];
}
if (s) {
BeforeChange();
current_view->buffer()->insertInset(new_inset);
// Update(1);//BUG
- new_inset->Edit(0,0);
+ new_inset->Edit(0, 0);
new_inset->InsertSymbol(s);
} else
- if (current_view->buffer()->the_locking_inset->LyxCode()==Inset::MATH_CODE)
+ if (current_view->buffer()->the_locking_inset->LyxCode() == Inset::MATH_CODE)
static_cast<InsetFormula*>(current_view->buffer()->the_locking_inset)->InsertSymbol(s);
else
lyxerr << "Math error: attempt to write on a wrong "
}
}
-BitmapMenu * sym_menu=0;
+BitmapMenu * sym_menu= 0;
void create_symbol_menues(FD_panel * symb_form)
{
char** pixmapFromBitmapData(char const *s, int wx, int hx)
{
int i, id;
- char** data=0;
+ char** data= 0;
- id=-1;
+ id= -1;
- for (i=0; i<6; i++) {
+ for (i= 0; i<6; i++) {
char const **latex_str = 0;
switch (i) {
case 0: latex_str = latex_greek; break;
}
for (int k = 0; latex_str[k][0]>' '; k++) {
- if (strcmp(latex_str[k], s)==0) {
+ if (strcmp(latex_str[k], s) == 0) {
id = k;
break;
}
}
- if (id>=0) break;
+ if (id>= 0) break;
}
- if (i<6 && id>=0) {
+ if (i<6 && id>= 0) {
unsigned char *bdata = 0;
int w = 0, h = 0, dw = 0, dh = 0;
lyxerr[Debug::MATHED] << "Imando " << i << ", " << id << endl;
switch (i) {
case 0:
- if (id<=10) {
+ if (id<= 10) {
w = Greek_width;
h = Greek_height;
bdata = Greek_bits;
// Dirty hack to get blue symbols quickly
char *sx = strstr(data[2], "FFFFFFFF");
if (sx) {
- for (int k=0; k<8; k++) sx[k] = '0';
+ for (int k= 0; k<8; k++) sx[k] = '0';
}
// XDestroyImage(xima);
issorted = true;
}
- int result=0, m, k, l= 0, r = bopCount;
+ int result= 0, m, k, l= 0, r = bopCount;
while (l < r) {
m = (l+r)/2;
k = binary_op_table[m].id - id;
- if (k==0) {
+ if (k == 0) {
result = binary_op_table[m].isrel;
break;
} else
#include "support/lstrings.h"
#include "debug.h"
-extern char const *latex_mathenv[];
-extern char *latex_mathspace[];
+extern char const * latex_mathenv[];
+extern char * latex_mathspace[];
// quite a hack i know. Should be done with return values...
static int number_of_newlines;
-char const *math_font_name[] = {
+char const * math_font_name[] = {
"mathrm",
"mathcal",
"mathbf",
void
-MathSpaceInset::Write(FILE *outf)
+MathSpaceInset::Write(FILE * outf)
{
- if (space>=0 && space<6) {
+ if (space >= 0 && space < 6) {
string output;
MathSpaceInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
void
-MathSpaceInset::Write(string &outf)
+MathSpaceInset::Write(string & outf)
{
- if (space>=0 && space<6) {
+ if (space >= 0 && space < 6) {
outf += '\\';
outf += latex_mathspace[space];
outf += ' ';
void
-MathDotsInset::Write(FILE *outf)
+MathDotsInset::Write(FILE * outf)
{
string output;
MathDotsInset::Write(output);
}
void
-MathDotsInset::Write(string &outf)
+MathDotsInset::Write(string & outf)
{
outf += '\\';
outf += name;
}
-void MathSqrtInset::Write(FILE *outf)
+void MathSqrtInset::Write(FILE * outf)
{
string output;
MathSqrtInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
-void MathSqrtInset::Write(string &outf)
+void MathSqrtInset::Write(string & outf)
{
outf += '\\';
outf += name;
}
-void MathDelimInset::Write(FILE *outf)
+void MathDelimInset::Write(FILE * outf)
{
string output;
MathDelimInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
-void MathDelimInset::Write(string &outf)
+void MathDelimInset::Write(string & outf)
{
- latexkeys* l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
- latexkeys* r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
+ latexkeys * l = (left != '|') ? lm_get_key_by_id(left, LM_TK_SYM): 0;
+ latexkeys * r = (right != '|') ? lm_get_key_by_id(right, LM_TK_SYM): 0;
outf += "\\left";
if (l) {
outf += '\\';
outf += l->name;
outf += ' ';
} else {
- if (left=='{' || left=='}') {
+ if (left == '{' || left == '}') {
outf += '\\';
outf += (char) left;
outf += ' ';
outf += r->name;
outf += ' ';
} else {
- if (right=='{' || right=='}') {
+ if (right == '{' || right == '}') {
outf += '\\';
outf += (char) right;
outf += ' ';
}
-void MathDecorationInset::Write(FILE *outf)
+void MathDecorationInset::Write(FILE * outf)
{
string output;
MathDecorationInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
-void MathDecorationInset::Write(string &outf)
+void MathDecorationInset::Write(string & outf)
{
- latexkeys* l = lm_get_key_by_id(deco, LM_TK_WIDE);
+ latexkeys * l = lm_get_key_by_id(deco, LM_TK_WIDE);
outf += '\\';
outf += l->name;
outf += '{';
}
-void MathAccentInset::Write(FILE *outf)
+void MathAccentInset::Write(FILE * outf)
{
string output;
MathAccentInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
-void MathAccentInset::Write(string &outf)
+void MathAccentInset::Write(string & outf)
{
- latexkeys* l = lm_get_key_by_id(code, LM_TK_ACCENT);
+ latexkeys * l = lm_get_key_by_id(code, LM_TK_ACCENT);
outf += '\\';
outf += l->name;
- if (code!=LM_not)
+ if (code!= LM_not)
outf += '{';
else
outf += ' ';
if (inset) {
inset->Write(outf);
} else {
- if (fn>=LM_TC_RM && fn<=LM_TC_TEXTRM) {
+ if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM) {
outf += '\\';
outf += math_font_name[fn-LM_TC_RM];
outf += '{';
} else
outf += (char) c;
- if (fn>=LM_TC_RM && fn<=LM_TC_TEXTRM)
+ if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
outf += '}';
}
- if (code!=LM_not)
+ if (code!= LM_not)
outf += '}';
}
-void MathBigopInset::Write(FILE *outf)
+void MathBigopInset::Write(FILE * outf)
{
string output;
MathBigopInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
-void MathBigopInset::Write(string &outf)
+void MathBigopInset::Write(string & outf)
{
bool limp = GetLimits();
outf += '\\';
outf += name;
- if (limp && !(sym!=LM_int && sym!=LM_oint && (GetStyle()==LM_ST_DISPLAY)))
+ if (limp && !(sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY)))
outf += "\\limits ";
else
- if (!limp && (sym!=LM_int && sym!=LM_oint && (GetStyle()==LM_ST_DISPLAY)))
+ if (!limp && (sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY)))
outf += "\\nolimits ";
else
outf += ' ';
}
-void MathFracInset::Write(FILE *outf)
+void MathFracInset::Write(FILE * outf)
{
string output;
MathFracInset::Write(output);
fprintf(outf, "%s", output.c_str());
}
-void MathFracInset::Write(string &outf)
+void MathFracInset::Write(string & outf)
{
outf += '\\';
outf += name;
}
-void MathParInset::Write(FILE *outf)
+void MathParInset::Write(FILE * outf)
{
if (!array) return;
string output;
}
-void MathParInset::Write(string &outf)
+void MathParInset::Write(string & outf)
{
if (!array) return;
int brace = 0;
- latexkeys *l;
+ latexkeys * l;
MathedIter data(array);
// hack
- MathedRowSt const* crow = getRowSt();
+ MathedRowSt const * crow = getRowSt();
data.Reset();
if (!Permit(LMPF_FIXED_SIZE)) {
}
while (data.OK()) {
byte cx = data.GetChar();
- if (cx>=' ') {
+ if (cx>= ' ') {
int ls;
- byte *s = data.GetString(ls);
+ byte * s = data.GetString(ls);
- if (data.FCode()>=LM_TC_RM && data.FCode()<=LM_TC_TEXTRM) {
+ if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM) {
outf += '\\';
outf += math_font_name[data.FCode()-LM_TC_RM];
outf += '{';
}
while (ls>0) {
if (MathIsSymbol(data.FCode())) {
- l = lm_get_key_by_id(*s,(data.FCode()==LM_TC_BSYM)?LM_TK_BIGSYM:LM_TK_SYM);
+ l = lm_get_key_by_id(*s,(data.FCode() == LM_TC_BSYM)?LM_TK_BIGSYM:LM_TK_SYM);
if (l) {
outf += '\\';
outf += l->name;
}
} else {
// Is there a standard logical XOR?
- if ((data.FCode()==LM_TC_TEX && *s!='{' && *s!='}') ||
- (data.FCode()==LM_TC_SPECIAL))
+ if ((data.FCode() == LM_TC_TEX && *s!= '{' && *s!= '}') ||
+ (data.FCode() == LM_TC_SPECIAL))
outf += '\\';
else {
- if (*s=='{') brace++;
- if (*s=='}') brace--;
+ if (*s == '{') brace++;
+ if (*s == '}') brace--;
}
- if (*s=='}' && data.FCode()==LM_TC_TEX && brace<0)
+ if (*s == '}' && data.FCode() == LM_TC_TEX && brace<0)
lyxerr <<"Math warning: Unexpected closing brace."
<< endl;
else
}
s++; ls--;
}
- if (data.FCode()>=LM_TC_RM && data.FCode()<=LM_TC_TEXTRM)
+ if (data.FCode()>= LM_TC_RM && data.FCode()<= LM_TC_TEXTRM)
outf += '}';
} else
if (MathIsInset(cx)) {
MathedInset *p = data.GetInset();
- if (cx==LM_TC_UP)
+ if (cx == LM_TC_UP)
outf += "^{";
- if (cx==LM_TC_DOWN)
+ if (cx == LM_TC_DOWN)
outf += "_{";
p->Write(outf);
- if (cx==LM_TC_UP || cx==LM_TC_DOWN)
+ if (cx == LM_TC_UP || cx == LM_TC_DOWN)
outf += '}';
data.Next();
} else
{
if (crow) {
if (!crow->isNumbered()) {
- outf +="\\nonumber ";
+ outf += "\\nonumber ";
}
if (crow->getLabel()) {
outf += "\\label{";
if (crow) {
if (!crow->isNumbered()) {
- outf +="\\nonumber ";
+ outf += "\\nonumber ";
}
if (crow->getLabel()) {
outf += "\\label{";
outf += "\\begin{";
outf += name;
outf += '}';
- if (v_align=='t' || v_align=='b') {
+ if (v_align == 't' || v_align == 'b') {
outf += '[';
outf += (char) v_align;
outf += ']';
extern int tex_code_break_column;
-void mathed_write(MathParInset* p, string& outf, int* newlines,
+void mathed_write(MathParInset* p, string & outf, int* newlines,
char fragile, char const* label)
{
number_of_newlines = 0;
short mathed_env = p->GetType();
- if (mathed_env==LM_EN_INTEXT) {
+ if (mathed_env == LM_EN_INTEXT) {
if (fragile) outf += "\\protect";
outf += "\\( "; // changed from " \\( " (Albrecht Dress)
}
outf += "\n";
number_of_newlines++;
}
- if (mathed_env==LM_EN_DISPLAY){
+ if (mathed_env == LM_EN_DISPLAY){
outf += "\\[\n";
}
else {
number_of_newlines++;
}
- if (label && label[0]>' ' && mathed_env==LM_EN_EQUATION){
+ if (label && label[0]>' ' && mathed_env == LM_EN_EQUATION){
outf += "\\label{";
outf += label;
outf += "}\n";
p->Write(outf);
- if (mathed_env==LM_EN_INTEXT){
+ if (mathed_env == LM_EN_INTEXT){
if (fragile) outf += "\\protect";
outf += " \\)";
}
- else if (mathed_env==LM_EN_DISPLAY){
+ else if (mathed_env == LM_EN_DISPLAY){
outf += "\\]\n";
number_of_newlines++;
}
outf += "\n\\end{";
outf += latex_mathenv[mathed_env];
outf += "}\n";
- number_of_newlines+=2;
+ number_of_newlines+= 2;
}
*newlines = number_of_newlines;
}
// This file was created automatically. Don't change it! [asierra18jan96]
-#ifndef __SYMBOL_DEF__
-#define __SYMBOL_DEF__
+#ifndef SYMBOL_DEF
+#define SYMBOL_DEF
// Symbols that do exist in X11 symbol font
#define LM_Gamma 0x47
LM_bigcap, LM_bigcup, LM_biguplus, LM_bigvee, LM_bigwedge,
LM_ell, LM_imath, LM_jmath, LM_hbar, LM_angle, LM_top, LM_Vert, LM_flat,
LM_natural, LM_triangle,
- LM_widehat,LM_widetilde, LM_underline, LM_overline, LM_underbrace,
+ LM_widehat, LM_widetilde, LM_underline, LM_overline, LM_underbrace,
LM_overbrace, LM_overleftarrow, LM_overightarrow,
LM_ldots, LM_cdots, LM_vdots, LM_ddots,
LM_backslash, LM_emptyset,