mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +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,10 +317,12 @@ 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
|
||||
time this is the width of the workarea, but if there is a
|
||||
minipage somewhere, it will be the width of this minipage */
|
||||
//
|
||||
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;
|
||||
|
||||
protected:
|
||||
@ -529,7 +531,7 @@ public:
|
||||
///
|
||||
virtual bool searchBackward(BufferView *, string const &,
|
||||
bool = true, bool = false);
|
||||
|
||||
|
||||
protected:
|
||||
///
|
||||
void toggleCursorVisible() 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,7 +167,8 @@ void InsetERT::read(Buffer const * buf, LyXLex & lex)
|
||||
}
|
||||
par = par->next();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (!token_found) {
|
||||
if (collapsed_) {
|
||||
status(0, 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
|
||||
}
|
||||
|
||||
|
||||
@ -671,6 +677,18 @@ void InsetERT::close(BufferView * bv) const
|
||||
|
||||
string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,float &) const
|
||||
{
|
||||
bv->unlockInset(const_cast<InsetERT *>(this));
|
||||
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
|
||||
///
|
||||
|
@ -581,7 +581,7 @@ void LyXText::drawArabicComposeChar(DrawRowParams & p, pos_type & vpos)
|
||||
|
||||
|
||||
void LyXText::drawChars(DrawRowParams & p, pos_type & vpos,
|
||||
bool hebrew, bool arabic)
|
||||
bool hebrew, bool arabic)
|
||||
{
|
||||
pos_type pos = vis2log(vpos);
|
||||
pos_type const last = rowLastPrintable(p.row);
|
||||
|
11
src/text2.C
11
src/text2.C
@ -172,9 +172,10 @@ LyXFont const LyXText::getFont(Buffer const * buf, Paragraph * par,
|
||||
if (!par_depth) {
|
||||
if (layout.labeltype == LABEL_MANUAL
|
||||
&& pos < beginningOfMainBody(buf, par)) {
|
||||
// 1% goes here
|
||||
LyXFont f = par->getFontSettings(buf->params,
|
||||
pos);
|
||||
// 1% goes here
|
||||
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