+2000-02-15 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
+
+ * src/lyxfunc.C (Dispatch): fix LFUN_LAYOUT when giving a
+ nonexisting layout; correctly redirect obsoleted layouts.
+
+ * lib/lyxrc.example: document \view_dvi_paper_option
+
+ * src/lyxrc.[Ch]: add support for the \view_dvi_paper_option
+ variable.
+
+ * src/lyx_cb.C (RunScript): handle $$FName for command names.
+ (PreviewDVI): handle the view_dvi_paper_option variable.
+ [Both from Roland Krause]
+
2000-02-14 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/Painter.C (text(int,int,char,LyXFont)): call text(int, int,
# Define which program to use to view dvi files here.
# You can include any options you need by "quoting" the entire command.
-# You don't need to specify the paper-size and orientation, which is done
-# automatically by LyX (hence, your viewer has to interpret the -paper
-# option like xdvi does)
# The default is "xdvi".
# Example: the next line would use xdvi and display with shrink 2:
#\view_dvi_command "xdvi -s 2"
# It can get more involved. Expert users might prefer something like:
#\view_dvi_command "xdvi -s 2 -expert -geometry 1014x720+0+0 -keep -margins 1.5"
+# \view_dvi_paper_option allows to specify a paper option to the dvi
+# viewer. By default LyX specifies the paper size of the document to
+# the dvi viewer via the command line option -paper size, where size
+# is one of "us","letter","a3","a4" and so on. The command
+# \view_dvi_paper_option allows the user to overwrite the name of the
+# command line flag, i.e. replace -paper with something else. If
+# specified and left empty, i.e. \view_dvi_paper_option "", LyX does
+# not append the -paper option to the dvi command at all. This case is
+# especially useful when viewing your documents on Windows with yap,
+# because yap does not allow a command line option for the paper size.
+#\view_dvi_paper ""
+
# LyX assumes that the default papersize should be usletter. If this is not
# true for your site, use the next line to specify usletter, legal,
# executive, a3, a4, a5, or b5 as the default papersize.
path = buffer->tmppath;
}
Path p(path);
-
- cmd = command + ' ' + QuoteName(name);
+ // At this point we check whether the command contains the
+ // filename parameter $$FName and if that's the case we
+ // substitute the real file name otherwise the filename is
+ // simply appended. rokrau 1/12/00
+ cmd = command;
+ std::string::size_type i;
+ if ( (i=command.find("$$FName")) != std::string::npos)
+ {
+ cmd.replace(i,7,QuoteName(name));
+ }
+ else
+ cmd = command + ' ' + QuoteName(name);
Systemcalls one;
//if (!bv->text)
// return false;
- string paper;
-
- // wrong type
- char real_papersize = buffer->params.papersize;
- if (real_papersize == BufferParams::PAPER_DEFAULT)
- real_papersize = lyxrc->default_papersize;
-
- switch (real_papersize) {
- case BufferParams::PAPER_USLETTER:
- paper = "us";
- break;
- case BufferParams::PAPER_A3PAPER:
- paper = "a3";
- break;
- case BufferParams::PAPER_A4PAPER:
- paper = "a4";
- break;
- case BufferParams::PAPER_A5PAPER:
- paper = "a5";
- break;
- case BufferParams::PAPER_B5PAPER:
- paper = "b5";
- break;
- case BufferParams::PAPER_EXECUTIVEPAPER:
- paper = "foolscap";
- break;
- case BufferParams::PAPER_LEGALPAPER:
- paper = "legal";
- break;
- default: /* If nothing else fits, keep the empty value */
- break;
- }
-
- if (paper.empty()) {
- if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- // we HAVE to give a size when the page is in
- // landscape, so use USletter.
- paper = " -paper usr";
- } else {
- paper = " -paper " + paper;
- if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- paper+= 'r';
- }
-
- // push directorypath, if necessary
- string path = OnlyPath(buffer->fileName());
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
- path = buffer->tmppath;
+ string paper = lyxrc->view_dvi_paper_option;
+ if (!paper.empty()) {
+ // wrong type
+ char real_papersize = buffer->params.papersize;
+ if (real_papersize == BufferParams::PAPER_DEFAULT)
+ real_papersize = lyxrc->default_papersize;
+
+ switch (real_papersize) {
+ case BufferParams::PAPER_USLETTER:
+ paper += " us";
+ break;
+ case BufferParams::PAPER_A3PAPER:
+ paper += " a3";
+ break;
+ case BufferParams::PAPER_A4PAPER:
+ paper += " a4";
+ break;
+ case BufferParams::PAPER_A5PAPER:
+ paper += " a5";
+ break;
+ case BufferParams::PAPER_B5PAPER:
+ paper += " b5";
+ break;
+ case BufferParams::PAPER_EXECUTIVEPAPER:
+ paper += " foolscap";
+ break;
+ case BufferParams::PAPER_LEGALPAPER:
+ paper += " legal";
+ break;
+ default: /* If nothing else fits, keep the empty value */
+ break;
+ }
+ if (real_papersize==' ') {
+ // if (paper.empty()) {
+ if (buffer->params.orientation
+ == BufferParams::ORIENTATION_LANDSCAPE)
+ // we HAVE to give a size when the page is in
+ // landscape, so use USletter.
+ paper = " -paper usr";
+ } else {
+ // paper = " -paper " + paper;
+ if (buffer->params.orientation
+ == BufferParams::ORIENTATION_LANDSCAPE)
+ paper+= 'r';
+ }
}
- Path p(path);
- // Run dvi-viewer
- string command = lyxrc->view_dvi_command + paper ;
+ // push directorypath, if necessary
+ string path = OnlyPath(buffer->fileName());
+ if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ path = buffer->tmppath;
+ }
+ Path p(path);
+ // Run dvi-viewer
+ string command = lyxrc->view_dvi_command + " " + paper;
bool ret = RunScript(buffer, false, command);
return ret;
}
// Derive layout number from given argument (string)
// and current buffer's textclass (number). */
- int layoutno =
- textclasslist.NumberOfLayout(owner->
- view()->
- text->parameters->
- textclass,
- argument).second;
+ LyXTextClassList::ClassList::size_type tclass =
+ owner->view()->text->parameters->textclass;
+ pair <bool, int> layout =
+ textclasslist.NumberOfLayout(tclass, argument);
+
+ // If the entry is obsolete, use the new one instead.
+ if (layout.first) {
+ string obs = textclasslist.Style(tclass,layout.second)
+ .obsoleted_by();
+ if (!obs.empty())
+ layout =
+ textclasslist.NumberOfLayout(tclass, obs);
+ }
// see if we found the layout number:
- if (layoutno == -1) {
+ if (!layout.first) {
setErrorMessage(string(N_("Layout ")) + argument +
N_(" not known"));
break;
}
-
- if (current_layout != layoutno) {
+
+ if (current_layout != layout.second) {
owner->view()->getScreen()->HideCursor();
- current_layout = layoutno;
+ current_layout = layout.second;
owner->view()->update(-2);
owner->view()->text->
- SetLayout(layoutno);
+ SetLayout(layout.second);
owner->getToolbar()->combox->
select(owner->view()->
text->cursor.par->
RC_NUMLASTFILES,
RC_CHECKLASTFILES,
RC_VIEWDVI_COMMAND,
+ RC_VIEWDVI_PAPEROPTION,
RC_DEFAULT_PAPERSIZE,
RC_PS_COMMAND,
RC_VIEWPS_COMMAND,
{ "\\use_personal_dictionary", RC_USE_PERS_DICT },
{ "\\use_tempdir", RC_USETEMPDIR },
{ "\\view_dvi_command", RC_VIEWDVI_COMMAND },
+ { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
{ "\\view_pdf_command", RC_VIEWPDF_COMMAND },
{ "\\view_ps_command", RC_VIEWPS_COMMAND },
{ "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
view_ps_command = "ghostview -swap";
view_pspic_command = "ghostview";
view_dvi_command = "xdvi";
+ view_dvi_paper_option = "-paper";
view_pdf_command = "xpdf";
default_papersize = BufferParams::PAPER_USLETTER;
custom_export_format = "ps";
view_dvi_command = lexrc.GetString();
break;
+ case RC_VIEWDVI_PAPEROPTION:
+ if (lexrc.next())
+ view_dvi_paper_option = lexrc.GetString();
+ else
+ view_dvi_paper_option = "";
+ break;
+
case RC_VIEWPDF_COMMAND:
if (lexrc.next())
view_pdf_command = lexrc.GetString();
<< "\n";
case RC_VIEWDVI_COMMAND:
os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
+ case RC_VIEWDVI_PAPEROPTION:
+ os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
case RC_VIEWPDF_COMMAND:
os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
case RC_DEFAULT_PAPERSIZE:
string view_pspic_command;
/// program for viewing dvi output (default "xdvi")
string view_dvi_command;
+ /// option for telling the dvi viewer about the paper size
+ string view_dvi_paper_option;
/// program for viewing pdf output (default "xpdf")
string view_pdf_command;
/// default paper size for local xdvi/dvips/ghostview/whatever