Two patches from Dekel (\\protect and depth bars); remove ! for margin notes; fixes to the 'use AMS math' feature

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@717 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-05-05 10:17:05 +00:00
parent 5e79e0d5c6
commit 8c818bc598
7 changed files with 250 additions and 94 deletions

View File

@ -1,3 +1,36 @@
2000-05-05 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/text.C (draw): do not display an exclamation mark in the
margin for margin notes. This is confusing, ugly and
uninformative.
* src/LaTeXFeatures.C (getPackages): load amssymb also when 'Use
AMS math' is checked.
* src/buffer.C (makeLaTeXFile): do not depend on the textclass
name to see whether including the amsmath package is needed.
2000-05-05 Dekel Tsur <dekel@math.tau.ac.il>
* src/paragraph.C (validate): Compute UsedLanguages correctly
(don't insert the american language if it doesn't appear in the
document)
* src/paragraph.C (TeXOnePar,SimpleTeXOnePar,SimpleTeXSpecialChars)
The argument of \thanks{} command is considered moving argument
* src/paragraph.C (SimpleTeXOnePar): Put \protect before \\ if in
moving argument.
2000-05-04 Dekel Tsur <dekel@math.tau.ac.il>
* src/text.C (GetVisibleRow): Improved drawing of vertical lines
for appendix/minipage/depth. The lines can be now both in the footnote
frame, and outside the frame.
* src/text.C (SingleWidth,draw): Correct rendering of Hebrew vowels
points ("nikud")
2000-05-05 Juergen Vigna <jug@sad.it>
* src/table.[Ch]: removed the inset and buffer stuff as this is now

11
NEWS
View File

@ -13,7 +13,10 @@ User-visible changes:
- Right-to-Left support for Hebrew and Arabic, this is a first attempt
only and is likely to improve in future versions.
- Per-paragraph spacing, currently only settable wrom the
- New visual feedback for environment depth of paragraphs (also the !
in the margin for margin notes has been removed).
- Per-paragraph spacing, currently only settable from the
command-line/window:
paragraph-spacing (default,single,onehalf,double,other) [float]
@ -30,7 +33,7 @@ User-visible changes:
- Removed support for XForms older than 0.88.
- Some commandline options and X resources are not supported anymore
- Some command-line options and X resources are not supported anymore
(The color ones, and -mono -fastselection, -reverse)
- new lyxrc variables: \show_banner [true|false] to remove the banner
@ -57,8 +60,8 @@ In the user-visible department, we find:
- better placement of accents for characters that LyX draws by itself;
- improved translations, in particular in finnish (overhauled UI
translation), dutch (tutorial and examples), german
- improved translations, in particular in Finnish (overhauled UI
translation), Dutch (tutorial and examples), German
- new configure flag --with-lyxname which allows to choose the name
under which lyx is installed. Default is "lyx", of course. It used

View File

@ -158,7 +158,7 @@ string LaTeXFeatures::getPackages()
packages += "\\usepackage{rotating}\n";
// amssymb.sty
if (amssymb)
if (amssymb || params.use_amsmath)
packages += "\\usepackage{amssymb}\n";
// latexsym.sty

View File

