From: Lars Gullik Bjønnes Date: Mon, 15 Nov 1999 11:06:41 +0000 (+0000) Subject: white-space changes. X-Git-Tag: 1.6.10~22522 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d8a6abd63afb7e88a014e2f7acf84069396d52ff;p=lyx.git white-space changes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@313 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/mathed/array.h b/src/mathed/array.h index 88fc0ad24b..7562df412a 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -39,7 +39,7 @@ public: }; /// - LyxArrayBase(int size=ARRAY_STEP); + LyxArrayBase(int size= ARRAY_STEP); /// LyxArrayBase(const LyxArrayBase&); /// @@ -47,7 +47,7 @@ public: /// - int Empty() { return (last==0); } + int Empty() { return (last == 0); } /// int Last() { return last; } @@ -83,7 +83,7 @@ public: byte operator[](const int); /// Constructs a new array with dx elements starting at pos - LyxArrayBase& operator=(const LyxArrayBase&); + LyxArrayBase& operator= (const LyxArrayBase&); protected: /// @@ -152,7 +152,7 @@ LyxArrayBase::LyxArrayBase(const LyxArrayBase& a) } inline -LyxArrayBase& LyxArrayBase::operator=(const LyxArrayBase& a) +LyxArrayBase& LyxArrayBase::operator= (const LyxArrayBase& a) { if (this != &a) { Resize(a.maxsize); @@ -165,8 +165,8 @@ inline 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); @@ -227,9 +227,9 @@ inline 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; } diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 072ae17914..1af49fe968 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -78,18 +78,18 @@ int MathedInset::df_width; // 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); @@ -138,7 +138,7 @@ LyXFont WhichFont(short type, int size) switch (size) { case LM_ST_DISPLAY: - if (type==LM_TC_BSYM) { + if (type == LM_TC_BSYM) { f.incSize(); f.incSize(); } @@ -157,7 +157,7 @@ LyXFont WhichFont(short type, int size) break; } - if (type!=LM_TC_TEXTRM) + if (type!= LM_TC_TEXTRM) f.setColor(LyXFont::MATH); return f; } @@ -169,7 +169,7 @@ void mathed_init_fonts() //removed 'static' because DEC cxx does not 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); @@ -207,7 +207,7 @@ void mathed_set_font(short type, int size) 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 @@ -222,7 +222,7 @@ int mathed_string_width(short type, int size, byte const* s, int ls) byte sx[80]; if (MathIsBinary(type)) { byte *ps = &sx[0]; - for (int i=0; i des) des = font.descent(s[i]); if (font.ascent(s[i]) > asc) @@ -271,7 +271,7 @@ void MathedInset::drawStr(short type, int siz, int x, int y, byte* s, int ls) byte sx[80]; if (MathIsBinary(type)) { byte *ps = &sx[0]; - for (int i=0; i(s), ls); XFlush(fl_display); } @@ -300,7 +300,7 @@ InsetFormula::InsetFormula(bool 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; @@ -424,7 +424,7 @@ void InsetFormula::Draw(LyXFont f, LyXScreen &scr, int baseline, float &x) 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); @@ -439,21 +439,21 @@ void InsetFormula::Draw(LyXFont f, LyXScreen &scr, int baseline, float &x) } 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) { @@ -574,12 +574,12 @@ void InsetFormula::ToggleInsetSelection() 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; @@ -588,7 +588,7 @@ void InsetFormula::SetDisplay(bool dspf) } 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(); } } @@ -601,9 +601,9 @@ void InsetFormula::SetDisplay(bool dspf) 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++; @@ -622,14 +622,14 @@ string InsetFormula::getLabel(int il) const { //#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; } @@ -661,7 +661,7 @@ void InsetFormula::InsetButtonRelease(int x, int y, int /*button*/) if (sel_flag) { sel_flag = false; sel_x = sel_y = 0; - UpdateInset(this,false); + UpdateInset(this, false); } } @@ -692,7 +692,7 @@ void InsetFormula::InsetMotionNotify(int x, int y, int /*button*/) 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; } @@ -708,7 +708,7 @@ bool InsetFormula::SetNumber(bool numbf) { 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); @@ -722,16 +722,16 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) // 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) { @@ -886,7 +886,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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()) { @@ -905,7 +905,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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()); @@ -945,13 +945,13 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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; } @@ -974,7 +974,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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; @@ -984,7 +984,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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) @@ -1028,7 +1028,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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); @@ -1053,7 +1053,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) // 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 { @@ -1072,20 +1072,20 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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; @@ -1102,49 +1102,49 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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) @@ -1159,10 +1159,10 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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")); @@ -1174,7 +1174,7 @@ bool InsetFormula::LocalDispatch(int action, char const *arg) 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))) @@ -1197,7 +1197,7 @@ MathFuncInset::Draw(int x, int y) 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); @@ -1227,11 +1227,11 @@ void mathedValidate(LaTeXFeatures &features, MathParInset *par) 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); } @@ -1239,7 +1239,7 @@ void mathedValidate(LaTeXFeatures &features, MathParInset *par) } else { MathedInset* p = it.GetInset(); if (!features.boldsymbol && p->GetName() && - strcmp(p->GetName(), "boldsymbol")==0) { + strcmp(p->GetName(), "boldsymbol") == 0) { features.boldsymbol = true; } } diff --git a/src/mathed/formula.h b/src/mathed/formula.h index f24bcaa219..e040f55534 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -14,14 +14,13 @@ * 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" @@ -32,35 +31,35 @@ class MathedCursor; 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; } /// @@ -71,7 +70,7 @@ public: } /// 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); /// @@ -85,7 +84,7 @@ public: /// void HideInsetCursor(); /// - void GetCursorPos(int&, int&); + void GetCursorPos(int &, int &); /// void ToggleInsetSelection(); /// @@ -93,17 +92,17 @@ public: /// 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); /// @@ -113,12 +112,11 @@ public: protected: void UpdateLocal(); - MathParInset* par; + MathParInset * par; static MathedCursor* mathcursor; private: bool disp_flag; - //char *label; string label; }; @@ -128,4 +126,3 @@ private: bool OpenMathInset(Buffer *); #endif - diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 9149979157..806ad0cc6b 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -160,8 +160,8 @@ void InsetFormulaMacro::Draw(LyXFont font, LyXScreen &scr, } 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); @@ -197,9 +197,9 @@ void InsetFormulaMacro::InsetUnlock() 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 && igetNoArgs()) { + if (i>= 0 && igetNoArgs()) { mathcursor->Insert(tmacro->getMacroPar(i), LM_TC_INSET); InsetFormula::UpdateLocal(); } diff --git a/src/mathed/formulamacro.h b/src/mathed/formulamacro.h index 4e06ef80f9..1a95390f97 100644 --- a/src/mathed/formulamacro.h +++ b/src/mathed/formulamacro.h @@ -14,8 +14,8 @@ * 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 @@ -35,7 +35,7 @@ public: /// InsetFormulaMacro(); /// - InsetFormulaMacro(string name, int na=0, bool env=false); + InsetFormulaMacro(string name, int na= 0, bool env= false); /// ~InsetFormulaMacro(); /// diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index 209baf8a7d..8d02039c92 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -33,11 +33,11 @@ extern void mathed_set_font(short type, int style); 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 @@ -68,7 +68,7 @@ struct MathStackXIter { 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; } @@ -97,23 +97,23 @@ struct MathStackXIter { } 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; kGetType()>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); @@ -173,7 +173,7 @@ void MathedCursor::Redraw() 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); @@ -273,7 +273,7 @@ bool MathedCursor::Right(bool sel) } 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(); @@ -340,19 +340,19 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) { 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()GetType()>LM_OT_MIN) { + if (p == par && p->GetType()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; @@ -367,7 +367,7 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) 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) { @@ -376,7 +376,7 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) } 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); @@ -385,7 +385,7 @@ void MathedCursor::Insert(byte c, MathedTextCodes t) } } else { if (macro_mode) { - if (MathIsAlphaFont(t) || t==LM_TC_MIN) { + if (MathIsAlphaFont(t) || t == LM_TC_MIN) { MacroModeInsert(c); return; } @@ -439,7 +439,7 @@ void MathedCursor::Delete() if (cursor->Empty() && !mathstk.Empty()) { cursor = mathstk.pop(); } -// if (cursor->GetChar()!=LM_TC_TAB) +// if (cursor->GetChar()!= LM_TC_TAB) cursor->Delete(); cursor->checkTabs(); } @@ -452,7 +452,7 @@ void MathedCursor::DelLine() 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(); } } @@ -490,9 +490,9 @@ bool MathedCursor::Up(bool sel) 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(); @@ -544,9 +544,9 @@ bool MathedCursor::Down(bool sel) 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(); @@ -571,7 +571,7 @@ bool MathedCursor::Limits() MathedInset *p = cursor->GetInset(); bool ol = p->GetLimits(); p->SetLimits(!ol); - return (ol!=p->GetLimits()); + return (ol!= p->GetLimits()); } return false; } @@ -605,9 +605,9 @@ void MathedCursor::Interpret(char const *s) 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 @@ -615,18 +615,18 @@ void MathedCursor::Interpret(char const *s) 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; @@ -637,7 +637,7 @@ void MathedCursor::Interpret(char const *s) 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 @@ -771,7 +771,7 @@ void MathedCursor::MacroModeClose() } 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(); @@ -820,7 +820,7 @@ void MathedCursor::SelCopy() 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; @@ -836,7 +836,7 @@ void MathedCursor::SelDel() { // lyxerr << "Deleting sel " if (selection) { - if (cursor->pos==selpos) return; + if (cursor->pos == selpos) return; cursor->Clean(selpos); cursor->Adjust(); SelClear(); @@ -930,7 +930,7 @@ XPoint *MathedCursor::SelGetArea(int& np) 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 (x1xo) { @@ -957,7 +957,7 @@ XPoint *MathedCursor::SelGetArea(int& np) np = i; // lyxerr << "AN[" << x << " " << y << " " << x1 << " " << y1 << "] "; // lyxerr << "MT[" << a << " " << d << " " << a1 << " " << d1 << "] "; -// for (i=0; 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]); @@ -1001,8 +1001,8 @@ void MathedCursor::doAccent(MathedInset *p) { 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]); diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index dea75ab022..1772357f3e 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -16,8 +16,8 @@ * 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 @@ -31,25 +31,25 @@ 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(); /// @@ -67,26 +67,26 @@ class MathedCursor { /// 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; /// @@ -117,7 +117,7 @@ class MathedCursor { /// void SelBalance(); /// - XPoint *SelGetArea(int&); + XPoint * SelGetArea(int &); /// void clearLastCode() { lastcode = LM_TC_MIN; } /// @@ -139,7 +139,7 @@ class MathedCursor { /// int selpos; /// - MathedXIter cursel, *anchor; + MathedXIter cursel, * anchor; /// // LyxArrayBase *selarray; /// @@ -147,15 +147,15 @@ class MathedCursor { /// 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; /// @@ -169,7 +169,7 @@ class MathedCursor { /// int macroln; /// - MathFuncInset* imacro; + MathFuncInset * imacro; }; @@ -177,4 +177,3 @@ class MathedCursor { #endif - diff --git a/src/mathed/math_defs.h b/src/mathed/math_defs.h index 0e34bb0ce4..58f8ef217d 100644 --- a/src/mathed/math_defs.h +++ b/src/mathed/math_defs.h @@ -47,7 +47,7 @@ /// Standard Math Sizes (Math mode styles) enum MathedStyles { /// - LM_ST_DISPLAY=0, + LM_ST_DISPLAY= 0, /// LM_ST_TEXT, /// @@ -60,7 +60,7 @@ enum MathedStyles { /// Standard LaTeX Math Environments enum MathedEnvironment { /// - LM_EN_INTEXT=0, + LM_EN_INTEXT= 0, /// LM_EN_DISPLAY, /// @@ -224,18 +224,18 @@ class MathedInset { 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; } /// @@ -319,7 +319,7 @@ enum MathedParFlag { 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*); /// @@ -347,9 +347,9 @@ class MathParInset: public MathedInset { /// 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); @@ -372,7 +372,7 @@ class MathParInset: public MathedInset { // Vertical switching /// - virtual bool setArgumentIdx(int i) { return (i==0); } + virtual bool setArgumentIdx(int i) { return (i == 0); } /// virtual bool setNextArgIdx() { return false; } /// @@ -408,7 +408,7 @@ class MathParInset: public MathedInset { /// 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); }; @@ -473,7 +473,7 @@ struct MathedRowSt { 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*); /// @@ -531,9 +531,9 @@ class MathMatrixInset: public MathParInset { /// 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); /// @@ -544,19 +544,19 @@ int MathedLookupBOP(short); /************************ 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) @@ -564,12 +564,12 @@ int MathedLookupBOP(short); /// 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); } @@ -583,7 +583,7 @@ MathedInset::MathedInset(char const *nm, short ot, short st): 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); } @@ -597,7 +597,7 @@ void MathParInset::GetXY(int& x, int& y) const inline void MathParInset::UserSetSize(short sz) { - if (sz>=0) { + if (sz>= 0) { size = sz; flag = flag & ~LMPF_FIXED_SIZE; } diff --git a/src/mathed/math_delim.C b/src/mathed/math_delim.C index acc7687bcc..a60dce8217 100644 --- a/src/mathed/math_delim.C +++ b/src/mathed/math_delim.C @@ -227,17 +227,17 @@ inline int odd(int x) { return ((x) & 1); } 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&); @@ -253,7 +253,7 @@ void Matriz::rota(int code) 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; @@ -264,7 +264,7 @@ void Matriz::rota(int code) 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); } @@ -274,7 +274,7 @@ void Matriz::matmat(matriz_data& a) { 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]; } @@ -291,9 +291,9 @@ extern GC latexGC, mathGC, mathLineGC, cursorGC; 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; } @@ -303,7 +303,7 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int code) 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; @@ -321,7 +321,7 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int code) 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) { @@ -331,7 +331,7 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int 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); @@ -345,10 +345,10 @@ void mathed_draw_deco(Window win, int x, int y, int w, int h, int code) case 4: { n = (int)d[i++]; - for (j=0; jp->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; @@ -102,25 +102,25 @@ MathParInset::Draw(int x, int y) 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; @@ -133,9 +133,9 @@ MathParInset::Draw(int x, int y) } 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); } } @@ -144,10 +144,10 @@ MathParInset::Draw(int x, int y) 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; @@ -173,11 +173,11 @@ MathParInset::Metrics() 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(); @@ -185,14 +185,14 @@ MathParInset::Metrics() } 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 (ascent0) { 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 (ascent4*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); } @@ -268,7 +268,7 @@ MathSqrtInset::Metrics() 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; @@ -281,11 +281,11 @@ MathFracInset::Draw(int x, int y) 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; @@ -301,7 +301,7 @@ MathFracInset::Metrics() 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; @@ -324,9 +324,9 @@ MathBigopInset::Draw(int x, int y) 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 { @@ -335,8 +335,8 @@ MathBigopInset::Draw(int x, int y) 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++; } @@ -352,9 +352,9 @@ MathBigopInset::Metrics() 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 { @@ -365,6 +365,6 @@ MathBigopInset::Metrics() mathed_set_font(t, size); mathed_string_height(t, size, reinterpret_cast(s), ls, ascent, descent); width = mathed_string_width(t, size, reinterpret_cast(s), ls); - if (sym==LM_oint) width += 2; + if (sym == LM_oint) width += 2; } diff --git a/src/mathed/math_forms.C b/src/mathed/math_forms.C index 04c7a2062c..3c0ec49ad2 100644 --- a/src/mathed/math_forms.C +++ b/src/mathed/math_forms.C @@ -6,7 +6,7 @@ /* Form definition file generated with fdesign. */ #include FORMS_H_LOCATION -#include +#include #include "math_panel.h" FD_panel *create_form_panel(void) @@ -15,62 +15,62 @@ 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; @@ -85,32 +85,32 @@ FD_delim *create_form_delim(void) 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; @@ -125,39 +125,39 @@ FD_matrix *create_form_matrix(void) 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; @@ -172,13 +172,13 @@ FD_deco *create_form_deco(void) 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; @@ -193,42 +193,42 @@ FD_space *create_form_space(void) 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(); diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 02f5ac5247..a89e60394c 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -1,9 +1,9 @@ /* C code produced by gperf version 2.5 (GNU C++ version) */ /* Command-line: gperf -a -p -o -t -G -D keywords */ #include -#include -#include -#include +#include +#include +#include #include "math_defs.h" #include "math_parser.h" @@ -17,9 +17,9 @@ /* 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, @@ -38,7 +38,7 @@ hash (register const char *str, register int len) 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}, @@ -312,7 +312,7 @@ static struct latexkeys wordlist[] = {"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, @@ -353,7 +353,7 @@ static short lookup[] = }; 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) { @@ -392,7 +392,7 @@ latexkeys *lm_get_key_by_id(int t, short tk) 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; diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index b977e6b5ce..3656a70a87 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -56,8 +56,8 @@ MathFuncInset::MathFuncInset(char const *nm, short ot, short st): 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 { @@ -91,7 +91,7 @@ MathParInset::MathParInset(short st, char const *nm, short ot): width = 4; descent = 0; flag = 1; - if (objtype==LM_OT_SCRIPT) + if (objtype == LM_OT_SCRIPT) flag |= LMPF_SCRIPT; } @@ -130,7 +130,7 @@ void MathParInset::SetData(LyxArrayBase *a) 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(); @@ -155,7 +155,7 @@ MathedInset *MathSqrtInset::Clone() 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); } @@ -176,7 +176,7 @@ MathedInset *MathDelimInset::Clone() 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() @@ -193,7 +193,7 @@ MathFracInset::MathFracInset(short ot): MathParInset(LM_ST_TEXT, "frac", ot) 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"); } @@ -217,7 +217,7 @@ MathedInset *MathFracInset::Clone() bool MathFracInset::setArgumentIdx(int i) { - if (i==0 || i==1) { + if (i == 0 || i == 1) { idx = i; return true; } else @@ -229,7 +229,7 @@ void MathFracInset::SetStyle(short st) { 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) @@ -240,7 +240,7 @@ 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); @@ -249,7 +249,7 @@ void MathFracInset::SetData(LyxArrayBase *d) void MathFracInset::GetXY(int& x, int& y) const { - if (idx==0) + if (idx == 0) MathParInset::GetXY(x, y); else den->GetXY(x, y); @@ -257,7 +257,7 @@ void MathFracInset::GetXY(int& x, int& y) const LyxArrayBase *MathFracInset::GetData() { - if (idx==0) + if (idx == 0) return array; else return den->GetData(); @@ -268,7 +268,7 @@ bool MathFracInset::Inside(int x, int y) { 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) @@ -284,7 +284,7 @@ MathMatrixInset::MathMatrixInset(int m, int n, short st): 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; @@ -294,7 +294,7 @@ MathMatrixInset::MathMatrixInset(int m, int n, short st): 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); } @@ -317,7 +317,7 @@ MathMatrixInset::MathMatrixInset(MathMatrixInset *mt): 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); @@ -406,8 +406,8 @@ void MathMatrixInset::Draw(int x, int baseline) 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 "; @@ -418,14 +418,14 @@ void MathMatrixInset::Metrics() // 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; } @@ -433,12 +433,12 @@ void MathMatrixInset::Metrics() // Vertical positions of each row cxrow = row; while (cxrow) { - for (i=0; iw[i]) ws[i]=cxrow->w[i]; - if (cxrow->next==0 && ws[i]==0) ws[i] = df_width; + for (i= 0; iw[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; @@ -461,10 +461,10 @@ void MathMatrixInset::Metrics() cxrow = row; width = MATH_COLSEP; while (cxrow) { - int rg=MATH_COLSEP, ww, lf=0, *w = cxrow->w; - for (i=0; iw; + for (i= 0; iy -= ascent; cxrow = cxrow->next; diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index 67c495570e..6497d698ed 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -19,8 +19,8 @@ // 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 @@ -38,7 +38,7 @@ 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(); /// @@ -67,9 +67,9 @@ protected: 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(); /// @@ -103,7 +103,7 @@ class MathAccentInset: public MathedInset { class MathDotsInset: public MathedInset { public: /// - MathDotsInset(char const*,int,short st=LM_ST_TEXT); + MathDotsInset(char const*, int, short st= LM_ST_TEXT); /// ~MathDotsInset() { }; /// @@ -126,7 +126,7 @@ class MathDotsInset: public MathedInset { 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() { }; /// @@ -153,7 +153,7 @@ class MathSpaceInset: public MathedInset { class MathBigopInset: public MathedInset { public: /// - MathBigopInset(char const*, int, short st=LM_ST_TEXT); + MathBigopInset(char const*, int, short st= LM_ST_TEXT); /// ~MathBigopInset() { }; /// @@ -184,7 +184,7 @@ class MathBigopInset: public MathedInset { class MathSqrtInset: public MathParInset { public: /// - MathSqrtInset(short st=LM_ST_TEXT); + MathSqrtInset(short st= LM_ST_TEXT); /// ~MathSqrtInset() { }; /// @@ -210,7 +210,7 @@ class MathSqrtInset: public MathParInset { class MathFracInset: public MathParInset { public: /// - MathFracInset(short ot=LM_OT_FRAC); + MathFracInset(short ot= LM_OT_FRAC); /// ~MathFracInset(); /// @@ -233,7 +233,7 @@ class MathFracInset: public MathParInset { /// void GetXY(int& x, int& y) const; /// - void SetFocus(int,int); + void SetFocus(int, int); /// bool Inside(int, int); /// @@ -260,7 +260,7 @@ class MathFracInset: public MathParInset { class MathDelimInset: public MathParInset { public: /// - MathDelimInset(int, int, short st=LM_ST_TEXT); + MathDelimInset(int, int, short st= LM_ST_TEXT); /// ~MathDelimInset() { }; /// @@ -285,7 +285,7 @@ class MathDelimInset: public MathParInset { class MathDecorationInset: public MathParInset { public: /// - MathDecorationInset(int, short st=LM_ST_TEXT); + MathDecorationInset(int, short st= LM_ST_TEXT); /// ~MathDecorationInset() { }; /// @@ -316,13 +316,13 @@ class MathDecorationInset: public MathParInset { 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 @@ -344,7 +344,7 @@ void MathSpaceInset::Metrics() { 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; } @@ -361,7 +361,7 @@ bool MathBigopInset::GetLimits() const { // 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 @@ -377,7 +377,7 @@ void MathBigopInset::SetLimits(bool ls) inline bool MathDecorationInset::GetLimits() const { - return (bool)(deco==LM_underbrace||deco==LM_overbrace); + return (bool)(deco == LM_underbrace||deco == LM_overbrace); } diff --git a/src/mathed/math_iter.C b/src/mathed/math_iter.C index 5d5833d629..2ea46c45b0 100644 --- a/src/mathed/math_iter.C +++ b/src/mathed/math_iter.C @@ -66,7 +66,7 @@ byte* MathedIter::GetString(int& len) } byte *s = &array->bf[pos]; len = pos; - while (array->bf[pos]>=' ' && poslast) pos++; + while (array->bf[pos]>= ' ' && poslast) pos++; len = pos-len; return s; @@ -126,7 +126,7 @@ bool MathedIter::Next() bool MathedIter::goNextCode(MathedTextCodes code) { while (Next()) { - if (array->bf[pos]==code) + if (array->bf[pos] == code) return true; } @@ -156,32 +156,32 @@ void MathedIter::Insert(byte c, MathedTextCodes t) { 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 @@ -191,7 +191,7 @@ void MathedIter::Insert(byte c, MathedTextCodes t) 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; @@ -200,7 +200,7 @@ void MathedIter::Insert(byte c, MathedTextCodes t) if (t != fcode) { if (f) array->bf[pos+shift-1] = fcode; - if (c>=' ') { + if (c>= ' ') { array->bf[pos++] = t; fcode = t; } else { @@ -216,7 +216,7 @@ void MathedIter::split(int shift) { 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 { @@ -227,7 +227,7 @@ void MathedIter::split(int shift) 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; @@ -239,18 +239,18 @@ void MathedIter::split(int 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; @@ -294,12 +294,12 @@ bool MathedIter::Delete() 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 @@ -308,7 +308,7 @@ bool MathedIter::Delete() 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."; } @@ -317,9 +317,9 @@ bool MathedIter::Delete() } } - 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 @@ -336,14 +336,14 @@ LyxArrayBase *MathedIter::Copy(int pos1, int pos2) // 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--; @@ -351,7 +351,7 @@ LyxArrayBase *MathedIter::Copy(int pos1, int pos2) } } - 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; @@ -392,7 +392,7 @@ void MathedIter::Clear() 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 @@ -408,7 +408,7 @@ void MathedIter::checkTabs() // MathedIter:Reset(); while (OK()) { - if ((IsTab() && col>=ncols-1) || (IsCR() && !(MthIF_CR&flags))) { + if ((IsTab() && col>= ncols-1) || (IsCR() && !(MthIF_CR&flags))) { Delete(); continue; } @@ -457,7 +457,7 @@ void MathedXIter::Clean(int pos2) if (IsInset()) { MathedInset* inset = GetInset(); Next(); - if (inset->GetType()!=LM_OT_MACRO_ARG) + if (inset->GetType()!= LM_OT_MACRO_ARG) delete inset; continue; } @@ -474,7 +474,7 @@ void MathedXIter::Clean(int pos2) } ipop(); - if (pos2<=array->Last()) { + if (pos2<= array->Last()) { pos = pos1; join(pos2); checkTabs(); @@ -498,7 +498,7 @@ void MathedXIter::Merge(LyxArrayBase *a0) 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); @@ -588,28 +588,28 @@ bool MathedXIter::Next() { // 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; @@ -622,9 +622,9 @@ bool MathedXIter::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; @@ -666,7 +666,7 @@ void MathedXIter::Adjust() bool MathedXIter::Prev() { - if (pos==0 || (pos==1 && GetChar()>=' ')) + if (pos == 0 || (pos == 1 && GetChar()>= ' ')) return false; int pos2 = pos; // pos1 @@ -683,24 +683,24 @@ bool MathedXIter::Prev() 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 (rowcolp) // || (stck.col==colp && stck.x<=xp && x>xp)) + if (col>colp) // || (stck.col == colp && stck.x<= xp && x>xp)) ipop(); return true; @@ -709,7 +709,7 @@ bool MathedXIter::Up() 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) { @@ -719,7 +719,7 @@ bool MathedXIter::Down() 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; } @@ -811,7 +811,7 @@ void MathedXIter::ipop() if (p) { crow = p->getRowSt(); if (crow) - for (int i=0; inext; } } @@ -826,7 +826,7 @@ void MathedXIter::fitCoord(int /*xx*/, int yy) 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(); @@ -837,7 +837,7 @@ void MathedXIter::fitCoord(int /*xx*/, int yy) void MathedXIter::setTab(int tx, int tab) { - if (crow && tab<=ncols) { + if (crow && tab<= ncols) { crow->w[tab] = tx; } else @@ -859,9 +859,9 @@ void MathedXIter::subMetrics(int a, int d) // 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; @@ -879,7 +879,7 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent) } 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); @@ -888,7 +888,7 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent) } 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); @@ -904,10 +904,10 @@ void MathedXIter::IMetrics(int pos2, int& width, int& ascent, int& descent) } 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 { @@ -956,7 +956,7 @@ MathedRowSt *MathedXIter::adjustVerticalSt() 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; diff --git a/src/mathed/math_iter.h b/src/mathed/math_iter.h index 304de0f0fc..7dcc62663c 100644 --- a/src/mathed/math_iter.h +++ b/src/mathed/math_iter.h @@ -17,8 +17,8 @@ * */ -#ifndef __MATH_ITER__ -#define __MATH_ITER__ +#ifndef MATH_ITER +#define MATH_ITER #ifdef __GNUG__ #pragma interface @@ -61,11 +61,11 @@ class MathedIter { /// 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(); /// @@ -89,9 +89,9 @@ class MathedIter { /// 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(); /// @@ -116,7 +116,7 @@ class MathedIter { 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(); @@ -243,7 +243,7 @@ class MathedXIter: public MathedIter { // 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; @@ -293,14 +293,14 @@ bool MathedIter::IsScript() 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); } diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index f8aab67183..dadbaef667 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -37,9 +37,9 @@ ostream & operator<<(ostream & o, MathedTextCodes mtc) } 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) @@ -58,7 +58,7 @@ MathMacro::MathMacro(MathMacroTemplate* t): nargs = tmplate->getNoArgs(); tcode = tmplate->getTCode(); args = new MacroArgumentBase[nargs]; - for (int i=0; igetMacroPar(i)->Permit(LMPF_ALLOW_CR)) // args[i].row = new MathedRowSt(tmplate->getMacroPar(i)->GetColumns()); // else @@ -66,7 +66,7 @@ MathMacro::MathMacro(MathMacroTemplate* t): /* int k = tmplate->getMacroPar(i)->GetColumns(); if (k>0) { args[i].array = new LyxArrayBase; - for (int j=0; jInsert(j, LM_TC_TAB); + for (int j= 0; jInsert(j, LM_TC_TAB); }*/ } idx = 0; @@ -82,7 +82,7 @@ MathMacro::MathMacro(MathMacro* m): args = new MacroArgumentBase[nargs]; idx = 0; SetName(tmplate->GetName()); - for (int i=0; inargs; i++) { + for (int i= 0; inargs; i++) { m->setArgumentIdx(i); MathedIter it(m->GetData()); args[i].row = m->args[i].row; @@ -92,7 +92,7 @@ MathMacro::MathMacro(MathMacro* m): MathMacro::~MathMacro() { - for (idx=0; idxSetStyle(size); mathGC = latexGC; tmplate->Draw(x, y); - for (int i=0; iGetMacroXY(i, args[i].x, args[i].y); } @@ -189,7 +189,7 @@ void MathMacro::Write(string &file) if (!(tmplate->flags & MMF_Env) && nargs>0) file += '{'; - for (int i=0; i0) { tcode = LM_TC_ACTIVE_INSET; args = new MathMacroArgument[nargs]; - for (int i=0; i0) ? args[0].getExpand(): false; if (flags & MMF_Edit) { - for (int i=0; i0) ? args[0].getExpand(): false; if (flags & MMF_Edit) { - for (int i=0; igetArgumentIdx(): 0; - for (int i=0; isetArgumentIdx(i); args[i].SetData(macro->GetData()); @@ -373,7 +373,7 @@ void MathMacroTemplate::WriteDef(FILE *file) fprintf(file, "{"); - for (int i=0; i=0 && i= 0 && iGetName())==0) + for (int i= 0; iGetName()) == 0) return macro_table[i]; } @@ -531,10 +531,10 @@ void MathMacroTable::builtinMacros() 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); @@ -547,7 +547,7 @@ void MathMacroTable::builtinMacros() // 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 diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index 9732e301de..75cf5a9e92 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -140,7 +140,7 @@ class MathMacroTemplate: public MathParInset { 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(); /// @@ -156,7 +156,7 @@ class MathMacroTemplate: public MathParInset /// MathedTextCodes getTCode() { return tcode; } /// - void setArgument(LyxArrayBase *, int i=0); + void setArgument(LyxArrayBase *, int i= 0); /// Number of arguments int getNoArgs() { return nargs; } /// @@ -169,7 +169,7 @@ class MathMacroTemplate: public MathParInset void setEditMode(bool); /// Replace the appropriate arguments with a specific macro's data - void update(MathMacro* m=0); + void update(MathMacro* m= 0); private: /// @@ -227,7 +227,7 @@ class MathMacroTable inline bool MathMacro::setArgumentIdx(int i) { - if (i>=0 && i= 0 && i #include FORMS_H_LOCATION -#include -#include +#include +#include #include "lyx_gui_misc.h" #include "math_panel.h" @@ -37,15 +37,15 @@ #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, @@ -54,13 +54,14 @@ int delim_code[] = { 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", @@ -72,7 +73,7 @@ static char const *func_code[] = { 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) { @@ -83,7 +84,7 @@ void button_cb(FL_OBJECT *ob, long data) case MM_BOP: case MM_MISC: { - BitmapMenu *menu = (BitmapMenu *)ob->u_vdata; + BitmapMenu * menu = static_cast(ob->u_vdata); menu->Show(); break; } @@ -94,19 +95,19 @@ void button_cb(FL_OBJECT *ob, long data) 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: @@ -128,8 +129,8 @@ void button_cb(FL_OBJECT *ob, long data) /* 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) { @@ -139,15 +140,15 @@ void delim_cb(FL_OBJECT *, long 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)) @@ -157,8 +158,8 @@ void delim_cb(FL_OBJECT *, long data) 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; @@ -183,19 +184,19 @@ void matrix_cb(FL_OBJECT *, long data) { 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; icolumns)+0.5); + for (int i= 0; iform_main); @@ -217,40 +218,43 @@ void deco_cb(FL_OBJECT *, long data) { 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; @@ -264,7 +268,8 @@ char** mathed_get_pixmap_from_icon(int d) } } -FD_panel *create_math_panel( ) + +FD_panel * create_math_panel( ) { fd_panel = create_form_panel(); fd_delim = create_form_delim(); @@ -275,7 +280,7 @@ FD_panel *create_math_panel( ) /* 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); @@ -287,7 +292,7 @@ FD_panel *create_math_panel( ) 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]); } @@ -296,7 +301,7 @@ FD_panel *create_math_panel( ) 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); @@ -309,6 +314,7 @@ FD_panel *create_math_panel( ) extern BitmapMenu* sym_menu; extern void create_symbol_menues(FD_panel *); + void free_symbols_form() { if (fd_panel) { @@ -320,13 +326,15 @@ void free_symbols_form() } } + 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) { diff --git a/src/mathed/math_panel.h b/src/mathed/math_panel.h index 14553ba560..4d33d0aba7 100644 --- a/src/mathed/math_panel.h +++ b/src/mathed/math_panel.h @@ -33,17 +33,17 @@ enum { }; /// -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 /// @@ -53,20 +53,20 @@ protected: /// 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(); /// @@ -78,11 +78,11 @@ protected: /// 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 diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index e2c136d79f..be49f67e1d 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -16,8 +16,8 @@ */ #include -#include -#include +#include +#include #ifdef __GNUG__ #pragma implementation "math_parser.h" @@ -47,9 +47,9 @@ YYSTYPE yylval; 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", @@ -59,11 +59,11 @@ char const *latex_mathenv[] = { }; -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 { @@ -86,11 +86,11 @@ 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); @@ -98,7 +98,7 @@ char *strnew(char const* s) } -static void mathPrintError(char const *msg) +static void mathPrintError(char const * msg) { lyxerr << "Line ~" << yylineno << ": Math parse error: " << msg << endl; @@ -107,9 +107,7 @@ static void mathPrintError(char const *msg) 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; @@ -121,7 +119,7 @@ static void LexInitCodes() 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; @@ -135,22 +133,23 @@ static void LexInitCodes() 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; @@ -158,14 +157,15 @@ static char LexGetArg(char lf, bool accept_spaces=false) } 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; @@ -176,52 +176,52 @@ static int yylex(void) 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++; @@ -230,16 +230,16 @@ static int yylex(void) 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; @@ -254,15 +254,15 @@ static int yylex(void) 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]; @@ -276,12 +276,12 @@ void setAccent(int ac) } -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]); @@ -292,12 +292,12 @@ MathedInset *doAccent(byte c, MathedTextCodes t) } -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]); @@ -310,7 +310,8 @@ MathedInset *doAccent(MathedInset *p) -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; @@ -318,20 +319,20 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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 {}"); @@ -367,7 +368,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m // ugly trick to be removed soon (lyx3) char c = getc(yyin); ungetc(c, yyin); - if (c=='[') { + if (c == '[') { LexGetArg('['); na = atoi(yytext); } @@ -393,7 +394,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m case LM_TK_OPEN: { brace++; - if (accent && tprev==LM_TK_ACCENT) { + if (accent && tprev == LM_TK_ACCENT) { acc_braces[acc_brace++] = brace; break; } @@ -417,7 +418,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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; } @@ -440,8 +441,8 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m { if (flags & FLAG_BRACK_ARG) { flags &= ~FLAG_BRACK_ARG; - char rg=LexGetArg('['); - if (rg!=']') { + char rg= LexGetArg('['); + if (rg!= ']') { mathPrintError("Expected ']'"); panic = true; break; @@ -472,7 +473,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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); @@ -516,7 +517,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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; } @@ -554,15 +555,15 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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; } @@ -570,20 +571,20 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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)); @@ -600,16 +601,16 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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 << "]"; @@ -630,13 +631,14 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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; @@ -654,7 +656,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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 @@ -669,18 +671,18 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m 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 { @@ -691,7 +693,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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)) @@ -705,23 +707,23 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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; } @@ -731,7 +733,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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); @@ -752,13 +754,13 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m #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"); @@ -768,7 +770,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m case LM_TK_MACRO: { - MathedInset* p = + MathedInset * p = MathMacroTable::mathMTable.getMacro(yylval.l->name); if (p) { @@ -820,7 +822,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } 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; @@ -831,7 +833,7 @@ LyxArrayBase *mathed_parse(unsigned flags, LyxArrayBase *array, MathParInset **m } -void mathed_parser_file(FILE* file, int lineno) +void mathed_parser_file(FILE * file, int lineno) { yyin = file; yylineno = lineno; diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index a11b016e47..a3131f8888 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -16,8 +16,8 @@ * 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 @@ -67,28 +67,28 @@ enum MathTokenEnum }; /// -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; diff --git a/src/mathed/math_root.C b/src/mathed/math_root.C index 0d7d1024f9..f182316783 100644 --- a/src/mathed/math_root.C +++ b/src/mathed/math_root.C @@ -49,7 +49,7 @@ MathedInset *MathRootInset::Clone() void MathRootInset::SetData(LyxArrayBase *d) { - if (idx==1) + if (idx == 1) MathParInset::SetData(d); else { uroot->SetData(d); @@ -59,7 +59,7 @@ void MathRootInset::SetData(LyxArrayBase *d) bool MathRootInset::setArgumentIdx(int i) { - if (i==0 || i==1) { + if (i == 0 || i == 1) { idx = i; return true; } else @@ -69,7 +69,7 @@ bool MathRootInset::setArgumentIdx(int i) void MathRootInset::GetXY(int& x, int& y) const { - if (idx==1) + if (idx == 1) MathParInset::GetXY(x, y); else uroot->GetXY(x, y); @@ -77,7 +77,7 @@ void MathRootInset::GetXY(int& x, int& y) const LyxArrayBase *MathRootInset::GetData() { - if (idx==1) + if (idx == 1) return array; else return uroot->GetData(); diff --git a/src/mathed/math_root.h b/src/mathed/math_root.h index 2c7c52ab43..692c558e73 100644 --- a/src/mathed/math_root.h +++ b/src/mathed/math_root.h @@ -12,14 +12,14 @@ * 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 +#include #include "math_defs.h" #include "math_inset.h" #include "symbol_def.h" @@ -30,27 +30,27 @@ 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; /// @@ -68,10 +68,8 @@ class MathRootInset: public MathSqrtInset { /// int idx; /// - MathParInset *uroot; + MathParInset * uroot; /// int wroot, dh; }; - - #endif diff --git a/src/mathed/math_symbols.C b/src/mathed/math_symbols.C index d8287efceb..72b103638d 100644 --- a/src/mathed/math_symbols.C +++ b/src/mathed/math_symbols.C @@ -82,7 +82,7 @@ static char const *latex_brel[] = { 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", @@ -182,9 +182,9 @@ void BitmapMenu::Show() { 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, ""); @@ -212,7 +212,7 @@ void BitmapMenu::Create() return; } form = fl_bgn_form(FL_UP_BOX, w, h); - for (i=0; iu_vdata = this; } @@ -222,10 +222,10 @@ void BitmapMenu::Create() int BitmapMenu::GetIndex(FL_OBJECT* ob) { - if (active==this) { + if (active == this) { int k = 0; - for (i=0; itype == ButtonPress) @@ -248,9 +248,9 @@ int peek_event(FL_FORM * /*form*/, void *xev) 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(); @@ -261,7 +261,7 @@ int peek_event(FL_FORM * /*form*/, void *xev) // 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); } @@ -310,7 +310,7 @@ extern "C" void math_cb(FL_OBJECT* ob, long data) 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; @@ -337,14 +337,14 @@ char** get_pixmap_from_symbol(char const *arg, int wx, int hx) 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) { @@ -366,10 +366,10 @@ void math_insert_symbol(char const* 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(current_view->buffer()->the_locking_inset)->InsertSymbol(s); else lyxerr << "Math error: attempt to write on a wrong " @@ -377,7 +377,7 @@ void math_insert_symbol(char const* s) } } -BitmapMenu * sym_menu=0; +BitmapMenu * sym_menu= 0; void create_symbol_menues(FD_panel * symb_form) { @@ -433,11 +433,11 @@ static 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; @@ -449,21 +449,21 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx) } 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; @@ -537,7 +537,7 @@ char** pixmapFromBitmapData(char const *s, int wx, int hx) // 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); diff --git a/src/mathed/math_utils.C b/src/mathed/math_utils.C index 8609e7a9a5..cb6da98baf 100644 --- a/src/mathed/math_utils.C +++ b/src/mathed/math_utils.C @@ -70,12 +70,12 @@ int MathedLookupBOP(short id) 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 diff --git a/src/mathed/math_write.C b/src/mathed/math_write.C index 3adbdfd25b..dad0345c93 100644 --- a/src/mathed/math_write.C +++ b/src/mathed/math_write.C @@ -23,13 +23,13 @@ #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", @@ -41,9 +41,9 @@ char const *math_font_name[] = { 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()); @@ -51,9 +51,9 @@ MathSpaceInset::Write(FILE *outf) } 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 += ' '; @@ -62,7 +62,7 @@ MathSpaceInset::Write(string &outf) void -MathDotsInset::Write(FILE *outf) +MathDotsInset::Write(FILE * outf) { string output; MathDotsInset::Write(output); @@ -70,7 +70,7 @@ MathDotsInset::Write(FILE *outf) } void -MathDotsInset::Write(string &outf) +MathDotsInset::Write(string & outf) { outf += '\\'; outf += name; @@ -78,14 +78,14 @@ MathDotsInset::Write(string &outf) } -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; @@ -95,24 +95,24 @@ void MathSqrtInset::Write(string &outf) } -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 += ' '; @@ -128,7 +128,7 @@ void MathDelimInset::Write(string &outf) outf += r->name; outf += ' '; } else { - if (right=='{' || right=='}') { + if (right == '{' || right == '}') { outf += '\\'; outf += (char) right; outf += ' '; @@ -140,16 +140,16 @@ void MathDelimInset::Write(string &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 += '{'; @@ -158,19 +158,19 @@ void MathDecorationInset::Write(string &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 += ' '; @@ -178,7 +178,7 @@ void MathAccentInset::Write(string &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 += '{'; @@ -193,47 +193,47 @@ void MathAccentInset::Write(string &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; @@ -245,7 +245,7 @@ void MathFracInset::Write(string &outf) } -void MathParInset::Write(FILE *outf) +void MathParInset::Write(FILE * outf) { if (!array) return; string output; @@ -254,14 +254,14 @@ void MathParInset::Write(FILE *outf) } -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)) { @@ -274,18 +274,18 @@ void MathParInset::Write(string &outf) } 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; @@ -296,14 +296,14 @@ void MathParInset::Write(string &outf) } } 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 @@ -311,17 +311,17 @@ void MathParInset::Write(string &outf) } 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 @@ -336,7 +336,7 @@ void MathParInset::Write(string &outf) { if (crow) { if (!crow->isNumbered()) { - outf +="\\nonumber "; + outf += "\\nonumber "; } if (crow->getLabel()) { outf += "\\label{"; @@ -358,7 +358,7 @@ void MathParInset::Write(string &outf) if (crow) { if (!crow->isNumbered()) { - outf +="\\nonumber "; + outf += "\\nonumber "; } if (crow->getLabel()) { outf += "\\label{"; @@ -386,7 +386,7 @@ void MathMatrixInset::Write(string &outf) 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 += ']'; @@ -415,13 +415,13 @@ void mathed_write(MathParInset* p, FILE* outf, int* newlines, char fragile, ch 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) } @@ -436,7 +436,7 @@ void mathed_write(MathParInset* p, string& outf, int* newlines, outf += "\n"; number_of_newlines++; } - if (mathed_env==LM_EN_DISPLAY){ + if (mathed_env == LM_EN_DISPLAY){ outf += "\\[\n"; } else { @@ -447,7 +447,7 @@ void mathed_write(MathParInset* p, string& outf, int* newlines, 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"; @@ -456,11 +456,11 @@ void mathed_write(MathParInset* p, string& outf, int* newlines, 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++; } @@ -468,7 +468,7 @@ void mathed_write(MathParInset* p, string& outf, int* newlines, outf += "\n\\end{"; outf += latex_mathenv[mathed_env]; outf += "}\n"; - number_of_newlines+=2; + number_of_newlines+= 2; } *newlines = number_of_newlines; } diff --git a/src/mathed/symbol_def.h b/src/mathed/symbol_def.h index f61b279f33..05b1209aea 100644 --- a/src/mathed/symbol_def.h +++ b/src/mathed/symbol_def.h @@ -1,7 +1,7 @@ // 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 @@ -130,7 +130,7 @@ enum Math_Symbols_enum { 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,