]> git.lyx.org Git - features.git/commitdiff
some ert fixes
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 25 Jul 2001 19:45:21 +0000 (19:45 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 25 Jul 2001 19:45:21 +0000 (19:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2346 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/BufferView.h
src/ChangeLog
src/insets/ChangeLog
src/insets/insetert.C
src/insets/insetert.h
src/insets/insettext.C

index 4caf746d9521d7ed8ba3cd41aae0ae0818339e50..3a2388f2eaa7f3c276a647062c78b3e658bf5beb 100644 (file)
@@ -17,7 +17,6 @@
 #include "BufferView.h"
 #include "BufferView_pimpl.h"
 #include "lyxtext.h"
-#include "WorkArea.h"
 #include "lyxscreen.h"
 
 
index 548306dbac80fb9af1fb991ec66b5ab2189f6fd9..5610aa32c5d066d6b7b39aa15863048e3f60e799 100644 (file)
@@ -27,7 +27,6 @@ class LyXText;
 class TeXErrors;
 class Buffer;
 class LyXScreen;
-class WorkArea;
 class Language;
 class Painter;
 class UpdatableInset;
index b37a54c5cf50261ae1cf5c0e04173c356495f740..7d7f875dc03afb6804ad0fe3ac4ecd1bc79adcf2 100644 (file)
@@ -1,3 +1,9 @@
+2001-07-25  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * BufferView.h: don't forward declare WorkArea
+
+       * BufferView.C: don't include WorkArea.h
+
 2001-07-25  André Pönitz <poenitz@gmx.net>
 
        * commandtags.h:
index 57a2c0825bc0c0bb088c5b8e99a3ea939e10b3e4..a2fd7445e8e43d301a012058631627df66d4cf7b 100644 (file)
@@ -1,5 +1,11 @@
 2001-07-25  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
+       * 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.
 
index 9ecca22ac56abda724c807d1fcf7d5fdf72b3801..4b2d281bc9ffdce478f4cbbdb4b65c9075642f8b 100644 (file)
@@ -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"));
+       }
+}
index 935ecd9022e083f709f4ac8813dc2ded2aefc75f..eed211de9943f4d3ad3a60dc28dc5ca9b815200b 100644 (file)
@@ -68,6 +68,8 @@ private:
        void init();
        ///
        string const get_new_label() const;
+       ///
+       void setButtonLabel();
 };
 
 #endif
index 6d320824d7d5dcd24f7fa42e42aa9f752b2d6375..a2870f1e65dc0da4b2c41d3325d1267e1325384c 100644 (file)
@@ -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<Buffer*>(buf)->insertErtContents(par, pos, font, false);
+#endif
                        break;
+               }
+               
                if (const_cast<Buffer*>(buf)->
                        parseSingleLyXformat2Token(lex, par, return_par,
                                                   token, pos, depth, font)) {