mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
support for \substack
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3540 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
e6947f6187
commit
5e6481b76e
@ -123,6 +123,8 @@ libmathed_la_SOURCES = \
|
||||
math_streamstr.h \
|
||||
math_stringinset.C \
|
||||
math_stringinset.h \
|
||||
math_substackinset.C \
|
||||
math_substackinset.h \
|
||||
math_support.C \
|
||||
math_support.h \
|
||||
math_symbolinset.C \
|
||||
|
@ -196,7 +196,7 @@ namespace {
|
||||
out = out.substr(6);
|
||||
|
||||
// parse output as matrix or single number
|
||||
MathAtom at(new MathArrayInset(out));
|
||||
MathAtom at(new MathArrayInset("array", out));
|
||||
MathArrayInset const * mat = at.nucleus()->asArrayInset();
|
||||
MathArray res;
|
||||
if (mat->ncols() == 1 && mat->nrows() == 1)
|
||||
|
@ -17,23 +17,25 @@ using std::istringstream;
|
||||
using std::getline;
|
||||
|
||||
|
||||
MathArrayInset::MathArrayInset(int m, int n)
|
||||
: MathGridInset(m, n)
|
||||
MathArrayInset::MathArrayInset(string const & name, int m, int n)
|
||||
: MathGridInset(m, n), name_(name)
|
||||
{}
|
||||
|
||||
|
||||
MathArrayInset::MathArrayInset(int m, int n, char valign, string const & halign)
|
||||
: MathGridInset(m, n, valign, halign)
|
||||
MathArrayInset::MathArrayInset(string const & name, int m, int n,
|
||||
char valign, string const & halign)
|
||||
: MathGridInset(m, n, valign, halign), name_(name)
|
||||
{}
|
||||
|
||||
|
||||
MathArrayInset::MathArrayInset(char valign, string const & halign)
|
||||
: MathGridInset(valign, halign)
|
||||
MathArrayInset::MathArrayInset(string const & name, char valign,
|
||||
string const & halign)
|
||||
: MathGridInset(valign, halign), name_(name)
|
||||
{}
|
||||
|
||||
|
||||
MathArrayInset::MathArrayInset(string const & str)
|
||||
: MathGridInset(1, 1)
|
||||
MathArrayInset::MathArrayInset(string const & name, string const & str)
|
||||
: MathGridInset(1, 1), name_(name)
|
||||
{
|
||||
vector< vector<string> > dat;
|
||||
istringstream is(str.c_str());
|
||||
@ -76,7 +78,7 @@ void MathArrayInset::write(WriteStream & os) const
|
||||
{
|
||||
if (os.fragile())
|
||||
os << "\\protect";
|
||||
os << "\\begin{array}";
|
||||
os << "\\begin{" << name_ << "}";
|
||||
|
||||
if (v_align_ == 't' || v_align_ == 'b')
|
||||
os << '[' << char(v_align_) << ']';
|
||||
@ -86,13 +88,13 @@ void MathArrayInset::write(WriteStream & os) const
|
||||
|
||||
if (os.fragile())
|
||||
os << "\\protect";
|
||||
os << "\\end{array}\n";
|
||||
os << "\\end{" << name_ << "}\n";
|
||||
}
|
||||
|
||||
|
||||
void MathArrayInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[array ";
|
||||
os << "[" << name_ << " ";
|
||||
MathGridInset::normalize(os);
|
||||
os << "]";
|
||||
}
|
||||
|
@ -12,13 +12,14 @@
|
||||
class MathArrayInset : public MathGridInset {
|
||||
public:
|
||||
///
|
||||
MathArrayInset(int m, int n);
|
||||
MathArrayInset(string const &, int m, int n);
|
||||
///
|
||||
MathArrayInset(int m, int n, char valign, string const & halign);
|
||||
MathArrayInset(string const &, int m, int n,
|
||||
char valign, string const & halign);
|
||||
///
|
||||
MathArrayInset(char valign, string const & halign);
|
||||
MathArrayInset(string const &, char valign, string const & halign);
|
||||
/// convienience constructor from whitespace/newline seperated data
|
||||
MathArrayInset(string const & str);
|
||||
MathArrayInset(string const &, string const & str);
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
@ -32,6 +33,10 @@ public:
|
||||
void normalize(NormalStream &) const;
|
||||
///
|
||||
void maplize(MapleStream &) const;
|
||||
|
||||
private:
|
||||
///
|
||||
string name_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1265,7 +1265,7 @@ bool MathCursor::interpret(string const & s)
|
||||
m = std::max(1u, m);
|
||||
n = std::max(1u, n);
|
||||
v_align += 'c';
|
||||
niceInsert(MathAtom(new MathArrayInset(m, n, v_align[0], h_align)));
|
||||
niceInsert(MathAtom(new MathArrayInset("array", m, n, v_align[0], h_align)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "math_parser.h"
|
||||
#include "math_arrayinset.h"
|
||||
#include "math_amsarrayinset.h"
|
||||
#include "math_binominset.h"
|
||||
#include "math_boxinset.h"
|
||||
@ -23,6 +24,7 @@
|
||||
#include "math_specialcharinset.h"
|
||||
#include "math_sqrtinset.h"
|
||||
#include "math_stackrelinset.h"
|
||||
#include "math_substackinset.h"
|
||||
#include "math_symbolinset.h"
|
||||
#include "math_undersetinset.h"
|
||||
#include "math_unknowninset.h"
|
||||
@ -108,6 +110,12 @@ MathAtom createMathInset(string const & s)
|
||||
if (s == "cases")
|
||||
return MathAtom(new MathCasesInset);
|
||||
|
||||
if (s == "substack")
|
||||
return MathAtom(new MathSubstackInset);
|
||||
|
||||
if (s == "subarray" || s == "array")
|
||||
return MathAtom(new MathArrayInset(s, 1, 1));
|
||||
|
||||
if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix")
|
||||
return MathAtom(new MathAMSArrayInset(s));
|
||||
|
||||
|
@ -1074,10 +1074,10 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
|
||||
else if (t.cs() == "begin") {
|
||||
string const name = getArg('{', '}');
|
||||
if (name == "array") {
|
||||
if (name == "array" || name == "subarray") {
|
||||
string const valign = getArg('[', ']') + 'c';
|
||||
string const halign = getArg('{', '}');
|
||||
array.push_back(MathAtom(new MathArrayInset(valign[0], halign)));
|
||||
array.push_back(MathAtom(new MathArrayInset(name, valign[0], halign)));
|
||||
parse_lines(array.back(), false, false);
|
||||
} else if (name == "split" || name == "cases") {
|
||||
array.push_back(createMathInset(name));
|
||||
@ -1120,6 +1120,12 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
|
||||
return;
|
||||
}
|
||||
|
||||
else if (t.cs() == "substack") {
|
||||
array.push_back(createMathInset(t.cs()));
|
||||
skipBegin();
|
||||
parse_lines2(array.back(), true);
|
||||
}
|
||||
|
||||
else if (t.cs() == "xymatrix") {
|
||||
array.push_back(createMathInset(t.cs()));
|
||||
skipBegin();
|
||||
|
53
src/mathed/math_substackinset.C
Normal file
53
src/mathed/math_substackinset.C
Normal file
@ -0,0 +1,53 @@
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "math_substackinset.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_streamstr.h"
|
||||
|
||||
|
||||
MathSubstackInset::MathSubstackInset()
|
||||
: MathGridInset(1, 1)
|
||||
{}
|
||||
|
||||
|
||||
MathInset * MathSubstackInset::clone() const
|
||||
{
|
||||
return new MathSubstackInset(*this);
|
||||
}
|
||||
|
||||
|
||||
void MathSubstackInset::metrics(MathMetricsInfo const & st) const
|
||||
{
|
||||
MathMetricsInfo mi = st;
|
||||
if (mi.style == LM_ST_DISPLAY)
|
||||
mi.style = LM_ST_TEXT;
|
||||
MathGridInset::metrics(mi);
|
||||
}
|
||||
|
||||
|
||||
void MathSubstackInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\substack{";
|
||||
MathGridInset::write(os);
|
||||
os << "}\n";
|
||||
}
|
||||
|
||||
|
||||
void MathSubstackInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[substack ";
|
||||
MathGridInset::normalize(os);
|
||||
os << "]";
|
||||
}
|
||||
|
||||
|
||||
void MathSubstackInset::maplize(MapleStream & os) const
|
||||
{
|
||||
os << "substack(";
|
||||
MathGridInset::maplize(os);
|
||||
os << ")";
|
||||
}
|
33
src/mathed/math_substackinset.h
Normal file
33
src/mathed/math_substackinset.h
Normal file
@ -0,0 +1,33 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef MATH_SUBSTACK_H
|
||||
#define MATH_SUBSTACK_H
|
||||
|
||||
#include "math_gridinset.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
|
||||
class MathSubstackInset : public MathGridInset {
|
||||
public:
|
||||
///
|
||||
MathSubstackInset();
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MathMetricsInfo const & st) const;
|
||||
///
|
||||
MathSubstackInset const * asSubstackInset() const { return this; }
|
||||
|
||||
///
|
||||
void normalize();
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
///
|
||||
void normalize(NormalStream &) const;
|
||||
///
|
||||
void maplize(MapleStream &) const;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user