* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
+ * Copyright 1995-2001 The LyX Team.
*
* ====================================================== */
using std::ostream;
using std::endl;
+#ifndef CXX_GLOBAL_CSTD
+using std::strlen;
+#endif
+
+
//
// Names for the GUI
//
OFF,
OFF,
OFF,
- OFF,
OFF };
// Initialize static member
INHERIT,
INHERIT,
INHERIT,
- INHERIT,
OFF };
// Initialize static member
IGNORE,
IGNORE,
IGNORE,
- IGNORE,
IGNORE };
fb1.emph == emph &&
fb1.underbar == underbar &&
fb1.noun == noun &&
- fb1.latex == latex &&
fb1.number == number;
}
}
-LyXFont::LyXFont()
-{
- bits = sane;
- lang = default_language;
-}
-
-
LyXFont::LyXFont(LyXFont::FONT_INIT1)
-{
- bits = inherit;
- lang = default_language;
-}
+ : bits(inherit), lang(inherit_language)
+{}
LyXFont::LyXFont(LyXFont::FONT_INIT2)
-{
- bits = ignore;
- lang = ignore_language;
-}
+ : bits(ignore), lang(ignore_language)
+{}
LyXFont::LyXFont(LyXFont::FONT_INIT3)
-{
- bits = sane;
- lang = default_language;
-}
+ : bits(sane), lang(default_language)
+{}
LyXFont::LyXFont(LyXFont::FONT_INIT1, Language const * l)
-{
- bits = inherit;
- lang = l;
-}
+ : bits(inherit), lang(l)
+{}
LyXFont::LyXFont(LyXFont::FONT_INIT2, Language const * l)
-{
- bits = ignore;
- lang = l;
-}
+ : bits(ignore), lang(l)
+{}
LyXFont::LyXFont(LyXFont::FONT_INIT3, Language const * l)
-{
- bits = sane;
- lang = l;
-}
-
-
-LyXFont::FONT_FAMILY LyXFont::family() const
-{
- return bits.family;
-}
-
-
-LyXFont::FONT_SERIES LyXFont::series() const
-{
- return bits.series;
-}
-
-
-LyXFont::FONT_SHAPE LyXFont::shape() const
-{
- return bits.shape;
-}
-
-
-LyXFont::FONT_SIZE LyXFont::size() const
-{
- return bits.size;
-}
-
-
-LyXFont::FONT_MISC_STATE LyXFont::emph() const
-{
- return bits.emph;
-}
+ : bits(sane), lang(l)
+{}
LyXFont::FONT_MISC_STATE LyXFont::underbar() const
}
-LyXFont::FONT_MISC_STATE LyXFont::noun() const
-{
- return bits.noun;
-}
-
-
-LyXFont::FONT_MISC_STATE LyXFont::latex() const
-{
- return bits.latex;
-}
-
-
LColor::color LyXFont::color() const
{
return bits.color;
bool LyXFont::isVisibleRightToLeft() const
{
- return (lang->RightToLeft() && latex() != ON && number() != ON);
+ return (lang->RightToLeft() &&
+ number() != ON);
}
}
-LyXFont & LyXFont::setLatex(LyXFont::FONT_MISC_STATE l)
-{
- bits.latex = l;
- return *this;
-}
-
-
LyXFont & LyXFont::setColor(LColor::color c)
{
bits.color = c;
/// Updates font settings according to request
-void LyXFont::update(LyXFont const & newfont,
- Language const * document_language, bool toggleall)
+void LyXFont::update(LyXFont const & newfont, bool toggleall)
{
if (newfont.family() == family() && toggleall)
setFamily(INHERIT_FAMILY); // toggle 'back'
setEmph(setMisc(newfont.emph(), emph()));
setUnderbar(setMisc(newfont.underbar(), underbar()));
setNoun(setMisc(newfont.noun(), noun()));
- setLatex(setMisc(newfont.latex(), latex()));
-
+
setNumber(setMisc(newfont.number(), number()));
if (newfont.language() == language() && toggleall)
- if (language() == document_language)
- setLanguage(default_language);
- else
- setLanguage(document_language);
+ setLanguage(inherit_language);
else if (newfont.language() != ignore_language)
setLanguage(newfont.language());
setUnderbar(INHERIT);
if (noun() == tmplt.noun())
setNoun(INHERIT);
- if (latex() == tmplt.latex())
- setLatex(INHERIT);
if (color() == tmplt.color())
setColor(LColor::inherit);
+ if (language() == tmplt.language())
+ setLanguage(inherit_language);
}
/// Realize font from a template
-LyXFont & LyXFont::realize(LyXFont const & tmplt)
-{
+LyXFont & LyXFont::realize(LyXFont const & tmplt, Language const * deflang)
+{
+ if (language() == inherit_language) {
+ if (tmplt.language() == inherit_language ||
+ tmplt.language() == ignore_language ||
+ tmplt.language() == default_language)
+ {
+ setLanguage(deflang);
+ } else {
+ setLanguage(tmplt.language());
+ }
+ }
if (bits == inherit) {
bits = tmplt.bits;
return *this;
if (bits.noun == INHERIT) {
bits.noun = tmplt.bits.noun;
}
- if (bits.latex == INHERIT) {
- bits.latex = tmplt.bits.latex;
- }
if (bits.color == LColor::inherit) {
bits.color = tmplt.bits.color;
}
return (family() != INHERIT_FAMILY && series() != INHERIT_SERIES &&
shape() != INHERIT_SHAPE && size() != INHERIT_SIZE &&
emph() != INHERIT && underbar() != INHERIT &&
- noun() != INHERIT && latex() != INHERIT &&
- color() != LColor::inherit);
+ noun() != INHERIT &&
+ color() != LColor::inherit &&
+ language() != inherit_language);
}
/// Build GUI description of font state
string const LyXFont::stateText(BufferParams * params) const
{
- std::ostringstream ost;
+ ostringstream ost;
if (family() != INHERIT_FAMILY)
ost << _(GUIFamilyNames[family()]) << ", ";
if (series() != INHERIT_SERIES)
<< _(GUIMiscNames[underbar()]) << ", ";
if (noun() != INHERIT)
ost << _("Noun ") << _(GUIMiscNames[noun()]) << ", ";
- if (latex() != INHERIT)
- ost << _("Latex ") << _(GUIMiscNames[latex()]) << ", ";
if (bits == inherit)
ost << _("Default") << ", ";
if (!params || (language() != params->language))
{
bool error = false;
bool finished = false;
- while (!finished && lex.IsOK() && !error) {
+ while (!finished && lex.isOK() && !error) {
lex.next();
- string const tok = lowercase(lex.GetString());
+ string const tok = lowercase(lex.getString());
if (tok.empty()) {
continue;
finished = true;
} else if (tok == "family") {
lex.next();
- string const ttok = lex.GetString();
+ string const ttok = lex.getString();
setLyXFamily(ttok);
} else if (tok == "series") {
lex.next();
- string const ttok = lex.GetString();
+ string const ttok = lex.getString();
setLyXSeries(ttok);
} else if (tok == "shape") {
lex.next();
- string const ttok = lex.GetString();
+ string const ttok = lex.getString();
setLyXShape(ttok);
} else if (tok == "size") {
lex.next();
- string const ttok = lex.GetString();
+ string const ttok = lex.getString();
setLyXSize(ttok);
- } 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'");
- }
} else if (tok == "misc") {
lex.next();
- string const ttok = lowercase(lex.GetString());
+ string const ttok = lowercase(lex.getString());
if (ttok == "no_bar") {
setUnderbar(OFF);
}
} else if (tok == "color") {
lex.next();
- string const ttok = lex.GetString();
+ string const ttok = lex.getString();
setLyXColor(ttok);
} else {
lex.printError("Unknown tag `$$Token'");
/// Writes the changes from this font to orgfont in .lyx format in file
-void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
+void LyXFont::lyxWriteChanges(LyXFont const & orgfont,
+ Language const * doclang, ostream & os) const
{
os << "\n";
if (orgfont.family() != family()) {
if (orgfont.noun() != noun()) {
os << "\\noun " << LyXMiscNames[noun()] << " \n";
}
- 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;
- }
- }
if (orgfont.color() != color()) {
// To make us file compatible with older
// lyx versions we emit "default" instead
os << "\\color " << col_str << "\n";
}
if (orgfont.language() != language()) {
- if (language())
+ if (language() == inherit_language)
+ os << "\\lang " << doclang->lang() << "\n";
+ else if (language())
os << "\\lang " << language()->lang() << "\n";
else
os << "\\lang unknown\n";
// Returns number of chars written
// This one corresponds to latexWriteStartChanges(). (Asger)
int LyXFont::latexWriteEndChanges(ostream & os, LyXFont const & base,
- LyXFont const & next) const
+ LyXFont const & next) const
{
int count = 0;
bool env = false;
LColor::color LyXFont::realColor() const
{
- if (latex() == ON)
- return LColor::latex;
if (color() == LColor::none)
return LColor::foreground;
return color();
}
-bool LyXFont::equalExceptLatex(LyXFont const & f) const
-{
- LyXFont f1 = *this;
- f1.setLatex(f.latex());
- return f1 == f;
-}
-
-
ostream & operator<<(ostream & o, LyXFont::FONT_MISC_STATE fms)
{
return o << int(fms);