- Add support for the align environment from amsmath

- RTL fixes.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1479 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2001-02-11 09:58:20 +00:00
parent d89e29cf7c
commit a996b1bd2b
14 changed files with 133 additions and 24 deletions

View File

@ -146,9 +146,11 @@ Menuset
Menu "edit_math"
Item "Make eqnarray|e" "break-line e"
Item "Make multline|m" "break-line m"
Item "Make alignat 1 column|1" "break-line 1"
Item "Make alignat 2 columns|2" "break-line 2"
Item "Make alignat 3 columns|3" "break-line 3"
Item "Make align 1 column|1" "break-line 1"
Item "Make align 2 columns|2" "break-line 2"
Item "Make align 3 columns|3" "break-line 3"
Item "Make alignat 2 columns|2" "break-line B"
Item "Make alignat 3 columns|3" "break-line C"
Separator
Item "Toggle numbering|n" "math-number"
Item "Toggle numbering of line|u" "math-nonumber"

View File

@ -1,3 +1,12 @@
2001-02-10 Dekel Tsur <dekelts@tau.ac.il>
* text.C (PrepareToPrint): RTL Fix.
* paragraph.C (GetUChar): New method.
(String): Use GetUChar.
* buffer.C (asciiParagraph): Use GetUChar.
2001-02-09 Dekel Tsur <dekelts@tau.ac.il>
* text.C (GetVisibleRow): Fix selection drawing for RTL text in tables.

View File

