mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
export patch from Dekel
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1001 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2fa9fa22c4
commit
83882f6d92
29
ChangeLog
29
ChangeLog
@ -1,3 +1,32 @@
|
||||
2000-09-04 Dekel Tsur <dekel@math.tau.ac.il>
|
||||
|
||||
* src/converter.C (add_options): New function.
|
||||
(SetViewer): Change $$FName into '$$FName'.
|
||||
(View): Add options when running xdvi
|
||||
(Add): Change $$FName into '$$FName'. Same for $$BaseName/$$OutName.
|
||||
(Convert): The 3rd parameter is now the desired filename. Converts
|
||||
calls to lyx::rename if necessary.
|
||||
Add options when running dvips.
|
||||
(dvi_papersize,dvips_options): New methods.
|
||||
|
||||
* src/exporter.C (Export): Use getLatexName() instead of fileName().
|
||||
|
||||
* src/frontends/Liason.C (printBuffer): Removed duplicate code by
|
||||
using a call to Converter::dvips_options.
|
||||
Fixed to work with nex export code.
|
||||
|
||||
* src/support/copy.C
|
||||
* src/support/rename.C: New files
|
||||
|
||||
* src/support/syscall.h
|
||||
* src/support/syscall.C: Added Starttype SystemDontWait.
|
||||
|
||||
* lib/ui/default.ui: Changed to work with new export code
|
||||
|
||||
* lib/configure.m4: Changed to work with new export code
|
||||
|
||||
* src/encoding.C: Changed latex name for iso8859_7 encoding.
|
||||
|
||||
2000-09-04 Angus Leeming <a.leeming@ic.ac.uk> +
|
||||
|
||||
* src/frontends/xforms/Menubar_pimpl.C: added two using directives
|
||||
|
167
lib/configure
vendored
167
lib/configure
vendored
@ -335,7 +335,7 @@ fi
|
||||
# Search for a program to preview pdf
|
||||
echo $ac_n "checking for a PDF preview""... $ac_c"
|
||||
echo "$ac_t""(xpdf acroread gv ghostview)"
|
||||
PDFVIEWER=
|
||||
PDF_VIEWER=
|
||||
for ac_prog in xpdf acroread gv ghostview
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
@ -346,33 +346,33 @@ if test -n "$ac_word"; then
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
PDFVIEWER="$ac_prog"
|
||||
PDF_VIEWER="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$PDFVIEWER"; then
|
||||
if test -n "$PDF_VIEWER"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$PDFVIEWER" && break
|
||||
test -n "$PDF_VIEWER" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$PDFVIEWER" ; then
|
||||
PDFVIEWER=none
|
||||
if test -z "$PDF_VIEWER" ; then
|
||||
PDF_VIEWER=none
|
||||
fi
|
||||
|
||||
|
||||
# Search for a program to convert pdf to ps
|
||||
echo $ac_n "checking for a PDF to PS converter""... $ac_c"
|
||||
echo "$ac_t""(pdf2ps pdftops)"
|
||||
PDFPS=
|
||||
for ac_prog in pdf2ps pdftops
|
||||
# Search something to preview dvi
|
||||
echo $ac_n "checking for a DVI previewer""... $ac_c"
|
||||
echo "$ac_t""(xdvi)"
|
||||
DVI_VIEWER=
|
||||
for ac_prog in xdvi
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
@ -382,32 +382,105 @@ if test -n "$ac_word"; then
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
PDFPS="$ac_prog"
|
||||
DVI_VIEWER="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$PDFPS"; then
|
||||
if test -n "$DVI_VIEWER"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$PDFPS" && break
|
||||
test -n "$DVI_VIEWER" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$PDFPS" ; then
|
||||
PDFPS=none
|
||||
if test -z "$DVI_VIEWER" ; then
|
||||
DVI_VIEWER=none
|
||||
fi
|
||||
|
||||
|
||||
# Search something to preview html
|
||||
echo $ac_n "checking for a HTML previewer""... $ac_c"
|
||||
echo "$ac_t""(netscape)"
|
||||
HTML_VIEWER=
|
||||
for ac_prog in netscape
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
if test -n "$ac_word"; then
|
||||
echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
HTML_VIEWER="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$HTML_VIEWER"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$HTML_VIEWER" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$HTML_VIEWER" ; then
|
||||
HTML_VIEWER=none
|
||||
fi
|
||||
|
||||
|
||||
# Search for a program to convert ps to pdf
|
||||
echo $ac_n "checking for a PS to PDF converter""... $ac_c"
|
||||
echo "$ac_t""(ps2pdf)"
|
||||
ps_to_pdf_command=
|
||||
for ac_prog in ps2pdf
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog ; ac_word=$2
|
||||
if test -n "$ac_word"; then
|
||||
echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
|
||||
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
ps_to_pdf_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$ps_to_pdf_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$ps_to_pdf_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$ps_to_pdf_command" ; then
|
||||
ps_to_pdf_command=none
|
||||
fi
|
||||
|
||||
test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName"
|
||||
|
||||
# Search for a program to convert dvi to ps
|
||||
echo $ac_n "checking for a DVI to PS converter""... $ac_c"
|
||||
echo "$ac_t""(dvips)"
|
||||
DVIPS=
|
||||
dvi_to_ps_command=
|
||||
for ac_prog in dvips
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
@ -418,27 +491,28 @@ if test -n "$ac_word"; then
|
||||
for ac_dir in $PATH; do
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -x $ac_dir/$ac_word; then
|
||||
DVIPS="$ac_prog"
|
||||
dvi_to_ps_command="$ac_prog"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS="$ac_save_ifs"
|
||||
|
||||
if test -n "$DVIPS"; then
|
||||
if test -n "$dvi_to_ps_command"; then
|
||||
ac_result=yes
|
||||
else
|
||||
ac_result=no
|
||||
fi
|
||||
|
||||
echo "$ac_t""$ac_result"
|
||||
test -n "$DVIPS" && break
|
||||
test -n "$dvi_to_ps_command" && break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$DVIPS" ; then
|
||||
DVIPS=none
|
||||
if test -z "$dvi_to_ps_command" ; then
|
||||
dvi_to_ps_command=none
|
||||
fi
|
||||
|
||||
test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName"
|
||||
|
||||
# Search a *roff program (used to translate tables in ASCII export)
|
||||
echo $ac_n "checking for a *roff formatter""... $ac_c"
|
||||
@ -641,8 +715,8 @@ fi
|
||||
|
||||
case $LINUXDOC in
|
||||
sgml2lyx)
|
||||
linuxdoc_to_latex_command="sgml2latex"
|
||||
linuxdoc_to_html_command="sgml2html '\$\$FName'"
|
||||
linuxdoc_to_latex_command="sgml2latex \$\$FName"
|
||||
linuxdoc_to_html_command="sgml2html \$\$FName"
|
||||
linuxdoc_to_lyx_command="sgml2lyx";;
|
||||
none)
|
||||
linuxdoc_to_latex_command="none"
|
||||
@ -693,11 +767,11 @@ fi
|
||||
|
||||
case $DOCBOOK in
|
||||
sgmltools)
|
||||
docbook_to_dvi_command="sgmltools -b dvi"
|
||||
docbook_to_html_command="sgmltools -b html '\$\$FName'";;
|
||||
docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
|
||||
docbook_to_html_command="sgmltools -b html \$\$FName";;
|
||||
db2dvi)
|
||||
docbook_to_dvi_command="db2dvi"
|
||||
docbook_to_html_command="db2html '\$\$FName'";;
|
||||
docbook_to_dvi_command="db2dvi \$\$FName"
|
||||
docbook_to_html_command="db2html \$\$FName";;
|
||||
none)
|
||||
docbook_to_dvi_command="none"
|
||||
docbook_to_html_command="none";;
|
||||
@ -781,10 +855,11 @@ if test -z "$TOHTML" ; then
|
||||
TOHTML=none
|
||||
fi
|
||||
|
||||
latex_to_html_command = $TOHTML
|
||||
case $TOHTML in
|
||||
tth) html_command="tth -t < '\$\$FName' > '\$\$OutName'";;
|
||||
latex2html) html_command="latex2html -no_subdir -split 0 -show_section_numbers '\$\$FName'";;
|
||||
hevea) html_command="hevea -s '\$\$FName'";;
|
||||
tth) latex_to_html_command="tth -t < \$\$FName > \$\$OutName";;
|
||||
latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
|
||||
hevea) latex_to_html_command="hevea -s \$\$FName";;
|
||||
esac
|
||||
|
||||
#### Explore the LaTeX configuration
|
||||
@ -870,27 +945,31 @@ cat >lyxrc.defaults <<EOF
|
||||
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as
|
||||
# ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
|
||||
# override the values given here.
|
||||
\\latex_command "$LATEX"
|
||||
\\pdflatex_command "$PDFLATEX"
|
||||
\\view_pdf_command "$PDFVIEWER"
|
||||
\\pdf_to_ps_command "$PDFPS"
|
||||
\\dvi_to_ps_command "$DVIPS"
|
||||
\\converter tex dvi "$LATEX" noflags
|
||||
\\converter tex pdf "$PDFLATEX" noflags
|
||||
\\converter dvi ps "$dvi_to_ps_command" noflags
|
||||
\\converter ps pdf "$ps_to_pdf_command" noflags
|
||||
\\converter sgml tex "$linuxdoc_to_latex_command" noflags
|
||||
\\converter sgml html "$linuxdoc_to_html_command" noflags
|
||||
\\converter docbook dvi "$docbook_to_dvi_command" noflags
|
||||
\\converter docbook html "$docbook_to_html_command" noflags
|
||||
\\converter tex html "$latex_to_html_command" noflags
|
||||
|
||||
\\viewer dvi "$DVI_VIEWER"
|
||||
\\viewer html "$HTML_VIEWER"
|
||||
\\viewer pdf "$PDF_VIEWER"
|
||||
\\viewer ps "$GHOSTVIEW -swap"
|
||||
\\viewer pspic "$GHOSTVIEW"
|
||||
|
||||
\\relyx_command "$RELYX"
|
||||
\\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
|
||||
\\literate_command "$LITERATE"
|
||||
\\literate_extension "$LITERATE_EXT"
|
||||
\\ps_command "$GS"
|
||||
\\view_ps_command "$GHOSTVIEW -swap"
|
||||
\\view_pspic_command "$GHOSTVIEW"
|
||||
\\ascii_roff_command "$ascii_roff_command"
|
||||
\\chktex_command "$chktex_command"
|
||||
\\spell_command "$SPELL"
|
||||
\\fax_command "$fax_command"
|
||||
\\linuxdoc_to_latex_command "$linuxdoc_to_latex_command"
|
||||
\\linuxdoc_to_html_command "$linuxdoc_to_html_command"
|
||||
\\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
|
||||
\\docbook_to_dvi_command "$docbook_to_dvi_command"
|
||||
\\docbook_to_html_command "$docbook_to_html_command"
|
||||
\\html_command "$html_command"
|
||||
\\print_spool_command "$print_spool_command"
|
||||
\\print_spool_printerprefix "$print_spool_printerprefix"
|
||||
\\font_encoding "$chk_fontenc"
|
||||
|
@ -196,13 +196,21 @@ SEARCH_PROG([for a Postscript interpreter],GS, gs)
|
||||
SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
|
||||
|
||||
# Search for a program to preview pdf
|
||||
SEARCH_PROG([for a PDF preview],PDFVIEWER,xpdf acroread gv ghostview)
|
||||
SEARCH_PROG([for a PDF preview],PDF_VIEWER,xpdf acroread gv ghostview)
|
||||
|
||||
# Search for a program to convert pdf to ps
|
||||
SEARCH_PROG([for a PDF to PS converter],PDFPS,pdf2ps pdftops)
|
||||
# Search something to preview dvi
|
||||
SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi)
|
||||
|
||||
# Search something to preview html
|
||||
SEARCH_PROG([for a HTML previewer],HTML_VIEWER, netscape)
|
||||
|
||||
# Search for a program to convert ps to pdf
|
||||
SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf)
|
||||
test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName"
|
||||
|
||||
# Search for a program to convert dvi to ps
|
||||
SEARCH_PROG([for a DVI to PS converter],DVIPS,dvips)
|
||||
SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips)
|
||||
test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName"
|
||||
|
||||
# Search a *roff program (used to translate tables in ASCII export)
|
||||
SEARCH_PROG([for a *roff formatter],ROFF,groff nroff)
|
||||
@ -240,8 +248,8 @@ fi
|
||||
|
||||
case $LINUXDOC in
|
||||
sgml2lyx)
|
||||
linuxdoc_to_latex_command="sgml2latex"
|
||||
linuxdoc_to_html_command="sgml2html '\$\$FName'"
|
||||
linuxdoc_to_latex_command="sgml2latex \$\$FName"
|
||||
linuxdoc_to_html_command="sgml2html \$\$FName"
|
||||
linuxdoc_to_lyx_command="sgml2lyx";;
|
||||
none)
|
||||
linuxdoc_to_latex_command="none"
|
||||
@ -259,11 +267,11 @@ fi
|
||||
|
||||
case $DOCBOOK in
|
||||
sgmltools)
|
||||
docbook_to_dvi_command="sgmltools -b dvi"
|
||||
docbook_to_html_command="sgmltools -b html '\$\$FName'";;
|
||||
docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
|
||||
docbook_to_html_command="sgmltools -b html \$\$FName";;
|
||||
db2dvi)
|
||||
docbook_to_dvi_command="db2dvi"
|
||||
docbook_to_html_command="db2html '\$\$FName'";;
|
||||
docbook_to_dvi_command="db2dvi \$\$FName"
|
||||
docbook_to_html_command="db2html \$\$FName";;
|
||||
none)
|
||||
docbook_to_dvi_command="none"
|
||||
docbook_to_html_command="none";;
|
||||
@ -281,10 +289,11 @@ esac
|
||||
|
||||
# Search for a latex to html converter
|
||||
SEARCH_PROG([for an HTML converter], TOHTML, tth latex2html hevea)
|
||||
latex_to_html_command = $TOHTML
|
||||
case $TOHTML in
|
||||
tth) html_command="tth -t < '\$\$FName' > '\$\$OutName'";;
|
||||
latex2html) html_command="latex2html -no_subdir -split 0 -show_section_numbers '\$\$FName'";;
|
||||
hevea) html_command="hevea -s '\$\$FName'";;
|
||||
tth) latex_to_html_command="tth -t < \$\$FName > \$\$OutName";;
|
||||
latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
|
||||
hevea) latex_to_html_command="hevea -s \$\$FName";;
|
||||
esac
|
||||
|
||||
#### Explore the LaTeX configuration
|
||||
@ -358,27 +367,31 @@ cat >lyxrc.defaults <<EOF
|
||||
# want to customize LyX, make a copy of the file LYXDIR/lyxrc as
|
||||
# ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
|
||||
# override the values given here.
|
||||
\\latex_command "$LATEX"
|
||||
\\pdflatex_command "$PDFLATEX"
|
||||
\\view_pdf_command "$PDFVIEWER"
|
||||
\\pdf_to_ps_command "$PDFPS"
|
||||
\\dvi_to_ps_command "$DVIPS"
|
||||
\\converter tex dvi "$LATEX" noflags
|
||||
\\converter tex pdf "$PDFLATEX" noflags
|
||||
\\converter dvi ps "$dvi_to_ps_command" noflags
|
||||
\\converter ps pdf "$ps_to_pdf_command" noflags
|
||||
\\converter sgml tex "$linuxdoc_to_latex_command" noflags
|
||||
\\converter sgml html "$linuxdoc_to_html_command" noflags
|
||||
\\converter docbook dvi "$docbook_to_dvi_command" noflags
|
||||
\\converter docbook html "$docbook_to_html_command" noflags
|
||||
\\converter tex html "$latex_to_html_command" noflags
|
||||
|
||||
\\viewer dvi "$DVI_VIEWER"
|
||||
\\viewer html "$HTML_VIEWER"
|
||||
\\viewer pdf "$PDF_VIEWER"
|
||||
\\viewer ps "$GHOSTVIEW -swap"
|
||||
\\viewer pspic "$GHOSTVIEW"
|
||||
|
||||
\\relyx_command "$RELYX"
|
||||
\\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
|
||||
\\literate_command "$LITERATE"
|
||||
\\literate_extension "$LITERATE_EXT"
|
||||
\\ps_command "$GS"
|
||||
\\view_ps_command "$GHOSTVIEW -swap"
|
||||
\\view_pspic_command "$GHOSTVIEW"
|
||||
\\ascii_roff_command "$ascii_roff_command"
|
||||
\\chktex_command "$chktex_command"
|
||||
\\spell_command "$SPELL"
|
||||
\\fax_command "$fax_command"
|
||||
\\linuxdoc_to_latex_command "$linuxdoc_to_latex_command"
|
||||
\\linuxdoc_to_html_command "$linuxdoc_to_html_command"
|
||||
\\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
|
||||
\\docbook_to_dvi_command "$docbook_to_dvi_command"
|
||||
\\docbook_to_html_command "$docbook_to_html_command"
|
||||
\\html_command "$html_command"
|
||||
\\print_spool_command "$print_spool_command"
|
||||
\\print_spool_printerprefix "$print_spool_printerprefix"
|
||||
\\font_encoding "$chk_fontenc"
|
||||
|
@ -34,11 +34,11 @@ Menuset
|
||||
Item "Save As|A" "buffer-write-as"
|
||||
Item "Revert to saved|R" "buffer-reload"
|
||||
Separator
|
||||
Item "View dvi|d" "buffer-view"
|
||||
Item "View Postscript|w" "buffer-view-ps"
|
||||
Item "View dvi|d" "buffer-view dvi"
|
||||
Item "View Postscript|w" "buffer-view ps"
|
||||
Submenu "View" "view"
|
||||
Item "Update dvi|v" "buffer-typeset"
|
||||
Item "Update Postscript|U" "buffer-typeset-ps"
|
||||
Item "Update dvi|v" "buffer-update dvi"
|
||||
Item "Update Postscript|U" "buffer-update ps"
|
||||
Submenu "Update" "update"
|
||||
OptItem "Build program|B" "build-program"
|
||||
Separator
|
||||
@ -81,14 +81,14 @@ Menuset
|
||||
|
||||
Menu "export"
|
||||
ExportFormats
|
||||
OptItem "as LaTeX|L" "buffer-export latex"
|
||||
OptItem "as LinuxDoc|L" "buffer-export linuxdoc"
|
||||
OptItem "as DocBook|B" "buffer-export docbook"
|
||||
Item "as DVI|D" "buffer-export dvi"
|
||||
# OptItem "as LaTeX|L" "buffer-export latex"
|
||||
# OptItem "as LinuxDoc|L" "buffer-export linuxdoc"
|
||||
# OptItem "as DocBook|B" "buffer-export docbook"
|
||||
# Item "as DVI|D" "buffer-export dvi"
|
||||
# Item "as Postscript|P" "buffer-export postscript"
|
||||
Item "as Ascii|A" "buffer-export ascii"
|
||||
Item "as HTML|H" "buffer-export html"
|
||||
OptItem "Custom...|C" "buffer-export custom"
|
||||
# Item "as Ascii|A" "buffer-export ascii"
|
||||
# Item "as HTML|H" "buffer-export html"
|
||||
# OptItem "Custom...|C" "buffer-export custom"
|
||||
End
|
||||
|
||||
Menu "edit"
|
||||
|
@ -22,6 +22,11 @@
|
||||
// only to get access to NEW_INSETS and NEW_TABULAR
|
||||
#include "lyxparagraph.h"
|
||||
#endif
|
||||
#if 1
|
||||
// only to get access to NEW_EXPORT
|
||||
#include "exporter.h"
|
||||
#endif
|
||||
|
||||
|
||||
using std::ostream;
|
||||
using std::endl;
|
||||
|
188
src/converter.C
188
src/converter.C
@ -15,30 +15,25 @@
|
||||
#endif
|
||||
|
||||
#include <queue>
|
||||
#include <stack>
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <algorithm> // sort()
|
||||
|
||||
#include "converter.h"
|
||||
#include "lyxrc.h"
|
||||
#include "support/syscall.h"
|
||||
#include "support/path.h"
|
||||
#include "debug.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#include "bufferview_funcs.h"
|
||||
#include "LaTeX.h"
|
||||
#include "LyXView.h"
|
||||
#include "minibuffer.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "lyx_cb.h"
|
||||
#include "lyx_cb.h" // ShowMessage()
|
||||
|
||||
using std::map;
|
||||
using std::vector;
|
||||
using std::queue;
|
||||
using std::pair;
|
||||
using std::sort;
|
||||
using std::stack;
|
||||
using std::endl;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -46,6 +41,14 @@ using std::endl;
|
||||
map<string, Format> Formats::formats;
|
||||
vector<Command> Converter::commands;
|
||||
|
||||
inline
|
||||
string add_options(string const & command, string const & options)
|
||||
{
|
||||
string head;
|
||||
string tail = split(command, head, ' ');
|
||||
return head + ' ' + options + ' ' + tail;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Format::Format(string const & n)
|
||||
@ -83,17 +86,17 @@ void Formats::Add(string const & name)
|
||||
|
||||
void Formats::SetViewer(string const & name, string const & command)
|
||||
{
|
||||
|
||||
string command2 = subst(command, "$$FName", "'$$FName'");
|
||||
if (!contains(command,"$$FName"))
|
||||
command2 += " '$$FName'";
|
||||
|
||||
Add(name);
|
||||
Format * f = GetFormat(name);
|
||||
if (!f->viewer.empty())
|
||||
lyxerr << "Error: a viewer for " << name
|
||||
<< " is already defined!" << endl;
|
||||
else
|
||||
f->viewer = command;
|
||||
GetFormat(name)->viewer = command2;
|
||||
}
|
||||
|
||||
|
||||
bool Formats::View(string const & filename)
|
||||
bool Formats::View(Buffer * buffer, string const & filename)
|
||||
{
|
||||
string extension = GetExtension(filename);
|
||||
Format * format = GetFormat(extension);
|
||||
@ -105,30 +108,24 @@ bool Formats::View(string const & filename)
|
||||
}
|
||||
|
||||
string command = format->viewer;
|
||||
|
||||
if (extension == "dvi" &&
|
||||
!lyxrc.view_dvi_paper_option.empty()) {
|
||||
string options = lyxrc.view_dvi_paper_option;
|
||||
options += " " + Converter::dvi_papersize(buffer);
|
||||
if (buffer->params.orientation
|
||||
== BufferParams::ORIENTATION_LANDSCAPE)
|
||||
options += 'r';
|
||||
command = add_options(command, options);
|
||||
}
|
||||
|
||||
string command2 = subst(command, "$$FName", OnlyFilename(filename));
|
||||
lyxerr << "Executing command: " << command2 << endl;
|
||||
ShowMessage(buffer, _("Executing command:"), command2);
|
||||
|
||||
command = subst(command, "$$FName", filename);
|
||||
#ifndef __EMX__
|
||||
command += " &";
|
||||
#else
|
||||
// OS/2 cmd.exe has another use for '&'
|
||||
// This is not NLS safe, but it's OK, I think.
|
||||
string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
|
||||
if (sh.empty()) {
|
||||
// COMSPEC is set, unless user unsets
|
||||
sh = OnlyFilename(GetEnvPath("COMSPEC"));
|
||||
if (sh.empty())
|
||||
sh = "cmd.exe";
|
||||
}
|
||||
sh = lowercase(sh);
|
||||
if (contains(sh, "cmd.exe")
|
||||
|| contains(sh, "4os2.exe"))
|
||||
command = "start /min/n " + command;
|
||||
else
|
||||
command += " &";
|
||||
#endif
|
||||
lyxerr << "Executing command: " << command << endl;
|
||||
//ShowMessage(buffer, _("Executing command:"), command);
|
||||
Systemcalls one;
|
||||
int res = one.startscript(Systemcalls::System, command);
|
||||
int res = one.startscript(Systemcalls::SystemDontWait, command);
|
||||
|
||||
if (res) {
|
||||
WriteAlert(_("Can not view file"),
|
||||
@ -149,6 +146,7 @@ Format * Formats::GetFormat(string const & name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
string const Formats::PrettyName(string const & name)
|
||||
{
|
||||
string format;
|
||||
@ -162,20 +160,26 @@ string const Formats::PrettyName(string const & name)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Converter::Add(string const & from, string const & to,
|
||||
string const & command, string const & flags)
|
||||
{
|
||||
for (vector<Command>::const_iterator cit = commands.begin();
|
||||
cit != commands.end(); ++cit)
|
||||
if ((*cit).from == from && (*cit).to == to) {
|
||||
lyxerr << "Error: Convertor from " << from
|
||||
<< " to " << to
|
||||
<< " already exists!" << endl;
|
||||
if (command == "none")
|
||||
return;
|
||||
|
||||
bool original_dir = flags == "origdir";
|
||||
string command2 =
|
||||
subst(command, "$$FName", "'$$FName'");
|
||||
command2 = subst(command2, "$$BaseName", "'$$BaseName'");
|
||||
command2 = subst(command2, "$$OutName", "'$$OutName'");
|
||||
|
||||
for (vector<Command>::iterator it = commands.begin();
|
||||
it != commands.end(); ++it)
|
||||
if ((*it).from == from && (*it).to == to) {
|
||||
*it = Command(from, to, command2, original_dir);
|
||||
return;
|
||||
}
|
||||
bool original_dir = flags == "origdir";
|
||||
commands.push_back(Command(from, to, command, original_dir));
|
||||
|
||||
commands.push_back(Command(from, to, command2, original_dir));
|
||||
Formats::Add(from);
|
||||
Formats::Add(to);
|
||||
++Formats::GetFormat(to)->in_degree;
|
||||
@ -232,15 +236,16 @@ Converter::GetReachable(string const & from, bool only_viewable)
|
||||
}
|
||||
|
||||
|
||||
bool Converter::convert(Buffer * buffer, string const & from_file,
|
||||
string const & to_format)
|
||||
|
||||
bool Converter::Convert(Buffer * buffer, string const & from_file,
|
||||
string const & to_file, string const & using_format)
|
||||
{
|
||||
string format;
|
||||
string using_format = SplitFormat(to_format, format);
|
||||
string from_format = GetExtension(from_file);
|
||||
if (from_format == format)
|
||||
return true;
|
||||
string to_format = GetExtension(to_file);
|
||||
if (from_format == to_format)
|
||||
if (from_file != to_file)
|
||||
return lyx::rename(from_file.c_str(), to_file.c_str());
|
||||
else
|
||||
return true;
|
||||
|
||||
queue< vector<Command>::iterator > Q;
|
||||
for (vector<Command>::iterator it = commands.begin();
|
||||
@ -262,7 +267,7 @@ bool Converter::convert(Buffer * buffer, string const & from_file,
|
||||
vector<Command>::iterator it;
|
||||
while (!Q.empty()) {
|
||||
it = Q.front();
|
||||
if ((*it).to == format &&
|
||||
if ((*it).to == to_format &&
|
||||
(using_format.empty() || using_format == (*it).from)) {
|
||||
found = true;
|
||||
break;
|
||||
@ -285,19 +290,18 @@ bool Converter::convert(Buffer * buffer, string const & from_file,
|
||||
return false;
|
||||
}
|
||||
|
||||
stack< vector<Command>::iterator > S;
|
||||
vector< vector<Command>::iterator > S;
|
||||
while (it != commands.end()) {
|
||||
S.push(it);
|
||||
S.push_back(it);
|
||||
it = (*it).previous;
|
||||
}
|
||||
|
||||
//Path p(OnlyPath(buffer->fileName()));
|
||||
Path p(OnlyPath(from_file));
|
||||
|
||||
string basename = ChangeExtension(from_file, "");
|
||||
while (!S.empty()) {
|
||||
it = S.top();
|
||||
S.pop();
|
||||
for (vector< vector<Command>::iterator >::reverse_iterator rit =
|
||||
S.rbegin(); rit != S.rend(); ++rit) {
|
||||
it = *rit;
|
||||
lyxerr << "Converting from "
|
||||
<< (*it).from << " to " << (*it).to << endl;
|
||||
|
||||
@ -316,6 +320,11 @@ bool Converter::convert(Buffer * buffer, string const & from_file,
|
||||
command = subst(command, "$$FName", infile);
|
||||
command = subst(command, "$$BaseName", basename);
|
||||
command = subst(command, "$$OutName", outfile);
|
||||
|
||||
if ((*it).from == "dvi" && (*it).to == "ps")
|
||||
command = add_options(command,
|
||||
dvips_options(buffer));
|
||||
|
||||
lyxerr << "Calling " << command << endl;
|
||||
ShowMessage(buffer, _("Executing command:"), command);
|
||||
|
||||
@ -335,6 +344,14 @@ bool Converter::convert(Buffer * buffer, string const & from_file,
|
||||
}
|
||||
}
|
||||
|
||||
string result_file = ChangeExtension(from_file, to_format);
|
||||
if (result_file != to_file)
|
||||
if ((*it).from == "tex" &&
|
||||
( (*it).to == "dvi" || (*it).to == "pdf") )
|
||||
return lyx::copy(result_file.c_str(), to_file.c_str());
|
||||
else
|
||||
return lyx::rename(result_file.c_str(), to_file.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -408,3 +425,56 @@ bool Converter::runLaTeX(Buffer * buffer, string const & command)
|
||||
|
||||
}
|
||||
|
||||
|
||||
string Converter::dvi_papersize(Buffer * buffer)
|
||||
{
|
||||
char real_papersize = buffer->params.papersize;
|
||||
if (real_papersize == BufferParams::PAPER_DEFAULT)
|
||||
real_papersize = lyxrc.default_papersize;
|
||||
|
||||
switch (real_papersize) {
|
||||
case BufferParams::PAPER_A3PAPER:
|
||||
return "a3";
|
||||
case BufferParams::PAPER_A4PAPER:
|
||||
return "a4";
|
||||
case BufferParams::PAPER_A5PAPER:
|
||||
return "a5";
|
||||
case BufferParams::PAPER_B5PAPER:
|
||||
return "b5";
|
||||
case BufferParams::PAPER_EXECUTIVEPAPER:
|
||||
return "foolscap";
|
||||
case BufferParams::PAPER_LEGALPAPER:
|
||||
return "legal";
|
||||
case BufferParams::PAPER_USLETTER:
|
||||
default:
|
||||
return "us";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string Converter::dvips_options(Buffer * buffer)
|
||||
{
|
||||
string result;
|
||||
if (buffer->params.use_geometry
|
||||
&& buffer->params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
||||
&& !lyxrc.print_paper_dimension_flag.empty()
|
||||
&& !buffer->params.paperwidth.empty()
|
||||
&& !buffer->params.paperheight.empty()) {
|
||||
// using a custom papersize
|
||||
result = lyxrc.print_paper_dimension_flag;
|
||||
result += ' ' + buffer->params.paperwidth;
|
||||
result += ',' + buffer->params.paperheight;
|
||||
} else {
|
||||
string paper_option = dvi_papersize(buffer);
|
||||
if (paper_option != "letter" ||
|
||||
buffer->params.orientation != BufferParams::ORIENTATION_LANDSCAPE) {
|
||||
// dvips won't accept -t letter -t landscape. In all other
|
||||
// cases, include the paper size explicitly.
|
||||
result = lyxrc.print_paper_flag;
|
||||
result += ' ' + paper_option;
|
||||
}
|
||||
}
|
||||
if (buffer->params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
|
||||
result += ' ' + lyxrc.print_landscape_flag;
|
||||
return result;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
void SetViewer(string const & name, string const & command);
|
||||
///
|
||||
static
|
||||
bool View(string const & filename);
|
||||
bool View(Buffer * buffer, string const & filename);
|
||||
///
|
||||
static
|
||||
Format * GetFormat(string const & name);
|
||||
@ -97,11 +97,16 @@ public:
|
||||
bool only_viewable = false);
|
||||
///
|
||||
static
|
||||
bool convert(Buffer * buffer, string const & from_file,
|
||||
string const & to_format);
|
||||
bool Convert(Buffer * buffer, string const & from_file,
|
||||
string const & to_file, string const & using_format);
|
||||
static
|
||||
string const SplitFormat(string const & str, string & format);
|
||||
///
|
||||
static
|
||||
string const SplitFormat(string const & str, string & format);
|
||||
string dvi_papersize(Buffer * buffer);
|
||||
///
|
||||
static
|
||||
string dvips_options(Buffer * buffer);
|
||||
private:
|
||||
///
|
||||
static
|
||||
|
@ -462,7 +462,7 @@ Encoding iso8859_2("latin2",tab_iso8859_2);
|
||||
Encoding iso8859_3("latin3",tab_iso8859_3);
|
||||
Encoding iso8859_4("latin4",tab_iso8859_4);
|
||||
Encoding iso8859_6("unknown",tab_iso8859_6_16);
|
||||
Encoding iso8859_7("unknown",tab_iso8859_7);
|
||||
Encoding iso8859_7("iso-8859-7",tab_iso8859_7);
|
||||
Encoding iso8859_9("latin5",tab_iso8859_9);
|
||||
Encoding cp1255("cp1255",tab_cp1255);
|
||||
Encoding koi8("koi8-r",tab_koi8);
|
||||
|
@ -14,15 +14,11 @@
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "exporter.h"
|
||||
#include "converter.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "lyx_cb.h"
|
||||
#include "support/path.h"
|
||||
#include "lyx_cb.h" //ShowMessage()
|
||||
#include "support/filetools.h"
|
||||
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
@ -33,39 +29,34 @@ bool Exporter::Export(Buffer * buffer, string const & format0,
|
||||
string format;
|
||||
string using_format = Converter::SplitFormat(format0, format);
|
||||
|
||||
string filename = buffer->fileName();
|
||||
string backend_format = BufferExtension(buffer);
|
||||
bool only_backend = backend_format == format;
|
||||
|
||||
//string file = buffer->getLatexName(true);
|
||||
string file = filename;
|
||||
string filename = buffer->getLatexName(false);
|
||||
if (!buffer->tmppath.empty())
|
||||
file = AddName(buffer->tmppath, file);
|
||||
file = ChangeExtension(file, backend_format);
|
||||
filename = AddName(buffer->tmppath, filename);
|
||||
filename = ChangeExtension(filename, backend_format);
|
||||
|
||||
if (buffer->isLinuxDoc())
|
||||
buffer->makeLinuxDocFile(file, only_backend);
|
||||
buffer->makeLinuxDocFile(filename, only_backend);
|
||||
else if (only_backend)
|
||||
buffer->makeLaTeXFile(file, string(), true);
|
||||
buffer->makeLaTeXFile(filename, string(), true);
|
||||
else
|
||||
buffer->makeLaTeXFile(file, buffer->filepath, false);
|
||||
buffer->makeLaTeXFile(filename, buffer->filepath, false);
|
||||
|
||||
bool return_value = Converter::convert(buffer, file, format0);
|
||||
if (!return_value)
|
||||
string outfile = (put_in_tempdir)
|
||||
? ChangeExtension(filename, format)
|
||||
: ChangeExtension(buffer->getLatexName(false), format);
|
||||
|
||||
if (!Converter::Convert(buffer, filename, outfile, using_format))
|
||||
return false;
|
||||
|
||||
if (!put_in_tempdir) {
|
||||
file = ChangeExtension(file, format);
|
||||
string outfile = ChangeExtension(filename, format);
|
||||
if (file != outfile)
|
||||
rename(file.c_str(), outfile.c_str());
|
||||
|
||||
if (!put_in_tempdir)
|
||||
ShowMessage(buffer,
|
||||
_("Document exported as ")
|
||||
+ Formats::PrettyName(format)
|
||||
+ _(" to file `")
|
||||
+ MakeDisplayPath(outfile) +'\'');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -78,11 +69,11 @@ bool Exporter::Preview(Buffer * buffer, string const & format0)
|
||||
string format;
|
||||
Converter::SplitFormat(format0, format);
|
||||
|
||||
string filename = buffer->fileName();
|
||||
string filename = buffer->getLatexName(false);
|
||||
if (!buffer->tmppath.empty())
|
||||
filename = AddName(buffer->tmppath, filename);
|
||||
filename = ChangeExtension(filename, format);
|
||||
return Formats::View(filename);
|
||||
return Formats::View(buffer, filename);
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,12 +25,15 @@
|
||||
#include "support/filetools.h"
|
||||
#include "support/path.h"
|
||||
#include "exporter.h"
|
||||
#include "converter.h"
|
||||
#include "minibuffer.h"
|
||||
#include "support/syscall.h"
|
||||
|
||||
extern LyXRC lyxrc;
|
||||
#ifndef NEW_EXPORT
|
||||
extern bool RunScript(Buffer * buffer, bool wait, string const & command,
|
||||
string const & orgname = string(), bool need_shell=true);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CXX_WORKING_NAMESPACES
|
||||
namespace Liason
|
||||
@ -48,7 +51,9 @@ PrinterParams getPrinterParams(Buffer * buffer)
|
||||
|
||||
bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
||||
{
|
||||
#ifndef NEW_EXPORT
|
||||
bool result(false);
|
||||
#endif
|
||||
string command(lyxrc.print_command + ' ');
|
||||
|
||||
if (pp.target == PrinterParams::PRINTER
|
||||
@ -88,12 +93,6 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
||||
command += lyxrc.print_reverse_flag + ' ';
|
||||
}
|
||||
|
||||
BufferParams params(buffer->params);
|
||||
if (params.orientation
|
||||
== BufferParams::ORIENTATION_LANDSCAPE) {
|
||||
command += lyxrc.print_landscape_flag + ' ';
|
||||
}
|
||||
|
||||
if (1 < pp.count_copies) {
|
||||
if (pp.unsorted_copies) {
|
||||
command += lyxrc.print_copies_flag;
|
||||
@ -109,57 +108,63 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
||||
command += lyxrc.print_extra_options + ' ';
|
||||
}
|
||||
|
||||
char real_papersize = params.papersize;
|
||||
if (real_papersize == BufferParams::PAPER_DEFAULT) {
|
||||
real_papersize = lyxrc.default_papersize;
|
||||
}
|
||||
command += Converter::dvips_options(buffer) + ' ';
|
||||
|
||||
if (params.use_geometry
|
||||
&& params.papersize2 == BufferParams::VM_PAPER_CUSTOM
|
||||
&& !lyxrc.print_paper_dimension_flag.empty()
|
||||
&& !params.paperwidth.empty()
|
||||
&& !params.paperheight.empty()) {
|
||||
// using a custom papersize
|
||||
command += lyxrc.print_paper_dimension_flag + ' ';
|
||||
command += params.paperwidth + ',';
|
||||
command += params.paperheight + ' ';
|
||||
} else if (!lyxrc.print_paper_flag.empty()
|
||||
&& (real_papersize != BufferParams::PAPER_USLETTER
|
||||
|| params.orientation
|
||||
== BufferParams::ORIENTATION_PORTRAIT)) {
|
||||
// There's a problem with US Letter + landscape
|
||||
string paper;
|
||||
switch (real_papersize) {
|
||||
case BufferParams::PAPER_USLETTER:
|
||||
paper = "letter";
|
||||
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 empty value */
|
||||
break;
|
||||
}
|
||||
if (!paper.empty()) {
|
||||
command += lyxrc.print_paper_flag + ' ';
|
||||
command += paper + ' ';
|
||||
}
|
||||
}
|
||||
#ifdef NEW_EXPORT
|
||||
if (!Exporter::Export(buffer, "dvi", true))
|
||||
return false;
|
||||
|
||||
// Push directory path.
|
||||
string path = OnlyPath(buffer->fileName());
|
||||
if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
|
||||
path = buffer->tmppath;
|
||||
}
|
||||
Path p(path);
|
||||
|
||||
// there are three cases here:
|
||||
// 1. we print to a file
|
||||
// 2. we print direct to a printer
|
||||
// 3. we print using a spool command (print to file first)
|
||||
Systemcalls one;
|
||||
int res = 0;
|
||||
string dviname = ChangeExtension(buffer->getLatexName(true), "dvi");
|
||||
switch (pp.target) {
|
||||
case PrinterParams::PRINTER:
|
||||
if (!lyxrc.print_spool_command.empty()) {
|
||||
// case 3
|
||||
string psname = ChangeExtension(dviname, ".ps");
|
||||
command += lyxrc.print_to_file
|
||||
+ QuoteName(psname) + ' ';
|
||||
command += QuoteName(dviname);
|
||||
string command2 = lyxrc.print_spool_command + ' ';
|
||||
if (!pp.printer_name.empty())
|
||||
command2 += lyxrc.print_spool_printerprefix
|
||||
+ pp.printer_name + ' ';
|
||||
command2 += QuoteName(psname);
|
||||
// First run dvips.
|
||||
// If successful, then spool command
|
||||
lyxerr << "command1 = " << command << endl;
|
||||
lyxerr << "command2 = " << command2 << endl;
|
||||
res = one.startscript(Systemcalls::System, command);
|
||||
if (res == 0)
|
||||
res = one.startscript(Systemcalls::SystemDontWait,
|
||||
command2);
|
||||
} else
|
||||
// case 2
|
||||
res = one.startscript(Systemcalls::SystemDontWait, command);
|
||||
break;
|
||||
|
||||
case PrinterParams::FILE:
|
||||
// case 1
|
||||
command += lyxrc.print_to_file
|
||||
+ QuoteName(MakeAbsPath(pp.file_name, path));
|
||||
command += ' ' + QuoteName(dviname);
|
||||
lyxerr << "command1 = " << command << endl;
|
||||
res = one.startscript(Systemcalls::SystemDontWait, command);
|
||||
break;
|
||||
}
|
||||
return res == 0;
|
||||
#else
|
||||
// Push directory path if necessary.
|
||||
// PS file should go where the source file is unless it's a
|
||||
// read-only directory in which case we write it to tmpdir.
|
||||
@ -172,7 +177,6 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
||||
}
|
||||
Path p(path);
|
||||
|
||||
#ifndef NEW_EXPORT
|
||||
// there are three cases here:
|
||||
// 1. we print to a file
|
||||
// 2. we print direct to a printer
|
||||
@ -209,8 +213,8 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
|
||||
result = RunScript(buffer, false, command);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
void setMinibuffer(LyXView * lv, char const * msg)
|
||||
|
@ -1122,9 +1122,6 @@ int LyXRC::read(string const & filename)
|
||||
command = lexrc.GetString();
|
||||
if (lexrc.next())
|
||||
flags = lexrc.GetString();
|
||||
command = subst(command, "$$FName", "'$$FName'");
|
||||
command = subst(command, "$$BaseName", "'$$BaseName'");
|
||||
command = subst(command, "$$OutName", "'$$OutName'");
|
||||
Converter::Add(from, to, command, flags);
|
||||
break;
|
||||
}
|
||||
@ -1135,7 +1132,6 @@ int LyXRC::read(string const & filename)
|
||||
format = lexrc.GetString();
|
||||
if (lexrc.next())
|
||||
command = lexrc.GetString();
|
||||
command = subst(command, "$$FName", "'$$FName'");
|
||||
Formats::SetViewer(format, command);
|
||||
break;
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ libsupport_la_SOURCES = \
|
||||
abort.C \
|
||||
block.h \
|
||||
chdir.C \
|
||||
copy.C \
|
||||
date.C \
|
||||
filetools.C \
|
||||
filetools.h \
|
||||
@ -50,6 +51,7 @@ libsupport_la_SOURCES = \
|
||||
path.C \
|
||||
path.h \
|
||||
putenv.C \
|
||||
rename.C \
|
||||
$(REGEX) syscall.C \
|
||||
syscall.h \
|
||||
syscontr.C \
|
||||
|
15
src/support/copy.C
Normal file
15
src/support/copy.C
Normal file
@ -0,0 +1,15 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
#include "LString.h"
|
||||
#include "support/syscall.h"
|
||||
#include "support/filetools.h"
|
||||
|
||||
bool lyx::copy(char const * from, char const * to)
|
||||
{
|
||||
string command = "cp " + QuoteName(from) + " " + QuoteName(to);
|
||||
return Systemcalls().startscript(Systemcalls::System,
|
||||
command) == 0;
|
||||
}
|
@ -26,6 +26,10 @@ namespace lyx {
|
||||
char * getcwd(char * buffer, size_t size);
|
||||
///
|
||||
int chdir(char const * name);
|
||||
/// Returns false it it fails
|
||||
bool rename(char const * from, char const * to);
|
||||
/// Returns false it it fails
|
||||
bool copy(char const * from, char const * to);
|
||||
/// generates a checksum
|
||||
unsigned long sum(char const * file);
|
||||
/// returns a date string (not used currently)
|
||||
@ -48,6 +52,10 @@ struct lyx {
|
||||
static char * getcwd(char * buffer, size_t size);
|
||||
///
|
||||
static int chdir(char const * name);
|
||||
/// Returns false it it fails
|
||||
static bool rename(char const * from, char const * to);
|
||||
/// Returns false it it fails
|
||||
static bool copy(char const * from, char const * to);
|
||||
/// generates a checksum
|
||||
static unsigned long sum(char const * file);
|
||||
/// returns a date string (not used currently)
|
||||
|
10
src/support/rename.C
Normal file
10
src/support/rename.C
Normal file
@ -0,0 +1,10 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
|
||||
bool lyx::rename(char const * from, char const * to)
|
||||
{
|
||||
return ::rename(from, to) != -1;
|
||||
}
|
@ -50,6 +50,7 @@ int Systemcalls::startscript() {
|
||||
retval = 0;
|
||||
switch (start) {
|
||||
case System:
|
||||
case SystemDontWait:
|
||||
retval = system(command.c_str());
|
||||
callback();
|
||||
break;
|
||||
@ -193,6 +194,29 @@ int Systemcalls::startscript(Starttype how, string const & what,
|
||||
cbk = cback;
|
||||
pid = static_cast<pid_t>(0); // yet no child
|
||||
retval = 0;
|
||||
|
||||
if (how == SystemDontWait) {
|
||||
#ifndef __EMX__
|
||||
command += " &";
|
||||
#else
|
||||
// OS/2 cmd.exe has another use for '&'
|
||||
// This is not NLS safe, but it's OK, I think.
|
||||
string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
|
||||
if (sh.empty()) {
|
||||
// COMSPEC is set, unless user unsets
|
||||
sh = OnlyFilename(GetEnvPath("COMSPEC"));
|
||||
if (sh.empty())
|
||||
sh = "cmd.exe";
|
||||
}
|
||||
sh = lowercase(sh);
|
||||
if (contains(sh, "cmd.exe")
|
||||
|| contains(sh, "4os2.exe"))
|
||||
command = "start /min/n " + command;
|
||||
else
|
||||
command += " &";
|
||||
#endif
|
||||
}
|
||||
|
||||
return startscript();
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
///
|
||||
enum Starttype {
|
||||
System, // Uses system() which uses /bin/sh
|
||||
SystemDontWait, // Uses system() which uses /bin/sh
|
||||
Wait, // Uses fork() and execvp()
|
||||
DontWait // Uses fork() and execvp()
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user