]> git.lyx.org Git - lyx.git/commitdiff
New lyxrc variables for the preview stuff.
authorAngus Leeming <leeming@lyx.org>
Wed, 10 Jul 2002 09:09:37 +0000 (09:09 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 10 Jul 2002 09:09:37 +0000 (09:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4580 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/scripts/lyxpreview2ppm.sh
src/ChangeLog
src/graphics/ChangeLog
src/graphics/PreviewLoader.C
src/graphics/Previews.C
src/lyxrc.C
src/lyxrc.h
src/mathed/ChangeLog

index 0461f8da205985809ae408a188c6772c7745e000..776f68aab7c70f3b66a7df1a0eeebac7a55ec972 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-09  Angus Leeming  <leeming@lyx.org>
+
+       * lyxpreview2ppm.sh: don't use latex option "-interaction=batchmode"
+       as it's not portable apparently.
 
 2002-07-09  André Pönitz <poenitz@gmx.net>
        
index 8c60f9efdb970ced63d001cab8fbb7d9c5a68add..54c090081f4fade1eb15e7b619f822854b79ac57 100644 (file)
@@ -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 <praveend@sasken.com>
-# 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
index 7fbb7d14843900a80528a267b3b8246d7075e584..4aac0bc4416852cfa251d147fbd625a833eb7e69 100644 (file)
@@ -1,3 +1,7 @@
+2002-07-09  Angus Leeming  <leeming@lyx.org>
+
+       * lyxrc.[Ch]: added preview_hashed_labels and preview_scale_factor.
+
 2002-07-09  John Levon  <moz@compsoc.man.ac.uk>
 
        * 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  <leeming@lyx.org>
index 785c90dc1354f19549b95ccf0f28fa5b6f097d02..04f5f55d847a535ba284be65a08f52be6bdc8fd7 100644 (file)
@@ -1,3 +1,10 @@
+2002-07-09  Angus Leeming  <leeming@lyx.org>
+
+       * 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  <leeming@lyx.org>
 
        * PreviewLoader.C: Further refactoring of the code. Should now be
index 52d9df010d7f75d2976e5c1d73ff20dc4e42729e..de8110f73a1af777c42267e32bb42332e28d89a4 100644 (file)
@@ -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())
index 99d49c1265868301acd9d634431c851586f51770..a69316d0a1a2b1f8451e2124b4f3107cec690c2e 100644 (file)
@@ -24,7 +24,6 @@
 
 #include <map>
 
-
 namespace grfx {
 
 bool Previews::activated()
index 331d0d39a86e8c12d4256bf8dafcda89166df46b..d089fce6fd2e551c8950f94fe26fb7ab7ed3915e 100644 (file)
@@ -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:
index e2ba9f14e46ebef78ddd9450979b24b70840dd31..71be05a29c969d17b5a98acff62cb681743672b5 100644 (file)
@@ -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;
index 938a74f62ae97594abe8840aa3ef4e3d0e3518f0..efada9d5b0c95b164cc310ffdb9b0d3ec5587197 100644 (file)
@@ -9,7 +9,7 @@
 2002-07-05  Angus Leeming  <leeming@lyx.org>
 
        * 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.