@ -1528,7 +1528,7 @@ string const Buffer::asciiParagraph(LyXParagraph const * par,
} else {
islatex = 0;
}
c = par->GetChar(i);
c = par->GetUChar(params, i);
if (islatex)
continue;
switch (c) {

View File

@ -1,3 +1,8 @@
2001-02-10 Dekel Tsur <dekelts@tau.ac.il>
* insettext.C (LocalDispatch): Restore the language if the inset
becomes empty.
2001-02-09 Dekel Tsur <dekelts@tau.ac.il>
* insettext.C (moveRightIntern): Update the selection cursor.

View File

@ -1101,6 +1101,15 @@ InsetText::LocalDispatch(BufferView * bv,
result = UNDISPATCHED;
break;
}
/// If the action has deleted all text in the inset, we need to change the
// language to the language to the surronding text.
if (par->Last() == 0 && !par->next) {
LyXFont font(LyXFont::ALL_IGNORE);
font.setLanguage(bv->getParentLanguage(this));
SetFont(bv, font, false);
}
if (result != FINISHED) {
ShowInsetCursor(bv);
} else

View File

@ -441,6 +441,8 @@ public:
LyXFont const getFont(BufferParams const &, size_type pos) const;
///
value_type GetChar(size_type pos) const;
///
value_type GetUChar(BufferParams const &, size_type pos) const;
/// The position must already exist.
void SetChar(size_type pos, value_type c) {
#ifndef HAVE_ROPE

View File

@ -1,3 +1,7 @@
2001-02-10 Dekel Tsur <dekelts@tau.ac.il>
* Many files: add support for the align environment from amsmath.
2001-02-09 André Pönitz <poenitz@htwm.de>
* array.h: replace array buffer 'byte bf[]' by 'std::vector<byte> bf'

View File

@ -337,6 +337,12 @@ MathMatrixInset * create_multiline(short int type, int cols)
cols = 1;
switch (type) {
case LM_OT_ALIGN:
case LM_OT_ALIGNN:
columns = 2*cols;
for (int i = 0; i < cols; ++i)
align += "Rl";
break;
case LM_OT_ALIGNAT:
case LM_OT_ALIGNATN:
columns = 2*cols;
@ -377,8 +383,11 @@ void MathedCursor::Insert(byte c, MathedTextCodes t)
short int type = LM_OT_MPAR;
int cols = 1;
if (c >= '1' && c <= '9') {
type = LM_OT_ALIGN;
cols = c - '1' + 1;
} else if (c >= 'A' && c <= 'I') {
type = LM_OT_ALIGNAT;
cols = c - '0';
cols = c - 'A' + 1;
} else if (c == 'm')
type = LM_OT_MULTLINE;
else if (c == 'e')

View File

@ -145,6 +145,10 @@ enum MathedInsetTypes {
/// A multiline numbered paragraph
LM_OT_MPARN,
///
LM_OT_ALIGN,
///
LM_OT_ALIGNN,
///
LM_OT_ALIGNAT,
///
LM_OT_ALIGNATN,
@ -683,7 +687,8 @@ bool is_singlely_numbered(short int type)
inline
bool is_multi_numbered(short int type)
{
return type == LM_OT_MPARN || type == LM_OT_ALIGNATN;
return type == LM_OT_MPARN || type == LM_OT_ALIGNN
|| type == LM_OT_ALIGNATN;
}
inline
@ -695,7 +700,8 @@ bool is_numbered(short int type)
inline
bool is_multicolumn(short int type)
{
return type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;
return type == LM_OT_ALIGN || type == LM_OT_ALIGNN
|| type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;
}
#endif

View File

@ -464,6 +464,10 @@ void MathMatrixInset::Metrics()
}
descent = h - ascent + 2;
// Increase ws[i] for 'R' columns (except the first one)
for (i = 1; i < nc; ++i)
if (h_align[i] == 'R')
ws[i] += 10*df_width;
// Adjust local tabs
cxrow = row;
@ -477,10 +481,16 @@ void MathMatrixInset::Metrics()
isvoid = true;
}
switch (h_align[i]) {
case 'l': lf = 0; break;
case 'c': lf = (ws[i] - cxrow->getTab(i))/2;
case 'l':
lf = 0;
break;
case 'c':
lf = (ws[i] - cxrow->getTab(i))/2;
break;
case 'r':
case 'R':
lf = ws[i] - cxrow->getTab(i);
break;
case 'r': lf = ws[i] - cxrow->getTab(i); break;
}
ww = (isvoid) ? lf : lf + cxrow->getTab(i);
cxrow->setTab(i, lf + rg);

View File

@ -65,13 +65,15 @@ MathedInsetTypes mathed_env = LM_OT_MIN;
string mathed_label;
int const latex_mathenv_num = 10;
int const latex_mathenv_num = 12;
char const * latex_mathenv[latex_mathenv_num] = {
"math",
"displaymath",
"equation",
"eqnarray*",
"eqnarray",
"align*",
"align",
"alignat*",
"alignat",
"multline*",
@ -809,6 +811,15 @@ LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * array,
if (is_multiline(mathed_env)) {
int cols = 1;
if (is_multicolumn(mathed_env)) {
if (mathed_env != LM_OT_ALIGNAT &&
mathed_env != LM_OT_ALIGNATN &&
yyis->good()) {
char c;
yyis->get(c);
if (c != '%')
lyxerr << "Math parse error: unexpected '"
<< c << "'" << endl;
}
LexGetArg('{');
cols = strToInt(string(yytext));
}

View File

@ -336,8 +336,12 @@ void mathed_write(MathParInset * p, ostream & os, int * newlines,
os << "\\begin{"
<< latex_mathenv[mathed_env]
<< "}";
if (mathed_env == LM_OT_ALIGNAT || mathed_env == LM_OT_ALIGNATN)
if (is_multicolumn(mathed_env)) {
if (mathed_env != LM_OT_ALIGNAT
&& mathed_env != LM_OT_ALIGNATN)
os << "%";
os << "{" << p->GetColumns()/2 << "}";
}
os << "\n";
}
++number_of_newlines;

View File

@ -1018,6 +1018,47 @@ LyXParagraph::GetChar(LyXParagraph::size_type pos) const
}
LyXParagraph::value_type
LyXParagraph::GetUChar(BufferParams const & bparams,
LyXParagraph::size_type pos) const
{
value_type c = GetChar(pos);
if (!lyxrc.rtl_support)
return c;
value_type uc = c;
switch (c) {
case '(':
uc = ')';
break;
case ')':
uc = '(';
break;
case '[':
uc = ']';
break;
case ']':
uc = '[';
break;
case '{':
uc = '}';
break;
case '}':
uc = '{';
break;
case '<':
uc = '>';
break;
case '>':
uc = '<';
break;
}
if (uc != c && GetFontSettings(bparams, pos).isRightToLeft())
return uc;
else
return c;
}
// return an string of the current word, and the end of the word in lastpos.
string const LyXParagraph::GetWord(LyXParagraph::size_type & lastpos) const
{
@ -3995,7 +4036,7 @@ string const LyXParagraph::String(Buffer const * buffer,
s += labelstring + ' ';
for (LyXParagraph::size_type i = beg; i < end; ++i) {
value_type c = GetChar(i);
value_type c = GetUChar(buffer->params, i);
if (IsPrintable(c))
s += c;
else if (c == META_INSET) {

View File

@ -2196,21 +2196,18 @@ void LyXText::PrepareToPrint(BufferView * bview,
bool const is_rtl =
row->par()->isRightToLeftPar(bview->buffer()->params);
#ifndef NEW_INSETS
if (is_rtl) {
x = RightMargin(bview->buffer(), row);
x = (workWidth(bview) > 0)
? RightMargin(bview->buffer(), row) : 0;
#ifndef NEW_INSETS
if (row->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_SMALL);
x += lyxfont::width("Mwide-figM", font);
}
} else
#endif
if (workWidth(bview) > 0)
x = LeftMargin(bview, row);
else
x = 0;
} else
x = (workWidth(bview) > 0) ? LeftMargin(bview, row) : 0;
// is there a manual margin with a manual label
if (textclasslist.Style(bview->buffer()->params.textclass,