From a0003fb2a80f594c965236eda8e178514c12127b Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Wed, 10 Jul 2002 09:09:37 +0000 Subject: [PATCH] New lyxrc variables for the preview stuff. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4580 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/ChangeLog | 4 ++++ lib/scripts/lyxpreview2ppm.sh | 9 ++++----- src/ChangeLog | 6 +++++- src/graphics/ChangeLog | 7 +++++++ src/graphics/PreviewLoader.C | 14 ++++++++++--- src/graphics/Previews.C | 1 - src/lyxrc.C | 37 ++++++++++++++++++++++++++++++++++- src/lyxrc.h | 7 +++++++ src/mathed/ChangeLog | 2 +- 9 files changed, 75 insertions(+), 12 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 0461f8da20..776f68aab7 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,7 @@ +2002-07-09 Angus Leeming + + * lyxpreview2ppm.sh: don't use latex option "-interaction=batchmode" + as it's not portable apparently. 2002-07-09 André Pönitz diff --git a/lib/scripts/lyxpreview2ppm.sh b/lib/scripts/lyxpreview2ppm.sh index 8c60f9efdb..54c090081f 100644 --- a/lib/scripts/lyxpreview2ppm.sh +++ b/lib/scripts/lyxpreview2ppm.sh @@ -7,8 +7,8 @@ # \author Angus Leeming, leeming@lyx.org # # with much help from David Kastrup, david.kastrup@t-online.de. -# The sed script was created with advice from Praveen D V -# and the sed users' list sed-users@yahoogroups.com. +# The sed script was created with advice from Praveen D V, praveend@sasken.com +# and the sed users' list, sed-users@yahoogroups.com. # This script takes a LaTeX file and generates PPM files, one per page. # The idea is to use it with preview.sty to create small bitmap previews of @@ -58,8 +58,7 @@ METRICS=${BASE}.metrics # Perform the conversion. cd ${DIR} -latex -interaction=batchmode ${TEXFILE} - +latex ${TEXFILE} STATUS=$? EXECUTABLE="latex ${TEXFILE}"; CHECK_STATUS @@ -116,7 +115,7 @@ rm -f ${SEDSCRIPT} EXECUTABLE="extracting metrics"; CHECK_STATUS # The ppm files have spurious (?! say some !) white space on the left and right -# sides. If you want this set REMOVE_WS=1. +# sides. If you want this removed set REMOVE_WS=1. REMOVE_WS=0 which pnmcrop > /dev/null diff --git a/src/ChangeLog b/src/ChangeLog index 7fbb7d1484..4aac0bc441 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2002-07-09 Angus Leeming + + * lyxrc.[Ch]: added preview_hashed_labels and preview_scale_factor. + 2002-07-09 John Levon * lengthcommon.h: whitespace @@ -27,7 +31,7 @@ * LColor.C (LColor): add a corresponding entry to the items array. - * buffer.C (~Buffer): remove any previewed LaTeX snippets assocoated + * buffer.C (~Buffer): remove any previewed LaTeX snippets associated with this buffer. 2002-07-05 Angus Leeming diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 785c90dc13..04f5f55d84 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,10 @@ +2002-07-09 Angus Leeming + + * PreviewLoader.C (startLoading): prepend LaTeX file with "\batchmode". + Output equation labels as "(#)" if lyxrc preference is set. + (setFontScalingFactor): use lyxrc variable preview_scale_factor + rather than hard-coding this. + 2002-07-09 Angus Leeming * PreviewLoader.C: Further refactoring of the code. Should now be diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index 52d9df010d..de8110f73a 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -397,6 +397,7 @@ void PreviewLoader::Impl::startLoading() string const latexfile = filename_base + ".tex"; ofstream of(latexfile.c_str()); + of << "\\batchmode\n"; dumpPreamble(of); of << "\n\\begin{document}\n"; dumpData(of, inprogress.snippets); @@ -494,6 +495,11 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const } } + // All equation lables appear as "(#)" + preview.sty's rendering of + // the label name + if (lyxrc.preview_hashed_labels) + os << "\\renewcommand{\\theequation}{\\#}\n"; + // Use the preview style file to ensure that each snippet appears on a // fresh page. os << "\n" @@ -578,9 +584,8 @@ Converter const * setConverter() double setFontScalingFactor(Buffer & buffer) { - static double const lyxrc_preview_scale_factor = 0.9; double scale_factor = 0.01 * lyxrc.dpi * lyxrc.zoom * - lyxrc_preview_scale_factor; + lyxrc.preview_scale_factor; // Has the font size been set explicitly? string const & fontsize = buffer.params.fontsize; @@ -614,7 +619,10 @@ double setFontScalingFactor(Buffer & buffer) if (!prefixIs(frontStrip(str), "\\ExecuteOptions")) continue; - str = split(str, '{'); + // str contains just the options of \ExecuteOptions + string const tmp = split(str, '{'); + split(tmp, str, '}'); + int count = 0; string tok = token(str, ',', count++); while (!isValidLength(tok) && !tok.empty()) diff --git a/src/graphics/Previews.C b/src/graphics/Previews.C index 99d49c1265..a69316d0a1 100644 --- a/src/graphics/Previews.C +++ b/src/graphics/Previews.C @@ -24,7 +24,6 @@ #include - namespace grfx { bool Previews::activated() diff --git a/src/lyxrc.C b/src/lyxrc.C index 331d0d39a8..d089fce6fd 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -96,6 +96,8 @@ keyword_item lyxrcTags[] = { { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING }, { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT }, { "\\preview", LyXRC::RC_PREVIEW }, + { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS }, + { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR }, { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT }, { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG }, { "\\print_command", LyXRC::RC_PRINT_COMMAND }, @@ -257,6 +259,8 @@ void LyXRC::setDefaults() { dialogs_iconify_with_main = false; label_init_length = 3; preview = false; + preview_hashed_labels = false; + preview_scale_factor = 0.9; /// These variables are not stored on disk (perhaps they // should be moved from the LyXRC class). @@ -949,6 +953,16 @@ int LyXRC::read(string const & filename) preview = lexrc.getBool(); break; + case RC_PREVIEW_HASHED_LABELS: + if (lexrc.next()) + preview_hashed_labels = lexrc.getBool(); + break; + + case RC_PREVIEW_SCALE_FACTOR: + if (lexrc.next()) + preview_hashed_labels = lexrc.getInteger(); + break; + case RC_LAST: break; // this is just a dummy } } @@ -1133,6 +1147,19 @@ void LyXRC::output(ostream & os) const os << "\\preview " << tostr(preview) << "\n"; } + case RC_PREVIEW_HASHED_LABELS: + if (preview_hashed_labels != + system_lyxrc.preview_hashed_labels) { + os << "\\preview_hashed_labels " + << tostr(preview_hashed_labels) << "\n"; + } + + case RC_PREVIEW_SCALE_FACTOR: + if (preview_scale_factor != system_lyxrc.preview_scale_factor) { + os << "\\preview_scale_factor " + << preview_scale_factor << "\n"; + } + os << "\n#\n" << "# SCREEN & FONTS SECTION ############################\n" << "#\n\n"; @@ -2001,7 +2028,15 @@ string const LyXRC::getDescription(LyXRCTags tag) break; case RC_PREVIEW: - str = _("Shows a typeset preview besides formulas"); + str = _("Shows a typeset preview of things such as math"); + break; + + case RC_PREVIEW_HASHED_LABELS: + str = _("Previewed equations will have \"(#)\" labels rather than numbered ones"); + break; + + case RC_PREVIEW_SCALE_FACTOR: + str = _("Scale the preview size to suit."); break; default: diff --git a/src/lyxrc.h b/src/lyxrc.h index e2ba9f14e4..71be05a29c 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -121,6 +121,8 @@ enum LyXRCTags { RC_LABEL_INIT_LENGTH, RC_DISPLAY_GRAPHICS, RC_PREVIEW, + RC_PREVIEW_HASHED_LABELS, + RC_PREVIEW_SCALE_FACTOR, #ifdef USE_PSPELL RC_USE_PSPELL, #endif @@ -350,6 +352,11 @@ enum LyXRCTags { bool show_banner; /// bool preview; + /// + bool preview_hashed_labels; + /// + int preview_scale_factor; + private: /// Is a bind file already (or currently) read? bool hasBindFile; diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 938a74f62a..efada9d5b0 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -9,7 +9,7 @@ 2002-07-05 Angus Leeming * formula.[Ch] (generatePreview): instantiate new virtual method. - Strip out the preliminary preview code and replace with new that + Strip out the preliminary preview code and replace with code that makes full use of the graphics/Preview* files. Hide all the shenanigans behind a PreviewImpl firewall. -- 2.39.5