Hi guys,
here is the promised patch that does two things.

1 It allows for $$FName in \view_dvi_command and \view_ps_command so that on
NT/95 you can put
  \view_dvi_command "yap `cygpath -w $$FName`"
and resp.
  \view_ps_command "gsview32 `cygpath -w $$FName`"
in your lyxrc file. This removes the need for a startup script dvi.bat and
gv.bat on windows platforms.
2 It introduces
 \view_dvi_paper_option ""
also in lyxrc. With this option you can overwrite the papersize that is
specified when viewing a dvi file.
yap (the MikTeX dvi viewer) doesnt have a paper option at all, so you get an
error message when viewing a dvi file.
When this option is set to blank, i.e. "", no paper size is specified when yap
is called. If this command is not given at all
nothing is changed.

I hope that this can be include in the 1.1.4 release and that I didnt introduce
side effects because I had to rearrange the dvi preview method a bit.
Let me know it this can go in or if I need to change something.

Roland

Index: lyx-devel/src/lyx_cb.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_cb.C,v
retrieving revision 1.38
diff -u -r1.38 lyx_cb.C
--- lyx-devel/src/lyx_cb.C      2000/01/11 01:59:00     1.38
+++ lyx-devel/src/lyx_cb.C      2000/01/21 19:10:52
@@ -514,8 +514,20 @@
                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;
 
@@ -712,59 +724,58 @@
        // Who cares?
        //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;
-       }
+       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;
    
-       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';
+               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';
+               }
        }
-
        // push directorypath, if necessary 
-        string path = OnlyPath(buffer->fileName());
-        if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)){
+    string path = OnlyPath(buffer->fileName());
+    if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
                path = buffer->tmppath;
-        }
-        Path p(path);
+    }
+    Path p(path);
        // Run dvi-viewer
-       string command = lyxrc->view_dvi_command + paper ;
+       string command = lyxrc->view_dvi_command + " " + paper;
        bool ret = RunScript(buffer, false, command);
        return ret;
 }
Index: lyx-devel/src/lyxrc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.C,v
retrieving revision 1.15
diff -u -r1.15 lyxrc.C
--- lyx-devel/src/lyxrc.C       2000/01/13 16:28:53     1.15
+++ lyx-devel/src/lyxrc.C       2000/01/21 19:10:58
@@ -107,6 +107,7 @@
        RC_NUMLASTFILES,
        RC_CHECKLASTFILES,
        RC_VIEWDVI_COMMAND,
+       RC_VIEWDVI_PAPEROPTION,
        RC_DEFAULT_PAPERSIZE,
        RC_PS_COMMAND,
        RC_VIEWPS_COMMAND,
@@ -224,6 +225,7 @@
        { "\\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 }
@@ -277,6 +279,7 @@
        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";
@@ -608,6 +611,13 @@
                                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();
@@ -1072,6 +1082,8 @@
                   << "\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:
Index: lyx-devel/src/lyxrc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxrc.h,v
retrieving revision 1.9
diff -u -r1.9 lyxrc.h
--- lyx-devel/src/lyxrc.h       2000/01/11 01:59:00     1.9
+++ lyx-devel/src/lyxrc.h       2000/01/21 19:10:58
@@ -105,6 +105,8 @@
        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

Reply via email to