mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
get rid of NO_LATEX, split some methods, small cleanup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2417 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
abf2235642
commit
54e7ddb5d9
@ -889,7 +889,7 @@ Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
|
||||
(cursor.par()->getInset(cursor.pos() - 1)->editable())) {
|
||||
Inset * tmpinset = cursor.par()->getInset(cursor.pos()-1);
|
||||
LyXFont font = text->getFont(buffer_, cursor.par(),
|
||||
cursor.pos()-1);
|
||||
cursor.pos() - 1);
|
||||
int const width = tmpinset->width(bv_, font);
|
||||
int const inset_x = font.isVisibleRightToLeft()
|
||||
? cursor.x() : cursor.x() - width;
|
||||
@ -1215,12 +1215,7 @@ void BufferView::Pimpl::setState()
|
||||
return;
|
||||
|
||||
LyXText * text = bv_->getLyXText();
|
||||
if (text->real_current_font.isRightToLeft()
|
||||
#ifndef NO_LATEX
|
||||
&&
|
||||
text->real_current_font.latex() != LyXFont::ON
|
||||
#endif
|
||||
) {
|
||||
if (text->real_current_font.isRightToLeft()) {
|
||||
if (owner_->getIntl()->keymap == Intl::PRIMARY)
|
||||
owner_->getIntl()->KeyMapSec();
|
||||
} else {
|
||||
@ -1602,14 +1597,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
owner_->getDialogs()->setUserFreeFont();
|
||||
break;
|
||||
|
||||
#ifndef NO_LATEX
|
||||
case LFUN_TEX:
|
||||
Tex(bv_);
|
||||
setState();
|
||||
owner_->showState();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case LFUN_FILE_INSERT:
|
||||
{
|
||||
MenuInsertLyXFile(argument);
|
||||
@ -2863,18 +2850,6 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
|
||||
}
|
||||
break;
|
||||
|
||||
case LFUN_GETLATEX:
|
||||
{
|
||||
#ifndef NO_LATEX
|
||||
LyXFont & font = bv_->getLyXText()->current_font;
|
||||
if (font.latex() == LyXFont::ON)
|
||||
owner_->getLyXFunc()->setMessage("L");
|
||||
else
|
||||
#endif
|
||||
owner_->getLyXFunc()->setMessage("0");
|
||||
}
|
||||
break;
|
||||
|
||||
// --- accented characters ---------------------------
|
||||
|
||||
case LFUN_UMLAUT:
|
||||
@ -3366,9 +3341,6 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
|
||||
string(),
|
||||
0);
|
||||
update(bv_->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
#ifndef NO_LATEX
|
||||
bv_->text->current_font.setLatex(LyXFont::OFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
bv_->text->insertInset(bv_, inset);
|
||||
|
@ -272,9 +272,6 @@ XFontStruct * FontLoader::doLoad(LyXFont::FONT_FAMILY family,
|
||||
f.setEmph(LyXFont::INHERIT);
|
||||
f.setUnderbar(LyXFont::INHERIT);
|
||||
f.setNoun(LyXFont::INHERIT);
|
||||
#ifndef NO_LATEX
|
||||
f.setLatex(LyXFont::INHERIT);
|
||||
#endif
|
||||
f.setColor(LColor::inherit);
|
||||
lyxerr << "Font '" << f.stateText(0)
|
||||
<< "' matched by\n" << font << endl;
|
||||
|
@ -357,7 +357,6 @@ void LyXAction::init()
|
||||
{ LFUN_SELFINSERT, "self-insert", "", Noop },
|
||||
{ LFUN_CHARATCURSOR, "server-char-after", "", ReadOnly },
|
||||
{ LFUN_GETFONT, "server-get-font", "", ReadOnly },
|
||||
{ LFUN_GETLATEX, "server-get-latex", "", ReadOnly },
|
||||
{ LFUN_GETLAYOUT, "server-get-layout", "", ReadOnly },
|
||||
{ LFUN_GETNAME, "server-get-name", "", ReadOnly },
|
||||
{ LFUN_GETTIP, "server-get-tip", "", ReadOnly },
|
||||
@ -376,9 +375,6 @@ void LyXAction::init()
|
||||
N_("Tabular Features"), Noop },
|
||||
{ LFUN_INSET_TABULAR, "tabular-insert",
|
||||
N_("Insert a new Tabular Inset"), Noop },
|
||||
#ifndef NO_LATEX
|
||||
{ LFUN_TEX, "tex-mode", N_("Toggle TeX style"), Noop },
|
||||
#endif
|
||||
{ LFUN_INSET_TEXT, "text-insert",
|
||||
N_("Insert a new Text Inset"), Noop },
|
||||
#if 0
|
||||
|
@ -201,11 +201,10 @@ void LyXView::updateLayoutChoice()
|
||||
toolbar->updateLayoutList(true);
|
||||
last_textclass = int(buffer()->params.textclass);
|
||||
current_layout = 0;
|
||||
} else
|
||||
} else {
|
||||
toolbar->updateLayoutList(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
LyXTextClass::size_type layout =
|
||||
bufferview->text->cursor.par()->getLayout();
|
||||
|
||||
|
@ -332,12 +332,11 @@ PainterBase & Painter::text(int x, int y, char const * s, size_t ls,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f.underbar() == LyXFont::ON
|
||||
#ifndef NO_LATEX
|
||||
&& f.latex() != LyXFont::ON
|
||||
#endif
|
||||
)
|
||||
|
||||
if (f.underbar() == LyXFont::ON) {
|
||||
underline(f, x, y, lyxfont::width(s, ls, f));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -375,12 +374,11 @@ PainterBase & Painter::text(int x, int y, XChar2b const * s, int ls,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (f.underbar() == LyXFont::ON
|
||||
#ifndef NO_LATEX
|
||||
&& f.latex() != LyXFont::ON
|
||||
#endif
|
||||
)
|
||||
|
||||
if (f.underbar() == LyXFont::ON) {
|
||||
underline(f, x, y, lyxfont::width(s, ls, f));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -10,15 +10,16 @@
|
||||
#include "ShareContainer.h"
|
||||
#include "LString.h"
|
||||
#include "layout.h"
|
||||
|
||||
// Not yet... lyx 1.3.x or so
|
||||
//#define NO_PEXTRA_REALLY 1
|
||||
|
||||
#include "ParameterStruct.h"
|
||||
|
||||
class VSpace;
|
||||
class Spacing;
|
||||
|
||||
|
||||
// Not yet... lyx 1.3.x or so
|
||||
//#define NO_PEXTRA_REALLY 1
|
||||
|
||||
///
|
||||
class ParagraphParameters {
|
||||
public:
|
||||
|
@ -65,9 +65,6 @@ void ToolbarDefaults::init()
|
||||
add(LFUN_DEPTH);
|
||||
add(SEPARATOR);
|
||||
|
||||
#ifndef NO_LATEX
|
||||
add(LFUN_TEX);
|
||||
#endif
|
||||
add(LFUN_MATH_MODE);
|
||||
add(SEPARATOR);
|
||||
|
||||
|
93
src/buffer.C
93
src/buffer.C
@ -285,6 +285,7 @@ namespace {
|
||||
|
||||
string last_inset_read;
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
struct ErtComp
|
||||
{
|
||||
ErtComp() : active(false), in_tabular(false) {
|
||||
@ -296,11 +297,12 @@ struct ErtComp
|
||||
|
||||
std::stack<ErtComp> ert_stack;
|
||||
ErtComp ert_comp;
|
||||
|
||||
#endif
|
||||
|
||||
} // anon
|
||||
|
||||
|
||||
#warning And _why_ is this here? (Lgb)
|
||||
int unknown_layouts;
|
||||
|
||||
// candidate for move to BufferView
|
||||
@ -314,12 +316,11 @@ int unknown_layouts;
|
||||
bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
|
||||
{
|
||||
unknown_layouts = 0;
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
ert_comp.contents.erase();
|
||||
ert_comp.active = false;
|
||||
ert_comp.in_tabular = false;
|
||||
#endif
|
||||
|
||||
int pos = 0;
|
||||
Paragraph::depth_type depth = 0;
|
||||
bool the_end_read = false;
|
||||
@ -385,6 +386,7 @@ bool Buffer::readLyXformat2(LyXLex & lex, Paragraph * par)
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
void Buffer::insertErtContents(Paragraph * par, int & pos,
|
||||
LyXFont const & font, bool set_inactive)
|
||||
{
|
||||
@ -399,6 +401,7 @@ void Buffer::insertErtContents(Paragraph * par, int & pos,
|
||||
ert_comp.active = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
@ -410,6 +413,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
)
|
||||
{
|
||||
bool the_end_read = false;
|
||||
#ifndef NO_COMPABILITY
|
||||
#ifndef NO_PEXTRA_REALLY
|
||||
// This is super temporary but is needed to get the compability
|
||||
// mode for minipages work correctly together with new tabulars.
|
||||
@ -419,9 +423,9 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
static Paragraph * minipar;
|
||||
static Paragraph * parBeforeMinipage;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
if (token[0] != '\\') {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
if (ert_comp.active) {
|
||||
ert_comp.contents += token;
|
||||
} else {
|
||||
@ -431,7 +435,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
par->insertChar(pos, (*cit), font);
|
||||
++pos;
|
||||
}
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
}
|
||||
#endif
|
||||
} else if (token == "\\i") {
|
||||
@ -440,7 +444,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
par->insertInset(pos, inset, font);
|
||||
++pos;
|
||||
} else if (token == "\\layout") {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
ert_comp.in_tabular = false;
|
||||
// Do the insetert.
|
||||
insertErtContents(par, pos, font);
|
||||
@ -451,7 +455,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
= textclasslist.NumberOfLayout(params.textclass,
|
||||
layoutname);
|
||||
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
if (compare_no_case(layoutname, "latex") == 0) {
|
||||
ert_comp.active = true;
|
||||
}
|
||||
@ -546,6 +550,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
} else if (token == "\\begin_float") {
|
||||
insertErtContents(par, pos, font);
|
||||
//insertErtContents(par, pos, font, false);
|
||||
@ -634,6 +639,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
par->insertInset(pos, inset, font);
|
||||
++pos;
|
||||
insertErtContents(par, pos, font);
|
||||
#endif
|
||||
} else if (token == "\\begin_deeper") {
|
||||
++depth;
|
||||
} else if (token == "\\end_deeper") {
|
||||
@ -932,24 +938,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
} else if (token == "\\size") {
|
||||
lex.next();
|
||||
font.setLyXSize(lex.GetString());
|
||||
#ifndef NO_LATEX
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning compatability hack needed
|
||||
#endif
|
||||
} else if (token == "\\latex") {
|
||||
lex.next();
|
||||
string const tok = lex.GetString();
|
||||
// This is dirty, but gone with LyX3. (Asger)
|
||||
if (tok == "no_latex")
|
||||
font.setLatex(LyXFont::OFF);
|
||||
else if (tok == "latex")
|
||||
font.setLatex(LyXFont::ON);
|
||||
else if (tok == "default")
|
||||
font.setLatex(LyXFont::INHERIT);
|
||||
else
|
||||
lex.printError("Unknown LaTeX font flag "
|
||||
"`$$Token'");
|
||||
#else
|
||||
#ifndef NO_COMPABILITY
|
||||
} else if (token == "\\latex") {
|
||||
lex.next();
|
||||
string const tok = lex.GetString();
|
||||
@ -1015,6 +1004,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
} else if (token == "\\added_space_bottom") {
|
||||
lex.nextToken();
|
||||
par->params().spaceBottom(VSpace(lex.GetString()));
|
||||
#ifndef NO_COMPABILITY
|
||||
#ifndef NO_PEXTRA_REALLY
|
||||
} else if (token == "\\pextra_type") {
|
||||
lex.nextToken();
|
||||
@ -1034,6 +1024,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
} else if (token == "\\pextra_start_minipage") {
|
||||
lex.nextToken();
|
||||
par->params().pextraStartMinipage(lex.GetInteger());
|
||||
#endif
|
||||
#endif
|
||||
} else if (token == "\\labelwidthstring") {
|
||||
lex.EatLine();
|
||||
@ -1048,13 +1039,13 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
// But insets should read it, it is a part of
|
||||
// the inset isn't it? Lgb.
|
||||
} else if (token == "\\begin_inset") {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
insertErtContents(par, pos, font, false);
|
||||
ert_stack.push(ert_comp);
|
||||
ert_comp = ErtComp();
|
||||
#endif
|
||||
readInset(lex, par, pos, font);
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
ert_comp = ert_stack.top();
|
||||
ert_stack.pop();
|
||||
insertErtContents(par, pos, font);
|
||||
@ -1088,8 +1079,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
}
|
||||
++pos;
|
||||
} else if (token == "\\newline") {
|
||||
#ifdef NO_LATEX
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
if (!ert_comp.in_tabular && ert_comp.active) {
|
||||
ert_comp.contents += char(Paragraph::META_NEWLINE);
|
||||
} else {
|
||||
@ -1106,7 +1096,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
++pos;
|
||||
#endif
|
||||
} else if (token == "\\LyXTable") {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
ert_comp.in_tabular = true;
|
||||
#endif
|
||||
Inset * inset = new InsetTabular(*this);
|
||||
@ -1138,28 +1128,30 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
}
|
||||
par->bibkey->read(this, lex);
|
||||
} else if (token == "\\backslash") {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
if (ert_comp.active) {
|
||||
ert_comp.contents += "\\";
|
||||
} else {
|
||||
#endif
|
||||
par->insertChar(pos, '\\', font);
|
||||
++pos;
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
}
|
||||
#endif
|
||||
} else if (token == "\\the_end") {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
// If we still have some ert active here we have to insert
|
||||
// it so we don't loose it. (Lgb)
|
||||
insertErtContents(par, pos, font);
|
||||
#endif
|
||||
the_end_read = true;
|
||||
#ifndef NO_COMPABILITY
|
||||
#ifndef NO_PEXTRA_REALLY
|
||||
minipar = parBeforeMinipage = 0;
|
||||
#endif
|
||||
#endif
|
||||
} else {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
if (ert_comp.active) {
|
||||
ert_comp.contents += token;
|
||||
} else {
|
||||
@ -1173,11 +1165,12 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
par->insertChar(pos, (*cit), font);
|
||||
++pos;
|
||||
}
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NO_COMPABILITY
|
||||
#ifndef NO_PEXTRA_REALLY
|
||||
// I wonder if we could use this blanket fix for all the
|
||||
// checkminipage cases...
|
||||
@ -1330,6 +1323,7 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
|
||||
}
|
||||
// End of pextra_minipage compability
|
||||
--call_depth;
|
||||
#endif
|
||||
#endif
|
||||
return the_end_read;
|
||||
}
|
||||
@ -1805,9 +1799,6 @@ string const Buffer::asciiParagraph(Paragraph const * par,
|
||||
lyxerr << "Should this ever happen?" << endl;
|
||||
}
|
||||
|
||||
#ifndef NO_LATEX
|
||||
LyXFont const font1 = LyXFont(LyXFont::ALL_INHERIT, params.language);
|
||||
#endif
|
||||
for (Paragraph::size_type i = 0; i < par->size(); ++i) {
|
||||
if (!i && !noparbreak) {
|
||||
if (linelen > 0)
|
||||
@ -1846,17 +1837,6 @@ string const Buffer::asciiParagraph(Paragraph const * par,
|
||||
currlinelen += (ltype_depth-depth)*2;
|
||||
}
|
||||
}
|
||||
#ifndef NO_LATEX
|
||||
LyXFont const font2 = par->getFontSettings(params, i);
|
||||
if (font1.latex() != font2.latex()) {
|
||||
if (font2.latex() == LyXFont::OFF)
|
||||
islatex = 0;
|
||||
else
|
||||
islatex = 1;
|
||||
} else {
|
||||
islatex = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
char c = par->getUChar(params, i);
|
||||
if (islatex)
|
||||
@ -2960,11 +2940,7 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
#ifndef NO_LATEX
|
||||
font.latex() == LyXFont::ON ||
|
||||
#endif
|
||||
style.latexparam() == "CDATA") {
|
||||
if (style.latexparam() == "CDATA") {
|
||||
// "TeX"-Mode on == > SGML-Mode on.
|
||||
if (c != '\0')
|
||||
os << c;
|
||||
@ -3377,13 +3353,6 @@ void Buffer::simpleDocBookOnePar(ostream & os, string & extra,
|
||||
else
|
||||
os << tmp_out;
|
||||
}
|
||||
#ifndef NO_LATEX
|
||||
} else if (font.latex() == LyXFont::ON) {
|
||||
// "TeX"-Mode on ==> SGML-Mode on.
|
||||
if (c != '\0')
|
||||
os << c;
|
||||
++char_line_count;
|
||||
#endif
|
||||
} else {
|
||||
string sgml_string;
|
||||
if (par->linuxDocConvertChar(c, sgml_string)
|
||||
|
@ -31,6 +31,11 @@ class TeXErrors;
|
||||
class LaTeXFeatures;
|
||||
class Language;
|
||||
|
||||
// When lyx 1.3.x starts we should enable this
|
||||
// btw. we should also test this with 1.2 so that we
|
||||
// do not get any surprises. (Lgb)
|
||||
//#define NO_COMPABILITY 1
|
||||
|
||||
///
|
||||
struct DEPCLEAN {
|
||||
///
|
||||
@ -127,10 +132,12 @@ public:
|
||||
///
|
||||
void insertStringAsLines(Paragraph *&, Paragraph::size_type &,
|
||||
LyXFont const &, string const &) const;
|
||||
#ifndef NO_COMPABILITY
|
||||
///
|
||||
void insertErtContents(Paragraph * par, int & pos,
|
||||
LyXFont const & font,
|
||||
bool set_inactive = true);
|
||||
#endif
|
||||
///
|
||||
Paragraph * getParFromID(int id) const;
|
||||
private:
|
||||
|
@ -72,16 +72,6 @@ void lang(BufferView * bv, string const & l)
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_LATEX
|
||||
void tex(BufferView * bv)
|
||||
{
|
||||
LyXFont font(LyXFont::ALL_IGNORE);
|
||||
font.setLatex (LyXFont::TOGGLE);
|
||||
toggleAndShow(bv, font);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Change environment depth.
|
||||
// if decInc >= 0, increment depth
|
||||
// if decInc < 0, decrement depth
|
||||
@ -229,9 +219,6 @@ void toggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
bv->update(text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
|
||||
|
||||
if (font.language() != ignore_language ||
|
||||
#ifndef NO_LATEX
|
||||
font.latex() != LyXFont::IGNORE ||
|
||||
#endif
|
||||
font.number() != LyXFont::IGNORE)
|
||||
{
|
||||
LyXCursor & cursor = text->cursor;
|
||||
|
@ -12,9 +12,6 @@
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
// this will not be needed anymore when NO_LATEX is the default.
|
||||
#include "lyxfont.h"
|
||||
|
||||
/** These are all the lyxfunctions (as enums).
|
||||
Please add new functions at the end of the enum, right
|
||||
before LFUN_LASTACTION.
|
||||
@ -53,9 +50,6 @@ enum kb_action {
|
||||
LFUN_HFILL,
|
||||
LFUN_DEPTH,
|
||||
LFUN_FREE, // 30
|
||||
#ifndef NO_LATEX
|
||||
LFUN_TEX,
|
||||
#endif
|
||||
#if 0
|
||||
LFUN_FOOTMELT, // schedule for deletion
|
||||
LFUN_MARGINMELT, // schedule for deletion
|
||||
@ -125,7 +119,6 @@ enum kb_action {
|
||||
LFUN_LINEATCURSOR,
|
||||
LFUN_GETLAYOUT,
|
||||
LFUN_GETFONT,
|
||||
LFUN_GETLATEX,
|
||||
LFUN_GETNAME, // 100
|
||||
LFUN_NOTIFY,
|
||||
LFUN_GOTOFILEROW, // Edmar 12/23/98
|
||||
|
@ -143,10 +143,6 @@ character::FONT_STATE ControlCharacter::getBar() const
|
||||
|
||||
else if (font_->noun() != LyXFont::IGNORE)
|
||||
return character::NOUN_TOGGLE;
|
||||
#ifndef NO_LATEX
|
||||
else if (font_->latex() != LyXFont::IGNORE)
|
||||
return character::LATEX_TOGGLE;
|
||||
#endif
|
||||
}
|
||||
return character::IGNORE;
|
||||
}
|
||||
@ -159,9 +155,6 @@ void ControlCharacter::setBar(character::FONT_STATE val)
|
||||
font_->setEmph(LyXFont::IGNORE);
|
||||
font_->setUnderbar(LyXFont::IGNORE);
|
||||
font_->setNoun(LyXFont::IGNORE);
|
||||
#ifndef NO_LATEX
|
||||
font_->setLatex(LyXFont::IGNORE);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case character::EMPH_TOGGLE:
|
||||
@ -176,19 +169,10 @@ void ControlCharacter::setBar(character::FONT_STATE val)
|
||||
font_->setNoun(LyXFont::TOGGLE);
|
||||
break;
|
||||
|
||||
#ifndef NO_LATEX
|
||||
case character::LATEX_TOGGLE:
|
||||
font_->setLatex(LyXFont::TOGGLE);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case character::INHERIT:
|
||||
font_->setEmph(LyXFont::INHERIT);
|
||||
font_->setUnderbar(LyXFont::INHERIT);
|
||||
font_->setNoun(LyXFont::INHERIT);
|
||||
#ifndef NO_LATEX
|
||||
font_->setLatex(LyXFont::INHERIT);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-08-03 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* inset.C (convertFont): delete method. not used.
|
||||
|
||||
2001-08-03 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.C (setFont): don't call for a draw update if we're just
|
||||
|
@ -86,10 +86,16 @@ void Inset::edit(BufferView *, bool)
|
||||
{}
|
||||
|
||||
|
||||
#if 0
|
||||
LyXFont const Inset::convertFont(LyXFont const & font) const
|
||||
{
|
||||
#if 1
|
||||
return font;
|
||||
#else
|
||||
return LyXFont(font);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
string const Inset::editMessage() const
|
||||
|
@ -148,8 +148,10 @@ public:
|
||||
/// update the inset representation
|
||||
virtual void update(BufferView *, LyXFont const &, bool = false)
|
||||
{}
|
||||
#if 0
|
||||
///
|
||||
virtual LyXFont const convertFont(LyXFont const & font) const;
|
||||
#endif
|
||||
/// what appears in the minibuffer when opening
|
||||
virtual string const editMessage() const;
|
||||
///
|
||||
|
@ -39,11 +39,7 @@ InsetInfo::InsetInfo()
|
||||
: form(0), labelfont(LyXFont::ALL_SANE)
|
||||
{
|
||||
labelfont.decSize().decSize()
|
||||
.setColor(LColor::note)
|
||||
#ifndef NO_LATEX
|
||||
.setLatex(LyXFont::OFF)
|
||||
#endif
|
||||
;
|
||||
.setColor(LColor::note);
|
||||
}
|
||||
|
||||
|
||||
@ -51,11 +47,7 @@ InsetInfo::InsetInfo(string const & str)
|
||||
: contents(str), form(0), labelfont(LyXFont::ALL_SANE)
|
||||
{
|
||||
labelfont.decSize().decSize()
|
||||
.setColor(LColor::note)
|
||||
#ifndef NO_LATEX
|
||||
.setLatex(LyXFont::OFF)
|
||||
#endif
|
||||
;
|
||||
.setColor(LColor::note);
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,15 +207,17 @@ int InsetQuotes::width(BufferView *, LyXFont const & font) const
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
|
||||
{
|
||||
#if 1
|
||||
return f;
|
||||
#else
|
||||
LyXFont font(f);
|
||||
#ifndef NO_LATEX
|
||||
// quotes-insets cannot be latex of any kind
|
||||
font.setLatex(LyXFont::OFF);
|
||||
#endif
|
||||
return font;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
|
||||
|
@ -80,8 +80,10 @@ public:
|
||||
int width(BufferView *, LyXFont const &) const;
|
||||
///
|
||||
void draw(BufferView *, LyXFont const &, int, float &, bool) const;
|
||||
#if 0
|
||||
///
|
||||
LyXFont const convertFont(LyXFont const & font) const;
|
||||
#endif
|
||||
///
|
||||
void write(Buffer const *, std::ostream &) const;
|
||||
///
|
||||
|
@ -240,7 +240,7 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
|
||||
if (token.empty())
|
||||
continue;
|
||||
if (token == "\\end_inset") {
|
||||
#ifdef NO_LATEX
|
||||
#ifndef NO_COMPABILITY
|
||||
const_cast<Buffer*>(buf)->insertErtContents(par, pos, font, false);
|
||||
#endif
|
||||
break;
|
||||
|
@ -43,10 +43,6 @@
|
||||
#include "converter.h"
|
||||
#include "language.h"
|
||||
#include "support/os.h"
|
||||
// for NO_LATEX
|
||||
#if 1
|
||||
#include "lyxfont.h"
|
||||
#endif
|
||||
|
||||
using std::endl;
|
||||
|
||||
|
@ -107,9 +107,6 @@ LyXFont::FontBits LyXFont::sane = {
|
||||
SIZE_NORMAL,
|
||||
LColor::none,
|
||||
OFF,
|
||||
#ifndef NO_LATEX
|
||||
OFF,
|
||||
#endif
|
||||
OFF,
|
||||
OFF,
|
||||
OFF };
|
||||
@ -122,9 +119,6 @@ LyXFont::FontBits LyXFont::inherit = {
|
||||
INHERIT_SIZE,
|
||||
LColor::inherit,
|
||||
INHERIT,
|
||||
#ifndef NO_LATEX
|
||||
INHERIT,
|
||||
#endif
|
||||
INHERIT,
|
||||
INHERIT,
|
||||
OFF };
|
||||
@ -137,9 +131,6 @@ LyXFont::FontBits LyXFont::ignore = {
|
||||
IGNORE_SIZE,
|
||||
LColor::ignore,
|
||||
IGNORE,
|
||||
#ifndef NO_LATEX
|
||||
IGNORE,
|
||||
#endif
|
||||
IGNORE,
|
||||
IGNORE,
|
||||
IGNORE };
|
||||
@ -155,9 +146,6 @@ bool LyXFont::FontBits::operator==(LyXFont::FontBits const & fb1) const
|
||||
fb1.emph == emph &&
|
||||
fb1.underbar == underbar &&
|
||||
fb1.noun == noun &&
|
||||
#ifndef NO_LATEX
|
||||
fb1.latex == latex &&
|
||||
#endif
|
||||
fb1.number == number;
|
||||
}
|
||||
|
||||
@ -204,14 +192,6 @@ LyXFont::FONT_MISC_STATE LyXFont::underbar() const
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_LATEX
|
||||
LyXFont::FONT_MISC_STATE LyXFont::latex() const
|
||||
{
|
||||
return bits.latex;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
LColor::color LyXFont::color() const
|
||||
{
|
||||
return bits.color;
|
||||
@ -239,9 +219,6 @@ bool LyXFont::isRightToLeft() const
|
||||
bool LyXFont::isVisibleRightToLeft() const
|
||||
{
|
||||
return (lang->RightToLeft() &&
|
||||
#ifndef NO_LATEX
|
||||
latex() != ON &&
|
||||
#endif
|
||||
number() != ON);
|
||||
}
|
||||
|
||||
@ -295,15 +272,6 @@ LyXFont & LyXFont::setNoun(LyXFont::FONT_MISC_STATE n)
|
||||
}
|
||||
|
||||
|
||||
#ifndef NO_LATEX
|
||||
LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l)
|
||||
{
|
||||
bits.latex = l;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
LyXFont & LyXFont::setColor(LColor::color c)
|
||||
{
|
||||
bits.color = c;
|
||||
@ -452,9 +420,6 @@ void LyXFont::update(LyXFont const & newfont, bool toggleall)
|
||||
setEmph(setMisc(newfont.emph(), emph()));
|
||||
setUnderbar(setMisc(newfont.underbar(), underbar()));
|
||||
setNoun(setMisc(newfont.noun(), noun()));
|
||||
#ifndef NO_LATEX
|
||||
setLatex(setMisc(newfont.latex(), latex()));
|
||||
#endif
|
||||
|
||||
setNumber(setMisc(newfont.number(), number()));
|
||||
if (newfont.language() == language() && toggleall)
|
||||
@ -486,10 +451,6 @@ void LyXFont::reduce(LyXFont const & tmplt)
|
||||
setUnderbar(INHERIT);
|
||||
if (noun() == tmplt.noun())
|
||||
setNoun(INHERIT);
|
||||
#ifndef NO_LATEX
|
||||
if (latex() == tmplt.latex())
|
||||
setLatex(INHERIT);
|
||||
#endif
|
||||
if (color() == tmplt.color())
|
||||
setColor(LColor::inherit);
|
||||
if (language() == tmplt.language())
|
||||
@ -536,11 +497,6 @@ LyXFont & LyXFont::realize(LyXFont const & tmplt, Language const * deflang)
|
||||
if (bits.noun == INHERIT) {
|
||||
bits.noun = tmplt.bits.noun;
|
||||
}
|
||||
#ifndef NO_LATEX
|
||||
if (bits.latex == INHERIT) {
|
||||
bits.latex = tmplt.bits.latex;
|
||||
}
|
||||
#endif
|
||||
if (bits.color == LColor::inherit) {
|
||||
bits.color = tmplt.bits.color;
|
||||
}
|
||||
@ -555,9 +511,6 @@ bool LyXFont::resolved() const
|
||||
shape() != INHERIT_SHAPE && size() != INHERIT_SIZE &&
|
||||
emph() != INHERIT && underbar() != INHERIT &&
|
||||
noun() != INHERIT &&
|
||||
#ifndef NO_LATEX
|
||||
latex() != INHERIT &&
|
||||
#endif
|
||||
color() != LColor::inherit &&
|
||||
language() != inherit_language);
|
||||
}
|
||||
@ -585,10 +538,6 @@ string const LyXFont::stateText(BufferParams * params) const
|
||||
<< _(GUIMiscNames[underbar()]) << ", ";
|
||||
if (noun() != INHERIT)
|
||||
ost << _("Noun ") << _(GUIMiscNames[noun()]) << ", ";
|
||||
#ifndef NO_LATEX
|
||||
if (latex() != INHERIT)
|
||||
ost << _("Latex ") << _(GUIMiscNames[latex()]) << ", ";
|
||||
#endif
|
||||
if (bits == inherit)
|
||||
ost << _("Default") << ", ";
|
||||
if (!params || (language() != params->language))
|
||||
@ -725,19 +674,6 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
|
||||
lex.next();
|
||||
string const ttok = lex.GetString();
|
||||
setLyXSize(ttok);
|
||||
#ifndef NO_LATEX
|
||||
} else if (tok == "latex") {
|
||||
lex.next();
|
||||
string const ttok = lowercase(lex.GetString());
|
||||
|
||||
if (ttok == "no_latex") {
|
||||
setLatex(OFF);
|
||||
} else if (ttok == "latex") {
|
||||
setLatex(ON);
|
||||
} else {
|
||||
lex.printError("Illegal LaTeX type`$$Token'");
|
||||
}
|
||||
#endif
|
||||
} else if (tok == "misc") {
|
||||
lex.next();
|
||||
string const ttok = lowercase(lex.GetString());
|
||||
@ -812,24 +748,6 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont,
|
||||
if (orgfont.noun() != noun()) {
|
||||
os << "\\noun " << LyXMiscNames[noun()] << " \n";
|
||||
}
|
||||
#ifndef NO_LATEX
|
||||
if (orgfont.latex() != latex()) {
|
||||
// This is only for backwards compatibility
|
||||
switch (latex()) {
|
||||
case OFF: os << "\\latex no_latex \n"; break;
|
||||
case ON: os << "\\latex latex \n"; break;
|
||||
case TOGGLE: lyxerr << "LyXFont::lyxWriteFontChanges: "
|
||||
"TOGGLE should not appear here!"
|
||||
<< endl;
|
||||
break;
|
||||
case INHERIT: os << "\\latex default \n"; break;
|
||||
case IGNORE: lyxerr << "LyXFont::lyxWriteFontChanges: "
|
||||
"IGNORE should not appear here!"
|
||||
<< endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (orgfont.color() != color()) {
|
||||
// To make us file compatible with older
|
||||
// lyx versions we emit "default" instead
|
||||
@ -1020,10 +938,6 @@ int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
|
||||
|
||||
LColor::color LyXFont::realColor() const
|
||||
{
|
||||
#ifndef NO_LATEX
|
||||
if (latex() == ON)
|
||||
return LColor::latex;
|
||||
#endif
|
||||
if (color() == LColor::none)
|
||||
return LColor::foreground;
|
||||
return color();
|
||||
@ -1047,16 +961,6 @@ LyXFont::FONT_SHAPE LyXFont::realShape() const
|
||||
}
|
||||
|
||||
|
||||
bool LyXFont::equalExceptLatex(LyXFont const & f) const
|
||||
{
|
||||
LyXFont f1 = *this;
|
||||
#ifndef NO_LATEX
|
||||
f1.setLatex(f.latex());
|
||||
#endif
|
||||
return f1 == f;
|
||||
}
|
||||
|
||||
|
||||
ostream & operator<<(ostream & o, LyXFont::FONT_MISC_STATE fms)
|
||||
{
|
||||
return o << int(fms);
|
||||
|
@ -26,8 +26,6 @@ class LyXLex;
|
||||
class BufferParams;
|
||||
|
||||
|
||||
#define NO_LATEX 1
|
||||
|
||||
///
|
||||
class LyXFont {
|
||||
public:
|
||||
@ -188,10 +186,6 @@ public:
|
||||
///
|
||||
FONT_MISC_STATE noun() const;
|
||||
|
||||
#ifndef NO_LATEX
|
||||
///
|
||||
FONT_MISC_STATE latex() const;
|
||||
#endif
|
||||
///
|
||||
FONT_MISC_STATE number() const;
|
||||
|
||||
@ -221,10 +215,6 @@ public:
|
||||
LyXFont & setUnderbar(LyXFont::FONT_MISC_STATE u);
|
||||
///
|
||||
LyXFont & setNoun(LyXFont::FONT_MISC_STATE n);
|
||||
#ifndef NO_LATEX
|
||||
///
|
||||
LyXFont & setLatex(LyXFont::FONT_MISC_STATE l);
|
||||
#endif
|
||||
///
|
||||
LyXFont & setNumber(LyXFont::FONT_MISC_STATE n);
|
||||
///
|
||||
@ -306,9 +296,6 @@ public:
|
||||
friend
|
||||
bool operator==(LyXFont const & font1, LyXFont const & font2);
|
||||
|
||||
/// compares two fonts, ignoring the setting of the Latex part.
|
||||
bool equalExceptLatex(LyXFont const &) const;
|
||||
|
||||
/// Converts logical attributes to concrete shape attribute
|
||||
LyXFont::FONT_SHAPE realShape() const;
|
||||
private:
|
||||
@ -334,10 +321,6 @@ private:
|
||||
FONT_MISC_STATE underbar;
|
||||
///
|
||||
FONT_MISC_STATE noun;
|
||||
#ifndef NO_LATEX
|
||||
///
|
||||
FONT_MISC_STATE latex;
|
||||
#endif
|
||||
///
|
||||
FONT_MISC_STATE number;
|
||||
};
|
||||
|
@ -725,12 +725,6 @@ func_status::value_type LyXFunc::getStatus(int ac,
|
||||
if (font.series() == LyXFont::BOLD_SERIES)
|
||||
box = func_status::ToggleOn;
|
||||
break;
|
||||
#ifndef NO_LATEX
|
||||
case LFUN_TEX:
|
||||
if (font.latex() == LyXFont::ON)
|
||||
box = func_status::ToggleOn;
|
||||
break;
|
||||
#endif
|
||||
case LFUN_READ_ONLY_TOGGLE:
|
||||
if (buf->isReadonly())
|
||||
box = func_status::ToggleOn;
|
||||
@ -1158,14 +1152,6 @@ string const LyXFunc::dispatch(int ac,
|
||||
owner->getDialogs()->setUserFreeFont();
|
||||
break;
|
||||
|
||||
#ifndef NO_LATEX
|
||||
case LFUN_TEX:
|
||||
Tex(owner->view());
|
||||
owner->view()->setState();
|
||||
owner->showState();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case LFUN_RECONFIGURE:
|
||||
Reconfigure(owner->view());
|
||||
break;
|
||||
|
@ -96,6 +96,10 @@ public:
|
||||
LyXFont const getFont(Buffer const *, Paragraph * par,
|
||||
Paragraph::size_type pos) const;
|
||||
///
|
||||
LyXFont const getLayoutFont(Buffer const *, Paragraph * par) const;
|
||||
///
|
||||
LyXFont const getLabelFont(Buffer const *, Paragraph * par) const;
|
||||
///
|
||||
void setCharFont(Buffer const *, Paragraph * par,
|
||||
Paragraph::size_type pos, LyXFont const & font);
|
||||
void setCharFont(BufferView *, Paragraph * par,
|
||||
|
@ -559,15 +559,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
|
||||
//bv->owner()->message(_("math text mode toggled"));
|
||||
break;
|
||||
|
||||
#ifndef NO_LATEX
|
||||
case LFUN_TEX:
|
||||
if (!mathcursor->selection()) {
|
||||
mathcursor->handleFont(LM_TC_TEX);
|
||||
//bv->owner()->message(_("TeX mode toggled"));
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
case LFUN_MATH_LIMITS:
|
||||
bv->lockedInsetStoreUndo(Undo::INSERT);
|
||||
if (mathcursor->toggleLimits())
|
||||
@ -901,15 +892,22 @@ Inset::Code InsetFormulaBase::lyxCode() const
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
LyXFont const InsetFormulaBase::convertFont(LyXFont const & f) const
|
||||
{
|
||||
#warning Andre, you should be able to remove this now?
|
||||
// or change it to
|
||||
#if 1
|
||||
return f;
|
||||
#else
|
||||
// (Lgb)
|
||||
|
||||
// We have already discussed what was here
|
||||
LyXFont font(f);
|
||||
#ifndef NO_LATEX
|
||||
font.setLatex(LyXFont::OFF);
|
||||
#endif
|
||||
return font;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
|
||||
|
@ -82,8 +82,10 @@ public:
|
||||
virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
|
||||
///
|
||||
virtual Inset::Code lyxCode() const;
|
||||
#if 0
|
||||
///
|
||||
virtual LyXFont const convertFont(LyXFont const & f) const;
|
||||
#endif
|
||||
/// what appears in the minibuffer when opening
|
||||
virtual string const editMessage() const;
|
||||
///
|
||||
|
137
src/paragraph.C
137
src/paragraph.C
@ -611,9 +611,10 @@ LyXFont const Paragraph::getFirstFontSettings() const
|
||||
// If position is -1, we get the layout font of the paragraph.
|
||||
// If position is -2, we get the font of the manual label of the paragraph.
|
||||
LyXFont const Paragraph::getFont(BufferParams const & bparams,
|
||||
Paragraph::size_type pos) const
|
||||
Paragraph::size_type pos) const
|
||||
{
|
||||
LyXFont tmpfont;
|
||||
lyx::Assert(pos >= 0);
|
||||
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(bparams.textclass,
|
||||
getLayout());
|
||||
@ -621,40 +622,41 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
|
||||
if (layout.labeltype == LABEL_MANUAL)
|
||||
main_body = beginningOfMainBody();
|
||||
|
||||
if (pos >= 0) {
|
||||
LyXFont layoutfont;
|
||||
if (pos < main_body)
|
||||
layoutfont = layout.labelfont;
|
||||
else
|
||||
layoutfont = layout.font;
|
||||
tmpfont = getFontSettings(bparams, pos);
|
||||
tmpfont.realize(layoutfont, bparams.language);
|
||||
} else {
|
||||
// process layoutfont for pos == -1 and labelfont for pos < -1
|
||||
if (pos == -1)
|
||||
tmpfont = layout.font;
|
||||
else
|
||||
tmpfont = layout.labelfont;
|
||||
tmpfont.setLanguage(getParLanguage(bparams));
|
||||
}
|
||||
LyXFont layoutfont;
|
||||
if (pos < main_body)
|
||||
layoutfont = layout.labelfont;
|
||||
else
|
||||
layoutfont = layout.font;
|
||||
|
||||
LyXFont tmpfont = getFontSettings(bparams, pos);
|
||||
tmpfont.realize(layoutfont, bparams.language);
|
||||
|
||||
// check for environment font information
|
||||
char par_depth = getDepth();
|
||||
Paragraph const * par = this;
|
||||
while (par && par->getDepth() && !tmpfont.resolved()) {
|
||||
par = par->outerHook();
|
||||
if (par) {
|
||||
tmpfont.realize(textclasslist.
|
||||
Style(bparams.textclass,
|
||||
par->getLayout()).font, bparams.language);
|
||||
par_depth = par->getDepth();
|
||||
}
|
||||
}
|
||||
return pimpl_->realizeFont(tmpfont, bparams);
|
||||
}
|
||||
|
||||
tmpfont.realize(textclasslist
|
||||
.TextClass(bparams.textclass)
|
||||
.defaultfont(), bparams.language);
|
||||
return tmpfont;
|
||||
|
||||
LyXFont const Paragraph::getLabelFont(BufferParams const & bparams) const
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(bparams.textclass, getLayout());
|
||||
|
||||
LyXFont tmpfont = layout.labelfont;
|
||||
tmpfont.setLanguage(getParLanguage(bparams));
|
||||
|
||||
return pimpl_->realizeFont(tmpfont, bparams);
|
||||
}
|
||||
|
||||
|
||||
LyXFont const Paragraph::getLayoutFont(BufferParams const & bparams) const
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(bparams.textclass,
|
||||
getLayout());
|
||||
|
||||
LyXFont tmpfont = layout.font;
|
||||
tmpfont.setLanguage(getParLanguage(bparams));
|
||||
|
||||
return pimpl_->realizeFont(tmpfont, bparams);
|
||||
}
|
||||
|
||||
|
||||
@ -662,7 +664,7 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
|
||||
LyXFont::FONT_SIZE
|
||||
Paragraph::highestFontInRange(Paragraph::size_type startpos,
|
||||
Paragraph::size_type endpos,
|
||||
LyXFont::FONT_SIZE const def_size) const
|
||||
LyXFont::FONT_SIZE const def_size) const
|
||||
{
|
||||
if (pimpl_->fontlist.empty())
|
||||
return def_size;
|
||||
@ -677,12 +679,12 @@ Paragraph::highestFontInRange(Paragraph::size_type startpos,
|
||||
++end_it;
|
||||
|
||||
Pimpl::FontTable start_search(startpos, LyXFont());
|
||||
for (Pimpl::FontList::const_iterator cit =
|
||||
lower_bound(pimpl_->fontlist.begin(),
|
||||
pimpl_->fontlist.end(),
|
||||
start_search, Pimpl::matchFT());
|
||||
cit != end_it; ++cit)
|
||||
{
|
||||
Pimpl::FontList::const_iterator cit =
|
||||
lower_bound(pimpl_->fontlist.begin(),
|
||||
pimpl_->fontlist.end(),
|
||||
start_search, Pimpl::matchFT());
|
||||
|
||||
for (; cit != end_it; ++cit) {
|
||||
LyXFont::FONT_SIZE size = cit->font().size();
|
||||
if (size == LyXFont::INHERIT_SIZE)
|
||||
size = def_size;
|
||||
@ -1274,8 +1276,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
}
|
||||
|
||||
if (bparams.inputenc == "auto" &&
|
||||
language->encoding() != previous_language->encoding())
|
||||
{
|
||||
language->encoding() != previous_language->encoding()) {
|
||||
os << "\\inputencoding{"
|
||||
<< language->encoding()->LatexName()
|
||||
<< "}" << endl;
|
||||
@ -1312,7 +1313,10 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
// Is this really needed ? (Dekel)
|
||||
// We do not need to use to change the font for the last paragraph
|
||||
// or for a command.
|
||||
LyXFont font = getFont(bparams, size() - 1);
|
||||
LyXFont const font =
|
||||
(size() == 0
|
||||
? getLayoutFont(bparams)
|
||||
: getFont(bparams, size() - 1));
|
||||
|
||||
bool is_command = textclasslist.Style(bparams.textclass,
|
||||
getLayout()).isCommand();
|
||||
@ -1362,8 +1366,7 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
|
||||
further_blank_line = false;
|
||||
if (params().lineBottom()) {
|
||||
os << "\\lyxline{\\" << getFont(bparams,
|
||||
size() - 1).latexSize() << '}';
|
||||
os << "\\lyxline{\\" << font.latexSize() << '}';
|
||||
further_blank_line = true;
|
||||
}
|
||||
|
||||
@ -1426,9 +1429,9 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
if (main_body > 0) {
|
||||
os << '[';
|
||||
++column;
|
||||
basefont = getFont(bparams, -2); // Get label font
|
||||
basefont = getLabelFont(bparams);
|
||||
} else {
|
||||
basefont = getFont(bparams, -1); // Get layout font
|
||||
basefont = getLayoutFont(bparams);
|
||||
}
|
||||
|
||||
if (main_body >= 0
|
||||
@ -1457,7 +1460,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
column += running_font.latexWriteEndChanges(os, basefont, basefont);
|
||||
open_font = false;
|
||||
}
|
||||
basefont = getFont(bparams, -1); // Now use the layout font
|
||||
basefont = getLayoutFont(bparams);
|
||||
running_font = basefont;
|
||||
os << ']';
|
||||
++column;
|
||||
@ -1480,24 +1483,24 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
case LYX_ALIGN_LEFT:
|
||||
if (getParLanguage(bparams)->babel() != "hebrew") {
|
||||
os << "\\begin{flushleft}";
|
||||
column+= 17;
|
||||
column += 17;
|
||||
} else {
|
||||
os << "\\begin{flushright}";
|
||||
column+= 18;
|
||||
column += 18;
|
||||
}
|
||||
break;
|
||||
case LYX_ALIGN_RIGHT:
|
||||
if (getParLanguage(bparams)->babel() != "hebrew") {
|
||||
os << "\\begin{flushright}";
|
||||
column+= 18;
|
||||
column += 18;
|
||||
} else {
|
||||
os << "\\begin{flushleft}";
|
||||
column+= 17;
|
||||
column += 17;
|
||||
}
|
||||
break;
|
||||
case LYX_ALIGN_CENTER:
|
||||
os << "\\begin{center}";
|
||||
column+= 14;
|
||||
column += 14;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1507,18 +1510,21 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
// Fully instantiated font
|
||||
LyXFont font = getFont(bparams, i);
|
||||
|
||||
LyXFont last_font = running_font;
|
||||
LyXFont const last_font = running_font;
|
||||
|
||||
// Spaces at end of font change are simulated to be
|
||||
// outside font change, i.e. we write "\textXX{text} "
|
||||
// rather than "\textXX{text }". (Asger)
|
||||
if (open_font && c == ' ' && i <= size() - 2
|
||||
&& !getFont(bparams, i + 1).equalExceptLatex(running_font)
|
||||
&& !getFont(bparams, i + 1).equalExceptLatex(font)) {
|
||||
font = getFont(bparams, i + 1);
|
||||
if (open_font && c == ' ' && i <= size() - 2) {
|
||||
LyXFont const next_font = getFont(bparams, i + 1);
|
||||
if (next_font != running_font
|
||||
&& next_font != font) {
|
||||
font = next_font;
|
||||
}
|
||||
}
|
||||
|
||||
// We end font definition before blanks
|
||||
if (!font.equalExceptLatex(running_font) && open_font) {
|
||||
if (font != running_font && open_font) {
|
||||
column += running_font.latexWriteEndChanges(os,
|
||||
basefont,
|
||||
(i == main_body-1) ? basefont : font);
|
||||
@ -1536,8 +1542,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
}
|
||||
|
||||
// Do we need to change font?
|
||||
if (!font.equalExceptLatex(running_font)
|
||||
&& i != main_body-1) {
|
||||
if (font != running_font && i != main_body - 1) {
|
||||
column += font.latexWriteStartChanges(os, basefont,
|
||||
last_font);
|
||||
running_font = font;
|
||||
@ -1547,18 +1552,14 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
if (c == Paragraph::META_NEWLINE) {
|
||||
// newlines are handled differently here than
|
||||
// the default in SimpleTeXSpecialChars().
|
||||
if (!style.newline_allowed
|
||||
#ifndef NO_LATEX
|
||||
|| font.latex() == LyXFont::ON
|
||||
#endif
|
||||
) {
|
||||
if (!style.newline_allowed) {
|
||||
os << '\n';
|
||||
} else {
|
||||
if (open_font) {
|
||||
column += running_font.latexWriteEndChanges(os, basefont, basefont);
|
||||
open_font = false;
|
||||
}
|
||||
basefont = getFont(bparams, -1);
|
||||
basefont = getLayoutFont(bparams);
|
||||
running_font = basefont;
|
||||
if (font.family() ==
|
||||
LyXFont::TYPEWRITER_FAMILY) {
|
||||
|
@ -252,6 +252,8 @@ public:
|
||||
LyXFont::TOGGLE.
|
||||
*/
|
||||
LyXFont const getFont(BufferParams const &, size_type pos) const;
|
||||
LyXFont const getLayoutFont(BufferParams const &) const;
|
||||
LyXFont const getLabelFont(BufferParams const &) const;
|
||||
///
|
||||
value_type getChar(size_type pos) const;
|
||||
///
|
||||
|
@ -214,12 +214,6 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
|
||||
&& i
|
||||
&& getChar(i - 1) != ' '
|
||||
&& (i < size() - 1)
|
||||
#ifndef NO_LATEX
|
||||
// In LaTeX mode, we don't want to
|
||||
// break lines since some commands
|
||||
// do not like this
|
||||
&& ! (font.latex() == LyXFont::ON)
|
||||
#endif
|
||||
// same in FreeSpacing mode
|
||||
&& !style.free_spacing
|
||||
// In typewriter mode, we want to avoid
|
||||
@ -239,18 +233,11 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
|
||||
texrow.newline();
|
||||
texrow.start(owner_, i + 1);
|
||||
column = 0;
|
||||
} else
|
||||
#ifndef NO_LATEX
|
||||
if (font.latex() == LyXFont::OFF) {
|
||||
#endif
|
||||
if (style.free_spacing) {
|
||||
os << '~';
|
||||
} else {
|
||||
os << ' ';
|
||||
}
|
||||
#ifndef NO_LATEX
|
||||
} else if (style.free_spacing) {
|
||||
os << '~';
|
||||
} else {
|
||||
os << ' ';
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -315,7 +302,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
|
||||
basefont);
|
||||
open_font = false;
|
||||
}
|
||||
basefont = owner_->getFont(bparams, -1);
|
||||
basefont = owner_->getLayoutFont(bparams);
|
||||
running_font = basefont;
|
||||
break;
|
||||
|
||||
@ -326,202 +313,179 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
|
||||
|
||||
default:
|
||||
// And now for the special cases within each mode
|
||||
#ifndef NO_LATEX
|
||||
// Are we in LaTeX mode?
|
||||
if (font.latex() == LyXFont::ON) {
|
||||
// at present we only have one option
|
||||
// but I'll leave it as a switch statement
|
||||
// so its simpler to extend. (ARRae)
|
||||
switch (c) {
|
||||
default:
|
||||
// make sure that we will not print
|
||||
// error generating chars to the tex
|
||||
// file. This test would not be needed
|
||||
// if it were done in the buffer
|
||||
// itself.
|
||||
if (c != '\0') {
|
||||
os << c;
|
||||
|
||||
switch (c) {
|
||||
case '\\':
|
||||
os << "\\textbackslash{}";
|
||||
column += 15;
|
||||
break;
|
||||
|
||||
case '°': case '±': case '²': case '³':
|
||||
case '×': case '÷': case '¹': case 'ª':
|
||||
case 'º': case '¬': case 'µ':
|
||||
if (bparams.inputenc == "latin1" ||
|
||||
(bparams.inputenc == "auto" &&
|
||||
font.language()->encoding()->LatexName()
|
||||
== "latin1")) {
|
||||
os << "\\ensuremath{"
|
||||
<< c
|
||||
<< '}';
|
||||
column += 13;
|
||||
} else {
|
||||
os << c;
|
||||
}
|
||||
break;
|
||||
|
||||
case '|': case '<': case '>':
|
||||
// In T1 encoding, these characters exist
|
||||
if (lyxrc.fontenc == "T1") {
|
||||
os << c;
|
||||
//... but we should avoid ligatures
|
||||
if ((c == '>' || c == '<')
|
||||
&& i <= size() - 2
|
||||
&& getChar(i + 1) == c) {
|
||||
//os << "\\textcompwordmark{}";
|
||||
// Jean-Marc, have a look at
|
||||
// this. I think this works
|
||||
// equally well:
|
||||
os << "\\,{}";
|
||||
// Lgb
|
||||
column += 19;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
// Plain mode (i.e. not LaTeX)
|
||||
// Typewriter font also has them
|
||||
if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
||||
os << c;
|
||||
break;
|
||||
}
|
||||
// Otherwise, we use what LaTeX
|
||||
// provides us.
|
||||
switch (c) {
|
||||
case '\\':
|
||||
os << "\\textbackslash{}";
|
||||
column += 15;
|
||||
case '<':
|
||||
os << "\\textless{}";
|
||||
column += 10;
|
||||
break;
|
||||
|
||||
case '°': case '±': case '²': case '³':
|
||||
case '×': case '÷': case '¹': case 'ª':
|
||||
case 'º': case '¬': case 'µ':
|
||||
if (bparams.inputenc == "latin1" ||
|
||||
(bparams.inputenc == "auto" &&
|
||||
font.language()->encoding()->LatexName()
|
||||
== "latin1")) {
|
||||
os << "\\ensuremath{"
|
||||
<< c
|
||||
<< '}';
|
||||
column += 13;
|
||||
} else {
|
||||
os << c;
|
||||
}
|
||||
case '>':
|
||||
os << "\\textgreater{}";
|
||||
column += 13;
|
||||
break;
|
||||
|
||||
case '|': case '<': case '>':
|
||||
// In T1 encoding, these characters exist
|
||||
if (lyxrc.fontenc == "T1") {
|
||||
os << c;
|
||||
//... but we should avoid ligatures
|
||||
if ((c == '>' || c == '<')
|
||||
&& i <= size() - 2
|
||||
&& getChar(i + 1) == c) {
|
||||
//os << "\\textcompwordmark{}";
|
||||
// Jean-Marc, have a look at
|
||||
// this. I think this works
|
||||
// equally well:
|
||||
os << "\\,{}";
|
||||
// Lgb
|
||||
column += 19;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Typewriter font also has them
|
||||
if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
||||
os << c;
|
||||
break;
|
||||
}
|
||||
// Otherwise, we use what LaTeX
|
||||
// provides us.
|
||||
switch (c) {
|
||||
case '<':
|
||||
os << "\\textless{}";
|
||||
column += 10;
|
||||
break;
|
||||
case '>':
|
||||
os << "\\textgreater{}";
|
||||
column += 13;
|
||||
break;
|
||||
case '|':
|
||||
os << "\\textbar{}";
|
||||
column += 9;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '-': // "--" in Typewriter mode -> "-{}-"
|
||||
if (i <= size() - 2
|
||||
&& getChar(i + 1) == '-'
|
||||
&& font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
||||
os << "-{}";
|
||||
column += 2;
|
||||
} else {
|
||||
os << '-';
|
||||
}
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
os << "\\char`\\\"{}";
|
||||
case '|':
|
||||
os << "\\textbar{}";
|
||||
column += 9;
|
||||
break;
|
||||
|
||||
case '£':
|
||||
if (bparams.inputenc == "default") {
|
||||
os << "\\pounds{}";
|
||||
column += 8;
|
||||
} else {
|
||||
os << c;
|
||||
}
|
||||
break;
|
||||
|
||||
case '$': case '&':
|
||||
case '%': case '#': case '{':
|
||||
case '}': case '_':
|
||||
os << '\\' << c;
|
||||
column += 1;
|
||||
break;
|
||||
|
||||
case '~':
|
||||
os << "\\textasciitilde{}";
|
||||
column += 16;
|
||||
break;
|
||||
|
||||
case '^':
|
||||
os << "\\textasciicircum{}";
|
||||
column += 17;
|
||||
break;
|
||||
|
||||
case '*': case '[': case ']':
|
||||
// avoid being mistaken for optional arguments
|
||||
os << '{' << c << '}';
|
||||
column += 2;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
// Blanks are printed before font switching.
|
||||
// Sure? I am not! (try nice-latex)
|
||||
// I am sure it's correct. LyX might be smarter
|
||||
// in the future, but for now, nothing wrong is
|
||||
// written. (Asger)
|
||||
break;
|
||||
|
||||
default:
|
||||
/* idea for labels --- begin*/
|
||||
// Check for "LyX"
|
||||
if (c == 'L'
|
||||
&& i <= size() - 3
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'y'
|
||||
&& getChar(i + 2) == 'X') {
|
||||
os << "\\LyX{}";
|
||||
i += 2;
|
||||
column += 5;
|
||||
}
|
||||
// Check for "TeX"
|
||||
else if (c == 'T'
|
||||
&& i <= size() - 3
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'e'
|
||||
&& getChar(i + 2) == 'X') {
|
||||
os << "\\TeX{}";
|
||||
i += 2;
|
||||
column += 5;
|
||||
}
|
||||
// Check for "LaTeX2e"
|
||||
else if (c == 'L'
|
||||
&& i <= size() - 7
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'a'
|
||||
&& getChar(i + 2) == 'T'
|
||||
&& getChar(i + 3) == 'e'
|
||||
&& getChar(i + 4) == 'X'
|
||||
&& getChar(i + 5) == '2'
|
||||
&& getChar(i + 6) == 'e') {
|
||||
os << "\\LaTeXe{}";
|
||||
i += 6;
|
||||
column += 8;
|
||||
}
|
||||
// Check for "LaTeX"
|
||||
else if (c == 'L'
|
||||
&& i <= size() - 5
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'a'
|
||||
&& getChar(i + 2) == 'T'
|
||||
&& getChar(i + 3) == 'e'
|
||||
&& getChar(i + 4) == 'X') {
|
||||
os << "\\LaTeX{}";
|
||||
i += 4;
|
||||
column += 7;
|
||||
/* idea for labels --- end*/
|
||||
} else if (c != '\0') {
|
||||
os << c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifndef NO_LATEX
|
||||
break;
|
||||
|
||||
case '-': // "--" in Typewriter mode -> "-{}-"
|
||||
if (i <= size() - 2
|
||||
&& getChar(i + 1) == '-'
|
||||
&& font.family() == LyXFont::TYPEWRITER_FAMILY) {
|
||||
os << "-{}";
|
||||
column += 2;
|
||||
} else {
|
||||
os << '-';
|
||||
}
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
os << "\\char`\\\"{}";
|
||||
column += 9;
|
||||
break;
|
||||
|
||||
case '£':
|
||||
if (bparams.inputenc == "default") {
|
||||
os << "\\pounds{}";
|
||||
column += 8;
|
||||
} else {
|
||||
os << c;
|
||||
}
|
||||
break;
|
||||
|
||||
case '$': case '&':
|
||||
case '%': case '#': case '{':
|
||||
case '}': case '_':
|
||||
os << '\\' << c;
|
||||
column += 1;
|
||||
break;
|
||||
|
||||
case '~':
|
||||
os << "\\textasciitilde{}";
|
||||
column += 16;
|
||||
break;
|
||||
|
||||
case '^':
|
||||
os << "\\textasciicircum{}";
|
||||
column += 17;
|
||||
break;
|
||||
|
||||
case '*': case '[': case ']':
|
||||
// avoid being mistaken for optional arguments
|
||||
os << '{' << c << '}';
|
||||
column += 2;
|
||||
break;
|
||||
|
||||
case ' ':
|
||||
// Blanks are printed before font switching.
|
||||
// Sure? I am not! (try nice-latex)
|
||||
// I am sure it's correct. LyX might be smarter
|
||||
// in the future, but for now, nothing wrong is
|
||||
// written. (Asger)
|
||||
break;
|
||||
|
||||
default:
|
||||
/* idea for labels --- begin*/
|
||||
// Check for "LyX"
|
||||
if (c == 'L'
|
||||
&& i <= size() - 3
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'y'
|
||||
&& getChar(i + 2) == 'X') {
|
||||
os << "\\LyX{}";
|
||||
i += 2;
|
||||
column += 5;
|
||||
}
|
||||
// Check for "TeX"
|
||||
else if (c == 'T'
|
||||
&& i <= size() - 3
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'e'
|
||||
&& getChar(i + 2) == 'X') {
|
||||
os << "\\TeX{}";
|
||||
i += 2;
|
||||
column += 5;
|
||||
}
|
||||
// Check for "LaTeX2e"
|
||||
else if (c == 'L'
|
||||
&& i <= size() - 7
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'a'
|
||||
&& getChar(i + 2) == 'T'
|
||||
&& getChar(i + 3) == 'e'
|
||||
&& getChar(i + 4) == 'X'
|
||||
&& getChar(i + 5) == '2'
|
||||
&& getChar(i + 6) == 'e') {
|
||||
os << "\\LaTeXe{}";
|
||||
i += 6;
|
||||
column += 8;
|
||||
}
|
||||
// Check for "LaTeX"
|
||||
else if (c == 'L'
|
||||
&& i <= size() - 5
|
||||
&& font.family() != LyXFont::TYPEWRITER_FAMILY
|
||||
&& getChar(i + 1) == 'a'
|
||||
&& getChar(i + 2) == 'T'
|
||||
&& getChar(i + 3) == 'e'
|
||||
&& getChar(i + 4) == 'X') {
|
||||
os << "\\LaTeX{}";
|
||||
i += 4;
|
||||
column += 7;
|
||||
/* idea for labels --- end*/
|
||||
} else if (c != '\0') {
|
||||
os << c;
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,3 +526,27 @@ Paragraph * Paragraph::Pimpl::getParFromID(int id) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
|
||||
BufferParams const & bparams) const
|
||||
{
|
||||
LyXFont tmpfont(font);
|
||||
|
||||
// check for environment font information
|
||||
char par_depth = owner_->getDepth();
|
||||
Paragraph const * par = owner_;
|
||||
while (par && par->getDepth() && !tmpfont.resolved()) {
|
||||
par = par->outerHook();
|
||||
if (par) {
|
||||
tmpfont.realize(textclasslist.
|
||||
Style(bparams.textclass,
|
||||
par->getLayout()).font, bparams.language);
|
||||
par_depth = par->getDepth();
|
||||
}
|
||||
}
|
||||
|
||||
tmpfont.realize(textclasslist
|
||||
.TextClass(bparams.textclass)
|
||||
.defaultfont(), bparams.language);
|
||||
return tmpfont;
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ struct Paragraph::Pimpl {
|
||||
///
|
||||
void erase(Paragraph::size_type pos);
|
||||
///
|
||||
LyXFont const realizeFont(LyXFont const & font,
|
||||
BufferParams const & bparams) const;
|
||||
///
|
||||
Inset * inset_owner;
|
||||
///
|
||||
boost::array<int, 10> counter_;
|
||||
|
@ -1506,10 +1506,11 @@ void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
|
||||
|| token == "\\end_float"
|
||||
|| token == "\\end_deeper") {
|
||||
lex.pushToken(token);
|
||||
#ifndef NO_COMPABILITY
|
||||
// Here we need to insert the inset_ert_contents into the last
|
||||
// cell of the tabular.
|
||||
owner_->bufferOwner()->insertErtContents(par, pos, font);
|
||||
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (owner_->bufferOwner()->parseSingleLyXformat2Token(lex, par,
|
||||
|
47
src/text.C
47
src/text.C
@ -253,7 +253,7 @@ void LyXText::computeBidiTables(Buffer const * buf, Row * row) const
|
||||
LyXFont font = row->par()->getFontSettings(buf->params, pos);
|
||||
if (pos != lpos && 0 < lpos && rtl0 && font.isRightToLeft() &&
|
||||
font.number() == LyXFont::ON &&
|
||||
row->par()->getFontSettings(buf->params, lpos-1).number()
|
||||
row->par()->getFontSettings(buf->params, lpos - 1).number()
|
||||
== LyXFont::ON) {
|
||||
font = row->par()->getFontSettings(buf->params, lpos);
|
||||
is_space = false;
|
||||
@ -659,7 +659,7 @@ int LyXText::leftMargin(BufferView * bview, Row const * row) const
|
||||
|
||||
}
|
||||
|
||||
LyXFont const labelfont = getFont(bview->buffer(), row->par(), -2);
|
||||
LyXFont const labelfont = getLabelFont(bview->buffer(), row->par());
|
||||
switch (layout.margintype) {
|
||||
case MARGIN_DYNAMIC:
|
||||
if (!layout.leftmargin.empty()) {
|
||||
@ -944,7 +944,7 @@ LyXText::nextBreakPoint(BufferView * bview, Row const * row, int width) const
|
||||
++i;
|
||||
if (i == main_body) {
|
||||
x += lyxfont::width(layout.labelsep,
|
||||
getFont(bview->buffer(), par, -2));
|
||||
getLabelFont(bview->buffer(), par));
|
||||
if (par->isLineSeparator(i - 1))
|
||||
x-= singleWidth(bview, par, i - 1);
|
||||
int left_margin = labelEnd(bview, row);
|
||||
@ -1000,7 +1000,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
|
||||
|
||||
while (i <= last) {
|
||||
if (main_body > 0 && i == main_body) {
|
||||
w += lyxfont::width(layout.labelsep, getFont(bview->buffer(), row->par(), -2));
|
||||
w += lyxfont::width(layout.labelsep, getLabelFont(bview->buffer(), row->par()));
|
||||
if (row->par()->isLineSeparator(i - 1))
|
||||
w -= singleWidth(bview, row->par(), i - 1);
|
||||
int left_margin = labelEnd(bview, row);
|
||||
@ -1011,7 +1011,7 @@ int LyXText::fill(BufferView * bview, Row * row, int paper_width) const
|
||||
++i;
|
||||
}
|
||||
if (main_body > 0 && main_body > last) {
|
||||
w += lyxfont::width(layout.labelsep, getFont(bview->buffer(), row->par(), -2));
|
||||
w += lyxfont::width(layout.labelsep, getLabelFont(bview->buffer(), row->par()));
|
||||
if (last >= 0 && row->par()->isLineSeparator(last))
|
||||
w -= singleWidth(bview, row->par(), last);
|
||||
int const left_margin = labelEnd(bview, row);
|
||||
@ -1059,7 +1059,7 @@ int LyXText::labelFill(BufferView * bview, Row const * row) const
|
||||
int fill = 0;
|
||||
if (!row->par()->params().labelWidthString().empty()) {
|
||||
fill = max(lyxfont::width(row->par()->params().labelWidthString(),
|
||||
getFont(bview->buffer(), row->par(), -2)) - w,
|
||||
getLabelFont(bview->buffer(), row->par())) - w,
|
||||
0);
|
||||
}
|
||||
|
||||
@ -1210,11 +1210,11 @@ void LyXText::setHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
// do the assignment below too often.
|
||||
LyXFont font = getFont(bview->buffer(), par, row_ptr->pos());
|
||||
LyXFont::FONT_SIZE const tmpsize = font.size();
|
||||
font = getFont(bview->buffer(), par, -1);
|
||||
font = getLayoutFont(bview->buffer(), par);
|
||||
LyXFont::FONT_SIZE const size = font.size();
|
||||
font.setSize(tmpsize);
|
||||
|
||||
LyXFont labelfont = getFont(bview->buffer(), par, -2);
|
||||
LyXFont labelfont = getLabelFont(bview->buffer(), par);
|
||||
|
||||
float spacing_val = 1.0;
|
||||
if (!row_ptr->par()->params().spacing().isDefault()) {
|
||||
@ -1745,7 +1745,7 @@ void LyXText::insertChar(BufferView * bview, char c)
|
||||
cursor.pos()).number() == LyXFont::ON &&
|
||||
getFont(bview->buffer(),
|
||||
cursor.par(),
|
||||
cursor.pos()-1).number() == LyXFont::ON)
|
||||
cursor.pos() - 1).number() == LyXFont::ON)
|
||||
)
|
||||
number(bview); // Set current_font.number to OFF
|
||||
} else if (isdigit(c) &&
|
||||
@ -1767,7 +1767,7 @@ void LyXText::insertChar(BufferView * bview, char c)
|
||||
cursor.pos() >= 2 &&
|
||||
getFont(bview->buffer(),
|
||||
cursor.par(),
|
||||
cursor.pos()-2).number() == LyXFont::ON) {
|
||||
cursor.pos() - 2).number() == LyXFont::ON) {
|
||||
setCharFont(bview->buffer(),
|
||||
cursor.par(),
|
||||
cursor.pos() - 1,
|
||||
@ -2086,7 +2086,7 @@ void LyXText::prepareToPrint(BufferView * bview,
|
||||
textclasslist.Style(bview->buffer()->params.textclass,
|
||||
row->par()->getLayout());
|
||||
x += lyxfont::width(layout.labelsep,
|
||||
getFont(bview->buffer(), row->par(), -2));
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (main_body-1 <= last)
|
||||
x += fill_label_hfill;
|
||||
}
|
||||
@ -2295,12 +2295,7 @@ string const LyXText::selectNextWord(BufferView * bview,
|
||||
|
||||
// Now, skip until we have real text (will jump paragraphs)
|
||||
while ((cursor.par()->size() > cursor.pos()
|
||||
&& (!cursor.par()->isLetter(cursor.pos())
|
||||
#ifndef NO_LATEX
|
||||
|| cursor.par()->getFont(bview->buffer()->params, cursor.pos())
|
||||
.latex() == LyXFont::ON
|
||||
#endif
|
||||
)
|
||||
&& (!cursor.par()->isLetter(cursor.pos()))
|
||||
&& (!cursor.par()->isInset(cursor.pos()) ||
|
||||
!cursor.par()->getInset(cursor.pos())->isTextInset()))
|
||||
|| (cursor.par()->size() == cursor.pos()
|
||||
@ -3083,7 +3078,7 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
tmpx += fill_label_hfill +
|
||||
lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass,
|
||||
row_ptr->par()->getLayout()).labelsep,
|
||||
getFont(bview->buffer(),row_ptr->par(), -2));
|
||||
getLabelFont(bview->buffer(),row_ptr->par()));
|
||||
if (row_ptr->par()->isLineSeparator(main_body-1))
|
||||
tmpx -= singleWidth(bview, row_ptr->par(), main_body-1);
|
||||
}
|
||||
@ -3271,7 +3266,7 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
&& (layout.labeltype != LABEL_STATIC
|
||||
|| layout.latextype != LATEX_ENVIRONMENT
|
||||
|| row_ptr->par()->isFirstInSequence())) {
|
||||
font = getFont(bview->buffer(), row_ptr->par(), -2);
|
||||
font = getLabelFont(bview->buffer(), row_ptr->par());
|
||||
if (!row_ptr->par()->getLabelstring().empty()) {
|
||||
tmpx = x;
|
||||
string const tmpstring =
|
||||
@ -3320,8 +3315,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
layout.labeltype == LABEL_BIBLIO ||
|
||||
layout.labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
|
||||
if (row_ptr->par()->isFirstInSequence()) {
|
||||
font = getFont(bview->buffer(),
|
||||
row_ptr->par(), -2);
|
||||
font = getLabelFont(bview->buffer(),
|
||||
row_ptr->par());
|
||||
if (!row_ptr->par()->getLabelstring().empty()) {
|
||||
string const tmpstring =
|
||||
row_ptr->par()->getLabelstring();
|
||||
@ -3352,7 +3347,7 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
}
|
||||
}
|
||||
if (layout.labeltype == LABEL_BIBLIO && row_ptr->par()->bibkey) {
|
||||
font = getFont(bview->buffer(), row_ptr->par(), -1);
|
||||
font = getLayoutFont(bview->buffer(), row_ptr->par());
|
||||
if (is_rtl)
|
||||
tmpx = ww - leftMargin(bview, row_ptr)
|
||||
+ lyxfont::width(layout.labelsep, font);
|
||||
@ -3475,7 +3470,7 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
string const tmpstring = textclasslist.
|
||||
Style(bview->buffer()->params.textclass,
|
||||
layout).endlabelstring();
|
||||
font = getFont(bview->buffer(), row_ptr->par(), -2);
|
||||
font = getLabelFont(bview->buffer(), row_ptr->par());
|
||||
int const tmpx = is_rtl ?
|
||||
int(x) - lyxfont::width(tmpstring, font)
|
||||
: ww - rightMargin(bview->buffer(), row_ptr) - row_ptr->fill();
|
||||
@ -3503,8 +3498,8 @@ void LyXText::getVisibleRow(BufferView * bview, int y_offset, int x_offset,
|
||||
if (main_body > 0 && pos == main_body - 1) {
|
||||
x += fill_label_hfill
|
||||
+ lyxfont::width(layout.labelsep,
|
||||
getFont(bview->buffer(),
|
||||
row_ptr->par(), -2))
|
||||
getLabelFont(bview->buffer(),
|
||||
row_ptr->par()))
|
||||
- singleWidth(bview,
|
||||
row_ptr->par(),
|
||||
main_body - 1);
|
||||
@ -3601,7 +3596,7 @@ int LyXText::getColumnNearX(BufferView * bview, Row * row, int & x,
|
||||
if (main_body > 0 && c == main_body-1) {
|
||||
tmpx += fill_label_hfill +
|
||||
lyxfont::width(layout.labelsep,
|
||||
getFont(bview->buffer(), row->par(), -2));
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (row->par()->isLineSeparator(main_body - 1))
|
||||
tmpx -= singleWidth(bview, row->par(), main_body-1);
|
||||
}
|
||||
|
182
src/text2.C
182
src/text2.C
@ -41,6 +41,7 @@
|
||||
#include "FloatList.h"
|
||||
#include "language.h"
|
||||
#include "ParagraphParameters.h"
|
||||
#include "support/LAssert.h"
|
||||
|
||||
using std::copy;
|
||||
using std::find;
|
||||
@ -106,69 +107,15 @@ LyXText::~LyXText()
|
||||
}
|
||||
|
||||
|
||||
// Gets the fully instantiated font at a given position in a paragraph
|
||||
// Basically the same routine as Paragraph::getFont() in paragraph.C.
|
||||
// The difference is that this one is used for displaying, and thus we
|
||||
// are allowed to make cosmetic improvements. For instance make footnotes
|
||||
// smaller. (Asger)
|
||||
// If position is -1, we get the layout font of the paragraph.
|
||||
// If position is -2, we get the font of the manual label of the paragraph.
|
||||
LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
Paragraph::size_type pos) const
|
||||
namespace {
|
||||
|
||||
LyXFont const realizeFont(LyXFont const & font,
|
||||
Buffer const * buf,
|
||||
Paragraph * par)
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass, par->getLayout());
|
||||
|
||||
LyXFont tmpfont(font);
|
||||
Paragraph::depth_type par_depth = par->getDepth();
|
||||
// We specialize the 95% common case:
|
||||
if (!par_depth) {
|
||||
if (pos >= 0){
|
||||
// 95% goes here
|
||||
if (layout.labeltype == LABEL_MANUAL
|
||||
&& pos < beginningOfMainBody(buf, par)) {
|
||||
// 1% goes here
|
||||
LyXFont f = par->getFontSettings(buf->params,
|
||||
pos);
|
||||
return f.realize(layout.reslabelfont, buf->params.language);
|
||||
} else {
|
||||
LyXFont f = par->getFontSettings(buf->params, pos);
|
||||
return f.realize(layout.resfont, buf->params.language);
|
||||
}
|
||||
|
||||
} else {
|
||||
// 5% goes here.
|
||||
// process layoutfont for pos == -1 and labelfont for pos < -1
|
||||
if (pos == -1)
|
||||
return layout.resfont;
|
||||
else
|
||||
return layout.reslabelfont;
|
||||
}
|
||||
}
|
||||
|
||||
// The uncommon case need not be optimized as much
|
||||
|
||||
LyXFont layoutfont, tmpfont;
|
||||
|
||||
if (pos >= 0){
|
||||
// 95% goes here
|
||||
if (pos < beginningOfMainBody(buf, par)) {
|
||||
// 1% goes here
|
||||
layoutfont = layout.labelfont;
|
||||
} else {
|
||||
// 99% goes here
|
||||
layoutfont = layout.font;
|
||||
}
|
||||
tmpfont = par->getFontSettings(buf->params, pos);
|
||||
tmpfont.realize(layoutfont, buf->params.language);
|
||||
} else {
|
||||
// 5% goes here.
|
||||
// process layoutfont for pos == -1 and labelfont for pos < -1
|
||||
if (pos == -1)
|
||||
tmpfont = layout.font;
|
||||
else
|
||||
tmpfont = layout.labelfont;
|
||||
}
|
||||
|
||||
|
||||
// Resolve against environment font information
|
||||
while (par && par_depth && !tmpfont.resolved()) {
|
||||
par = par->outerHook();
|
||||
@ -187,6 +134,87 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
return tmpfont;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Gets the fully instantiated font at a given position in a paragraph
|
||||
// Basically the same routine as Paragraph::getFont() in paragraph.C.
|
||||
// The difference is that this one is used for displaying, and thus we
|
||||
// are allowed to make cosmetic improvements. For instance make footnotes
|
||||
// smaller. (Asger)
|
||||
// If position is -1, we get the layout font of the paragraph.
|
||||
// If position is -2, we get the font of the manual label of the paragraph.
|
||||
LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
Paragraph::size_type pos) const
|
||||
{
|
||||
lyx::Assert(pos >= 0);
|
||||
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass, par->getLayout());
|
||||
|
||||
Paragraph::depth_type par_depth = par->getDepth();
|
||||
// We specialize the 95% common case:
|
||||
if (!par_depth) {
|
||||
if (layout.labeltype == LABEL_MANUAL
|
||||
&& pos < beginningOfMainBody(buf, par)) {
|
||||
// 1% goes here
|
||||
LyXFont f = par->getFontSettings(buf->params,
|
||||
pos);
|
||||
return f.realize(layout.reslabelfont, buf->params.language);
|
||||
} else {
|
||||
LyXFont f = par->getFontSettings(buf->params, pos);
|
||||
return f.realize(layout.resfont, buf->params.language);
|
||||
}
|
||||
}
|
||||
|
||||
// The uncommon case need not be optimized as much
|
||||
|
||||
LyXFont layoutfont;
|
||||
|
||||
if (pos < beginningOfMainBody(buf, par)) {
|
||||
// 1% goes here
|
||||
layoutfont = layout.labelfont;
|
||||
} else {
|
||||
// 99% goes here
|
||||
layoutfont = layout.font;
|
||||
}
|
||||
|
||||
LyXFont tmpfont = par->getFontSettings(buf->params, pos);
|
||||
tmpfont.realize(layoutfont, buf->params.language);
|
||||
|
||||
return realizeFont(tmpfont, buf, par);
|
||||
}
|
||||
|
||||
|
||||
LyXFont const LyXText::getLayoutFont(Buffer const * buf, Paragraph * par) const
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass, par->getLayout());
|
||||
|
||||
Paragraph::depth_type par_depth = par->getDepth();
|
||||
|
||||
if (!par_depth) {
|
||||
return layout.resfont;
|
||||
}
|
||||
|
||||
return realizeFont(layout.font, buf, par);
|
||||
}
|
||||
|
||||
|
||||
LyXFont const LyXText::getLabelFont(Buffer const * buf, Paragraph * par) const
|
||||
{
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass, par->getLayout());
|
||||
|
||||
Paragraph::depth_type par_depth = par->getDepth();
|
||||
|
||||
if (!par_depth) {
|
||||
return layout.reslabelfont;
|
||||
}
|
||||
|
||||
return realizeFont(layout.labelfont, buf, par);
|
||||
}
|
||||
|
||||
|
||||
void LyXText::setCharFont(BufferView * bv, Paragraph * par,
|
||||
Paragraph::size_type pos, LyXFont const & fnt,
|
||||
@ -204,7 +232,6 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par,
|
||||
static_cast<UpdatableInset *>(inset);
|
||||
uinset->setFont(bv, fnt, toggleall, true);
|
||||
}
|
||||
font = inset->convertFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,10 +274,6 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
|
||||
Paragraph::size_type pos, LyXFont const & fnt)
|
||||
{
|
||||
LyXFont font(fnt);
|
||||
// Let the insets convert their font
|
||||
if (par->getChar(pos) == Paragraph::META_INSET) {
|
||||
font = par->getInset(pos)->convertFont(font);
|
||||
}
|
||||
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass,
|
||||
@ -675,11 +698,12 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
|
||||
// Determine basis font
|
||||
LyXFont layoutfont;
|
||||
if (cursor.pos() < beginningOfMainBody(bview->buffer(),
|
||||
cursor.par()))
|
||||
{
|
||||
layoutfont = getFont(bview->buffer(), cursor.par(),-2);
|
||||
cursor.par())) {
|
||||
layoutfont = getLabelFont(bview->buffer(),
|
||||
cursor.par());
|
||||
} else {
|
||||
layoutfont = getFont(bview->buffer(), cursor.par(),-1);
|
||||
layoutfont = getLayoutFont(bview->buffer(),
|
||||
cursor.par());
|
||||
}
|
||||
// Update current font
|
||||
real_current_font.update(font, toggleall);
|
||||
@ -2084,7 +2108,7 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
|
||||
bview->buffer()->params.textclass,
|
||||
row->par()->getLayout())
|
||||
.labelsep,
|
||||
getFont(bview->buffer(), row->par(), -2));
|
||||
getLabelFont(bview->buffer(), row->par()));
|
||||
if (row->par()->isLineSeparator(main_body-1))
|
||||
x -= singleWidth(bview, row->par(),main_body-1);
|
||||
}
|
||||
@ -2165,23 +2189,7 @@ void LyXText::setCursorFromCoordinates(BufferView * bview, int x, int y) const
|
||||
{
|
||||
LyXCursor old_cursor = cursor;
|
||||
|
||||
#if 0
|
||||
// Get the row first.
|
||||
|
||||
Row * row = getRowNearY(y);
|
||||
|
||||
bool bound = false;
|
||||
int column = getColumnNearX(bview, row, x, bound);
|
||||
|
||||
cursor.par(row->par());
|
||||
cursor.pos(row->pos() + column);
|
||||
cursor.x(x);
|
||||
cursor.y(y + row->baseline());
|
||||
cursor.row(row);
|
||||
cursor.boundary(bound);
|
||||
#else
|
||||
setCursorFromCoordinates(bview, cursor, x, y);
|
||||
#endif
|
||||
setCurrentFont(bview);
|
||||
deleteEmptyParagraphMechanism(bview, old_cursor);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user