extern char const * latex_special_chars;
int greek_kb_flag = 0;
+extern char const * latex_mathenv[];
// this is only used by Whichfont and mathed_init_fonts (Lgb)
LyXFont * Math_Fonts = 0;
static int sel_y;
static bool sel_flag;
-MathedCursor * InsetFormula::mathcursor = 0;
+// quite a hack i know. Should be done with return values...
+int number_of_newlines = 0;
-void mathed_init_fonts();
+static
+int mathed_write(MathParInset *, std::ostream &, bool fragile,
+ string const & label = string());
+void mathed_init_fonts();
static
void mathedValidate(LaTeXFeatures & features, MathParInset * par);
+MathedCursor * InsetFormula::mathcursor = 0;
+
+
LyXFont WhichFont(short type, int size)
{
LyXFont f;
par = is_multiline(p->GetType()) ?
new MathMatrixInset(static_cast<MathMatrixInset*>(p)):
- new MathParInset(p);
+ new MathParInset(*p);
// mathcursor = 0;
disp_flag = (par->GetType()>0);
int InsetFormula::Latex(Buffer const *, ostream & os, bool fragile, bool) const
{
- int ret = 0;
//#warning Alejandro, the number of lines is not returned in this case
// This problem will disapear at 0.13.
- mathed_write(par, os, &ret, fragile, label);
- return ret;
+ return mathed_write(par, os, fragile, label);
}
// Silly hack to read labels.
mathed_label.erase();
- mathed_parse(0, 0, &par);
+ MathedArray ar;
+ mathed_parse(ar, 0, &par);
par->Metrics();
disp_flag = (par->GetType() > 0);
par->SetStyle(LM_ST_DISPLAY);
} else {
if (is_multiline(par->GetType())) {
- MathParInset * p = new MathParInset(par);
- delete par;
- par = p;
if (mathcursor)
mathcursor->SetPar(par);
}
UpdatableInset::RESULT
-InsetFormula::LocalDispatch(BufferView * bv, int action, string const & arg)
+InsetFormula::LocalDispatch(BufferView * bv, kb_action action,
+ string const & arg)
{
// extern char *dispatch_result;
MathedTextCodes varcode = LM_TC_MIN;
case LFUN_MATH_SIZE:
if (!arg.empty()) {
- latexkeys * l = in_word_set(arg);
+ latexkeys const * l = in_word_set(arg);
int sz = (l) ? l->id: -1;
mathcursor->SetSize(sz);
UpdateLocal(bv);
if (mathcursor && p) {
if (k > 2 && int(strlen(s)) > m)
p->SetAlign(s[0], &s[1]);
- mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
+ mathcursor->insertInset(p, LM_TC_ACTIVE_INSET);
UpdateLocal(bv);
}
break;
bv->lockedInsetStoreUndo(Undo::INSERT);
char lf[40], rg[40], arg2[40];
int ilf = '(', irg = '.';
- latexkeys * l;
+ latexkeys const * l;
string vdelim("(){}[]./|");
if (arg.empty())
}
MathDelimInset * p = new MathDelimInset(ilf, irg);
- mathcursor->Insert(p, LM_TC_ACTIVE_INSET);
+ mathcursor->insertInset(p, LM_TC_ACTIVE_INSET);
UpdateLocal(bv);
break;
}
case LFUN_PROTECTEDSPACE:
bv->lockedInsetStoreUndo(Undo::INSERT);
sp = new MathSpaceInset(1);
- mathcursor->Insert(sp);
+ mathcursor->insertInset(sp, LM_TC_INSET);
space_on = true;
UpdateLocal(bv);
break;
static
void mathedValidate(LaTeXFeatures & features, MathParInset * par)
{
- MathedIter it(par->GetData());
+ MathedIter it(&par->GetData());
while (it.OK() && !(features.binom && features.boldsymbol)) {
if (it.IsInset()) {
it.Next();
}
}
+
+
+static
+int mathed_write(MathParInset * p, ostream & os,
+ bool fragile, string const & label)
+{
+ number_of_newlines = 0;
+ short mathed_env = p->GetType();
+
+ if (mathed_env == LM_OT_MIN) {
+ if (fragile) os << "\\protect";
+ os << "\\( "; // changed from " \\( " (Albrecht Dress)
+ } else {
+ if (mathed_env == LM_OT_PAR){
+ os << "\\[\n";
+ } else {
+ os << "\\begin{"
+ << latex_mathenv[mathed_env]
+ << "}";
+ if (is_multicolumn(mathed_env)) {
+ if (mathed_env != LM_OT_ALIGNAT
+ && mathed_env != LM_OT_ALIGNATN)
+ os << "%";
+ os << "{" << p->GetColumns()/2 << "}";
+ }
+ os << "\n";
+ }
+ ++number_of_newlines;
+ }
+
+ if (!label.empty() && label[0] > ' '
+ && is_singlely_numbered(mathed_env)) {
+ os << "\\label{"
+ << label
+ << "}\n";
+ ++number_of_newlines;
+ }
+
+ p->Write(os, fragile);
+
+ if (mathed_env == LM_OT_MIN){
+ if (fragile) os << "\\protect";
+ os << " \\)";
+ } else if (mathed_env == LM_OT_PAR) {
+ os << "\\]\n";
+ ++number_of_newlines;
+ } else {
+ os << "\n\\end{"
+ << latex_mathenv[mathed_env]
+ << "}\n";
+ number_of_newlines += 2;
+ }
+ return number_of_newlines;
+}