@ -1739,11 +1739,8 @@ void Buffer::makeLaTeXFile(string const & fname,
use_babel = true;
for (LaTeXFeatures::LanguageList::const_iterator cit =
features.UsedLanguages.begin();
cit != features.UsedLanguages.end(); ++cit) {
cit != features.UsedLanguages.end(); ++cit)
options += (*cit)->lang + ",";
}
if (default_language != params.language_info)
options += default_language->lang + ',';
options += params.language_info->lang + ',';
}
@ -1884,7 +1881,7 @@ void Buffer::makeLaTeXFile(string const & fname,
texrow.newline();
}
if (params.use_amsmath
&& !prefixIs(textclasslist.LatexnameOfClass(params.textclass), "ams")) {
&& !tclass.provides(LyXTextClass::amsmath)) {
ofs << "\\usepackage{amsmath}\n";
texrow.newline();
}
@ -2128,7 +2125,7 @@ void Buffer::latexParagraphs(ostream & ofs, LyXParagraph *par,
par = par->TeXEnvironment(ofs, texrow,
ftnote, ft_texrow, ftcount);
} else {
par = par->TeXOnePar(ofs, texrow,
par = par->TeXOnePar(ofs, texrow, false,
ftnote, ft_texrow, ftcount);
}

View File

@ -152,10 +152,11 @@ public:
///
LyXParagraph * TeXOnePar(std::ostream &, TexRow & texrow,
bool moving_arg,
std::ostream & foot, TexRow & foot_texrow,
int & foot_count);
///
bool SimpleTeXOnePar(std::ostream &, TexRow & texrow);
bool SimpleTeXOnePar(std::ostream &, TexRow & texrow, bool moving_arg);
///
LyXParagraph * TeXEnvironment(std::ostream &, TexRow & texrow,
@ -590,6 +591,7 @@ private:
LyXLayout const & style);
///
void SimpleTeXSpecialChars(std::ostream &, TexRow & texrow,
bool moving_arg,
LyXFont & font, LyXFont & running_font,
LyXFont & basefont, bool & open_font,
LyXLayout const & style,

View File

@ -367,12 +367,22 @@ void LyXParagraph::validate(LaTeXFeatures & features) const
<< (*cit).font.stateText()
<< endl;
}
#if 0
Language const * language = (*cit).font.language();
if (language != doc_language && language != default_language) {
if (language != doc_language) {
features.UsedLanguages.insert(language);
lyxerr[Debug::LATEX] << "Found language "
<< language->lang << endl;
}
}
#endif
}
// This is not efficient. I plan to use the code above, after I
// change the fontlist handling.
for (size_type i = 0; i < size(); ++i) {
Language const * language = GetFontSettings(i).language();
if (language != doc_language)
features.UsedLanguages.insert(language);
}
// then the insets
@ -1964,6 +1974,7 @@ int LyXParagraph::GetPositionOfInset(Inset * inset) const
LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
bool moving_arg,
ostream & foot,
TexRow & foot_texrow,
int & foot_count)
@ -2041,7 +2052,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
break;
}
bool need_par = SimpleTeXOnePar(os, texrow);
bool need_par = SimpleTeXOnePar(os, texrow, moving_arg);
// Spit out footnotes
LyXParagraph * par = next;
@ -2059,7 +2070,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
par = par->TeXFootnote(os, texrow, foot,
foot_texrow, foot_count,
is_rtl);
par->SimpleTeXOnePar(os, texrow);
par->SimpleTeXOnePar(os, texrow, moving_arg);
is_rtl = par->GetFontSettings(par->size()-1).isRightToLeft();
if (par->next &&
par->next->footnoteflag != LyXParagraph::NO_FOOTNOTE &&
@ -2075,7 +2086,7 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
par = par->TeXFootnote(os, texrow,
foot, foot_texrow, foot_count,
false);
par->SimpleTeXOnePar(os, texrow);
par->SimpleTeXOnePar(os, texrow, moving_arg);
par = par->next;
}
}
@ -2184,7 +2195,8 @@ LyXParagraph * LyXParagraph::TeXOnePar(ostream & os, TexRow & texrow,
// This one spits out the text of the paragraph
bool LyXParagraph::SimpleTeXOnePar(ostream & os, TexRow & texrow)
bool LyXParagraph::SimpleTeXOnePar(ostream & os, TexRow & texrow,
bool moving_arg)
{
lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl;
@ -2226,6 +2238,8 @@ bool LyXParagraph::SimpleTeXOnePar(ostream & os, TexRow & texrow)
return_value = true;
}
}
moving_arg |= style.needprotect;
// Which font is currently active?
LyXFont running_font(basefont);
@ -2356,13 +2370,15 @@ bool LyXParagraph::SimpleTeXOnePar(ostream & os, TexRow & texrow)
LyXFont::TYPEWRITER_FAMILY) {
os << "~";
}
if (moving_arg)
os << "\\protect ";
os << "\\\\\n";
}
texrow.newline();
texrow.start(this, i + 1);
column = 0;
} else {
SimpleTeXSpecialChars(os, texrow,
SimpleTeXSpecialChars(os, texrow, moving_arg,
font, running_font, basefont,
open_font, style, i, column, c);
}
@ -2549,7 +2565,7 @@ bool LyXParagraph::SimpleTeXOneTablePar(ostream & os, TexRow & texrow)
}
texrow.start(this, i + 1);
} else {
SimpleTeXSpecialChars(os, texrow,
SimpleTeXSpecialChars(os, texrow, false,
font, running_font, basefont,
open_font, style, i, column, c);
}
@ -2661,7 +2677,7 @@ bool LyXParagraph::TeXContTableRows(ostream & os,
column += 9;
}
}
SimpleTeXSpecialChars(os, texrow, font,
SimpleTeXSpecialChars(os, texrow, false, font,
running_font, basefont,
open_font, style, i, column, c);
}
@ -3110,6 +3126,7 @@ void LyXParagraph::SimpleTeXBlanks(ostream & os, TexRow & texrow,
void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
bool moving_arg,
LyXFont & font,
LyXFont & running_font,
LyXFont & basefont,
@ -3135,7 +3152,7 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
close = true;
}
int tmp = inset->Latex(os, style.isCommand(),
int tmp = inset->Latex(os, moving_arg,
style.free_spacing);
if (close)
@ -3472,7 +3489,7 @@ LyXParagraph * LyXParagraph::TeXDeeper(ostream & os, TexRow & texrow,
foot, foot_texrow,
foot_count);
} else {
par = par->TeXOnePar(os, texrow,
par = par->TeXOnePar(os, texrow, false,
foot, foot_texrow,
foot_count);
}
@ -3623,7 +3640,7 @@ LyXParagraph * LyXParagraph::TeXEnvironment(ostream & os, TexRow & texrow,
}
LyXParagraph * par = this;
do {
par = par->TeXOnePar(os, texrow,
par = par->TeXOnePar(os, texrow, false,
foot, foot_texrow, foot_count);
if (minipage_open && par && !style.isEnvironment() &&
@ -3807,8 +3824,10 @@ LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
texrow.newline();
}
bool moving_arg = false;
bool need_closing = false;
bool is_rtl = isRightToLeftPar();
if (is_rtl != parent_is_rtl) {
if (is_rtl)
os << "\\R{";
@ -3824,6 +3843,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
if (style.intitle) {
os << "\\thanks{\n";
footer_in_body = false;
moving_arg = true;
} else {
if (foot_count == -1) {
// we're at depth 0 so we can use:
@ -3918,7 +3938,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
foot, foot_texrow,
foot_count);
} else {
par = par->TeXOnePar(os, texrow,
par = par->TeXOnePar(os, texrow, moving_arg,
foot, foot_texrow,
foot_count);
}
@ -3960,6 +3980,7 @@ LyXParagraph * LyXParagraph::TeXFootnote(ostream & os, TexRow & texrow,
dummy_count);
} else {
par = par->TeXOnePar(foot, foot_texrow,
moving_arg,
dummy, dummy_texrow,
dummy_count);
}

View File

@ -101,12 +101,20 @@ static int iso885968x[] = {
};
inline
bool is_arabic(unsigned char c)
{
return 0xa8 <= c && c <= 0xea && iso885968x[c-0xa8];
}
inline
bool is_nikud(unsigned char c)
{
return 192 <= c && c <= 210;
}
unsigned char LyXText::TransformChar(unsigned char c, Letter_Form form) const
{
if (is_arabic(c) &&
@ -179,9 +187,14 @@ int LyXText::SingleWidth(LyXParagraph * par,
// The most common case is handled first (Asger)
if (IsPrintable(c)) {
if (font.language()->lang == "arabic" &&
lyxrc.font_norm == "iso8859-6.8x")
c = TransformChar(c, par, pos);
if (font.language()->RightToLeft) {
if (font.language()->lang == "arabic" &&
lyxrc.font_norm == "iso8859-6.8x")
c = TransformChar(c, par, pos);
else if (font.language()->lang == "hebrew" &&
is_nikud(c))
return 0;
}
return lyxfont::width(c, font);
} else if (IsHfillChar(c)) {
@ -450,10 +463,15 @@ void LyXText::draw(Row const * row,
switch (c) {
case LyXParagraph::META_MARGIN:
fs = "margin";
#ifdef WITH_WARNINGS
#warning I think we do not need that '!' (JMarc)
#endif
#if 0
// Draw a sign at the left margin!
owner_->painter()
.text((LYX_PAPER_MARGIN - lyxfont::width('!', font))/2,
offset + row->baseline, "!", 1, font);
#endif
break;
case LyXParagraph::META_FIG:
fs = "fig";
@ -518,31 +536,70 @@ void LyXText::draw(Row const * row,
// So IMHO we should go with the easier and clearer implementation.
// And even if 1024 is a large number here it might overflow, string
// will only overflow if the machine is out of memory...
bool do_transform =
font2.language()->lang == "arabic" &&
lyxrc.font_norm == "iso8859-6.8x";
if (do_transform)
c = TransformChar(c, row->par, pos);
static string textstring;
textstring = c;
++vpos;
LyXParagraph::size_type last = RowLastPrintable(row);
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
&& font2 == GetFont(row->par, pos)) {
if (do_transform)
c = TransformChar(c, row->par, pos);
textstring += c;
++vpos;
}
float tmpx = x;
// Draw text and set the new x position
pain.text(int(x), offset + row->baseline, textstring, font);
x += lyxfont::width(textstring, font);
if (font.language()->lang == "hebrew") {
if (is_nikud(c)) {
LyXParagraph::size_type vpos2 = vpos;
int width = lyxfont::width(c, font2);
int dx = 0;
while (vpos2 <= last &&
(pos = vis2log(vpos2)) >= 0
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
&& is_nikud(c))
++vpos2;
if (static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
&& !is_nikud(c)) {
int width2 = SingleWidth(row->par, pos, c);
dx = (c == 'ø' || c == 'ã')
? width2-width : (width2-width)/2;
}
// Draw nikud
pain.text(int(x)+dx, offset + row->baseline, textstring, font);
} else {
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
&& !is_nikud(c)
&& font2 == GetFont(row->par, pos)) {
textstring += c;
++vpos;
}
// Draw text and set the new x position
pain.text(int(x), offset + row->baseline, textstring, font);
x += lyxfont::width(textstring, font);
}
} else if (font.language()->lang == "arabic" &&
lyxrc.font_norm == "iso8859-6.8x") {
textstring = TransformChar(c, row->par, pos);
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
&& font2 == GetFont(row->par, pos)) {
c = TransformChar(c, row->par, pos);
textstring += c;
++vpos;
}
// Draw text and set the new x position
pain.text(int(x), offset + row->baseline, textstring, font);
x += lyxfont::width(textstring, font);
} else {
while (vpos <= last &&
(pos = vis2log(vpos)) >= 0
&& static_cast<unsigned char>(c = row->par->GetChar(pos)) > ' '
&& font2 == GetFont(row->par, pos)) {
textstring += c;
++vpos;
}
// Draw text and set the new x position
pain.text(int(x), offset + row->baseline, textstring, font);
x += lyxfont::width(textstring, font);
}
// what about underbars?
if (font.underbar() == LyXFont::ON && font.latex() != LyXFont::ON) {
@ -3581,7 +3638,7 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
float x, tmpx;
int y_top, y_bottom;
float fill_separator, fill_hfill, fill_label_hfill;
LyXParagraph * par, * firstpar;
LyXFont font;
int maxdesc;
if (row_ptr->height <= 0) {
@ -3727,55 +3784,14 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
}
}
if (row_ptr->par->appendix){
pain.line(1, offset,
1, offset + row_ptr->height,
LColor::appendixline);
pain.line(paperwidth - 2, offset,
paperwidth - 2, offset + row_ptr->height,
LColor::appendixline);
}
int depth = row_ptr->par->GetDepth();
if (depth > 0) {
int next_depth = (row_ptr->next)
? next_depth = row_ptr->next->par->GetDepth() : 0;
int prev_depth = (row_ptr->previous)
? row_ptr->previous->par->GetDepth() : 0;
for (int i = 1; i <= depth; ++i)
pain.line(4*i, offset,
4*i, offset + row_ptr->height - 1 - (i-next_depth-1)*3,
LColor::depthbar);
for (int i = prev_depth + 1; i <= depth; ++i)
pain.fillRectangle(4*i, offset,
4, 2,
LColor::depthbar);
for (int i = next_depth + 1; i <= depth; ++i)
pain.fillRectangle(4*i, offset + row_ptr->height - 2 - (i-next_depth-1)*3,
4, 2,
LColor::depthbar);
}
if (row_ptr->par->pextra_type == LyXParagraph::PEXTRA_MINIPAGE) {
/* draw a marker at the left margin! */
LyXFont font = GetFont(row_ptr->par, 0);
int asc = lyxfont::maxAscent(font);
int x = (LYX_PAPER_MARGIN - lyxfont::width('|', font)) / 2;
int y1 = (offset + row_ptr->baseline);
int y2 = (offset + row_ptr->baseline) - asc;
pain.line(x, y1, x, y2, LColor::minipageline);
}
int box_x = 0;
if (row_ptr->par->footnoteflag == LyXParagraph::OPEN_FOOTNOTE) {
LyXFont font(LyXFont::ALL_SANE);
font.setSize(LyXFont::SIZE_FOOTNOTE);
font.setColor(LColor::footnote);
int box_x = LYX_PAPER_MARGIN;
box_x += lyxfont::width(" wide-tab ", font);
if (row_ptr->previous &&
box_x = LYX_PAPER_MARGIN + lyxfont::width(" wide-tab ", font);
if (row_ptr->previous &&
row_ptr->previous->par->footnoteflag != LyXParagraph::OPEN_FOOTNOTE){
string fs;
switch (row_ptr->par->footnotekind) {
@ -3843,6 +3859,35 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
paperwidth - LYX_PAPER_MARGIN,
offset + row_ptr->height,
LColor::footnoteframe);
// Draw appendix lines
LyXParagraph * p = row_ptr->par->PreviousBeforeFootnote()->FirstPhysicalPar();
if (p->appendix){
pain.line(1, offset,
1, offset + row_ptr->height,
LColor::appendixline);
pain.line(paperwidth - 2, offset,
paperwidth - 2, offset + row_ptr->height,
LColor::appendixline);
}
// Draw minipage line
bool minipage = p->pextra_type == LyXParagraph::PEXTRA_MINIPAGE;
if (minipage)
pain.line(LYX_PAPER_MARGIN/5, offset,
LYX_PAPER_MARGIN/5,
offset + row_ptr->height - 1,
LColor::minipageline);
// Draw depth lines
int depth = p->GetDepth();
for (int i = 1; i <= depth; ++i) {
int line_x = (LYX_PAPER_MARGIN/5)*(i+minipage);
pain.line(line_x, offset, line_x,
offset + row_ptr->height - 1,
LColor::depthbar);
}
} else if (row_ptr->previous &&
row_ptr->previous->par->footnoteflag
== LyXParagraph::OPEN_FOOTNOTE) {
@ -3856,12 +3901,67 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
paperwidth - LYX_PAPER_MARGIN,
offset, LColor::footnote);
}
// Draw appendix lines
LyXParagraph * firstpar = row_ptr->par->FirstPhysicalPar();
if (firstpar->appendix){
pain.line(1, offset,
1, offset + row_ptr->height,
LColor::appendixline);
pain.line(paperwidth - 2, offset,
paperwidth - 2, offset + row_ptr->height,
LColor::appendixline);
}
// Draw minipage line
bool minipage = firstpar->pextra_type == LyXParagraph::PEXTRA_MINIPAGE;
if (minipage)
pain.line(LYX_PAPER_MARGIN/5 + box_x, offset,
LYX_PAPER_MARGIN/5 + box_x,
offset + row_ptr->height - 1,
LColor::minipageline);
// Draw depth lines
int depth = firstpar->GetDepth();
if (depth > 0) {
int next_depth = 0;
int prev_depth = 0;
if (row_ptr->next)
if (row_ptr->par->footnoteflag ==
row_ptr->next->par->footnoteflag)
next_depth = row_ptr->next->par->GetDepth();
else if (row_ptr->par->footnoteflag != LyXParagraph::OPEN_FOOTNOTE)
next_depth = depth;
if (row_ptr->previous)
if (row_ptr->par->footnoteflag ==
row_ptr->previous->par->footnoteflag)
prev_depth = row_ptr->previous->par->GetDepth();
else if (row_ptr->par->footnoteflag != LyXParagraph::OPEN_FOOTNOTE)
prev_depth = depth;
for (int i = 1; i <= depth; ++i) {
int line_x = (LYX_PAPER_MARGIN/5)*(i+minipage)+box_x;
pain.line(line_x, offset, line_x,
offset + row_ptr->height - 1 - (i-next_depth-1)*3,
LColor::depthbar);
if (i > prev_depth)
pain.fillRectangle(line_x, offset, LYX_PAPER_MARGIN/5, 2,
LColor::depthbar);
if (i > next_depth)
pain.fillRectangle(line_x,
offset + row_ptr->height - 2 - (i-next_depth-1)*3,
LYX_PAPER_MARGIN/5, 2,
LColor::depthbar);
}
}
LyXLayout const & layout =
textclasslist.Style(buffer->params.textclass,
row_ptr->par->GetLayout());
firstpar = row_ptr->par->FirstPhysicalPar();
y_top = 0;
y_bottom = row_ptr->height;
@ -4052,7 +4152,7 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
}
/* is it a last row? */
par = row_ptr->par->LastPhysicalPar();
LyXParagraph * par = row_ptr->par->LastPhysicalPar();
if (row_ptr->par->ParFromPos(last + 1) == par
&& (!row_ptr->next || row_ptr->next->par != row_ptr->par)) {