mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Fix for #143. Changed handling of Font stuff for ERTInsets so that the
latex fonts are not really set but only displayed on screen. So we fixed the problem of cut&paste in and out of ERT insets retaining the latex color and font. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3576 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0e87319e51
commit
9443f625d8
@ -9,6 +9,7 @@ src/converter.C
|
||||
src/CutAndPaste.C
|
||||
src/debug.C
|
||||
src/exporter.C
|
||||
src/ext_l10n.h
|
||||
src/figure_form.C
|
||||
src/figureForm.C
|
||||
src/FontLoader.C
|
||||
|
@ -219,11 +219,11 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
|
||||
if (pos > (*par)->size())
|
||||
pos = (*par)->size();
|
||||
|
||||
#if 0
|
||||
// Paragraph * tmpbuf;
|
||||
Paragraph * tmppar = *par;
|
||||
int tmppos = pos;
|
||||
|
||||
#if 0
|
||||
// There are two cases: cutbuffer only one paragraph or many
|
||||
if (!buf->next()) {
|
||||
// only within a paragraph
|
||||
|
@ -406,7 +406,7 @@ void Buffer::insertErtContents(Paragraph * par, int & pos, bool set_inactive)
|
||||
if (!ert_comp.contents.empty()) {
|
||||
lyxerr[Debug::INSETS] << "ERT contents:\n'"
|
||||
<< ert_comp.contents << "'" << endl;
|
||||
Inset * inset = new InsetERT(ert_comp.contents, true);
|
||||
Inset * inset = new InsetERT(params.language, ert_comp.contents, true);
|
||||
par->insertInset(pos++, inset, ert_comp.font);
|
||||
ert_comp.contents.erase();
|
||||
}
|
||||
|
@ -317,8 +317,10 @@ public:
|
||||
// if this inset has paragraphs should they be output all as default
|
||||
// paragraphs with "Standard" layout?
|
||||
virtual bool forceDefaultParagraphs(Inset const *) const;
|
||||
// needed for widths which are % of something
|
||||
/* returns the value of \textwidth in this inset. Most of the
|
||||
//
|
||||
virtual void getDrawFont(LyXFont &) const {}
|
||||
/* needed for widths which are % of something
|
||||
returns the value of \textwidth in this inset. Most of the
|
||||
time this is the width of the workarea, but if there is a
|
||||
minipage somewhere, it will be the width of this minipage */
|
||||
virtual int latexTextWidth(BufferView *) const;
|
||||
|
@ -75,20 +75,20 @@ Inset * InsetERT::clone(Buffer const &, bool same_id) const
|
||||
}
|
||||
|
||||
|
||||
InsetERT::InsetERT(string const & contents, bool collapsed)
|
||||
InsetERT::InsetERT(Language const * l, string const & contents, bool collapsed)
|
||||
: InsetCollapsable(collapsed)
|
||||
{
|
||||
if (collapsed)
|
||||
status_ = Collapsed;
|
||||
else
|
||||
status_ = Open;
|
||||
#ifndef INHERIT_LANG
|
||||
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
|
||||
#else
|
||||
LyXFont font(LyXFont::ALL_INHERIT);
|
||||
#endif
|
||||
|
||||
LyXFont font(LyXFont::ALL_INHERIT, l);
|
||||
#ifdef SET_HARD_FONT
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
#endif
|
||||
|
||||
string::const_iterator cit = contents.begin();
|
||||
string::const_iterator end = contents.end();
|
||||
pos_type pos = 0;
|
||||
@ -151,12 +151,12 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex)
|
||||
#endif
|
||||
inset.read(buf, lex);
|
||||
|
||||
#ifdef SET_HARD_FONT
|
||||
#ifndef INHERIT_LANG
|
||||
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
|
||||
#else
|
||||
LyXFont font(LyXFont::ALL_INHERIT);
|
||||
#endif
|
||||
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
Paragraph * par = inset.paragraph();
|
||||
@ -167,6 +167,7 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex)
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!token_found) {
|
||||
if (collapsed_) {
|
||||
@ -511,8 +512,9 @@ void InsetERT::setButtonLabel() const
|
||||
}
|
||||
|
||||
|
||||
bool InsetERT::checkInsertChar(LyXFont & font)
|
||||
bool InsetERT::checkInsertChar(LyXFont & /* font */)
|
||||
{
|
||||
#ifdef SET_HARD_FONT
|
||||
#ifndef INHERIT_LANG
|
||||
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
|
||||
#else
|
||||
@ -521,6 +523,7 @@ bool InsetERT::checkInsertChar(LyXFont & font)
|
||||
font = f;
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -603,8 +606,9 @@ void InsetERT::draw(BufferView * bv, LyXFont const & f,
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::set_latex_font(BufferView * bv)
|
||||
void InsetERT::set_latex_font(BufferView * /* bv */)
|
||||
{
|
||||
#ifdef SET_HARD_FONT
|
||||
#ifndef INHERIT_LANG
|
||||
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
|
||||
#else
|
||||
@ -613,7 +617,9 @@ void InsetERT::set_latex_font(BufferView * bv)
|
||||
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
|
||||
inset.getLyXText(bv)->setFont(bv, font, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -674,3 +680,15 @@ string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,float &) const
|
||||
bv->unlockInset(const_cast<InsetERT *>(this));
|
||||
return string();
|
||||
}
|
||||
|
||||
void InsetERT::getDrawFont(LyXFont & font) const
|
||||
{
|
||||
#ifndef INHERIT_LANG
|
||||
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
|
||||
#else
|
||||
LyXFont f(LyXFont::ALL_INHERIT);
|
||||
#endif
|
||||
font = f;
|
||||
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
|
||||
font.setColor(LColor::latex);
|
||||
}
|
||||
|
@ -29,6 +29,9 @@
|
||||
Note that collapsed_ encompasses both the inline and collapsed button
|
||||
versions of this inset.
|
||||
*/
|
||||
|
||||
class Language;
|
||||
|
||||
class InsetERT : public InsetCollapsable {
|
||||
public:
|
||||
///
|
||||
@ -44,7 +47,7 @@ public:
|
||||
///
|
||||
Inset * clone(Buffer const &, bool same_id = false) const;
|
||||
///
|
||||
InsetERT(string const & contents, bool collapsed);
|
||||
InsetERT(Language const *, string const & contents, bool collapsed);
|
||||
///
|
||||
~InsetERT();
|
||||
///
|
||||
@ -123,6 +126,8 @@ public:
|
||||
///
|
||||
bool showInsetDialog(BufferView *) const;
|
||||
///
|
||||
void getDrawFont(LyXFont &) const;
|
||||
///
|
||||
bool forceDefaultParagraphs(Inset const *) const {
|
||||
return true;
|
||||
}
|
||||
|
@ -2627,3 +2627,11 @@ void InsetText::collapseParagraphs(BufferParams const & bparams) const
|
||||
}
|
||||
reinitLyXText();
|
||||
}
|
||||
|
||||
|
||||
void InsetText::getDrawFont(LyXFont & font) const
|
||||
{
|
||||
if (!owner())
|
||||
return;
|
||||
owner()->getDrawFont(font);
|
||||
}
|
||||
|
@ -246,6 +246,8 @@ public:
|
||||
///
|
||||
bool checkInsertChar(LyXFont &);
|
||||
///
|
||||
void getDrawFont(LyXFont &) const;
|
||||
///
|
||||
//
|
||||
// Public structures and variables
|
||||
///
|
||||
|
@ -173,8 +173,9 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
if (layout.labeltype == LABEL_MANUAL
|
||||
&& pos < beginningOfMainBody(buf, par)) {
|
||||
// 1% goes here
|
||||
LyXFont f = par->getFontSettings(buf->params,
|
||||
pos);
|
||||
LyXFont f = par->getFontSettings(buf->params, pos);
|
||||
if (par->inInset())
|
||||
par->inInset()->getDrawFont(f);
|
||||
#ifndef INHERIT_LANGUAGE
|
||||
return f.realize(layout.reslabelfont);
|
||||
#else
|
||||
@ -182,6 +183,8 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
#endif
|
||||
} else {
|
||||
LyXFont f = par->getFontSettings(buf->params, pos);
|
||||
if (par->inInset())
|
||||
par->inInset()->getDrawFont(f);
|
||||
#ifndef INHERIT_LANGUAGE
|
||||
return f.realize(layout.resfont);
|
||||
#else
|
||||
@ -208,6 +211,8 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
#else
|
||||
tmpfont.realize(layoutfont, buf->params.language);
|
||||
#endif
|
||||
if (par->inInset())
|
||||
par->inInset()->getDrawFont(tmpfont);
|
||||
|
||||
return realizeFont(tmpfont, buf, par);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user