mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 19:25:39 +00:00
improve end-of-line handling in the presence of optional args to \\
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2477 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7a058f4f03
commit
431543cc20
@ -206,17 +206,37 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
|
||||
void MathGridInset::write(std::ostream & os, bool fragile) const
|
||||
{
|
||||
for (int row = 0; row < nrows(); ++row) {
|
||||
if (row)
|
||||
os << " \\\\\n";
|
||||
for (int col = 0; col < ncols(); ++col) {
|
||||
if (col)
|
||||
os << " & ";
|
||||
cell(index(row, col)).write(os, fragile);
|
||||
os << eocString(row);
|
||||
}
|
||||
os << eolString(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string MathGridInset::eolString(int row) const
|
||||
{
|
||||
if (row == nrows() - 1)
|
||||
return "";
|
||||
|
||||
// make sure an upcoming '[' does not break anything
|
||||
MathArray const & c = cell(index(row + 1, 0));
|
||||
if (c.size() && (*c.begin())->getChar() == '[')
|
||||
return "\\\\[0pt]\n";
|
||||
|
||||
return "\\\\\n";
|
||||
}
|
||||
|
||||
|
||||
string MathGridInset::eocString(int col) const
|
||||
{
|
||||
if (col == ncols() - 1)
|
||||
return "";
|
||||
return " & ";
|
||||
}
|
||||
|
||||
|
||||
void MathGridInset::addRow(int row)
|
||||
{
|
||||
rowinfo_.insert(rowinfo_.begin() + row + 1, RowInfo());
|
||||
|
@ -125,6 +125,11 @@ public:
|
||||
std::vector<int> idxBetween(int from, int to) const;
|
||||
|
||||
protected:
|
||||
/// returns proper 'end of line' code for LaTeX
|
||||
string eolString(int row) const;
|
||||
/// returns proper 'end of column' code for LaTeX
|
||||
string eocString(int col) const;
|
||||
|
||||
/// row info
|
||||
std::vector<RowInfo> rowinfo_;
|
||||
/// column info
|
||||
|
@ -141,11 +141,8 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
||||
bool n = numberedType();
|
||||
|
||||
for (int row = 0; row < nrows(); ++row) {
|
||||
if (row)
|
||||
os << " \\\\\n";
|
||||
for (int col = 0; col < ncols(); ++col) {
|
||||
if (col)
|
||||
os << " & ";
|
||||
os << eocString(col);
|
||||
cell(index(row, col)).write(os, fragile);
|
||||
}
|
||||
if (n) {
|
||||
@ -154,6 +151,7 @@ void MathMatrixInset::write(std::ostream & os, bool fragile) const
|
||||
if (nonum_[row])
|
||||
os << "\\nonumber ";
|
||||
}
|
||||
os << eolString(row);
|
||||
}
|
||||
|
||||
footer_write(os);
|
||||
|
@ -303,7 +303,7 @@ int Parser::yylex()
|
||||
|
||||
while (is_.good()) {
|
||||
unsigned char c = getuchar();
|
||||
//lyxerr << "reading byte: '" << c << "' code: " << lexcode[c] << endl;
|
||||
lyxerr << "reading byte: '" << c << "' code: " << lexcode[c] << endl;
|
||||
|
||||
if (lexcode[c] == LexNewLine) {
|
||||
++lineno_;
|
||||
@ -672,6 +672,8 @@ void Parser::parse_into(MathArray & array, unsigned flags)
|
||||
break;
|
||||
|
||||
case LM_TK_NEWLINE:
|
||||
{
|
||||
lexArg('['); // ignore things like \\[5pt] for a while
|
||||
if (flags & FLAG_NEWLINE) {
|
||||
flags &= ~FLAG_NEWLINE;
|
||||
--plevel;
|
||||
@ -680,6 +682,7 @@ void Parser::parse_into(MathArray & array, unsigned flags)
|
||||
lyxerr[Debug::MATHED]
|
||||
<< "found newline unexpectedly, array: '" << array << "'\n";
|
||||
break;
|
||||
}
|
||||
|
||||
case LM_TK_PROTECT:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user