New lyxrc variables for the preview stuff.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4580 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-07-10 09:09:37 +00:00
parent 3731a877b3
commit a0003fb2a8
9 changed files with 75 additions and 12 deletions

View 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> 2002-07-09 André Pönitz <poenitz@gmx.net>

View File

@ -7,8 +7,8 @@
# \author Angus Leeming, leeming@lyx.org # \author Angus Leeming, leeming@lyx.org
# #
# with much help from David Kastrup, david.kastrup@t-online.de. # 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> # The sed script was created with advice from Praveen D V, praveend@sasken.com
# and the sed users' list sed-users@yahoogroups.com. # and the sed users' list, sed-users@yahoogroups.com.
# This script takes a LaTeX file and generates PPM files, one per page. # 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 # 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. # Perform the conversion.
cd ${DIR} cd ${DIR}
latex -interaction=batchmode ${TEXFILE} latex ${TEXFILE}
STATUS=$? STATUS=$?
EXECUTABLE="latex ${TEXFILE}"; CHECK_STATUS EXECUTABLE="latex ${TEXFILE}"; CHECK_STATUS
@ -116,7 +115,7 @@ rm -f ${SEDSCRIPT}
EXECUTABLE="extracting metrics"; CHECK_STATUS EXECUTABLE="extracting metrics"; CHECK_STATUS
# The ppm files have spurious (?! say some !) white space on the left and right # 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 REMOVE_WS=0
which pnmcrop > /dev/null which pnmcrop > /dev/null

View 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> 2002-07-09 John Levon <moz@compsoc.man.ac.uk>
* lengthcommon.h: whitespace * lengthcommon.h: whitespace
@ -27,7 +31,7 @@
* LColor.C (LColor): add a corresponding entry to the items array. * 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. with this buffer.
2002-07-05 Angus Leeming <leeming@lyx.org> 2002-07-05 Angus Leeming <leeming@lyx.org>

View 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> 2002-07-09 Angus Leeming <leeming@lyx.org>
* PreviewLoader.C: Further refactoring of the code. Should now be * PreviewLoader.C: Further refactoring of the code. Should now be

View File

@ -397,6 +397,7 @@ void PreviewLoader::Impl::startLoading()
string const latexfile = filename_base + ".tex"; string const latexfile = filename_base + ".tex";
ofstream of(latexfile.c_str()); ofstream of(latexfile.c_str());
of << "\\batchmode\n";
dumpPreamble(of); dumpPreamble(of);
of << "\n\\begin{document}\n"; of << "\n\\begin{document}\n";
dumpData(of, inprogress.snippets); 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 // Use the preview style file to ensure that each snippet appears on a
// fresh page. // fresh page.
os << "\n" os << "\n"
@ -578,9 +584,8 @@ Converter const * setConverter()
double setFontScalingFactor(Buffer & buffer) double setFontScalingFactor(Buffer & buffer)
{ {
static double const lyxrc_preview_scale_factor = 0.9;
double scale_factor = 0.01 * lyxrc.dpi * lyxrc.zoom * double scale_factor = 0.01 * lyxrc.dpi * lyxrc.zoom *
lyxrc_preview_scale_factor; lyxrc.preview_scale_factor;
// Has the font size been set explicitly? // Has the font size been set explicitly?
string const & fontsize = buffer.params.fontsize; string const & fontsize = buffer.params.fontsize;
@ -614,7 +619,10 @@ double setFontScalingFactor(Buffer & buffer)
if (!prefixIs(frontStrip(str), "\\ExecuteOptions")) if (!prefixIs(frontStrip(str), "\\ExecuteOptions"))
continue; continue;
str = split(str, '{'); // str contains just the options of \ExecuteOptions
string const tmp = split(str, '{');
split(tmp, str, '}');
int count = 0; int count = 0;
string tok = token(str, ',', count++); string tok = token(str, ',', count++);
while (!isValidLength(tok) && !tok.empty()) while (!isValidLength(tok) && !tok.empty())

View File

@ -24,7 +24,6 @@
#include <map> #include <map>
namespace grfx { namespace grfx {
bool Previews::activated() bool Previews::activated()

View File

@ -96,6 +96,8 @@ keyword_item lyxrcTags[] = {
{ "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING }, { "\\popup_font_encoding", LyXRC::RC_POPUP_FONT_ENCODING },
{ "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT }, { "\\popup_normal_font", LyXRC::RC_POPUP_NORMAL_FONT },
{ "\\preview", LyXRC::RC_PREVIEW }, { "\\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_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
{ "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG }, { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
{ "\\print_command", LyXRC::RC_PRINT_COMMAND }, { "\\print_command", LyXRC::RC_PRINT_COMMAND },
@ -257,6 +259,8 @@ void LyXRC::setDefaults() {
dialogs_iconify_with_main = false; dialogs_iconify_with_main = false;
label_init_length = 3; label_init_length = 3;
preview = false; preview = false;
preview_hashed_labels = false;
preview_scale_factor = 0.9;
/// These variables are not stored on disk (perhaps they /// These variables are not stored on disk (perhaps they
// should be moved from the LyXRC class). // should be moved from the LyXRC class).
@ -949,6 +953,16 @@ int LyXRC::read(string const & filename)
preview = lexrc.getBool(); preview = lexrc.getBool();
break; 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 case RC_LAST: break; // this is just a dummy
} }
} }
@ -1133,6 +1147,19 @@ void LyXRC::output(ostream & os) const
os << "\\preview " << tostr(preview) << "\n"; 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" os << "\n#\n"
<< "# SCREEN & FONTS SECTION ############################\n" << "# SCREEN & FONTS SECTION ############################\n"
<< "#\n\n"; << "#\n\n";
@ -2001,7 +2028,15 @@ string const LyXRC::getDescription(LyXRCTags tag)
break; break;
case RC_PREVIEW: 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; break;
default: default:

View File

@ -121,6 +121,8 @@ enum LyXRCTags {
RC_LABEL_INIT_LENGTH, RC_LABEL_INIT_LENGTH,
RC_DISPLAY_GRAPHICS, RC_DISPLAY_GRAPHICS,
RC_PREVIEW, RC_PREVIEW,
RC_PREVIEW_HASHED_LABELS,
RC_PREVIEW_SCALE_FACTOR,
#ifdef USE_PSPELL #ifdef USE_PSPELL
RC_USE_PSPELL, RC_USE_PSPELL,
#endif #endif
@ -350,6 +352,11 @@ enum LyXRCTags {
bool show_banner; bool show_banner;
/// ///
bool preview; bool preview;
///
bool preview_hashed_labels;
///
int preview_scale_factor;
private: private:
/// Is a bind file already (or currently) read? /// Is a bind file already (or currently) read?
bool hasBindFile; bool hasBindFile;

View File

@ -9,7 +9,7 @@
2002-07-05 Angus Leeming <leeming@lyx.org> 2002-07-05 Angus Leeming <leeming@lyx.org>
* formula.[Ch] (generatePreview): instantiate new virtual method. * 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 makes full use of the graphics/Preview* files. Hide all the shenanigans
behind a PreviewImpl firewall. behind a PreviewImpl firewall.