]> git.lyx.org Git - lyx.git/commitdiff
autologofication cleanup from John
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 23 Nov 2001 09:59:01 +0000 (09:59 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 23 Nov 2001 09:59:01 +0000 (09:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3064 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView2.C
src/ChangeLog
src/paragraph_pimpl.C
src/paragraph_pimpl.h

index 58f73496e092c7abc742961b9d09661b8e36977b..8c73c998c2346c4f2f5fae506ecc9451df2d828b 100644 (file)
@@ -287,10 +287,12 @@ void BufferView::copy()
 {
        if (available()) {
                text->copySelection(this);
+#if 0
                // clear the selection, even if mark_set
                toggleSelection();
                text->clearSelection();
                update(text, BufferView::SELECT|BufferView::FITCUR);
+#endif
                owner()->message(_("Copy"));
        }
 }
index 5145638acf02087eb1021ed701f42e155315c376..965fe0566eb6a9f93a4e320202692e2268d4a40d 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-23  John Levon  <moz@compsoc.man.ac.uk>
+
+       * paragraph_pimpl.h:
+       * paragraph_pimpl.C: cleanup 
+        
 2001-11-22  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * text2.C (removeRow): 
index a2a31eb5fa3a627a49cb40a93f56231604dd6904..1c4e244197e09cc8a6977f62d9f0a9aeeeb3179b 100644 (file)
@@ -244,6 +244,18 @@ void Paragraph::Pimpl::simpleTeXBlanks(std::ostream & os, TexRow & texrow,
 }
 
 
+bool Paragraph::Pimpl::isTextAt(string const & str, Paragraph::size_type pos)
+{
+       for (int i=0; i < str.length(); ++i) {
+               if (pos + i >= size())
+                       return false;
+               if (str[i] != getChar(pos + i))
+                       return false;
+       }
+       return true;
+}
+
 void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                                             BufferParams const & bparams,
                                             std::ostream & os,
@@ -441,53 +453,32 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf,
                        break;
 
                default:
-                       /* idea for labels --- begin*/
-                       // Check for "LyX"
-                       if (c ==  'L'
-                           && i <= size() - 3
-                           && font.family() != LyXFont::TYPEWRITER_FAMILY
-                           && getChar(i + 1) == 'y'
-                           && getChar(i + 2) == 'X') {
+                       // I assume this is hack treating typewriter as verbatim
+                       if (font.family() == LyXFont::TYPEWRITER_FAMILY) {
+                               if (c != '\0') {
+                                       os << c;
+                               }
+                               break;
+                       }
+                               
+                       if (isTextAt("LyX", i)) {
                                os << "\\LyX{}";
                                i += 2;
                                column += 5;
-                       }
-                       // Check for "TeX"
-                       else if (c == 'T'
-                                && i <= size() - 3
-                                && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                && getChar(i + 1) == 'e'
-                                && getChar(i + 2) == 'X') {
+                       } else if (isTextAt("TeX", i)) {
                                os << "\\TeX{}";
                                i += 2;
                                column += 5;
-                       }
-                       // Check for "LaTeX2e"
-                       else if (c == 'L'
-                                && i <= size() - 7
-                                && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                && getChar(i + 1) == 'a'
-                                && getChar(i + 2) == 'T'
-                                && getChar(i + 3) == 'e'
-                                && getChar(i + 4) == 'X'
-                                && getChar(i + 5) == '2'
-                                && getChar(i + 6) == 'e') {
+                       } else if (isTextAt("LaTeX2e", i)) {
                                os << "\\LaTeXe{}";
                                i += 6;
                                column += 8;
-                       }
-                       // Check for "LaTeX"
-                       else if (c == 'L'
-                                && i <= size() - 5
-                                && font.family() != LyXFont::TYPEWRITER_FAMILY
-                                && getChar(i + 1) == 'a'
-                                && getChar(i + 2) == 'T'
-                                && getChar(i + 3) == 'e'
-                                && getChar(i + 4) == 'X') {
+                       } else if (isTextAt("LaTeX", i)) {
                                os << "\\LaTeX{}";
                                i += 4;
                                column += 7;
-                               /* idea for labels --- end*/ 
+                       // do we really try to print out '\0' ?
                        } else if (c != '\0') {
                                os << c;
                        }
@@ -545,25 +536,22 @@ LyXFont const Paragraph::Pimpl::realizeFont(LyXFont const & font,
        while (par && par->getDepth() && !tmpfont.resolved()) {
                par = par->outerHook();
                if (par) {
-#ifndef INHERIT_LANGUAGE
                        tmpfont.realize(textclasslist.
                                        Style(bparams.textclass,
-                                             par->getLayout()).font);
-#else
-                       tmpfont.realize(textclasslist.
-                                       Style(bparams.textclass,
-                                             par->getLayout()).font, bparams.language);
+                                             par->getLayout()).font
+#ifdef INHERIT_LANGUAGE
+                                       , bparams.language
 #endif
+                                       );
                        par_depth = par->getDepth();
                }
        }
 
-#ifndef INHERIT_LANGUAGE
-       tmpfont.realize(textclasslist.TextClass(bparams.textclass)
-                       .defaultfont());
-#else
        tmpfont.realize(textclasslist.TextClass(bparams.textclass)
-                       .defaultfont(), bparams.language);
+                       .defaultfont()
+#ifdef INHERIT_LANGUAGE
+               , bparams.language
 #endif
+               );
        return tmpfont; 
 }
index 8f6fc9547fecb723670e5424fcce5837d49f100c..bfc07e8377508c2a1d0df5f8f88a01ba80ecbf87 100644 (file)
@@ -151,6 +151,9 @@ struct Paragraph::Pimpl {
        ///
        ParagraphParameters params;
 private:
+       /// match a string against a particular point in the paragraph
+       bool isTextAt(string const & str, Paragraph::size_type pos);
        /// Who owns us?
        Paragraph * owner_;
        ///