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
This commit is contained in:
André Pönitz 2002-06-26 08:59:25 +00:00
parent a153642391
commit 9c1a896972
6 changed files with 69 additions and 32 deletions

View 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

View 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())
if (!graphic_.get() || status_ != grfx::WaitingToLoad)
return;
if (graphic_->status() != grfx::Loaded)
// 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;
if (status_ != grfx::WaitingToLoad)
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

View 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;
}

View 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;

View 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;

View 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 + ")");