]> git.lyx.org Git - lyx.git/commitdiff
There is now a \preview lyxrc variable defaulting to 'false'.
authorAndré Pönitz <poenitz@gmx.net>
Wed, 26 Jun 2002 08:59:25 +0000 (08:59 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 26 Jun 2002 08:59:25 +0000 (08:59 +0000)
Would be nice if someone would make this available in the preferences
dialog.

And this incorporates Herberts' patch to use pdfLaTeX which means
we are approaching TeXMacs ballpark of sluggishness...

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4484 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/frontends/screen.C
src/lyxrc.C
src/lyxrc.h
src/mathed/formula.C
src/mathed/preview.C

index 918ad1ceb9254923da8a528f6864c52468212cc1..925195eb49d6f9681a565785d114ae314419961d 100644 (file)
@@ -1,3 +1,8 @@
+
+2002-06-26  André Pönitz <poenitz@gmx.net>
+
+       * lyxrc.[Ch]: introduce \preview, revive half-dead \show_banner
+
 2002-06-25  Angus Leeming  <leeming@lyx.org>
 
        * lyxfunc.C (dispatch): Comment out the call to
index ce174f8f48ad0f0048d4bc9be8cc2c7571b1d952..1d38beafcc0aa1b4a3b588820808c734a645058f 100644 (file)
@@ -50,7 +50,7 @@ public:
        /// This is a singleton class. Get the instance.
        static SplashScreen const & get();
        ///
-       grfx::GImage const * image() const { return image_.get(); }
+       grfx::GImage const * image() const { return graphic_->image().get(); }
        ///
        string const & text() const { return text_; }
        ///
@@ -73,10 +73,6 @@ private:
         *  erased unexpectedly by the cache itself.
         */
        grfx::GraphicPtr graphic_;
-       /** We generate a pixmap from a copy of the grfx::GImage * stored in
-        *  the cache.
-        */
-       grfx::ImagePtr image_;
        /// The loading status of the image.
        grfx::ImageStatus status_;
        /// The text to be written on top of the pixmap
@@ -140,27 +136,22 @@ SplashScreen::~SplashScreen()
 
 void SplashScreen::createPixmap()
 {
-       if (!graphic_.get() || image_.get())
-               return;
-
-       if (graphic_->status() != grfx::Loaded)
+       if (!graphic_.get() || status_ != grfx::WaitingToLoad)
                return;
 
-       if (status_ != grfx::WaitingToLoad)
+       // We aren't going to modify the image, so don't bother making a
+       // local copy
+       grfx::GImage * const image = graphic_->image().get();
+       if (!image)
                return;
 
-       // Strictly speaking, we need to create a copy only if we're going to
-       // modify the image (scale, etc).
-       image_.reset(graphic_->image()->clone());
-       
-       bool const success = image_->setPixmap(grfx::GParams());
-
-       if (success) {
+       if (image->getPixmap()) {
                status_ = grfx::Loaded;
-       } else {
-               image_.reset();
-               status_ = grfx::ErrorScalingEtc;
+               return;
        }
+
+       bool const success = image->setPixmap(grfx::GParams());
+       status_ = success ? grfx::Loaded : grfx::ErrorLoading;
 }
 
 } // namespace anon
index 51d6d777759125eb12d216a52cb7949277ae4c74..331d0d39a86e8c12d4256bf8dafcda89166df46b 100644 (file)
@@ -43,6 +43,7 @@ extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
 
 namespace {
 
+// when adding something to this array keep it sorted!
 keyword_item lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
        { "\\alternate_language", LyXRC::RC_ALT_LANG },
@@ -94,6 +95,7 @@ keyword_item lyxrcTags[] = {
        { "\\popup_bold_font", LyXRC::RC_POPUP_BOLD_FONT },
        { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
        { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
+       { "\\preview", LyXRC::RC_PREVIEW },
        { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
        { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
        { "\\print_command", LyXRC::RC_PRINT_COMMAND },
@@ -130,6 +132,7 @@ keyword_item lyxrcTags[] = {
        { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
        { "\\serverpipe", LyXRC::RC_SERVERPIPE },
        { "\\set_color", LyXRC::RC_SET_COLOR },
+       { "\\show_banner", LyXRC::RC_SHOW_BANNER },
        { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
        { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
        { "\\template_path", LyXRC::RC_TEMPLATEPATH },
@@ -253,6 +256,7 @@ void LyXRC::setDefaults() {
        cursor_follows_scrollbar = false;
        dialogs_iconify_with_main = false;
        label_init_length = 3;
+       preview = false;
 
        /// These variables are not stored on disk (perhaps they
        // should be moved from the LyXRC class).
@@ -935,6 +939,16 @@ int LyXRC::read(string const & filename)
                                label_init_length = lexrc.getInteger();
                        break;
 
+               case RC_SHOW_BANNER:
+                       if (lexrc.next())
+                               show_banner = lexrc.getBool();
+                       break;
+
+               case RC_PREVIEW:
+                       if (lexrc.next())
+                               preview = lexrc.getBool();
+                       break;
+
                case RC_LAST: break; // this is just a dummy
                }
        }
@@ -1109,6 +1123,16 @@ void LyXRC::output(ostream & os) const
                           << "\n";
                }
 
+       case RC_SHOW_BANNER:
+               if (show_banner != system_lyxrc.show_banner) {
+                       os << "\\show_banner " << tostr(show_banner) << "\n";
+               }
+
+       case RC_PREVIEW:
+               if (preview != system_lyxrc.preview) {
+                       os << "\\preview " << tostr(preview) << "\n";
+               }
+
                os << "\n#\n"
                   << "# SCREEN & FONTS SECTION ############################\n"
                   << "#\n\n";
@@ -1976,6 +2000,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("Maximum number of words in the initialization string for a new label");
                break;
 
+       case RC_PREVIEW:
+               str = _("Shows a typeset preview besides formulas");
+               break;
+
        default:
                break;
        }
index 4cd02e3eefbffa59b47a2f1c0e9ff554efcdea8b..e2ba9f14e46ebef78ddd9450979b24b70840dd31 100644 (file)
@@ -120,6 +120,7 @@ enum LyXRCTags {
        RC_DEFAULT_LANGUAGE,
        RC_LABEL_INIT_LENGTH,
        RC_DISPLAY_GRAPHICS,
+       RC_PREVIEW,
 #ifdef USE_PSPELL
        RC_USE_PSPELL,
 #endif
@@ -132,7 +133,7 @@ enum LyXRCTags {
        ///
        void setDefaults();
        ///
-       int read (string const & filename);
+       int read(string const & filename);
        ///
        void readBindFileIfNeeded();
        ///
@@ -345,6 +346,10 @@ enum LyXRCTags {
        int label_init_length;
        ///
        string display_graphics;
+       ///
+       bool show_banner;
+       ///
+       bool preview;
 private:
        /// Is a bind file already (or currently) read?
        bool hasBindFile;
index 8d745d9e98f2a69617abf6ff42de8fb8bfb60d61..df95abb12ea3240f499acaaee4394b165b528e30 100644 (file)
@@ -188,15 +188,15 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
        par_->draw(pi, x, y);
 
        // preview stuff
-#if 0
-       ostringstream os;
-       WriteStream wi(os, false, false);
-       par_->write(wi);
-       if (preview(os.str(), preview_)) {
-               cerr << "image could be drawn\n";
-               pi.pain.image(x + 40, y, 50, 50, *(preview_->image()));
+       if (lyxrc.preview) {
+               ostringstream os;
+               WriteStream wi(os, false, false);
+               par_->write(wi);
+               if (preview(os.str(), preview_)) {
+                       cerr << "image could be drawn\n";
+                       pi.pain.image(x + 40, y, 50, 50, *(preview_->image()));
+               }
        }
-#endif
 
        xx += par_->width();
        xo_ = x;
index bfb4caabef9f6eb9a5a55984de9b82479cfd97fd..7c5376330783366d8a4b141fd956b58211ac9d7c 100644 (file)
@@ -48,7 +48,9 @@ bool preview(string const & str, grfx::GraphicPtr & graphic)
                if (gr->status() == grfx::Loaded) {
                        cerr << "file '" << file << "' ready for display\n";
                        graphic = gr;
-                       return graphic->image()->setPixmap(grfx::GParams());
+                       grfx::GParams pars;
+                       bool const res = graphic->image()->setPixmap(pars);
+                       return res;
                }
 
                // otherwise we have to wait again
@@ -59,16 +61,22 @@ bool preview(string const & str, grfx::GraphicPtr & graphic)
        // The real work starts.
        string const texfile = dir + base + ".tex";
        std::ofstream of(texfile.c_str());
-       of << "\\documentclass{article}"
+       of << "\\batchmode"
+          << "\\documentclass{article}"
           << "\\usepackage{amssymb}"
           << "\\thispagestyle{empty}"
+          << "\\pdfoutput=0"
           << "\\begin{document}"
           << str
           << "\\end{document}\n";
        of.close();
 
        string const cmd =
-               "latex " + base + ".tex ; dvips -E -o " + base + ".eps " + base + ".dvi ";
+//             "latex " + base + ".tex ; " + "
+//    "dvips -x 2500 -R -E -o " + base + ".eps " + base + ".dvi ";
+       // Herbert says this is faster
+               "pdflatex --interaction batchmode " + base + "; " +
+               "dvips -x 2000 -R -E -o " + base + ".eps " + base + ".dvi ";
        //cerr << "calling: '" << "(cd " + dir + "; " + cmd + ")\n";
        Systemcall sc;
        sc.startscript(Systemcall::Wait, "(cd " + dir + "; " + cmd + ")");