mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Fix bug #6341: Can't set equal spacing in xymatrix.
Now we also 'support' \xymatrix!C (columns), \xymatrix!R (rows), \xymatrix!0 (all equal and ignore entry sizes) and \xymatrix! (all equal). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32518 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
43207c17bc
commit
c4701b2256
@ -20,8 +20,9 @@
|
||||
namespace lyx {
|
||||
|
||||
|
||||
InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c)
|
||||
: InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c)
|
||||
InsetMathXYMatrix::InsetMathXYMatrix(Buffer * buf, Length const & s, char c,
|
||||
bool e) : InsetMathGrid(buf, 1, 1), spacing_(s), spacing_code_(c),
|
||||
equal_spacing_(e)
|
||||
{
|
||||
}
|
||||
|
||||
@ -56,6 +57,15 @@ void InsetMathXYMatrix::write(WriteStream & os) const
|
||||
{
|
||||
MathEnsurer ensurer(os);
|
||||
os << "\\xymatrix";
|
||||
if (equal_spacing_) {
|
||||
os << "@!";
|
||||
switch (spacing_code_) {
|
||||
case '0':
|
||||
case 'R':
|
||||
case 'C':
|
||||
os << spacing_code_;
|
||||
}
|
||||
} else {
|
||||
switch (spacing_code_) {
|
||||
case 'R':
|
||||
case 'C':
|
||||
@ -70,6 +80,7 @@ void InsetMathXYMatrix::write(WriteStream & os) const
|
||||
if (!spacing_.empty())
|
||||
os << "@=" << from_ascii(spacing_.asLatexString());
|
||||
}
|
||||
}
|
||||
os << '{';
|
||||
InsetMathGrid::write(os);
|
||||
os << "}\n";
|
||||
@ -79,6 +90,14 @@ void InsetMathXYMatrix::write(WriteStream & os) const
|
||||
void InsetMathXYMatrix::infoize(odocstream & os) const
|
||||
{
|
||||
os << "xymatrix ";
|
||||
if (equal_spacing_) {
|
||||
switch (spacing_code_) {
|
||||
case '0':
|
||||
case 'R':
|
||||
case 'C':
|
||||
os << '!' << spacing_code_ << ' ';
|
||||
}
|
||||
} else {
|
||||
switch (spacing_code_) {
|
||||
case 'R':
|
||||
case 'C':
|
||||
@ -93,6 +112,7 @@ void InsetMathXYMatrix::infoize(odocstream & os) const
|
||||
if (!spacing_.empty())
|
||||
os << from_ascii(spacing_.asLatexString()) << ' ';
|
||||
}
|
||||
}
|
||||
InsetMathGrid::infoize(os);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,8 @@ namespace lyx {
|
||||
class InsetMathXYMatrix : public InsetMathGrid {
|
||||
public:
|
||||
///
|
||||
InsetMathXYMatrix(Buffer * buf, Length const & = Length(), char c = '\0');
|
||||
InsetMathXYMatrix(Buffer * buf, Length const & = Length(), char c = '\0',
|
||||
bool equal_spacing = false);
|
||||
///
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
///
|
||||
@ -54,6 +55,8 @@ private:
|
||||
Length spacing_;
|
||||
///
|
||||
char spacing_code_;
|
||||
///
|
||||
bool equal_spacing_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -374,11 +374,23 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
|
||||
if (s.substr(0, 8) == "xymatrix") {
|
||||
char spacing_code = '\0';
|
||||
Length spacing;
|
||||
bool equal_spacing = false;
|
||||
size_t const len = s.length();
|
||||
size_t i = 8;
|
||||
if (i < len && s[i] == '@') {
|
||||
++i;
|
||||
if (i < len && s[i] == '!') {
|
||||
equal_spacing = true;
|
||||
++i;
|
||||
if (i < len) {
|
||||
switch (s[i]) {
|
||||
case '0':
|
||||
case 'R':
|
||||
case 'C':
|
||||
spacing_code = static_cast<char>(s[i]);
|
||||
}
|
||||
}
|
||||
} else if (i < len) {
|
||||
switch (s[i]) {
|
||||
case 'R':
|
||||
case 'C':
|
||||
@ -390,13 +402,14 @@ MathAtom createInsetMath(docstring const & s, Buffer * buf)
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < len && s[i] == '=') {
|
||||
++i;
|
||||
spacing = Length(to_ascii(s.substr(i)));
|
||||
}
|
||||
}
|
||||
return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code));
|
||||
}
|
||||
return MathAtom(new InsetMathXYMatrix(buf, spacing, spacing_code,
|
||||
equal_spacing));
|
||||
}
|
||||
if (s == "xrightarrow" || s == "xleftarrow")
|
||||
return MathAtom(new InsetMathXArrow(buf, s));
|
||||
|
Loading…
Reference in New Issue
Block a user