#include "support/LOstream.h"
#include "support/LAssert.h"
#include "support/lyxlib.h"
-#include "support/syscall.h"
+#include "support/systemcall.h"
#include "support/lstrings.h"
#include "support/filetools.h" // LibFileSearch
#include "LyXView.h"
#include "math_hullinset.h"
#include "math_support.h"
#include "math_mathmlstream.h"
+#include "textpainter.h"
using std::ostream;
using std::ifstream;
string outfile = lyx::tempName(string(), "mathextern");
string full = "echo '" + data + "' | (" + cmd + ") > " + outfile;
lyxerr << "calling: " << full << "\n";
- Systemcalls dummy(Systemcalls::Wait, full);
+ Systemcall dummy;
+ dummy.startscript(Systemcall::Wait, full);
string out = GetFileContents(outfile);
lyx::unlink(outfile);
lyxerr << "result: '" << out << "'\n";
"eval(`latex/latex/*`)):\n";
// remove spurious \\noalign{\\medskip} in matrix output
- header +=
+ header +=
"`latex/latex/matrix`:= "
"subs(`\\\\\\\\\\\\noalign{\\\\medskip}` = `\\\\\\\\`,"
"eval(`latex/latex/matrix`)):\n";
//
// ... > echo "1A;" | mint -i 1 -S -s -q
// on line 1: 1A;
- // ^ syntax error -
+ // ^ syntax error -
// Probably missing an operator such as * p
//
lyxerr << "checking expr: '" << expr << "'\n";
mathed_parse_cell(res, out);
return res;
}
-
-
+
+
MathArray pipeThroughOctave(string const &, MathArray const & ar)
{
ostringstream os;
for (int i = 0; i < 100; ++i) { // at most 100 attempts
//
- // try to fix missing '*' the hard way
+ // try to fix missing '*' the hard way
// parse error:
// >>> ([[1 2 3 ];[2 3 1 ];[3 1 2 ]])([[1 2 3 ];[2 3 1 ];[3 1 2 ]])
// ^
//
lyxerr << "checking expr: '" << expr << "'\n";
- out = captureOutput("octave -q 2>&1", expr);
+ out = captureOutput("octave -q 2>&1", expr);
lyxerr << "checking out: '" << out << "'\n";
// leave loop if expression syntax is probably ok
lyxerr << "converter to '" << lang << "' not found\n";
return MathArray();
}
-
+
// run external sript
string out = captureOutput(file, data);
MathArray res;
{}
-InsetFormula::InsetFormula(string const & s)
+InsetFormula::InsetFormula(string const & s)
{
if (s.size()) {
bool res = mathed_parse_normal(par_, s);
}
-void InsetFormula::write(Buffer const * buf, ostream & os) const
+void InsetFormula::write(Buffer const *, ostream & os) const
{
os << "Formula ";
- latex(buf, os, false, false);
+ WriteStream wi(os, false, false);
+ par_->write(wi);
}
-int InsetFormula::latex(Buffer const *, ostream & os, bool fragil, bool) const
+int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
{
- WriteStream wi(os, fragil);
+ WriteStream wi(os, fragile, true);
par_->write(wi);
return wi.line();
}
int InsetFormula::ascii(Buffer const *, ostream & os, int) const
{
+#if 1
+ TextMetricsInfo mi;
+ par()->metricsT(mi);
+ TextPainter tpain(par()->width(), par()->height());
+ par()->drawT(tpain, 0, par()->ascent());
+ tpain.show(os);
+ // reset metrics cache to "real" values
+ metrics();
+ return tpain.textheight();
+#else
WriteStream wi(os, false);
par_->write(wi);
return wi.line();
+#endif
}
void InsetFormula::draw(BufferView * bv, LyXFont const & font,
int y, float & xx, bool) const
{
- int x = int(xx);
-
- Painter & pain = bv->painter();
-
metrics(bv, font);
+
+ int x = int(xx);
int w = par_->width();
int h = par_->height();
int a = par_->ascent();
+ Painter & pain = bv->painter();
if (lcolor.getX11Name(LColor::mathbg)!=lcolor.getX11Name(LColor::background))
pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
switch (action) {
- case LFUN_BREAKLINE:
+ case LFUN_BREAKLINE:
bv->lockedInsetStoreUndo(Undo::INSERT);
mathcursor->breakLine();
mathcursor->normalize();
updateLocal(bv, true);
break;
}
-
+
case LFUN_PASTESELECTION:
{
string const clip = bv->getClipboard();
- if (!clip.empty())
+ if (!clip.empty())
mathed_parse_normal(par_, clip);
break;
}
{
// where are we?
if (!mathcursor)
- return;
+ return;
string lang;
string extra;
istringstream iss(arg.c_str());
iss >> lang >> extra;
if (extra.empty())
- extra = "noextra";
+ extra = "noextra";
bool selected = mathcursor->selection();
bool InsetFormula::insetAllowed(Inset::Code code) const
{
- return
+ return
(code == Inset::LABEL_CODE && display())
- || code == Inset::ERT_CODE;
+ || code == Inset::ERT_CODE;
}