From 57a2087d37403e5f60837e8ecbd9268649c36bc2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Wed, 25 Jul 2001 19:45:21 +0000 Subject: [PATCH] some ert fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2346 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 1 - src/BufferView.h | 1 - src/ChangeLog | 6 +++++ src/insets/ChangeLog | 6 +++++ src/insets/insetert.C | 59 ++++++++++++++++-------------------------- src/insets/insetert.h | 2 ++ src/insets/insettext.C | 7 ++++- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 4caf746d95..3a2388f2ea 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -17,7 +17,6 @@ #include "BufferView.h" #include "BufferView_pimpl.h" #include "lyxtext.h" -#include "WorkArea.h" #include "lyxscreen.h" diff --git a/src/BufferView.h b/src/BufferView.h index 548306dbac..5610aa32c5 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -27,7 +27,6 @@ class LyXText; class TeXErrors; class Buffer; class LyXScreen; -class WorkArea; class Language; class Painter; class UpdatableInset; diff --git a/src/ChangeLog b/src/ChangeLog index b37a54c5cf..7d7f875dc0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2001-07-25 Lars Gullik Bjønnes + + * BufferView.h: don't forward declare WorkArea + + * BufferView.C: don't include WorkArea.h + 2001-07-25 André Pönitz * commandtags.h: diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 57a2c0825b..a2fd7445e8 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,5 +1,11 @@ 2001-07-25 Lars Gullik Bjønnes + * insettext.C (read): handle old latex end_inset + + * insetert.C (setButtonLabel): new method + (init): use it, to set the dynamic label correctly + (read): use it + * Makefile.am (EXTRA_DIST): add files that is not part or the binary here. diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 9ecca22ac5..4b2d281bc9 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -27,19 +27,12 @@ using std::ostream; void InsetERT::init() { -#if 0 - setLabel(_("666"), true); -#else - setLabel(_("666")); -#endif + setButtonLabel(); + labelfont = LyXFont(LyXFont::ALL_SANE); labelfont.decSize(); labelfont.decSize(); -#ifndef NO_LATEX - labelfont.setLatex(LyXFont::ON); -#else labelfont.setColor(LColor::latex); -#endif setInsetName("ERT"); } @@ -50,14 +43,6 @@ InsetERT::InsetERT() : InsetCollapsable() } -#if 0 -InsetERT::InsetERT(InsetERT const & in, bool same_id) - : InsetCollapsable(in, same_id) -{ -} -#endif - - InsetERT::InsetERT(string const & contents, bool collapsed) : InsetCollapsable(collapsed) { @@ -79,11 +64,8 @@ InsetERT::InsetERT(string const & contents, bool collapsed) void InsetERT::read(Buffer const * buf, LyXLex & lex) { InsetCollapsable::read(buf, lex); - if (collapsed_) { - setLabel(get_new_label()); - } else { - setLabel(_("666")); - } + + setButtonLabel(); } @@ -120,14 +102,11 @@ void InsetERT::setFont(BufferView *, LyXFont const &, bool, bool selectall) void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button) { InsetCollapsable::edit(bv, x, y, button); -#ifndef NO_LATEX - LyXFont font(LyXFont::ALL_SANE); - font.setLatex (LyXFont::ON); -#else + LyXFont font(LyXFont::ALL_INHERIT); font.setFamily(LyXFont::TYPEWRITER_FAMILY); font.setColor(LColor::latex); -#endif + inset.setFont(bv, font); } @@ -212,14 +191,9 @@ InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg) case LFUN_BREAKPARAGRAPH: case LFUN_BREAKPARAGRAPHKEEPLAYOUT: { -#ifndef NO_LATEX - LyXFont font(LyXFont::ALL_SANE); - font.setLatex (LyXFont::ON); -#else LyXFont font(LyXFont::ALL_INHERIT); font.setFamily(LyXFont::TYPEWRITER_FAMILY); font.setColor(LColor::latex); -#endif inset.setFont(bv, font); } break; @@ -236,18 +210,31 @@ string const InsetERT::get_new_label() const string la; Paragraph::size_type const max_length = 15; - int const n = std::min(max_length, inset.paragraph()->size()); + int const p_siz = inset.paragraph()->size(); + int const n = std::min(max_length, p_siz); int i = 0; int j = 0; - for(; i < n && j < inset.paragraph()->size(); ++j) { + for(; i < n && j < p_siz; ++j) { if (inset.paragraph()->isInset(j)) continue; la += inset.paragraph()->getChar(j); ++i; } - if ((i > 0) && (j < inset.paragraph()->size())) + if (i > 0 && j < p_siz) { la += "..."; - if (la.empty()) + } + if (la.empty()) { la = _("666"); + } return la; } + + +void InsetERT::setButtonLabel() +{ + if (collapsed_) { + setLabel(get_new_label()); + } else { + setLabel(_("666")); + } +} diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 935ecd9022..eed211de99 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -68,6 +68,8 @@ private: void init(); /// string const get_new_label() const; + /// + void setButtonLabel(); }; #endif diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 6d320824d7..a2870f1e65 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -237,8 +237,13 @@ void InsetText::read(Buffer const * buf, LyXLex & lex) token = lex.GetString(); if (token.empty()) continue; - if (token == "\\end_inset") + if (token == "\\end_inset") { +#ifdef NO_LATEX + const_cast(buf)->insertErtContents(par, pos, font, false); +#endif break; + } + if (const_cast(buf)-> parseSingleLyXformat2Token(lex, par, return_par, token, pos, depth, font)) { -- 2.39.2