mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
several smallish changes/bugfixes/left overs from Porto
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4474 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a3660106fe
commit
c649284611
@ -675,7 +675,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
case LFUN_PROTECTEDSPACE:
|
||||
case LFUN_MATH_SPACE:
|
||||
bv->lockedInsetStoreUndo(Undo::EDIT);
|
||||
mathcursor->insert(MathAtom(new MathSpaceInset(1)));
|
||||
mathcursor->insert(MathAtom(new MathSpaceInset(",")));
|
||||
updateLocal(bv, true);
|
||||
break;
|
||||
|
||||
|
@ -34,20 +34,26 @@ MathAtom::MathAtom(MathInset * p)
|
||||
{}
|
||||
|
||||
|
||||
MathAtom::MathAtom(MathAtom const & p)
|
||||
: nucleus_(p.nucleus_ ? p.nucleus_->clone() : 0)
|
||||
MathAtom::MathAtom(MathAtom const & at)
|
||||
: nucleus_(at.nucleus_ ? at.nucleus_->clone() : 0)
|
||||
{}
|
||||
|
||||
|
||||
void MathAtom::operator=(MathAtom const & p)
|
||||
void MathAtom::operator=(MathAtom const & at)
|
||||
{
|
||||
if (&p == this)
|
||||
if (&at == this)
|
||||
return;
|
||||
MathAtom tmp(p);
|
||||
MathAtom tmp(at);
|
||||
std::swap(tmp.nucleus_, nucleus_);
|
||||
}
|
||||
|
||||
|
||||
void MathAtom::operator=(MathInset * p)
|
||||
{
|
||||
reset(p);
|
||||
}
|
||||
|
||||
|
||||
MathAtom::~MathAtom()
|
||||
{
|
||||
delete nucleus_;
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
/// assignment invokes nucleus_->clone()
|
||||
void operator=(MathAtom const &);
|
||||
/// change inset under the hood
|
||||
void operator=(MathInset * p);
|
||||
/// change inset under the hood
|
||||
void reset(MathInset * p);
|
||||
/// access to the inset (checked with gprof)
|
||||
MathInset * nucleus() const { return nucleus_; }
|
||||
|
@ -1419,9 +1419,10 @@ bool MathCursor::interpret(char c)
|
||||
return true;
|
||||
}
|
||||
|
||||
// leave macro mode and try again
|
||||
// leave macro mode and try again if necessary
|
||||
macroModeClose();
|
||||
interpret(c);
|
||||
if (c != ' ')
|
||||
interpret(c);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,44 @@
|
||||
|
||||
using std::max;
|
||||
|
||||
namespace {
|
||||
|
||||
string convertDelimToLatexName(string const & name)
|
||||
{
|
||||
if (name == "(")
|
||||
return name;
|
||||
if (name == "[")
|
||||
return name;
|
||||
if (name == ".")
|
||||
return name;
|
||||
if (name == ")")
|
||||
return name;
|
||||
if (name == "]")
|
||||
return name;
|
||||
if (name == "/")
|
||||
return name;
|
||||
if (name == "|")
|
||||
return name;
|
||||
return "\\" + name + " ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
MathDelimInset::MathDelimInset(string const & l, string const & r)
|
||||
: MathNestInset(1), left_(l), right_(r)
|
||||
{}
|
||||
|
||||
|
||||
MathDelimInset::MathDelimInset
|
||||
(string const & l, string const & r, MathArray const & ar)
|
||||
: MathNestInset(1), left_(l), right_(r)
|
||||
{
|
||||
cell(0) = ar;
|
||||
}
|
||||
|
||||
|
||||
MathInset * MathDelimInset::clone() const
|
||||
{
|
||||
return new MathDelimInset(*this);
|
||||
|
@ -18,6 +18,8 @@ public:
|
||||
///
|
||||
MathDelimInset(string const & left, string const & right);
|
||||
///
|
||||
MathDelimInset(string const & left, string const & right, MathArray const &);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
MathDelimInset * asDelimInset() { return this; }
|
||||
|
@ -11,6 +11,13 @@ MathExFuncInset::MathExFuncInset(string const & name)
|
||||
{}
|
||||
|
||||
|
||||
MathExFuncInset::MathExFuncInset(string const & name, MathArray const & ar)
|
||||
: MathNestInset(1), name_(name)
|
||||
{
|
||||
cell(0) = ar;
|
||||
}
|
||||
|
||||
|
||||
MathInset * MathExFuncInset::clone() const
|
||||
{
|
||||
return new MathExFuncInset(*this);
|
||||
|
@ -12,6 +12,8 @@ public:
|
||||
///
|
||||
explicit MathExFuncInset(string const & name);
|
||||
///
|
||||
MathExFuncInset(string const & name, MathArray const & ar);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathMetricsInfo & st) const;
|
||||
|
@ -332,17 +332,31 @@ void extractExps(MathArray & ar)
|
||||
continue;
|
||||
|
||||
// create a proper exp-inset as replacement
|
||||
MathExFuncInset * func = new MathExFuncInset("exp");
|
||||
func->cell(0) = sup->cell(1);
|
||||
|
||||
// clean up
|
||||
(*it).reset(func);
|
||||
*it = new MathExFuncInset("exp", sup->cell(1));
|
||||
ar.erase(it + 1);
|
||||
}
|
||||
//lyxerr << "\nExps to: " << ar << "\n";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// extract det(...) from |matrix|
|
||||
//
|
||||
void extractDets(MathArray & ar)
|
||||
{
|
||||
//lyxerr << "\ndet from: " << ar << "\n";
|
||||
for (MathArray::iterator it = ar.begin(); it != ar.end(); ++it) {
|
||||
MathDelimInset * del = (*it)->asDelimInset();
|
||||
if (!del)
|
||||
continue;
|
||||
if (!del->isAbs())
|
||||
continue;
|
||||
*it = new MathExFuncInset("det", del->cell(0));
|
||||
}
|
||||
//lyxerr << "\ndet to: " << ar << "\n";
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// search numbers
|
||||
//
|
||||
@ -404,9 +418,7 @@ bool testCloseParan(MathInset * p)
|
||||
|
||||
MathInset * replaceDelims(const MathArray & ar)
|
||||
{
|
||||
MathDelimInset * del = new MathDelimInset("(", ")");
|
||||
del->cell(0) = ar;
|
||||
return del;
|
||||
return new MathDelimInset("(", ")", ar);
|
||||
}
|
||||
|
||||
|
||||
@ -761,6 +773,7 @@ void extractStructure(MathArray & ar)
|
||||
extractMatrices(ar);
|
||||
extractDelims(ar);
|
||||
extractFunctions(ar);
|
||||
extractDets(ar);
|
||||
extractIntegrals(ar);
|
||||
extractSums(ar);
|
||||
extractDiff(ar);
|
||||
@ -911,6 +924,7 @@ namespace {
|
||||
ms << ar;
|
||||
string expr = os.str().c_str();
|
||||
lyxerr << "ar: '" << ar << "'\n";
|
||||
lyxerr << "ms: '" << os.str() << "'\n";
|
||||
|
||||
for (int i = 0; i < 100; ++i) { // at most 100 attempts
|
||||
// try to fix missing '*' the hard way by using mint
|
||||
|
@ -321,8 +321,8 @@ MathAtom createMathInset(string const & s)
|
||||
return MathAtom(new MathUndersetInset);
|
||||
if (inset == "decoration")
|
||||
return MathAtom(new MathDecorationInset(l->name));
|
||||
//if (inset == "space")
|
||||
// return MathAtom(new MathSpaceInset(l->id));
|
||||
if (inset == "space")
|
||||
return MathAtom(new MathSpaceInset(l->name));
|
||||
if (inset == "dots")
|
||||
return MathAtom(new MathDotsInset(l->name));
|
||||
if (inset == "box")
|
||||
|
@ -1,87 +0,0 @@
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "math_funcinset.h"
|
||||
#include "frontends/font_metrics.h"
|
||||
#include "frontends/Painter.h"
|
||||
#include "math_support.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_streamstr.h"
|
||||
|
||||
|
||||
extern LyXFont WhichFont(short type, int size);
|
||||
|
||||
|
||||
MathFuncInset::MathFuncInset(string const & nm)
|
||||
: name_(nm)
|
||||
{}
|
||||
|
||||
|
||||
MathInset * MathFuncInset::clone() const
|
||||
{
|
||||
return new MathFuncInset(*this);
|
||||
}
|
||||
|
||||
|
||||
string const & MathFuncInset::name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::setName(string const & n)
|
||||
{
|
||||
name_ = n;
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::metrics(MathMetricsInfo & mi) const
|
||||
{
|
||||
mathed_string_dim(mi.font_, name_, ascent_, descent_, width_);
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::draw(Painter & pain, int x, int y) const
|
||||
{
|
||||
drawStr(pain, mi.font_, x, y, name_);
|
||||
}
|
||||
|
||||
|
||||
bool MathFuncInset::match(MathInset * p) const
|
||||
{
|
||||
MathFuncInset const * q = p->asFuncInset();
|
||||
return q && name_ == q->name_;
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::maplize(MapleStream & os) const
|
||||
{
|
||||
os << ' ' << name_;
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::mathmlize(MathMLStream & os) const
|
||||
{
|
||||
os << MTag("mi") << name_ << ETag("mi");
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::octavize(OctaveStream & os) const
|
||||
{
|
||||
os << ' ' << name_;
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[func " << name_ << ']';
|
||||
}
|
||||
|
||||
|
||||
void MathFuncInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\" << name_ << ' ';
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef MATH_FUNCINSET_H
|
||||
#define MATH_FUNCINSET_H
|
||||
|
||||
#include "math_diminset.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/**
|
||||
Functions or LaTeX names for objects that I don't know how to draw.
|
||||
*/
|
||||
class MathFuncInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathFuncInset(string const & nm);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathMetricsInfo & st) const;
|
||||
///
|
||||
void draw(Painter &, int x, int y) const;
|
||||
///
|
||||
string const & name() const;
|
||||
/// identifies FuncInsets
|
||||
MathFuncInset * asFuncInset() { return this; }
|
||||
///
|
||||
void setName(string const &);
|
||||
///
|
||||
bool match(MathInset * p) const;
|
||||
|
||||
///
|
||||
void normalize(NormalStream &) const;
|
||||
///
|
||||
void maplize(MapleStream &) const;
|
||||
///
|
||||
void mathmlize(MathMLStream &) const;
|
||||
///
|
||||
void octavize(OctaveStream &) const;
|
||||
///
|
||||
void write(WriteStream &) const;
|
||||
private:
|
||||
///
|
||||
string name_;
|
||||
///
|
||||
mutable LyXFont font_;
|
||||
};
|
||||
#endif
|
@ -881,8 +881,7 @@ void Parser::parse_into1(MathGridInset & grid, unsigned flags,
|
||||
MathArray ar;
|
||||
parse_into(ar, FLAG_RIGHT, mathmode);
|
||||
string r = getToken().asString();
|
||||
cell->push_back(MathAtom(new MathDelimInset(l, r)));
|
||||
cell->back()->cell(0) = ar;
|
||||
cell->push_back(MathAtom(new MathDelimInset(l, r, ar)));
|
||||
}
|
||||
|
||||
else if (t.cs() == "right") {
|
||||
|
@ -9,17 +9,29 @@
|
||||
#include "math_mathmlstream.h"
|
||||
|
||||
|
||||
|
||||
char const * latex_mathspace[] = {
|
||||
"!", ",", ":", ";", "quad", "qquad", "lyxnegspace"
|
||||
"!", ",", ";", ":", "quad", "qquad", "lyxnegspace", "lyxposspace"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
MathSpaceInset::MathSpaceInset(int sp)
|
||||
: space_(sp)
|
||||
{}
|
||||
|
||||
|
||||
MathSpaceInset::MathSpaceInset(string const & name)
|
||||
: space_(1)
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if (latex_mathspace[i] == name)
|
||||
space_ = i;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MathInset * MathSpaceInset::clone() const
|
||||
{
|
||||
return new MathSpaceInset(*this);
|
||||
@ -36,6 +48,7 @@ void MathSpaceInset::metrics(MathMetricsInfo &) const
|
||||
case 4: width_ = 20; break;
|
||||
case 5: width_ = 40; break;
|
||||
case 6: width_ = -2; break;
|
||||
case 7: width_ = 2; break;
|
||||
default: width_ = 6; break;
|
||||
}
|
||||
ascent_ = 4;
|
||||
@ -48,7 +61,7 @@ void MathSpaceInset::draw(MathPainterInfo & pain, int x, int y) const
|
||||
|
||||
// Sadly, HP-UX CC can't handle that kind of initialization.
|
||||
// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
|
||||
if (space_ == 6)
|
||||
if (space_ > 6)
|
||||
return;
|
||||
|
||||
int xp[4];
|
||||
@ -89,6 +102,6 @@ void MathSpaceInset::normalize(NormalStream & os) const
|
||||
|
||||
void MathSpaceInset::write(WriteStream & os) const
|
||||
{
|
||||
if (space_ >= 0 && space_ < 7)
|
||||
if (space_ >= 0 && space_ < 8)
|
||||
os << '\\' << latex_mathspace[space_] << ' ';
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ public:
|
||||
///
|
||||
explicit MathSpaceInset(int sp);
|
||||
///
|
||||
explicit MathSpaceInset(string const & name);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
MathSpaceInset const * asSpaceInset() const { return this; }
|
||||
|
@ -1,44 +0,0 @@
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "math_specialcharinset.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_support.h"
|
||||
|
||||
|
||||
MathSpecialCharInset::MathSpecialCharInset(char c)
|
||||
: char_(c)
|
||||
{}
|
||||
|
||||
|
||||
MathInset * MathSpecialCharInset::clone() const
|
||||
{
|
||||
return new MathSpecialCharInset(*this);
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::metrics(MathMetricsInfo & mi) const
|
||||
{
|
||||
MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
|
||||
mathed_char_dim(mi.base.font, char_, ascent_, descent_, width_);
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::draw(MathPainterInfo & pi, int x, int y) const
|
||||
{
|
||||
MathShapeChanger dummy(pi.base.font, LyXFont::ITALIC_SHAPE);
|
||||
pi.draw(x, y, char_);
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\" << char_;
|
||||
}
|
||||
|
||||
|
||||
void MathSpecialCharInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "\\" << char_;
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef MATH_SPECIALCHARINSET_H
|
||||
#define MATH_SPECIALCHARINSET_H
|
||||
|
||||
#include "math_diminset.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/** An inset for characters like {, #, and $ that need to be escaped
|
||||
when written out, but can be inserted by a single keystroke
|
||||
\author André Pönitz
|
||||
*/
|
||||
|
||||
class MathSpecialCharInset : public MathDimInset {
|
||||
public:
|
||||
///
|
||||
explicit MathSpecialCharInset(char c);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathMetricsInfo & st) const;
|
||||
///
|
||||
void draw(MathPainterInfo &, int x, int y) const;
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
///
|
||||
void normalize(NormalStream &) const;
|
||||
|
||||
private:
|
||||
/// the character
|
||||
char char_;
|
||||
};
|
||||
#endif
|
@ -54,7 +54,7 @@ void MathStringInset::maplize(MapleStream & os) const
|
||||
// insert '*' between adjacent chars if type is LM_TC_VAR
|
||||
os << str_[0];
|
||||
for (string::size_type i = 1; i < str_.size(); ++i)
|
||||
os << '*' << str_[i];
|
||||
os << str_[i];
|
||||
}
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ void MathStringInset::octavize(OctaveStream & os) const
|
||||
// insert '*' between adjacent chars if type is LM_TC_VAR
|
||||
os << str_[0];
|
||||
for (string::size_type i = 1; i < str_.size(); ++i)
|
||||
os << '*' << str_[i];
|
||||
os << str_[i];
|
||||
}
|
||||
|
||||
|
||||
|
@ -525,28 +525,6 @@ void math_font_max_dim(LyXFont const & font, int & asc, int & des)
|
||||
}
|
||||
|
||||
|
||||
string convertDelimToLatexName(string const & name)
|
||||
{
|
||||
if (name == "(")
|
||||
return name;
|
||||
if (name == "[")
|
||||
return name;
|
||||
if (name == ".")
|
||||
return name;
|
||||
if (name == ")")
|
||||
return name;
|
||||
if (name == "]")
|
||||
return name;
|
||||
if (name == "/")
|
||||
return name;
|
||||
if (name == "|")
|
||||
return name;
|
||||
return "\\" + name + " ";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct fontinfo {
|
||||
string cmd_;
|
||||
LyXFont::FONT_FAMILY family_;
|
||||
|
@ -39,8 +39,6 @@ void drawChar(MathPainterInfo & pain,
|
||||
|
||||
void math_font_max_dim(LyXFont const &, int & asc, int & desc);
|
||||
|
||||
string convertDelimToLatexName(string const & name);
|
||||
|
||||
void augmentFont(LyXFont & f, string const & cmd);
|
||||
|
||||
|
||||
|
@ -115,6 +115,8 @@ void MathSymbolInset::maplize(MapleStream & os) const
|
||||
{
|
||||
if (name() == "cdot")
|
||||
os << '*';
|
||||
else if (name() == "infty")
|
||||
os << "infinity";
|
||||
else
|
||||
os << name();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user