+2001-07-27 Juergen Vigna <jug@sad.it>
+
+ * text2.C: font.realize function adaption.
+
+ * text.C (draw): add a warnings lyxerr text if needed.
+
+ * layout.C: font.realize function adaption.
+
+ * language.C: add inherit_language and implement it's handlings
+
+ * bufferview_funcs.C (StyleReset): remove language parameter from
+ font creation (should be language_inherit now).
+
+ * bufferparams.C (writeFile): handle ignore_language.
+
+ * paragraph.C (getFontSettings): the language has to be resolved
+ otherwise we have problems in LyXFont!
+
+ * lyxfont.C (lyxWriteChanges): added document_language parameter
+ (update): removed unneeded language parameter
+
+ * paragraph.C (validate): fixed wrong output of color-package when
+ using interface colors for certain fonts in certain environments,
+ which should not seen as that on the final output.
+
+2001-07-26 Juergen Vigna <jug@sad.it>
+
+ * lyxfont.C (realize): honor ignore_language too!
+ (resolved): ditto.
+
+ * paragraph.C (TeXOnePar): handle ignore language right (hopefully).
+
+ * text.C (draw): one place more for ignore_language to not draw
+ itself!
+
2001-07-25 Angus Leeming <a.leeming@ic.ac.uk>
* LaTeXFeatures.C (getPackages): clean-up a little of the natbib code.
bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
- int & pos, char tc)
+ int & pos, char tc)
{
if (!checkPastePossible(*par))
return false;
}
/* then the text parameters */
- os << "\\language " << language->lang()
- << "\n\\inputencoding " << inputenc
+ if (language != ignore_language)
+ os << "\\language " << language->lang() << '\n';
+ os << "\\inputencoding " << inputenc
<< "\n\\fontscheme " << fonts
<< "\n\\graphics " << graphicsDriver << '\n';
void StyleReset(BufferView * bv)
{
- LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
+ LyXFont font(LyXFont::ALL_INHERIT);
ToggleAndShow(bv, font);
}
+2001-07-27 Juergen Vigna <jug@sad.it>
+
+ * insetert.C (checkInsertChar): implementation of function
+ checkInsertChar.
+
+ * inset.h: added new function checkInsertChar.
+
+ * various files: added c-tor and clone() function.
+
+ * insetcollapsable.h: removed clone function here as this should
+ be only realized in REAL insets and added it to all collapsable
+ insets! (with the copy-constructor).
+
2001-07-26 Lars Gullik Bjønnes <larsbj@birdstep.com>
* insetminipage.C (read): handle missing parameters more gracefully
#endif
/// close the inset
virtual void close(BufferView *) {}
+ /// check if the font of the char we want inserting is correct
+ /// and modify it if it is not.
+ virtual bool checkInsertChar(LyXFont & font) { return true; }
protected:
///
virtual bool nodraw() const {
return block_drawing_;
}
+ /// check if the font of the char we want inserting is correct
+ /// and modify it if it is not.
+ virtual bool checkInsertChar(LyXFont & font) { return true; }
///
// needed for spellchecking text
///
}
-Inset * InsetCollapsable::clone(Buffer const &, bool same_id) const
-{
- return new InsetCollapsable(*const_cast<InsetCollapsable *>(this),
- same_id);
-}
-
-
bool InsetCollapsable::insertInset(BufferView * bv, Inset * in)
{
if (!insetAllowed(in->lyxCode())) {
///
InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
///
- Inset * clone(Buffer const &, bool same_id = false) const;
-
void read(Buffer const *, LyXLex &);
///
void write(Buffer const *, std::ostream &) const;
///
bool insertInset(BufferView *, Inset * inset);
///
- bool insetAllowed(Inset::Code code) const {
+ virtual bool insetAllowed(Inset::Code code) const {
return inset.insetAllowed(code);
}
///
bool const & cs = true, bool const & mw = false) {
return inset.searchBackward(bv, str, cs, mw);
}
+ /// check if the font of the char we want inserting is correct
+ /// and modify it if it is not.
+ virtual bool checkInsertChar(LyXFont &) { return false; }
protected:
///
void InsetERT::init()
{
setButtonLabel();
-
labelfont = LyXFont(LyXFont::ALL_SANE);
labelfont.decSize();
labelfont.decSize();
}
+InsetERT::InsetERT(InsetERT const & in, bool same_id)
+ : InsetCollapsable(in, same_id)
+{
+ init();
+}
+
+
+Inset * InsetERT::clone(Buffer const &, bool same_id) const
+{
+ return new InsetERT(*const_cast<InsetERT *>(this), same_id);
+}
+
+
InsetERT::InsetERT(string const & contents, bool collapsed)
: InsetCollapsable(collapsed)
{
setLabel(_("666"));
}
}
+
+
+bool InsetERT::checkInsertChar(LyXFont & font)
+{
+ LyXFont f(LyXFont::ALL_INHERIT);
+ font = f;
+ font.setFamily(LyXFont::TYPEWRITER_FAMILY);
+ font.setColor(LColor::latex);
+ return true;
+}
///
InsetERT();
///
+ InsetERT(InsetERT const &, bool same_id = false);
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const;
+ ///
InsetERT(string const & contents, bool collapsed);
///
+ Inset::Code lyxCode() const { return Inset::ERT_CODE; }
+ ///
void read(Buffer const * buf, LyXLex & lex);
///
void write(Buffer const * buf, std::ostream & os) const;
///
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
string const &);
+ ///
+ bool checkInsertChar(LyXFont &);
+
private:
///
void init();
}
+InsetFoot::InsetFoot(InsetFoot const & in, bool same_id)
+ : InsetFootlike(in, same_id)
+{
+ setLabel(_("foot"));
+ setInsetName("Foot");
+}
+
+
+Inset * InsetFoot::clone(Buffer const &, bool same_id) const
+{
+ return new InsetFoot(*const_cast<InsetFoot *>(this), same_id);
+}
+
+
string const InsetFoot::editMessage() const
{
return _("Opened Footnote Inset");
///
InsetFoot();
///
+ InsetFoot(InsetFoot const &, bool same_id = false);
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const;
+ ///
Inset::Code lyxCode() const { return Inset::FOOT_CODE; }
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
font.decSize();
font.setColor(LColor::collapsable);
setLabelFont(font);
-#if 0
- setAutoCollapse(false);
-#endif
+}
+
+
+InsetFootlike::InsetFootlike(InsetFootlike const & in, bool same_id)
+ : InsetCollapsable(in, same_id)
+{
+ LyXFont font(LyXFont::ALL_SANE);
+ font.decSize();
+ font.decSize();
+ font.setColor(LColor::collapsable);
+ setLabelFont(font);
}
///
InsetFootlike();
///
+ InsetFootlike(InsetFootlike const &, bool same_id = false);
+ ///
void write(Buffer const * buf, std::ostream & os) const;
///
bool insetAllowed(Inset::Code) const;
}
+InsetMarginal::InsetMarginal(InsetMarginal const & in, bool same_id)
+ : InsetFootlike(in, same_id)
+{
+ setLabel(_("margin"));
+ setInsetName("Marginal");
+}
+
+
+Inset * InsetMarginal::clone(Buffer const &, bool same_id) const
+{
+ return new InsetMarginal(*const_cast<InsetMarginal *>(this), same_id);
+}
+
+
string const InsetMarginal::editMessage() const
{
return _("Opened Marginal Note Inset");
///
InsetMarginal();
///
+ InsetMarginal(InsetMarginal const &, bool same_id = false);
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const;
+ ///
Inset::Code lyxCode() const { return Inset::MARGIN_CODE; }
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
font.decSize();
font.setColor(LColor::note);
setLabelFont(font);
-#if 0
- setAutoCollapse(false);
-#endif
setBackgroundColor(LColor::note);
-
setLabel(_("note"));
setInsetName("Note");
}
}
+InsetNote::InsetNote(InsetNote const & in, bool same_id)
+ : InsetCollapsable(in, same_id)
+{
+ init();
+}
+
+
+Inset * InsetNote::clone(Buffer const &, bool same_id) const
+{
+ return new InsetNote(*const_cast<InsetNote *>(this), same_id);
+}
+
+
InsetNote::InsetNote(Buffer const * buf, string const & contents,
bool collapsed)
: InsetCollapsable(collapsed)
public:
///
InsetNote();
+ ///
+ InsetNote(InsetNote const &, bool same_id = false);
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const;
/// constructor with initial contents
InsetNote(Buffer const *, string const & contents, bool collapsed);
///
return the_locking_inset->getLyXText(bv);
}
return cached_text.get();
- } else if (it->second.remove) {
+ } else if (it != cache.end() && it->second.remove) {
if (locked) {
saveLyXTextState(it->second.text.get());
} else {
Language const * default_language;
Language ignore_lang("ignore", "ignore", "Ignore", false, 0, "ignore", "");
Language const * ignore_language = &ignore_lang;
+Language inherit_lang("inherit", "inherit", "Inherit", false, 0, "inherit", "");
+Language const * inherit_language = &inherit_lang;
void Languages::setDefaults()
{
extern Language const * default_language;
extern Language const * english_language;
extern Language const * ignore_language;
+extern Language const * inherit_language;
#endif
if (!lay.Read(lexrc, *this)) {
// Reslove fonts
lay.resfont = lay.font;
- lay.resfont.realize(defaultfont());
+ lay.resfont.realize(defaultfont(), default_language);
lay.reslabelfont = lay.labelfont;
- lay.reslabelfont.realize(defaultfont());
+ lay.reslabelfont.realize(defaultfont(), default_language);
return false; // no errors
}
lyxerr << "Error parsing style `" << lay.name() << "'" << endl;
if (!defaultfont_.resolved()) {
lexrc.printError("Warning: defaultfont should "
"be fully instantiated!");
- defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
+ defaultfont_.realize(LyXFont(LyXFont::ALL_SANE),
+ default_language);
}
break;
LyXFont::LyXFont(LyXFont::FONT_INIT1)
- : bits(inherit), lang(ignore_language)
+ : bits(inherit), lang(inherit_language)
{}
/// 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'
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());
#endif
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;
#ifndef NO_LATEX
latex() != INHERIT &&
#endif
- color() != LColor::inherit);
+ color() != LColor::inherit &&
+ language() != inherit_language);
}
/// 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()) {
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;
a INHERIT_FAMILY was asked for. This is necessary for the
toggle-user-defined-style button on the toolbar.
*/
- void update(LyXFont const & newfont,
- Language const * default_lang,
- bool toggleall = false);
+ void update(LyXFont const & newfont, bool toggleall = false);
/** Reduce font to fall back to template where possible.
Equal fields are reduced to INHERIT */
void reduce(LyXFont const & tmplt);
/// Realize font from a template (INHERIT are realized)
- LyXFont & realize(LyXFont const & tmplt);
+ LyXFont & realize(LyXFont const & tmplt, Language const * language);
/// Is a given font fully resolved?
bool resolved() const;
LyXFont & lyxRead(LyXLex &);
/// Writes the changes from this font to orgfont in .lyx format in file
- void lyxWriteChanges(LyXFont const & orgfont, std::ostream &) const;
+ void lyxWriteChanges(LyXFont const & orgfont, Language const * doclang,
+ std::ostream &) const;
/** Writes the head of the LaTeX needed to change to this font.
Writes to string, the head of the LaTeX needed to change
void Paragraph::writeFile(Buffer const * buf, ostream & os,
- BufferParams const & bparams,
- depth_type dth) const
+ BufferParams const & bparams,
+ depth_type dth) const
{
// The beginning or end of a deeper (i.e. nested) area?
if (dth != params().depth()) {
// Write font changes
LyXFont font2 = getFontSettings(bparams, i);
if (font2 != font1) {
- font2.lyxWriteChanges(font1, os);
+ font2.lyxWriteChanges(font1, bparams.language, os);
column = 0;
font1 = font2;
}
case LColor::none:
case LColor::inherit:
case LColor::ignore:
+ // probably we should put here all interface colors used for
+ // font displaying! For now I just add this ones I know of (Jug)
+ case LColor::latex:
+ case LColor::note:
break;
default:
features.color = true;
}
Language const * language = cit->font().language();
- if (language->babel() != doc_language->babel()) {
+ if (language != ignore_language &&
+ language != inherit_language &&
+ language->babel() != doc_language->babel())
+ {
features.UsedLanguages.insert(language);
lyxerr[Debug::LATEX] << "Found language "
<< language->babel() << endl;
return false;
if (minibuffer_char == Paragraph::META_INSET)
insertInset(pos, minibuffer_inset, minibuffer_font);
- else
- insertChar(pos, minibuffer_char, minibuffer_font);
+ else {
+ LyXFont f = minibuffer_font;
+ if (checkInsertChar(f))
+ insertChar(pos, minibuffer_char, f);
+ }
return true;
}
}
+bool Paragraph::checkInsertChar(LyXFont & font)
+{
+ if (pimpl_->inset_owner)
+ return pimpl_->inset_owner->checkInsertChar(font);
+ return true;
+}
+
+
void Paragraph::insertChar(Paragraph::size_type pos,
Paragraph::value_type c)
{
// Gets uninstantiated font setting at position.
LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
- Paragraph::size_type pos) const
+ Paragraph::size_type pos) const
{
lyx::Assert(pos <= size());
Pimpl::FontList::const_iterator cit = lower_bound(pimpl_->fontlist.begin(),
pimpl_->fontlist.end(),
search_font, Pimpl::matchFT());
- if (cit != pimpl_->fontlist.end())
- return cit->font();
-
- if (pos == size() && size())
- return getFontSettings(bparams, pos - 1);
-
- return LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
+ LyXFont retfont;
+ if (cit != pimpl_->fontlist.end()) {
+ retfont = cit->font();
+ } else if (pos == size() && size()) {
+ retfont = getFontSettings(bparams, pos - 1);
+ } else
+ retfont = LyXFont(LyXFont::ALL_INHERIT, getParLanguage(bparams));
+ if (retfont.language() == inherit_language)
+ retfont.setLanguage(bparams.language);
+
+ return retfont;
}
else
layoutfont = layout.font;
tmpfont = getFontSettings(bparams, pos);
- tmpfont.realize(layoutfont);
+ tmpfont.realize(layoutfont, bparams.language);
} else {
// process layoutfont for pos == -1 and labelfont for pos < -1
if (pos == -1)
if (par) {
tmpfont.realize(textclasslist.
Style(bparams.textclass,
- par->getLayout()).font);
+ par->getLayout()).font, bparams.language);
par_depth = par->getDepth();
}
}
tmpfont.realize(textclasslist
.TextClass(bparams.textclass)
- .defaultfont());
+ .defaultfont(), bparams.language);
return tmpfont;
}
Language const * doc_language = bparams.language;
Language const * previous_language = previous_
? previous_->getParLanguage(bparams) : doc_language;
+ if (language == ignore_language || language == inherit_language)
+ lyxerr << "1:" << language->lang() << endl;
if (language->babel() != doc_language->babel() &&
language->babel() != previous_language->babel()) {
os << subst(lyxrc.language_command_begin, "$$lang",
}
if (bparams.inputenc == "auto" &&
- language->encoding() != previous_language->encoding()) {
+ language->encoding() != previous_language->encoding())
+ {
os << "\\inputencoding{"
<< language->encoding()->LatexName()
<< "}" << endl;
texrow.newline();
}
-
+
switch (style.latextype) {
case LATEX_COMMAND:
os << '\\'
os << "}";
if (language->babel() != doc_language->babel() &&
- (!next_
- || next_->getParLanguage(bparams)->babel() != language->babel())) {
+ (!next_ ||
+ next_->getParLanguage(bparams)->babel() != language->babel()))
+ {
os << endl
<< subst(lyxrc.language_command_end, "$$lang",
doc_language->babel());
// If we have an open font definition, we have to close it
if (open_font) {
+#ifdef FIXED_LANGUAGE_END_DETECTION
if (next_) {
running_font
.latexWriteEndChanges(os, basefont,
- next_->getFont(bparams,
- 0));
+ next_->getFont(bparams,
+ 0));
} else {
running_font.latexWriteEndChanges(os, basefont,
- basefont);
+ basefont);
}
+#else
+#ifdef WITH_WARNINGS
+#warning For now we ALWAYS have to close the foreign font settings if they are
+#warning there as we start another \selectlanguage with the next paragraph if
+#warning we are in need of this. This should be fixed sometime (Jug)
+#endif
+ running_font.latexWriteEndChanges(os, basefont, basefont);
+#endif
}
// Needed if there is an optional argument but no contents.
Language const *
Paragraph::getParLanguage(BufferParams const & bparams) const
{
- if (size() > 0)
- return getFirstFontSettings().language();
- else if (previous_)
+ if (size() > 0) {
+ Language const * lang = getFirstFontSettings().language();
+#warning We should make this somewhat better, any ideas? (Jug)
+ if (lang == inherit_language || lang == ignore_language)
+ lang = bparams.language;
+ return lang;
+ } else if (previous_)
return previous_->getParLanguage(bparams);
else
return bparams.language;
Language const * doc_language = bparams.language;
for (Pimpl::FontList::const_iterator cit = pimpl_->fontlist.begin();
cit != pimpl_->fontlist.end(); ++cit)
- if (cit->font().language() != doc_language)
+ if (cit->font().language() != inherit_language &&
+ cit->font().language() != ignore_language &&
+ cit->font().language() != doc_language)
return true;
return false;
}
///
void insertChar(size_type pos, value_type c, LyXFont const &);
///
+ bool checkInsertChar(LyXFont &);
+ ///
void insertInset(size_type pos, Inset * inset);
///
void insertInset(size_type pos, Inset * inset, LyXFont const &);
x += lyxfont::width(textstring, font);
}
+#ifdef WITH_WARNINGS
+ if ((font.language() == inherit_language) ||
+ (font.language() == ignore_language))
+ lyxerr << "No this shouldn't happen!\n";
+#endif
if (lyxrc.mark_foreign_language &&
font.language() != bview->buffer()->params.language) {
int const y = offset + row->height() - 1;
// 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
+ Paragraph::size_type pos) const
{
LyXLayout const & layout =
textclasslist.Style(buf->params.textclass, par->getLayout());
// 1% goes here
LyXFont f = par->getFontSettings(buf->params,
pos);
- return f.realize(layout.reslabelfont);
+ return f.realize(layout.reslabelfont, buf->params.language);
} else {
LyXFont f = par->getFontSettings(buf->params, pos);
- return f.realize(layout.resfont);
+ return f.realize(layout.resfont, buf->params.language);
}
} else {
layoutfont = layout.font;
}
tmpfont = par->getFontSettings(buf->params, pos);
- tmpfont.realize(layoutfont);
+ tmpfont.realize(layoutfont, buf->params.language);
} else {
// 5% goes here.
// process layoutfont for pos == -1 and labelfont for pos < -1
if (par) {
tmpfont.realize(textclasslist.
Style(buf->params.textclass,
- par->getLayout()).font);
+ par->getLayout()).font,
+ buf->params.language);
par_depth = par->getDepth();
}
}
- tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+ tmpfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont(),
+ buf->params.language);
return tmpfont;
}
{
Buffer const * buf = bv->buffer();
LyXFont font = getFont(buf, par, pos);
- font.update(fnt, buf->params.language, toggleall);
+ font.update(fnt, toggleall);
// Let the insets convert their font
if (par->getChar(pos) == Paragraph::META_INSET) {
Inset * inset = par->getInset(pos);
tp = tp->outerHook();
if (tp)
layoutfont.realize(textclasslist.
- Style(buf->params.textclass,
- tp->getLayout()).font);
+ Style(buf->params.textclass,
+ tp->getLayout()).font,
+ buf->params.language);
}
}
- layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+ layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont(),
+ buf->params.language);
// Now, reduce font against full layout font
font.reduce(layoutfont);
tp = tp->outerHook();
if (tp)
layoutfont.realize(textclasslist.
- Style(buf->params.textclass,
- tp->getLayout()).font);
+ Style(buf->params.textclass,
+ tp->getLayout()).font,
+ buf->params.language);
}
}
- layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+ layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont(),
+ buf->params.language);
// Now, reduce font against full layout font
font.reduce(layoutfont);
else
layoutfont = getFont(bview->buffer(), cursor.par(),-1);
// Update current font
- real_current_font.update(font,
- bview->buffer()->params.language,
- toggleall);
+ real_current_font.update(font, toggleall);
// Reduce to implicit settings
current_font = real_current_font;
current_font.reduce(layoutfont);
// And resolve it completely
- real_current_font.realize(layoutfont);
+ real_current_font.realize(layoutfont,
+ bview->buffer()->params.language);
return;
}
// is disabled.
LyXCursor resetCursor = cursor;
bool implicitSelection = (font.language() == ignore_language
- && font.number() == LyXFont::IGNORE)
+ && font.number() == LyXFont::IGNORE)
? selectWordWhenUnderCursor(bview) : false;
// Set font