+2001-07-04 André Pönitz <poenitz@htwm.de>
+
+ * math_*inset.C: Change order of arguments in MathInset constructor
+
+ * math_cursor.C: Remove broken "increase space" feature for a while
+
2001-07-07 Dekel Tsur <dekelts@tau.ac.il>
* formulabase.C (mathDispatchInsertMath): Create an inline formula.
MathTextCodes varcode = LM_TC_MIN;
bool was_macro = mathcursor->InMacroMode();
bool sel = false;
- bool space_on = false;
bool was_selection = mathcursor->Selection();
RESULT result = DISPATCHED;
- static MathSpaceInset * sp = 0;
hideInsetCursor(bv);
}
break;
- case LFUN_INSERT_MATH:
+ case LFUN_INSERT_MATRIX:
if (!arg.empty()) {
bv->lockedInsetStoreUndo(Undo::INSERT);
- mathcursor->Interpret(arg);
+ mathcursor->Interpret("matrix " + arg);
updateLocal(bv);
}
break;
- case LFUN_INSERT_MATRIX:
- if (mathcursor) {
+ case LFUN_INSERT_MATH:
+ if (!arg.empty()) {
bv->lockedInsetStoreUndo(Undo::INSERT);
- int m = 1;
- int n = 1;
- string v_align;
- string h_align;
- istringstream is(arg.c_str());
- is >> m >> n >> v_align >> h_align;
- MathArrayInset * p = new MathArrayInset(m, n);
- p->valign(v_align[0]);
- p->halign(h_align);
- mathcursor->insert(p);
+ mathcursor->Interpret(arg);
updateLocal(bv);
}
break;
case LFUN_PROTECTEDSPACE:
bv->lockedInsetStoreUndo(Undo::INSERT);
mathcursor->insert(new MathSpaceInset(1));
- space_on = true;
updateLocal(bv);
break;
if (code != LM_TC_TEXTRM)
code = LM_TC_BOP;
mathcursor->insert(c, code);
- } else if (strchr(latex_special_chars, c) && c!= '_') {
+ } else if (strchr(latex_special_chars, c) && c != '_') {
MathTextCodes code = mathcursor->getLastCode();
if (code != LM_TC_TEXTRM)
code = LM_TC_SPECIAL;
mathcursor->insert(c, LM_TC_TEXTRM);
} else if (was_macro) {
mathcursor->MacroModeClose();
- } else if (sp) {
- int isp = (sp->GetSpace()<5) ? sp->GetSpace()+1: 0;
- sp->SetSpace(isp);
- space_on = true;
} else {
if (!mathcursor->pop())
result = FINISHED;
//if (mathcursor)
// updateLocal(bv);
- if (sp && !space_on)
- sp = 0;
-
if (mathcursor && (mathcursor->Selection() || was_selection))
toggleInsetSelection(bv);
using std::ostream;
MathAccentInset::MathAccentInset(byte cx, MathTextCodes f, int cd)
- : MathInset("", LM_OT_ACCENT),
- c(cx), fn(f), code(cd), inset(0)
+ : MathInset(1), c(cx), fn(f), code(cd), inset(0)
{}
MathAccentInset::MathAccentInset(MathInset * ins, int cd)
- : MathInset("", LM_OT_ACCENT),
- c(0), fn(LM_TC_MIN), code(cd), inset(ins)
+ : MathInset(0), c(0), fn(LM_TC_MIN), code(cd), inset(ins)
{}
void Metrics(MathStyles st);
///
int getAccentCode() const;
+ ///
+ bool isAccentInset() const { return true; }
protected:
///
byte c;
using std::ostream;
MathBigopInset::MathBigopInset(string const & name, int id)
- : MathScriptInset(true, false), lims_(0), sym_(id)
+ : MathScriptInset(false, true), lims_(0), sym_(id)
{
SetName(name);
}
t = LM_TC_TEXTRM;
}
if (sym_ == LM_oint) {
- pain.arc(x, y - 5 * width_ / 4, width_, width_, 0, 360 * 64,
- LColor::mathline);
- ++x;
+ int wid;
+ int asc;
+ int des;
+ mathed_char_dim(t, size(), LM_int, asc, des, wid);
+ wid += 2;
+ pain.arc(x - 1, y - (asc - des) / 2, wid, wid, 0, 360 * 64, LColor::mathline);
}
int asc, des, wid;
#include <cctype>
#include "math_inset.h"
+#include "math_arrayinset.h"
#include "math_parser.h"
#include "math_cursor.h"
#include "math_macro.h"
void MathCursor::Interpret(string const & s)
{
- lyxerr << "Interpret: '" << s << "'\n";
+ lyxerr << "Interpret: '" << s << "' ('" << s.substr(0, 7) << "' " <<
+in_word_set(s) << " \n";
if (s[0] == '^') {
MathScriptInset * p = nearbyScriptInset();
p = new MathRootInset;
else if (MathMacroTable::hasTemplate(s))
p = new MathMacro(MathMacroTable::provideTemplate(s));
+ else if (s.size() > 7 && s.substr(0, 7) == "matrix ") {
+ int m = 1;
+ int n = 1;
+ string v_align;
+ string h_align;
+ std::istringstream is(s.substr(7).c_str());
+ is >> m >> n >> v_align >> h_align;
+ m = std::max(1, m);
+ n = std::max(1, n);
+ MathArrayInset * pp = new MathArrayInset(m, n);
+ pp->valign(v_align[0]);
+ pp->halign(h_align);
+ p = pp;
+ }
else
p = new MathFuncInset(s, LM_OT_UNDEF);
} else {
break;
case LM_TK_STACK:
- p = new MathFracInset(LM_OT_STACKREL);
+ p = new MathFracInset("stackrel");
break;
case LM_TK_FRAC:
- p = new MathFracInset(LM_OT_FRAC);
+ p = new MathFracInset("frac");
break;
case LM_TK_SQRT:
imacro->SetName(l->name);
} else {
Left();
- if (nextInset()->GetType() == LM_OT_ACCENT)
+ if (nextInset()->isAccentInset())
setAccent(
static_cast<MathAccentInset*>(nextInset())->getAccentCode());
array().erase(cursor_);
MathDecorationInset::MathDecorationInset(int d)
- : MathInset("", LM_OT_DECO, 1), deco_(d)
+ : MathInset(1), deco_(d)
{
upper_ = deco_ != LM_underline && deco_ != LM_underbrace;
}
///
LM_OT_FUNCLIM,
///
- LM_OT_SCRIPT,
- ///
- LM_OT_SPACE,
- ///
- LM_OT_DOTS,
- /// A fraction
- LM_OT_FRAC,
- ///
- LM_OT_ATOP,
- ///
- LM_OT_STACKREL,
- /// A radical
- LM_OT_SQRT,
- /// A delimiter
- LM_OT_DELIM,
- /// A decoration
- LM_OT_DECO,
- /// An accent
- LM_OT_ACCENT,
- ///
LM_OT_MACRO,
///
LM_OT_MAX
MathDelimInset::MathDelimInset(int l, int r)
- : MathInset("", LM_OT_DELIM, 1), left_(l), right_(r)
+ : MathInset(1), left_(l), right_(r)
{}
MathDotsInset::MathDotsInset(string const & name, int id)
- : MathInset(name, LM_OT_DOTS), code_(id)
+ : MathInset(0, name), code_(id)
{}
#include "support/LOstream.h"
-MathFracInset::MathFracInset(MathInsetTypes ot)
- : MathInset("frac", ot, 2)
-{
- if (objtype == LM_OT_STACKREL)
- SetName("stackrel");
-}
+MathFracInset::MathFracInset(string const & name)
+ : MathInset(2, name)
+{}
MathInset * MathFracInset::clone() const
xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent() + 3 - 5);
- if (objtype == LM_OT_FRAC)
+ if (name() == "frac")
pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
}
class MathFracInset : public MathInset {
public:
///
- explicit MathFracInset(MathInsetTypes ot = LM_OT_FRAC);
+ explicit MathFracInset(const string & name);
///
virtual MathInset * clone() const;
///
MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot)
- : MathInset(nm, ot)
+ : MathInset(0, nm, ot)
{
lims_ = (GetType() == LM_OT_FUNCLIM);
}
MathGridInset::MathGridInset(int m, int n, string const & nm, MathInsetTypes ot)
- : MathInset(nm, ot, m * n), rowinfo_(n), colinfo_(m), v_align_('c')
+ : MathInset(m * n, nm, ot), rowinfo_(n), colinfo_(m), v_align_('c')
{
if (m <= 0)
lyxerr << "positve number of columns expected\n";
int MathInset::workwidth;
-MathInset::MathInset(string const & name, MathInsetTypes ot, int nargs)
+MathInset::MathInset(int nargs, string const & name, MathInsetTypes ot)
: name_(name), objtype(ot), width_(0), ascent_(0), descent_(0),
size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0)
{}
type and font-size
*/
///
- explicit
- MathInset (string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE, int na = 0);
+ explicit MathInset
+ (int na = 0, string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE);
+
/// The virtual base destructor
virtual ~MathInset() {}
bool covers(int x, int y) const;
/// Identifies ScriptInsets
virtual bool isScriptInset() const { return false; }
+ /// Identifies AccentInsets
+ virtual bool isAccentInset() const { return false; }
///
virtual bool isActive() const { return nargs() > 0; }
using std::endl;
MathMacro::MathMacro(MathMacroTemplate const & t)
- : MathInset(t.name(), LM_OT_MACRO, t.numargs()), tmplate_(&t)
+ : MathInset(t.numargs(), t.name(), LM_OT_MACRO), tmplate_(&t)
{}
// binom has two arguments
{
- MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
+ MathFracInset * frac = new MathFracInset("atop");
frac->cell(0).push_back(new MathMacroArgument(1));
frac->cell(1).push_back(new MathMacroArgument(2));
MathMacroTemplate::MathMacroTemplate() :
- MathInset("undefined", LM_OT_MACRO, 1), numargs_(0), users_()
+ MathInset(1, "undefined", LM_OT_MACRO), numargs_(0), users_()
{}
MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs) :
- MathInset(nm, LM_OT_MACRO, 1), numargs_(numargs), users_()
+ MathInset(1, nm, LM_OT_MACRO), numargs_(numargs), users_()
{}
case LM_OT_EQNARRAY:
switch (newtype) {
case LM_OT_SIMPLE:
- case LM_OT_EQUATION:
+ case LM_OT_EQUATION: {
+ string label;
+ bool allnonum = true;
+ for (int r = 0; r < nrows(); ++r) {
+ label += label_[r];
+ if (!nonum_[r])
+ allnonum = false;
+ }
glueall();
mutate(newtype);
+ label_[0] = label;
+ nonum_[0] = allnonum;
break;
+ }
case LM_OT_ALIGN:
default:
}
-void handle_frac(MathArray & dat, MathInsetTypes t)
+void handle_frac(MathArray & dat, string const & name)
{
- MathFracInset * p = new MathFracInset(t);
+ MathFracInset * p = new MathFracInset(name);
mathed_parse(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST);
mathed_parse(p->cell(1), FLAG_BRACE | FLAG_BRACE_LAST);
dat.push_back(p);
break;
case LM_TK_CHOOSE:
- handle_frac(array, LM_OT_ATOP);
+ handle_frac(array, "atop");
break;
case LM_TK_STACK:
- handle_frac(array, LM_OT_STACKREL);
+ handle_frac(array, "stackrel");
break;
case LM_TK_FRAC:
- handle_frac(array, LM_OT_FRAC);
+ handle_frac(array, "frac");
break;
case LM_TK_SQRT:
#include "Painter.h"
MathRootInset::MathRootInset()
- : MathInset("sqrt", LM_OT_SQRT, 2)
+ : MathInset(2)
{}
MathScriptInset::MathScriptInset()
- : MathInset("script", LM_OT_SCRIPT, 2), up_(false), down_(false)
+ : MathInset(2), up_(false), down_(false)
{}
MathScriptInset::MathScriptInset(bool up, bool down)
- : MathInset("script", LM_OT_SCRIPT, 2), up_(up), down_(down)
+ : MathInset(2), up_(up), down_(down)
{}
MathSizeInset::MathSizeInset(MathStyles st)
- : MathInset("", LM_OT_SIMPLE, 1), style_(st)
+ : MathInset(1), style_(st)
{
name_ = verbose();
}
#include "support/LOstream.h"
-MathSpaceInset::MathSpaceInset(int sp, MathInsetTypes ot)
- : MathInset("", ot), space_(sp)
+MathSpaceInset::MathSpaceInset(int sp)
+ : space_(sp)
{}
class MathSpaceInset : public MathInset {
public:
///
- MathSpaceInset(int sp, MathInsetTypes ot = LM_OT_SPACE);
+ explicit MathSpaceInset(int sp);
///
- MathInset * clone() const;
+ MathInset * clone() const;
///
void draw(Painter &, int, int);
///
MathSqrtInset::MathSqrtInset()
- : MathInset("sqrt", LM_OT_SQRT, 1)
+ : MathInset(1)
{}