mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 13:04:58 +00:00
This should clean up the language stuff a bit and a small new check for
inserting characters in insets (forced font change) which does not work as the method seems not to be called. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2366 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
811980f739
commit
d32d0cbb95
@ -1,3 +1,38 @@
|
||||
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.
|
||||
|
@ -187,7 +187,7 @@ bool CutAndPaste::copySelection(Paragraph * startpar, Paragraph * endpar,
|
||||
|
||||
|
||||
bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
|
||||
int & pos, char tc)
|
||||
int & pos, char tc)
|
||||
{
|
||||
if (!checkPastePossible(*par))
|
||||
return false;
|
||||
|
@ -89,8 +89,9 @@ void BufferParams::writeFile(ostream & os) const
|
||||
}
|
||||
|
||||
/* 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';
|
||||
|
||||
|
@ -129,7 +129,7 @@ void Roman(BufferView * bv)
|
||||
|
||||
void StyleReset(BufferView * bv)
|
||||
{
|
||||
LyXFont font(LyXFont::ALL_INHERIT, ignore_language);
|
||||
LyXFont font(LyXFont::ALL_INHERIT);
|
||||
ToggleAndShow(bv, font);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,16 @@
|
||||
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
|
||||
|
@ -287,6 +287,9 @@ public:
|
||||
#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:
|
||||
///
|
||||
@ -444,6 +447,9 @@ public:
|
||||
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
|
||||
///
|
||||
|
@ -79,13 +79,6 @@ InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id)
|
||||
}
|
||||
|
||||
|
||||
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())) {
|
||||
|
@ -46,8 +46,6 @@ public:
|
||||
///
|
||||
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;
|
||||
@ -70,7 +68,7 @@ public:
|
||||
///
|
||||
bool insertInset(BufferView *, Inset * inset);
|
||||
///
|
||||
bool insetAllowed(Inset::Code code) const {
|
||||
virtual bool insetAllowed(Inset::Code code) const {
|
||||
return inset.insetAllowed(code);
|
||||
}
|
||||
///
|
||||
@ -203,6 +201,9 @@ public:
|
||||
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:
|
||||
///
|
||||
|
@ -28,7 +28,6 @@ using std::ostream;
|
||||
void InsetERT::init()
|
||||
{
|
||||
setButtonLabel();
|
||||
|
||||
labelfont = LyXFont(LyXFont::ALL_SANE);
|
||||
labelfont.decSize();
|
||||
labelfont.decSize();
|
||||
@ -43,6 +42,19 @@ InsetERT::InsetERT() : InsetCollapsable()
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@ -238,3 +250,13 @@ void InsetERT::setButtonLabel()
|
||||
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;
|
||||
}
|
||||
|
@ -30,8 +30,14 @@ public:
|
||||
///
|
||||
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;
|
||||
@ -63,6 +69,9 @@ public:
|
||||
///
|
||||
UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
|
||||
string const &);
|
||||
///
|
||||
bool checkInsertChar(LyXFont &);
|
||||
|
||||
private:
|
||||
///
|
||||
void init();
|
||||
|
@ -32,6 +32,20 @@ InsetFoot::InsetFoot()
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
@ -28,6 +28,10 @@ public:
|
||||
///
|
||||
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;
|
||||
|
@ -29,9 +29,17 @@ InsetFootlike::InsetFootlike()
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,8 @@ public:
|
||||
///
|
||||
InsetFootlike();
|
||||
///
|
||||
InsetFootlike(InsetFootlike const &, bool same_id = false);
|
||||
///
|
||||
void write(Buffer const * buf, std::ostream & os) const;
|
||||
///
|
||||
bool insetAllowed(Inset::Code) const;
|
||||
|
@ -32,6 +32,20 @@ InsetMarginal::InsetMarginal()
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
|
@ -26,6 +26,10 @@ public:
|
||||
///
|
||||
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;
|
||||
|
@ -33,11 +33,7 @@ void InsetNote::init()
|
||||
font.decSize();
|
||||
font.setColor(LColor::note);
|
||||
setLabelFont(font);
|
||||
#if 0
|
||||
setAutoCollapse(false);
|
||||
#endif
|
||||
setBackgroundColor(LColor::note);
|
||||
|
||||
setLabel(_("note"));
|
||||
setInsetName("Note");
|
||||
}
|
||||
@ -50,6 +46,19 @@ InsetNote::InsetNote()
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
@ -25,6 +25,10 @@ class InsetNote : public InsetCollapsable {
|
||||
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);
|
||||
///
|
||||
|
@ -1801,7 +1801,7 @@ LyXText * InsetText::getLyXText(BufferView const * lbv,
|
||||
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 {
|
||||
|
@ -29,6 +29,8 @@ Language const * english_language;
|
||||
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()
|
||||
{
|
||||
|
@ -116,5 +116,6 @@ extern Languages languages;
|
||||
extern Language const * default_language;
|
||||
extern Language const * english_language;
|
||||
extern Language const * ignore_language;
|
||||
extern Language const * inherit_language;
|
||||
|
||||
#endif
|
||||
|
@ -775,9 +775,9 @@ bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
|
||||
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;
|
||||
@ -938,7 +938,8 @@ bool LyXTextClass::Read(string const & filename, bool merge)
|
||||
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;
|
||||
|
||||
|
@ -169,7 +169,7 @@ bool LyXFont::FontBits::operator!=(LyXFont::FontBits const & fb1) const
|
||||
|
||||
|
||||
LyXFont::LyXFont(LyXFont::FONT_INIT1)
|
||||
: bits(inherit), lang(ignore_language)
|
||||
: bits(inherit), lang(inherit_language)
|
||||
{}
|
||||
|
||||
|
||||
@ -409,8 +409,7 @@ LyXFont::FONT_MISC_STATE LyXFont::setMisc(FONT_MISC_STATE newfont,
|
||||
|
||||
|
||||
/// 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'
|
||||
@ -459,10 +458,7 @@ void LyXFont::update(LyXFont const & newfont,
|
||||
|
||||
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());
|
||||
|
||||
@ -496,12 +492,24 @@ void LyXFont::reduce(LyXFont const & tmplt)
|
||||
#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;
|
||||
@ -550,7 +558,8 @@ bool LyXFont::resolved() const
|
||||
#ifndef NO_LATEX
|
||||
latex() != INHERIT &&
|
||||
#endif
|
||||
color() != LColor::inherit);
|
||||
color() != LColor::inherit &&
|
||||
language() != inherit_language);
|
||||
}
|
||||
|
||||
|
||||
@ -762,7 +771,8 @@ LyXFont & LyXFont::lyxRead(LyXLex & lex)
|
||||
|
||||
|
||||
/// 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()) {
|
||||
@ -829,7 +839,9 @@ void LyXFont::lyxWriteChanges(LyXFont const & orgfont, ostream & os) const
|
||||
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";
|
||||
@ -936,7 +948,7 @@ int LyXFont::latexWriteStartChanges(ostream & os, LyXFont const & base,
|
||||
// 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;
|
||||
|
@ -262,16 +262,14 @@ public:
|
||||
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;
|
||||
@ -280,7 +278,8 @@ public:
|
||||
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
|
||||
|
@ -164,8 +164,8 @@ Paragraph::~Paragraph()
|
||||
|
||||
|
||||
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()) {
|
||||
@ -251,7 +251,7 @@ void Paragraph::writeFile(Buffer const * buf, ostream & os,
|
||||
// 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;
|
||||
}
|
||||
@ -349,6 +349,10 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
||||
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;
|
||||
@ -358,7 +362,10 @@ void Paragraph::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
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;
|
||||
@ -434,8 +441,11 @@ bool Paragraph::insertFromMinibuffer(Paragraph::size_type pos)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -458,6 +468,14 @@ void Paragraph::erase(Paragraph::size_type pos)
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@ -550,7 +568,7 @@ Inset const * Paragraph::getInset(Paragraph::size_type pos) const
|
||||
|
||||
// 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());
|
||||
|
||||
@ -558,13 +576,17 @@ LyXFont const Paragraph::getFontSettings(BufferParams const & bparams,
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@ -605,7 +627,7 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
|
||||
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)
|
||||
@ -623,14 +645,14 @@ LyXFont const Paragraph::getFont(BufferParams const & bparams,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1235,6 +1257,8 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
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",
|
||||
@ -1244,13 +1268,14 @@ 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;
|
||||
texrow.newline();
|
||||
}
|
||||
|
||||
|
||||
switch (style.latextype) {
|
||||
case LATEX_COMMAND:
|
||||
os << '\\'
|
||||
@ -1295,8 +1320,9 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
|
||||
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());
|
||||
@ -1550,15 +1576,24 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf,
|
||||
|
||||
// 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.
|
||||
@ -1794,9 +1829,13 @@ bool Paragraph::isWord(size_type pos ) const
|
||||
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;
|
||||
@ -1828,7 +1867,9 @@ bool Paragraph::isMultiLingual(BufferParams const & bparams)
|
||||
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;
|
||||
}
|
||||
|
@ -268,6 +268,8 @@ public:
|
||||
///
|
||||
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 &);
|
||||
|
@ -564,6 +564,11 @@ void LyXText::draw(BufferView * bview, Row const * row,
|
||||
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;
|
||||
|
41
src/text2.C
41
src/text2.C
@ -113,7 +113,7 @@ LyXText::~LyXText()
|
||||
// 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());
|
||||
@ -128,10 +128,10 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
// 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 {
|
||||
@ -158,7 +158,7 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
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
|
||||
@ -174,12 +174,14 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
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;
|
||||
}
|
||||
@ -191,7 +193,7 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par,
|
||||
{
|
||||
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);
|
||||
@ -224,12 +226,14 @@ void LyXText::setCharFont(BufferView * bv, Paragraph * par,
|
||||
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);
|
||||
@ -266,12 +270,14 @@ void LyXText::setCharFont(Buffer const * buf, Paragraph * par,
|
||||
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);
|
||||
@ -674,15 +680,14 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -1034,7 +1039,7 @@ void LyXText::toggleFree(BufferView * bview,
|
||||
// is disabled.
|
||||
LyXCursor resetCursor = cursor;
|
||||
bool implicitSelection = (font.language() == ignore_language
|
||||
&& font.number() == LyXFont::IGNORE)
|
||||
&& font.number() == LyXFont::IGNORE)
|
||||
? selectWordWhenUnderCursor(bview) : false;
|
||||
|
||||
// Set font
|
||||
|
Loading…
Reference in New Issue
Block a user