Patch from Roland for yap support under NT; fix to LFUN_LAYOUT

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@556 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2000-02-15 13:30:49 +00:00
parent d6f638ea96
commit 3923262592
6 changed files with 123 additions and 67 deletions

View File

@ -1,3 +1,17 @@
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,

View File

@ -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.

View File

@ -506,7 +506,17 @@ bool RunScript(Buffer * buffer, bool wait,
path = buffer->tmppath;
}
Path p(path);
// 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,8 +715,8 @@ bool PreviewDVI(Buffer * buffer)
//if (!bv->text)
// return false;
string paper;
string paper = lyxrc->view_dvi_paper_option;
if (!paper.empty()) {
// wrong type
char real_papersize = buffer->params.papersize;
if (real_papersize == BufferParams::PAPER_DEFAULT)
@ -714,49 +724,51 @@ bool PreviewDVI(Buffer * buffer)
switch (real_papersize) {
case BufferParams::PAPER_USLETTER:
paper = "us";
paper += " us";
break;
case BufferParams::PAPER_A3PAPER:
paper = "a3";
paper += " a3";
break;
case BufferParams::PAPER_A4PAPER:
paper = "a4";
paper += " a4";
break;
case BufferParams::PAPER_A5PAPER:
paper = "a5";
paper += " a5";
break;
case BufferParams::PAPER_B5PAPER:
paper = "b5";
paper += " b5";
break;
case BufferParams::PAPER_EXECUTIVEPAPER:
paper = "foolscap";
paper += " foolscap";
break;
case BufferParams::PAPER_LEGALPAPER:
paper = "legal";
paper += " legal";
break;
default: /* If nothing else fits, keep the empty value */
break;
}
if (paper.empty()) {
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
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 = " -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)){
if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
path = buffer->tmppath;
}
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;
}

View File

@ -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 <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->

View File

@ -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:

View File

@ -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