From 9c1a8969724a2c87eee1e873c42977c85c24d272 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Wed, 26 Jun 2002 08:59:25 +0000 Subject: [PATCH] There is now a \preview lyxrc variable defaulting to 'false'. 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 | 5 +++++ src/frontends/screen.C | 31 +++++++++++-------------------- src/lyxrc.C | 28 ++++++++++++++++++++++++++++ src/lyxrc.h | 7 ++++++- src/mathed/formula.C | 16 ++++++++-------- src/mathed/preview.C | 14 +++++++++++--- 6 files changed, 69 insertions(+), 32 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 918ad1ceb9..925195eb49 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ + +2002-06-26 André Pönitz + + * lyxrc.[Ch]: introduce \preview, revive half-dead \show_banner + 2002-06-25 Angus Leeming * lyxfunc.C (dispatch): Comment out the call to diff --git a/src/frontends/screen.C b/src/frontends/screen.C index ce174f8f48..1d38beafcc 100644 --- a/src/frontends/screen.C +++ b/src/frontends/screen.C @@ -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 diff --git a/src/lyxrc.C b/src/lyxrc.C index 51d6d77775..331d0d39a8 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -43,6 +43,7 @@ extern boost::scoped_ptr 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; } diff --git a/src/lyxrc.h b/src/lyxrc.h index 4cd02e3eef..e2ba9f14e4 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -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; diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 8d745d9e98..df95abb12e 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -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; diff --git a/src/mathed/preview.C b/src/mathed/preview.C index bfb4caabef..7c53763307 100644 --- a/src/mathed/preview.C +++ b/src/mathed/preview.C @@ -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 + ")"); -- 2.39.2