diff --git a/ChangeLog b/ChangeLog index edf67f13f2..fd813fafd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2000-02-15 Jean-Marc Lasgouttes + + * 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 * src/Painter.C (text(int,int,char,LyXFont)): call text(int, int, diff --git a/lib/lyxrc.example b/lib/lyxrc.example index c0e1ff3494..15757e197b 100644 --- a/lib/lyxrc.example +++ b/lib/lyxrc.example @@ -80,15 +80,24 @@ # 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. diff --git a/src/lyx_cb.C b/src/lyx_cb.C index f0f6f26b68..e28a61aacc 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -506,8 +506,18 @@ bool RunScript(Buffer * buffer, bool wait, 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; @@ -705,58 +715,60 @@ bool PreviewDVI(Buffer * buffer) //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; } diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 4fa02f314e..d5a806f837 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -1082,26 +1082,33 @@ string LyXFunc::Dispatch(int ac, // 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 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-> diff --git a/src/lyxrc.C b/src/lyxrc.C index 6f97ee50f6..e2563e2f4d 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -113,6 +113,7 @@ enum LyXRCTags { RC_NUMLASTFILES, RC_CHECKLASTFILES, RC_VIEWDVI_COMMAND, + RC_VIEWDVI_PAPEROPTION, RC_DEFAULT_PAPERSIZE, RC_PS_COMMAND, RC_VIEWPS_COMMAND, @@ -236,6 +237,7 @@ static keyword_item lyxrcTags[] = { { "\\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 } @@ -289,6 +291,7 @@ LyXRC::LyXRC() 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"; @@ -623,6 +626,13 @@ int LyXRC::read(string const & filename) 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(); @@ -1097,6 +1107,8 @@ void LyXRC::output(ostream & os) const << "\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: diff --git a/src/lyxrc.h b/src/lyxrc.h index 6b30d0a6db..eecba9f191 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -105,6 +105,8 @@ public: 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