mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Small bugfixes and cosmetic changes
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2208 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f6c9132899
commit
b24b504cd2
@ -1,3 +1,9 @@
|
||||
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.
|
||||
|
@ -477,10 +477,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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);
|
||||
|
||||
@ -690,27 +688,18 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
}
|
||||
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;
|
||||
@ -764,7 +753,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_PROTECTEDSPACE:
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
mathcursor->insert(new MathSpaceInset(1));
|
||||
space_on = true;
|
||||
updateLocal(bv);
|
||||
break;
|
||||
|
||||
@ -936,7 +924,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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;
|
||||
@ -960,10 +948,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
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;
|
||||
@ -997,9 +981,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
//if (mathcursor)
|
||||
// updateLocal(bv);
|
||||
|
||||
if (sp && !space_on)
|
||||
sp = 0;
|
||||
|
||||
if (mathcursor && (mathcursor->Selection() || was_selection))
|
||||
toggleInsetSelection(bv);
|
||||
|
||||
|
@ -8,14 +8,12 @@
|
||||
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)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
void Metrics(MathStyles st);
|
||||
///
|
||||
int getAccentCode() const;
|
||||
///
|
||||
bool isAccentInset() const { return true; }
|
||||
protected:
|
||||
///
|
||||
byte c;
|
||||
|
@ -11,7 +11,7 @@
|
||||
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);
|
||||
}
|
||||
@ -101,9 +101,12 @@ void MathBigopInset::draw(Painter & pain, int x, int y)
|
||||
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;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <cctype>
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_parser.h"
|
||||
#include "math_cursor.h"
|
||||
#include "math_macro.h"
|
||||
@ -560,7 +561,8 @@ void MathCursor::SetSize(MathStyles size)
|
||||
|
||||
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();
|
||||
@ -604,6 +606,20 @@ void MathCursor::Interpret(string const & s)
|
||||
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 {
|
||||
@ -624,11 +640,11 @@ void MathCursor::Interpret(string const & s)
|
||||
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:
|
||||
@ -709,7 +725,7 @@ void MathCursor::MacroModeClose()
|
||||
imacro->SetName(l->name);
|
||||
} else {
|
||||
Left();
|
||||
if (nextInset()->GetType() == LM_OT_ACCENT)
|
||||
if (nextInset()->isAccentInset())
|
||||
setAccent(
|
||||
static_cast<MathAccentInset*>(nextInset())->getAccentCode());
|
||||
array().erase(cursor_);
|
||||
|
@ -15,7 +15,7 @@ using std::ostream;
|
||||
|
||||
|
||||
MathDecorationInset::MathDecorationInset(int d)
|
||||
: MathInset("", LM_OT_DECO, 1), deco_(d)
|
||||
: MathInset(1), deco_(d)
|
||||
{
|
||||
upper_ = deco_ != LM_underline && deco_ != LM_underbrace;
|
||||
}
|
||||
|
@ -134,26 +134,6 @@ enum MathInsetTypes {
|
||||
///
|
||||
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
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
MathDelimInset::MathDelimInset(int l, int r)
|
||||
: MathInset("", LM_OT_DELIM, 1), left_(l), right_(r)
|
||||
: MathInset(1), left_(l), right_(r)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ using std::ostream;
|
||||
|
||||
|
||||
MathDotsInset::MathDotsInset(string const & name, int id)
|
||||
: MathInset(name, LM_OT_DOTS), code_(id)
|
||||
: MathInset(0, name), code_(id)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -13,12 +13,9 @@
|
||||
#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
|
||||
@ -46,7 +43,7 @@ void MathFracInset::draw(Painter & pain, int x, int y)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
class MathFracInset : public MathInset {
|
||||
public:
|
||||
///
|
||||
explicit MathFracInset(MathInsetTypes ot = LM_OT_FRAC);
|
||||
explicit MathFracInset(const string & name);
|
||||
///
|
||||
virtual MathInset * clone() const;
|
||||
///
|
||||
|
@ -18,7 +18,7 @@ extern LyXFont WhichFont(short type, int size);
|
||||
|
||||
|
||||
MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot)
|
||||
: MathInset(nm, ot)
|
||||
: MathInset(0, nm, ot)
|
||||
{
|
||||
lims_ = (GetType() == LM_OT_FUNCLIM);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ MathGridInset::ColInfo::ColInfo()
|
||||
|
||||
|
||||
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";
|
||||
|
@ -30,7 +30,7 @@
|
||||
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)
|
||||
{}
|
||||
|
@ -43,8 +43,9 @@ public:
|
||||
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() {}
|
||||
|
||||
@ -173,6 +174,8 @@ public:
|
||||
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; }
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
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)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -147,7 +147,7 @@ void MathMacroTable::builtinMacros()
|
||||
|
||||
// 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));
|
||||
|
||||
|
@ -10,12 +10,12 @@
|
||||
|
||||
|
||||
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_()
|
||||
{}
|
||||
|
||||
|
||||
|
@ -475,10 +475,20 @@ void MathMatrixInset::mutate(short newtype)
|
||||
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:
|
||||
|
@ -392,9 +392,9 @@ void do_insert(MathArray & dat, unsigned char ch, MathTextCodes fcode)
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -723,15 +723,15 @@ void mathed_parse(MathArray & array, unsigned flags)
|
||||
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:
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "Painter.h"
|
||||
|
||||
MathRootInset::MathRootInset()
|
||||
: MathInset("sqrt", LM_OT_SQRT, 2)
|
||||
: MathInset(2)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
|
||||
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)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
MathSizeInset::MathSizeInset(MathStyles st)
|
||||
: MathInset("", LM_OT_SIMPLE, 1), style_(st)
|
||||
: MathInset(1), style_(st)
|
||||
{
|
||||
name_ = verbose();
|
||||
}
|
||||
|
@ -11,8 +11,8 @@
|
||||
#include "support/LOstream.h"
|
||||
|
||||
|
||||
MathSpaceInset::MathSpaceInset(int sp, MathInsetTypes ot)
|
||||
: MathInset("", ot), space_(sp)
|
||||
MathSpaceInset::MathSpaceInset(int sp)
|
||||
: space_(sp)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
class MathSpaceInset : public MathInset {
|
||||
public:
|
||||
///
|
||||
MathSpaceInset(int sp, MathInsetTypes ot = LM_OT_SPACE);
|
||||
explicit MathSpaceInset(int sp);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
MathSqrtInset::MathSqrtInset()
|
||||
: MathInset("sqrt", LM_OT_SQRT, 1)
|
||||
: MathInset(1)
|
||||
{}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user