+2000-11-13 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
+
+ * src/converter.C: add "using" directive.
+
+ * src/frontends/xforms/FormPreferences.C: add "using" directive.
+ (compare_converter): add "int" as return type.
+
+ * src/frontends/xforms/Color.C: comment out FL_LIGHTER_COL1 here
+ too.
+
+2000-11-11 Angus Leeming <a.leeming@ic.ac.uk>
+
+ * src/lyx_gui.C (create_forms): map the xform colours, should a
+ mapping exist. Ie, call XformColor::read().
+
+ * src/frontends/xforms/Color.[Ch] renamed struct RGB as RGBColor
+ and struct HSV as HSVColor.
+ (XformColor::read, XformColor::write) : new methods that
+ input/output any changes to the cform GUI colors.
+
+ * src/frontends/xforms/Dialogs.C: FORMS_H_LOCATION no longer
+ included.
+
+ * src/frontends/xforms/FormPreferences.C Lots of little changes
+ associated with the changed name of the RGB and HSV structs. Can
+ now save changes to xforms GUI to file. Commented out
+ FL_LIGHTER_COL1 to allow compilation with xforms 0.88. It isn't
+ used currently anyway.
+
+2000-11-11 Dekel Tsur <dekelts@tau.ac.il>
+
+ * src/converter.C: A lot of changes:
+ - It is no longer possible to choose between two or more ways to
+ export to some format (the new code uses only the shortest path).
+ However, it is still possible to choose between pdflatex/ps2pdf
+ for creating a PDF file, by defining two PDF formats: pdf & pdf2.
+ - Added several methods that makes the FormPreferences code simpler.
+ - Changed the tokens $$FName and $$OutName to $$i and $$o.
+
+ * src/exporter.C (Export): lyxrc.use_pdf is set before
+ makeLaTeXFile is called. This works but not very nice.
+
+ * src/frontends/xforms/FormPreferences.C: The formats/converters
+ tabs are now fully functional.
+
+ * src/buffer.C (getTocList): Add numbers to the captions.
+
+ * lib/lyxrc.example: Removed fax section
+
+ * src/support/rename.C (rename): Delete the old file if lyx::copy
+ is called.
+
+2000-11-13 Rob Lahaye <lahaye@postech.edu>
+
+ * lib/ui/default.ui: minor polishing.
+
2000-11-10 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/frontends/xforms/Color.C: include <algorithm> and <cmath>
2000-11-08 Dekel Tsur <dekelts@tau.ac.il>
- * src/frontends/xforms/FormParagraph.C (updateLanguage): Check
+ * src/frontends/xforms/FormPreferences.C (updateLanguage): Check
iterators to prevent crash.
2000-11-08 Angus Leeming <a.leeming@ic.ac.uk>
fi
PATH=${save_PATH}
-test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$FName"
+test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
echo $ac_n "checking for a Noweb -> LyX converter""... $ac_c"
echo "$ac_t""(noweb2lyx)"
literate_to_lyx_command=none
fi
-test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$FName \$\$OutName"
+test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
# Search something to process a literate document
echo $ac_n "checking for a Noweb -> LaTeX converter""... $ac_c"
literate_to_tex_command=none
fi
-test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$FName > \$\$OutName"
+test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
echo $ac_n "checking for a HTML -> Latex converter""... $ac_c"
echo "$ac_t""(html2latex)"
html_to_latex_command=none
fi
-test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$FName"
+test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
echo $ac_n "checking for a MSWord -> Latex converter""... $ac_c"
echo "$ac_t""(wvCleanLatex word2x)"
word_to_latex_command=none
fi
-test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$FName \$\$OutName"
-test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$FName"
+test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
+test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
echo $ac_n "checking for Image converter""... $ac_c"
echo "$ac_t""(convert)"
image_command=none
fi
-test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName"
+test $image_command = "convert" && image_command="convert \$\$i \$\$o"
# Search for a Postscript interpreter
echo $ac_n "checking for a Postscript interpreter""... $ac_c"
ps_to_pdf_command=none
fi
-test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName"
+test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
# Search for a program to convert dvi to ps
echo $ac_n "checking for a DVI to PS converter""... $ac_c"
dvi_to_ps_command=none
fi
-test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName"
+test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
# Search a *roff program (used to translate tables in ASCII export)
echo $ac_n "checking for a *roff formatter""... $ac_c"
fax_command=none
fi
-test $fax_command = "ksendfax" && fax_command="ksendfax \$\$FName"
+test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
# Search for LinuxDoc support
echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c"
case $LINUXDOC in
sgml2lyx)
- linuxdoc_to_latex_command="sgml2latex \$\$FName"
- linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName"
- linuxdoc_to_html_command="sgml2html \$\$FName"
- linuxdoc_to_lyx_command="sgml2lyx \$\$FName";;
+ linuxdoc_to_latex_command="sgml2latex \$\$i"
+ linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
+ linuxdoc_to_html_command="sgml2html \$\$i"
+ linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
none)
linuxdoc_to_latex_command="none"
linuxdoc_to_dvi_command="none"
case $DOCBOOK in
sgmltools)
- docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
- docbook_to_html_command="sgmltools -b html \$\$FName";;
+ docbook_to_dvi_command="sgmltools -b dvi \$\$i"
+ docbook_to_html_command="sgmltools -b html \$\$i";;
db2dvi)
- docbook_to_dvi_command="db2dvi \$\$FName"
- docbook_to_html_command="db2html \$\$FName";;
+ docbook_to_dvi_command="db2dvi \$\$i"
+ docbook_to_html_command="db2html \$\$i";;
none)
docbook_to_dvi_command="none"
docbook_to_html_command="none";;
latex_to_html_command=$TOHTML
case $TOHTML in
- tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
- latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
- hevea) latex_to_html_command="hevea -s \$\$FName";;
+ tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
+ latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
+ hevea) latex_to_html_command="hevea -s \$\$i";;
esac
#### Explore the LaTeX configuration
# 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.
-\\Format latex tex LaTeX L
-\\Format dvi dvi DVI D
-\\Format ps ps Postscript t
-\\Format pdf pdf PDF P
-\\Format html html HTML H
-\\Format text txt ASCII A
-\\Format word doc Word W
-\\Format literate nw NoWeb N
-\\Format linuxdoc sgml LinuxDoc x
+\\Format text txt ASCII A
+\\Format textparagraph txt ASCII(paragraphs) ""
\\Format docbook sgml DocBook B
-\\Format program "" Program ""
+\\Format dvi dvi DVI D
+\\Format eps eps EPS ""
\\Format fax "" Fax ""
+\\Format gif gif GIF ""
+\\Format html html HTML H
+\\Format jpg jpg JPEG ""
+\\Format latex tex LaTeX L
+\\Format linuxdoc sgml LinuxDoc x
+\\Format lyx lyx LyX ""
+\\Format literate nw NoWeb N
+\\Format pdf pdf PDF P
+\\Format pdf2 pdf "PDF (pdflatex)" F
+\\Format png png PNG ""
+\\Format ps ps Postscript t
+\\Format program "" Program ""
+\\Format word doc Word W
+
-\\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
-\\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook"
-\\converter latex html "$latex_to_html_command"
- "originaldir,needaux,disable=linuxdoc&docbook"
+\\converter latex dvi "$LATEX \$\$i" "latex"
+\\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
+\\converter latex html "$latex_to_html_command" "originaldir,needaux"
\\converter literate latex "$literate_to_tex_command" ""
\\converter dvi ps "$dvi_to_ps_command" ""
\\converter ps pdf "$ps_to_pdf_command" ""
\\converter docbook dvi "$docbook_to_dvi_command" ""
\\converter docbook html "$docbook_to_html_command" ""
-\\converter latex lyx "$tex_to_lyx_command" "importer"
-\\converter literate lyx "$literate_to_lyx_command" "importer"
-\\converter html latex "$html_to_latex_command" "importer"
-\\converter word latex "$word_to_latex_command" "importer"
+\\converter latex lyx "$tex_to_lyx_command" ""
+\\converter literate lyx "$literate_to_lyx_command" ""
+\\converter html latex "$html_to_latex_command" ""
+\\converter word latex "$word_to_latex_command" ""
\converter gif eps "$image_command" ""
\converter png eps "$image_command" ""
PATH=${PATH}:./reLyX/
SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
PATH=${save_PATH}
-test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$FName"
+test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx)
-test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$FName \$\$OutName"
+test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
# Search something to process a literate document
SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave)
-test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$FName > \$\$OutName"
+test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
-test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$FName"
+test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x)
-test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$FName \$\$OutName"
-test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$FName"
+test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
+test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
SEARCH_PROG([for Image converter],image_command,convert)
-test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName"
+test $image_command = "convert" && image_command="convert \$\$i \$\$o"
# Search for a Postscript interpreter
SEARCH_PROG([for a Postscript interpreter],GS, gs)
# 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"
+test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
# Search for a program to convert dvi to ps
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"
+test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
# Search a *roff program (used to translate tables in ASCII export)
SEARCH_PROG([for a *roff formatter],ROFF,groff nroff)
# Search a GUI Fax program
SEARCH_PROG([for a fax program], fax_command, ksendfax)
-test $fax_command = "ksendfax" && fax_command="ksendfax \$\$FName"
+test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
# Search for LinuxDoc support
SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
case $LINUXDOC in
sgml2lyx)
- linuxdoc_to_latex_command="sgml2latex \$\$FName"
- linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName"
- linuxdoc_to_html_command="sgml2html \$\$FName"
- linuxdoc_to_lyx_command="sgml2lyx \$\$FName";;
+ linuxdoc_to_latex_command="sgml2latex \$\$i"
+ linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
+ linuxdoc_to_html_command="sgml2html \$\$i"
+ linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
none)
linuxdoc_to_latex_command="none"
linuxdoc_to_dvi_command="none"
case $DOCBOOK in
sgmltools)
- docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
- docbook_to_html_command="sgmltools -b html \$\$FName";;
+ docbook_to_dvi_command="sgmltools -b dvi \$\$i"
+ docbook_to_html_command="sgmltools -b html \$\$i";;
db2dvi)
- docbook_to_dvi_command="db2dvi \$\$FName"
- docbook_to_html_command="db2html \$\$FName";;
+ docbook_to_dvi_command="db2dvi \$\$i"
+ docbook_to_html_command="db2html \$\$i";;
none)
docbook_to_dvi_command="none"
docbook_to_html_command="none";;
SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea)
latex_to_html_command=$TOHTML
case $TOHTML in
- tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
- latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
- hevea) latex_to_html_command="hevea -s \$\$FName";;
+ tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
+ latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
+ hevea) latex_to_html_command="hevea -s \$\$i";;
esac
#### Explore the LaTeX configuration
# 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.
-\\Format latex tex LaTeX L
-\\Format dvi dvi DVI D
-\\Format ps ps Postscript t
-\\Format pdf pdf PDF P
-\\Format html html HTML H
-\\Format text txt ASCII A
-\\Format word doc Word W
-\\Format literate nw NoWeb N
-\\Format linuxdoc sgml LinuxDoc x
+\\Format text txt ASCII A
+\\Format textparagraph txt ASCII(paragraphs) ""
\\Format docbook sgml DocBook B
-\\Format program "" Program ""
+\\Format dvi dvi DVI D
+\\Format eps eps EPS ""
\\Format fax "" Fax ""
+\\Format gif gif GIF ""
+\\Format html html HTML H
+\\Format jpg jpg JPEG ""
+\\Format latex tex LaTeX L
+\\Format linuxdoc sgml LinuxDoc x
+\\Format lyx lyx LyX ""
+\\Format literate nw NoWeb N
+\\Format pdf pdf PDF P
+\\Format pdf2 pdf "PDF (pdflatex)" F
+\\Format png png PNG ""
+\\Format ps ps Postscript t
+\\Format program "" Program ""
+\\Format word doc Word W
+
-\\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
-\\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook"
-\\converter latex html "$latex_to_html_command"
- "originaldir,needaux,disable=linuxdoc&docbook"
+\\converter latex dvi "$LATEX \$\$i" "latex"
+\\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
+\\converter latex html "$latex_to_html_command" "originaldir,needaux"
\\converter literate latex "$literate_to_tex_command" ""
\\converter dvi ps "$dvi_to_ps_command" ""
\\converter ps pdf "$ps_to_pdf_command" ""
\\converter docbook dvi "$docbook_to_dvi_command" ""
\\converter docbook html "$docbook_to_html_command" ""
-\\converter latex lyx "$tex_to_lyx_command" "importer"
-\\converter literate lyx "$literate_to_lyx_command" "importer"
-\\converter html latex "$html_to_latex_command" "importer"
-\\converter word latex "$word_to_latex_command" "importer"
+\\converter latex lyx "$tex_to_lyx_command" ""
+\\converter literate lyx "$literate_to_lyx_command" ""
+\\converter html latex "$html_to_latex_command" ""
+\\converter word latex "$word_to_latex_command" ""
\converter gif eps "$image_command" ""
\converter png eps "$image_command" ""
# The converter command has 4 arguments: The source format, the target format,
# the command, and additional flags.
# For example, the following defines a DVI->Postscript converter:
-#\converter dvi ps "dvips -o $$OutName $$FName" ""
-# The variable name $$FName is replaced with the name of the source file,
-# and $$OutName is replaced with the name of the target file.
+#\converter dvi ps "dvips -o $$o $$i" ""
+# The variable name $$i is replaced with the name of the source file,
+# and $$o is replaced with the name of the target file.
# The flags argument is a list of comma separated flags.
# Known flags are
# - * : copy the previously defined flags
-# - importer : The converter is used for importing.
# - latex : The converter is latex or its derivatives (pdflatex).
# - originaldir : The converter must be invoked in the directory of the lyx
# file and not in the temporary directory. This is needed for tex->html
# - needaux : The converted uses the .aux file, so we need to call latex
# before running the converter.
# - resultdir=dir : The converter put all the files in dir.
-# Using "resultdir" is same as "resultdir=$$Basename".
+# Using "resultdir" is same as "resultdir=$$b".
# Note: When exporting, the whole directory will be moved from the temporary
# directory to the target directory.
# - resultfile=file : Name of main file in the result directory, for example
-# "index.html" or "$$BaseName.html"
+# "index.html" or "$$b.html"
# If "resultfile" is omitted, the name of this file is assumed to be
# "index.format"
# - parselog=filtername : filtername is a name of a filter command that takes
# the converter error log (from stderr), and converts it to a fake latex .log
# file.
-# - disable=backends : A list of & seperated backend in which the converter
-# should not be used.
# For example:
-#\converter latex html "latex2html -split 0 $$FName"
-# "originaldir,needaux,resultdir,disable=linuxdoc&docbook"
+#\converter latex html "latex2html -split 0 $$i"
+# "originaldir,needaux,resultdir"
#
# For literate programming, use something like
-#\converter literate latex "noweave -delay -index $$FName >$$OutName"
+#\converter literate latex "noweave -delay -index $$i >$$o"
# "parselog=listerrors g"
-#\converter literate program "build-script $$FName"
+#\converter literate program "build-script $$i"
# "originaldir,parselog=listerrors g"
# The format command is used to define file formats. It has 4 arguments:
# Default is "".
#\backupdir_path "~/Desktop/Trash/"
-
-#
-# FAX SECTION #############################################################
-#
-
-# In the following, the <$$something> strings are substituted by
-# reasonable values by LyX. The 's are important as there may be spaces in
-# the string. The default is auto-detected.
-# This one is what is used with HylaFax:
-#\fax_command "sendfax -n -h '$$Host' -c '$$Comment' -x '$$Enterprise' -d '$$Name'@'$$Phone' '$$FName'"
-# Use this for the efax-command:
-#\fax_command "faxsend '$$Phone' '$$FName'"
-
-# This is the name of your phone book. It's per default situated in ~/.lyx/,
-# but you can override that with an absolute path.
-#\phone_book phonebook
-
-# This is how to call an external FAX-program instead of the built-in.
-# You may also insert $$FName to reference the PostScript file.
-#\fax_program "myfaxprg '$$FName'"
-#\fax_program tkhylafax
-
#
# ASCII EXPORT SECTION ###################################################
#
Item "Close|C" "buffer-close"
Item "Save|S" "buffer-write"
Item "Save As...|A" "buffer-write-as"
- Item "Revert to saved|R" "buffer-reload"
+ Item "Revert to saved|d" "buffer-reload"
Submenu "Version control|V" "file_vc"
Separator
- Submenu "Import|m" "file_import"
- Submenu "Insert|I" "file_insert"
+ Submenu "Import|I" "file_import"
+ Submenu "Insert|r" "file_insert"
Separator
Submenu "Export|E" "file_export"
Item "Print...|P" "buffer-print"
End
Menu "file_import"
- Item "Ascii text as lines...|A" "buffer-import text"
- Item "Ascii text as paragraphs...|p" "buffer-import textparagraph"
ImportFormats
End
Menu "edit"
Item "Undo|U" "undo"
- Item "Redo|R" "redo"
+ Item "Redo|d" "redo"
Separator
Item "Cut|C" "cut"
Item "Copy|o" "copy"
- Item "Paste|P" "paste"
+ Item "Paste|a" "paste"
Submenu "Paste external selection|x" "edit_paste"
Separator
Item "Find & Replace...|F" "find-replace"
- Separator
Submenu "Tabular|T" "edit_tabular"
Submenu "Floats & Insets|I" "edit_floats"
+ Separator
Item "Spellchecker...|S" "spellchecker"
Item "Check TeX|h" "buffer-chktex"
Item "Remove all Error boxes|E" "error-remove-all"
Separator
- Item "Preferences...|n" "dialog-preferences"
- Item "Reconfigure|g" "reconfigure"
+ Item "Preferences...|P" "dialog-preferences"
+ Item "Reconfigure|R" "reconfigure"
End
Menu "edit_paste"
# INSERT MENU
#
Menu "insert"
- Item "Math text|M" "math-mode"
+ Item "Math text|t" "math-mode"
Item "Math display|d" "math-display"
Item "Math panel...|p" "math-panel"
Separator
Item "Cross reference...|r" "reference-insert"
Item "Label...|L" "label-insert"
Item "Footnote|F" "footnote-insert"
- Item "Marginal note|n" "marginpar-insert"
- Item "Index entry...|x" "index-insert"
+ Item "Marginal note|M" "marginpar-insert"
+ Item "Index entry...|I" "index-insert"
Item "Index entry of last word|w" "index-insert-last"
Item "URL...|U" "url-insert"
- Item "Note...|o" "note-insert"
+ Item "Note...|N" "note-insert"
Separator
Item "Figure...|g" "figure-insert"
- Item "Tabular...|T" "dialog-tabular-insert"
+ Item "Tabular...|b" "dialog-tabular-insert"
Submenu "Floats|a" "insert_floats"
Separator
- Submenu "Lists & TOC|i" "insert_toc"
+ Submenu "Lists & TOC|O" "insert_toc"
End
Menu "insert_special"
src/credits_form.C
src/CutAndPaste.C
src/exporter.C
+src/ext_l10n.h
src/filedlg.C
src/FontLoader.C
src/form1.C
#include "bufferlist.h"
#include "converter.h"
#include "exporter.h"
+#include "importer.h"
#include "support/filetools.h"
#include "support/lyxfunctional.h"
return *this;
}
-struct compare_formatpair {
- bool operator()(FormatPair const & a, FormatPair const & b) {
- return a.format->prettyname < b.format->prettyname;
- }
-};
void Menu::checkShortcuts() const
{
}
break;
+ case MenuItem::ImportFormats:
case MenuItem::ViewFormats:
case MenuItem::UpdateFormats:
case MenuItem::ExportFormats: {
- vector<FormatPair> names;
+ vector<Format const *> formats;
kb_action action;
- if ((*cit).kind() == MenuItem::ViewFormats) {
- names = Exporter::GetExportableFormats(buf, true);
+ switch ((*cit).kind()) {
+ case MenuItem::ImportFormats:
+ formats = Importer::GetImportableFormats();
+ action = LFUN_IMPORT;
+ break;
+ case MenuItem::ViewFormats:
+ formats = Exporter::GetExportableFormats(buf, true);
action = LFUN_PREVIEW;
- } else if ((*cit).kind() == MenuItem::UpdateFormats) {
- names = Exporter::GetExportableFormats(buf, true);
+ break;
+ case MenuItem::UpdateFormats:
+ formats = Exporter::GetExportableFormats(buf, true);
action = LFUN_UPDATE;
- } else {
- names = Exporter::GetExportableFormats(buf, false);
+ break;
+ default:
+ formats = Exporter::GetExportableFormats(buf, false);
action = LFUN_EXPORT;
}
- sort(names.begin(), names.end(), compare_formatpair());
-
- for (vector<FormatPair>::const_iterator fit = names.begin();
- fit != names.end() ; ++fit) {
- if ((*fit).format->dummy())
- continue;
- string fmt = (*fit).format->name;
- string label = (*fit).format->prettyname;
- bool same_before =
- fit != names.begin() &&
- (*fit).format == (*(fit-1)).format;
- bool same_after =
- fit+1 != names.end() &&
- (*fit).format == (*(fit+1)).format;
- if ((*fit).from &&
- (same_before || same_after)) {
- fmt += ":" + (*fit).from->name;
- string head;
- split((*fit).command, head, ' ');
- label += _(" (using ") + head + ")";
- if (!(*fit).format->shortcut.empty() &&
- !same_before)
- label += "|" + (*fit).format->shortcut;
- } else if (!(*fit).format->shortcut.empty())
- label += "|" + (*fit).format->shortcut;
- int action2 = lyxaction.getPseudoAction(action, fmt);
- tomenu.add(MenuItem(MenuItem::Command,
- label, action2));
- }
- }
- break;
-
- case MenuItem::ImportFormats: {
- vector<FormatPair> names = Converter::GetReachableTo("lyx");
- sort(names.begin(), names.end(), compare_formatpair());
+ sort(formats.begin(), formats.end());
- for (vector<FormatPair>::const_iterator fit = names.begin();
- fit != names.end() ; ++fit) {
- if ((*fit).format->dummy())
+ for (vector<Format const *>::const_iterator fit = formats.begin();
+ fit != formats.end() ; ++fit) {
+ if ((*fit)->dummy())
continue;
- string fmt = (*fit).format->name;
- string label = (*fit).format->prettyname;
- if (!(*fit).format->shortcut.empty())
- label += "|" + (*fit).format->shortcut;
- int action2 = lyxaction.getPseudoAction(LFUN_IMPORT, fmt);
+ string label = (*fit)->prettyname();
+ if ((*cit).kind() == MenuItem::ImportFormats)
+ if ((*fit)->name() == "text")
+ label = _("Ascii text as lines");
+ else if ((*fit)->name() == "textparagraph")
+ label = _("Ascii text as paragraphs");
+ if (!(*fit)->shortcut().empty())
+ label += "|" + (*fit)->shortcut();
+ int action2 = lyxaction.
+ getPseudoAction(action, (*fit)->name());
tomenu.add(MenuItem(MenuItem::Command,
label, action2));
}
vector<vector<Buffer::TocItem> > const Buffer::getTocList()
{
+ int figs = 0;
+ int tables = 0;
+ int algs = 0;
vector<vector<TocItem> > l(4);
LyXParagraph * par = paragraph;
while (par) {
switch (par->footnotekind) {
case LyXParagraph::FIG:
case LyXParagraph::WIDE_FIG:
+ tmp.str = tostr(++figs) + ". "
+ + tmp.str;
l[TOC_LOF].push_back(tmp);
break;
case LyXParagraph::TAB:
case LyXParagraph::WIDE_TAB:
+ tmp.str = tostr(++tables) + ". "
+ + tmp.str;
l[TOC_LOT].push_back(tmp);
break;
case LyXParagraph::ALGORITHM:
+ tmp.str = tostr(++algs) + ". "
+ + tmp.str;
l[TOC_LOA].push_back(tmp);
break;
case LyXParagraph::FOOTNOTE:
#pragma implementation
#endif
-#include <queue>
+#include <cctype>
#include "converter.h"
#include "lyxrc.h"
#include "minibuffer.h"
#include "lyx_gui_misc.h"
#include "lyx_cb.h" // ShowMessage()
+#include "support/lyxfunctional.h"
-using std::map;
using std::vector;
using std::queue;
-using std::pair;
using std::endl;
-using std::find;
+using std::fill;
using std::find_if;
+using std::reverse;
+using std::sort;
-//////////////////////////////////////////////////////////////////////////////
+static string const token_from("$$i");
+static string const token_base("$$b");
+static string const token_to("$$o");
-vector<Command> Converter::commands;
-string Converter::latex_command;
+//////////////////////////////////////////////////////////////////////////////
static inline
string const add_options(string const & command, string const & options)
//////////////////////////////////////////////////////////////////////////////
-
bool Format::dummy() const
{
- return extension.empty();
+ return extension().empty();
+}
+
+
+bool Format::IsChildFormat() const
+{
+ if (name_.empty())
+ return false;
+ return isdigit(name_[name_.length() - 1]);
+}
+
+
+string const Format::ParentFormat() const
+{
+ return name_.substr(0, name_.length() - 1);
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+// This method should return a reference, and throw an exception
+// if the format named name cannot be found (Lgb)
+Format const * Formats::GetFormat(string const & name) const
+{
+ FormatList::const_iterator cit =
+ find_if(formatlist.begin(), formatlist.end(),
+ compare_memfun(&Format::name, name));
+ if (cit != formatlist.end())
+ return &(*cit);
+ else
+ return 0;
+}
+
+
+int Formats::GetNumber(string const & name) const
+{
+ FormatList::const_iterator cit =
+ find_if(formatlist.begin(), formatlist.end(),
+ compare_memfun(&Format::name, name));
+ if (cit != formatlist.end())
+ return cit - formatlist.begin();
+ else
+ return -1;
}
void Formats::Add(string const & name)
{
- if (formats.find(name) == formats.end())
- formats[name] = Format(name, name, name, "", "");
+ if (!GetFormat(name))
+ Add(name, name, name, string());
}
void Formats::Add(string const & name, string const & extension,
string const & prettyname, string const & shortcut)
{
-
- if (prettyname.empty()) {
- FormatList::iterator it = formats.find(name);
- if (it != formats.end())
- formats.erase(it);
- return;
+ FormatList::iterator it =
+ find_if(formatlist.begin(), formatlist.end(),
+ compare_memfun(&Format::name, name));
+ if (it == formatlist.end())
+ formatlist.push_back(Format(name, extension, prettyname,
+ shortcut, ""));
+ else {
+ string viewer = it->viewer();
+ *it = Format(name, extension, prettyname, shortcut, viewer);
}
+}
+
- string const old_viewer = formats[name].viewer;
- formats[name] = Format(name, extension, prettyname, shortcut,
- old_viewer);
+void Formats::Delete(string const & name)
+{
+ FormatList::iterator it =
+ find_if(formatlist.begin(), formatlist.end(),
+ compare_memfun(&Format::name, name));
+ if (it != formatlist.end())
+ formatlist.erase(it);
}
-void Formats::SetViewer(string const & name, string const & command)
+void Formats::Sort()
{
- string command2 = command;
- if (!command2.empty() && !contains(command2,"$$FName"))
- command2 += " $$FName";
+ sort(formatlist.begin(), formatlist.end());
+}
+
+void Formats::SetViewer(string const & name, string const & command)
+{
Add(name);
- GetFormat(name)->viewer = command2;
+ FormatList::iterator it =
+ find_if(formatlist.begin(), formatlist.end(),
+ compare_memfun(&Format::name, name));
+ if (it != formatlist.end())
+ it->setViewer(command);
}
bool Formats::View(Buffer const * buffer, string const & filename,
- string const & format_name)
+ string const & format_name) const
{
if (filename.empty())
return false;
Format const * format = GetFormat(format_name);
- if (!format || format->viewer.empty()) {
+ if (format && format->viewer().empty() &&
+ format->IsChildFormat())
+ format = GetFormat(format->ParentFormat());
+ if (!format || format->viewer().empty()) {
WriteAlert(_("Can not view file"),
_("No information for viewing ")
+ PrettyName(format_name));
return false;
}
- string command = format->viewer;
+ string command = format->viewer();
if (format_name == "dvi" &&
!lyxrc.view_dvi_paper_option.empty()) {
- string options = lyxrc.view_dvi_paper_option;
- options += " " + Converter::dvi_papersize(buffer);
+ command += " " + lyxrc.view_dvi_paper_option;
+ command += " " + converters.dvi_papersize(buffer);
if (buffer->params.orientation
== BufferParams::ORIENTATION_LANDSCAPE)
- options += 'r';
- command = add_options(command, options);
+ command += 'r';
}
- string command2 = subst(command, "$$FName", OnlyFilename(filename));
+ string command2 = command + " " + OnlyFilename(filename);
lyxerr << "Executing command: " << command2 << endl;
ShowMessage(buffer, _("Executing command:"), command2);
- command = subst(command, "$$FName", QuoteName(filename));
+ command += " " + QuoteName(filename);
Systemcalls one;
int res = one.startscript(Systemcalls::SystemDontWait, command);
if (res) {
WriteAlert(_("Can not view file"),
_("Error while executing"),
- command.substr(0, 50));
+ command2.substr(0, 50));
return false;
}
return true;
}
-// This method should return a reference, and throw an exception
-// if the format named name cannot be found (Lgb)
-Format * Formats::GetFormat(string const & name)
-{
- FormatList::iterator it = formats.find(name);
- if (it != formats.end())
- return &it->second;
- else
- return 0;
-}
-
-
-string const Formats::PrettyName(string const & name)
+string const Formats::PrettyName(string const & name) const
{
Format const * format = GetFormat(name);
if (format)
- return format->prettyname;
+ return format->prettyname();
else
return name;
}
-string const Formats::Extension(string const & name)
+string const Formats::Extension(string const & name) const
{
Format const * format = GetFormat(name);
if (format)
- return format->extension;
+ return format->extension();
else
return name;
}
+//////////////////////////////////////////////////////////////////////////////
-vector<Format>
-const Formats::GetAllFormats() const
+void Converter::ReadFlags()
{
- vector<Format> result;
- for (FormatList::const_iterator cit = formats.begin();
- cit != formats.end(); ++cit)
- result.push_back(cit->second);
- return result;
+ string flag_list(flags);
+ while (!flag_list.empty()) {
+ string flag_name, flag_value;
+ flag_list = split(flag_list, flag_value, ',');
+ flag_value = split(flag_value, flag_name, '=');
+ if (flag_name == "latex")
+ latex = true;
+ else if (flag_name == "originaldir")
+ original_dir = true;
+ else if (flag_name == "needaux")
+ need_aux = true;
+ else if (flag_name == "resultdir")
+ result_dir = (flag_value.empty())
+ ? token_base : flag_value;
+ else if (flag_name == "resultfile")
+ result_file = flag_value;
+ else if (flag_name == "parselog")
+ parselog = flag_value;
+ }
+ if (!result_dir.empty() && result_file.empty())
+ result_file = "index." + formats.Extension(to);
+ //if (!contains(command, token_from))
+ // latex = true;
}
+bool operator<(Converter const & a, Converter const & b)
+{
+ int i = compare_no_case(a.From->prettyname(), b.From->prettyname());
+ if (i == 0)
+ return compare_no_case(a.To->prettyname(), b.To->prettyname())
+ < 0;
+ else
+ return i < 0;
+}
+
//////////////////////////////////////////////////////////////////////////////
-// Instead of storing an object we could just store an const reference.
-// _but_ that is not guaranteed to work in all cases. (Lgb)
-class compare_Command {
+class compare_Converter {
public:
- compare_Command(Command const & c) : com(c) {}
- bool operator()(Command const & c) {
- return c.from == com.from && c.to == com.to;
+ compare_Converter(string const & f, string const & t)
+ : from(f), to(t) {}
+ bool operator()(Converter const & c) {
+ return c.from == from && c.to == to;
}
private:
- Command com;
+ string from;
+ string to;
};
-void Converter::Add(string const & from, string const & to,
- string const & command, string const & flags)
+Converter const * Converters::GetConverter(string const & from,
+ string const & to)
{
- formats.Add(from);
- formats.Add(to);
- Command Com(formats.GetFormat(from), formats.GetFormat(to), command);
- vector<Command>::iterator it = find_if(commands.begin(),
- commands.end(),
- compare_Command(Com));
-
- if (command.empty() || command == "none") {
- if (it != commands.end())
- commands.erase(it);
- return;
- }
+ ConverterList::const_iterator cit =
+ find_if(converterlist.begin(), converterlist.end(),
+ compare_Converter(from, to));
+ if (cit != converterlist.end())
+ return &(*cit);
+ else
+ return 0;
+}
- // Read the flags
- string flag_list(flags);
- while (!flag_list.empty()) {
- string flag_name, flag_value;
- flag_list = split(flag_list, flag_value, ',');
- flag_value = split(flag_value, flag_name, '=');
- if (flag_name == "*") {
- if (it != commands.end()) {
- Com = *it;
- Com.command = command;
- }
- }
- else if (flag_name == "importer")
- Com.importer = true;
- else if (flag_name == "latex")
- Com.latex = true;
- else if (flag_name == "originaldir")
- Com.original_dir = true;
- else if (flag_name == "needaux")
- Com.need_aux = true;
- else if (flag_name == "resultdir")
- Com.result_dir = (flag_value.empty())
- ? "$$BaseName" : flag_value;
- else if (flag_name == "resultfile")
- Com.result_file = flag_value;
- else if (flag_name == "parselog")
- Com.parselog = flag_value;
- else if (flag_name == "disable") {
- while (!flag_value.empty()) {
- string tmp;
- flag_value = split(flag_value, tmp, '&');
- Com.disable.push_back(tmp);
- }
- }
- }
- if (!Com.result_dir.empty() && Com.result_file.empty())
- Com.result_file = "index." + to;
- //if (!contains(command, "$$FName"))
- // Com.latex = true;
+int Converters::GetNumber(string const & from, string const & to)
+{
+ ConverterList::const_iterator cit =
+ find_if(converterlist.begin(), converterlist.end(),
+ compare_Converter(from, to));
+ if (cit != converterlist.end())
+ return cit - converterlist.begin();
+ else
+ return -1;
+}
+
- if (Com.latex && (latex_command.empty() || to == "dvi"))
+void Converters::Add(string const & from, string const & to,
+ string const & command, string const & flags)
+{
+ formats.Add(from);
+ formats.Add(to);
+ ConverterList::iterator it = find_if(converterlist.begin(),
+ converterlist.end(),
+ compare_Converter(from, to));
+
+ Converter converter(from, to, command, flags);
+ if (it != converterlist.end() && !flags.empty() && flags[0] == '*') {
+ converter = *it;
+ converter.command = command;
+ converter.flags = flags;
+ }
+ converter.ReadFlags();
+
+ if (converter.latex && (latex_command.empty() || to == "dvi"))
latex_command = command;
// If we have both latex & pdflatex, we set latex_command to latex.
// The latex_command is used to update the .aux file when running
// a converter that uses it.
- if (it != commands.end()) {
- *it = Com;
- return;
+ if (it == converterlist.end())
+ converterlist.push_back(converter);
+ else {
+ converter.From = it->From;
+ converter.To = it->To;
+ *it = converter;
}
- commands.push_back(Com);
}
-static inline
-bool enable(vector<Command>::iterator it, string const & from)
+void Converters::Delete(string const & from, string const & to)
{
- return find(it->disable.begin(), it->disable.end(), from)
- == it->disable.end();
+ ConverterList::iterator it = find_if(converterlist.begin(),
+ converterlist.end(),
+ compare_Converter(from, to));
+ if (it != converterlist.end())
+ converterlist.erase(it);
}
-vector<FormatPair> const
-Converter::GetReachableTo(string const & target)
+// This method updates the pointers From and To in all the converters.
+// The code is not very efficient, but it doesn't matter as the number
+// of formats and converters is small.
+// Furthermore, this method is called only on startup, or after
+// adding/deleting a format in FormPreferences (the latter calls can be
+// eliminated if the formats in the Formats class are stored using a map or
+// a list (instead of a vector), but this will cause other problems).
+void Converters::Update(Formats const & formats)
{
- vector<FormatPair> result;
+ for (ConverterList::iterator it = converterlist.begin();
+ it != converterlist.end(); ++it) {
+ it->From = formats.GetFormat(it->from);
+ it->To = formats.GetFormat(it->to);
+ }
+}
- queue< vector<Command>::iterator > Q;
- for (vector<Command>::iterator it = commands.begin();
- it != commands.end(); ++it)
- if (it->to->name == target && it->importer) {
- Q.push(it);
- it->visited = true;
- } else
- it->visited = false;
+
+// This method updates the pointers From and To in the last converter.
+// It is called when adding a new converter in FormPreferences
+void Converters::UpdateLast(Formats const & formats)
+{
+ if (converterlist.begin() != converterlist.end()) {
+ ConverterList::iterator it = converterlist.end()-1;
+ it->From = formats.GetFormat(it->from);
+ it->To = formats.GetFormat(it->to);
+ }
+}
+
+
+void Converters::Sort()
+{
+ sort(converterlist.begin(), converterlist.end());
+}
+
+
+int Converters::BFS_init(string const & start, bool clear_visited)
+{
+ int s = formats.GetNumber(start);
+ if (s < 0)
+ return s;
+
+ Q = queue<int>();
+ if (clear_visited)
+ fill(visited.begin(), visited.end(), false);
+ if (visited[s] == false) {
+ Q.push(s);
+ visited[s] = true;
+ }
+ return s;
+}
+
+
+vector<Format const *> const
+Converters::GetReachableTo(string const & target, bool clear_visited)
+{
+ vector<Format const *> result;
+ int s = BFS_init(target, clear_visited);
+ if (s < 0)
+ return result;
while (!Q.empty()) {
- vector<Command>::iterator it = Q.front();
+ int i = Q.front();
Q.pop();
- result.push_back(FormatPair(it->from, 0, ""));
- for (vector<Command>::iterator it2 = commands.begin();
- it2 != commands.end(); ++it2)
- if (!it2->visited && it->from == it2->to &&
- it2->importer) {
- Q.push(it2);
- it2->visited = true;
+ if (i != s || target != "lyx")
+ result.push_back(&formats.Get(i));
+ for (vector<int>::iterator it = vertices[i].in_vertices.begin();
+ it != vertices[i].in_vertices.end(); ++it)
+ if (!visited[*it]) {
+ visited[*it] = true;
+ Q.push(*it);
}
}
}
-vector<FormatPair> const
-Converter::GetReachable(string const & from, bool only_viewable)
+vector<Format const *> const
+Converters::GetReachable(string const & from, bool only_viewable,
+ bool clear_visited)
{
- vector<FormatPair> result;
- Format const * format = formats.GetFormat(from);
- if (!format)
- return result;
-
- if (!only_viewable || !format->viewer.empty())
- result.push_back(FormatPair(format, 0, ""));
+ vector<Format const *> result;
- queue< vector<Command>::iterator > Q;
- for (vector<Command>::iterator it = commands.begin();
- it != commands.end(); ++it)
- if (it->from->name == from && enable(it, from)
- && !it->importer) {
- Q.push(it);
- it->visited = true;
- } else
- it->visited = false;
+ if (BFS_init(from, clear_visited) < 0)
+ return result;
while (!Q.empty()) {
- vector<Command>::iterator it = Q.front();
+ int i = Q.front();
Q.pop();
- if (!only_viewable || !it->to->viewer.empty())
- result.push_back(FormatPair(it->to, it->from,
- it->command));
- for (vector<Command>::iterator it2 = commands.begin();
- it2 != commands.end(); ++it2)
- if (!it2->visited && it->to == it2->from &&
- enable(it2, from) && !it2->importer) {
- Q.push(it2);
- it2->visited = true;
+ Format const & format = formats.Get(i);
+ if (format.name() == "lyx")
+ continue;
+ if (!only_viewable || !format.viewer().empty() ||
+ format.IsChildFormat())
+ result.push_back(&format);
+ for (vector<int>::iterator it = vertices[i].out_vertices.begin();
+ it != vertices[i].out_vertices.end(); ++it)
+ if (!visited[*it]) {
+ visited[*it] = true;
+ Q.push(*it);
}
}
}
-bool Converter::IsReachable(string const & from, string const & to)
+bool Converters::IsReachable(string const & from, string const & to)
{
if (from == to)
return true;
- queue< vector<Command>::iterator > Q;
- for (vector<Command>::iterator it = commands.begin();
- it != commands.end(); ++it)
- if (it->from->name == from && enable(it, from)) {
- Q.push(it);
- it->visited = true;
- } else
- it->visited = false;
+ int s = BFS_init(from);
+ int t = formats.GetNumber(to);
+ if (s < 0 || t < 0)
+ return false;
while (!Q.empty()) {
- vector<Command>::iterator it = Q.front();
+ int i = Q.front();
Q.pop();
- if (it->to->name == to)
+ if (i == t)
return true;
- for (vector<Command>::iterator it2 = commands.begin();
- it2 != commands.end(); ++it2)
- if (!it2->visited && it->to == it2->from &&
- enable(it2, from)) {
- Q.push(it2);
- it2->visited = true;
+ for (vector<int>::iterator it = vertices[i].out_vertices.begin();
+ it != vertices[i].out_vertices.end(); ++it)
+ if (!visited[*it]) {
+ visited[*it] = true;
+ Q.push(*it);
}
}
+
return false;
}
-bool Converter::Convert(Buffer const * buffer,
- string const & from_file, string const & to_file_base,
- string const & from_format, string const & to_format,
- string const & using_format, string & to_file)
+Converters::EdgePath const
+Converters::GetPath(string const & from, string const & to)
{
- to_file = ChangeExtension(to_file_base,
- formats.Extension(to_format));
+ EdgePath path;
+ if (from == to)
+ return path;
- if (from_format == to_format)
- if (from_file != to_file)
- return lyx::rename(from_file, to_file);
- else
- return true;
+ int s = BFS_init(from);
+ int t = formats.GetNumber(to);
+ if (s < 0 || t < 0)
+ return path;
- queue< vector<Command>::iterator > Q;
- for (vector<Command>::iterator it = commands.begin();
- it != commands.end(); ++it)
- if (it->from->name == from_format && enable(it, from_format)) {
- Q.push(it);
- it->visited = true;
- it->previous = commands.end();
- } else
- it->visited = false;
-
- if (Q.empty()) {
- WriteAlert(_("Can not convert file"),
- ("Unknown format ") + from_format);
- return false;
- }
+ vector<int> prev_edge(formats.size());
+ vector<int> prev_vertex(formats.size());
bool found = false;
- vector<Command>::iterator it;
while (!Q.empty()) {
- it = Q.front();
- if (it->to->name == to_format &&
- (using_format.empty() || using_format == it->from->name)) {
+ int i = Q.front();
+ Q.pop();
+ if (i == t) {
found = true;
break;
}
- Q.pop();
- for (vector<Command>::iterator it2 = commands.begin();
- it2 != commands.end(); ++it2)
- if (!it2->visited && it->to == it2->from &&
- enable(it2, from_format)) {
- Q.push(it2);
- it2->visited = true;
- it2->previous = it;
+ for (vector<int>::iterator it = vertices[i].out_vertices.begin();
+ it != vertices[i].out_vertices.end(); ++it)
+ if (!visited[*it]) {
+ int j = *it;
+ visited[j] = true;
+ Q.push(j);
+ int k = it - vertices[i].out_vertices.begin();
+ prev_edge[j] = vertices[i].out_edges[k];
+ prev_vertex[j] = i;
}
}
+ if (!found)
+ return path;
- if (!found) {
+ while (t != s) {
+ path.push_back(prev_edge[t]);
+ t = prev_vertex[t];
+ }
+ reverse(path.begin(), path.end());
+ return path;
+}
+
+
+bool Converters::UsePdflatex(EdgePath const & path)
+{
+ for (EdgePath::const_iterator cit = path.begin();
+ cit != path.end(); ++cit) {
+ Converter const & conv = converterlist[*cit];
+ if (conv.latex)
+ return contains(conv.to, "pdf");
+ }
+ return false;
+}
+
+
+bool Converters::Convert(Buffer const * buffer,
+ string const & from_file, string const & to_file_base,
+ string const & from_format, string const & to_format,
+ string & to_file)
+{
+ to_file = ChangeExtension(to_file_base,
+ formats.Extension(to_format));
+
+ if (from_format == to_format)
+ if (from_file != to_file)
+ return lyx::rename(from_file, to_file);
+ else
+ return true;
+
+ EdgePath edgepath = GetPath(from_format, to_format);
+ if (edgepath.empty()) {
WriteAlert(_("Can not convert file"),
_("No information for converting from ")
+ formats.PrettyName(from_format) + _(" to ")
return false;
}
- vector< vector<Command>::iterator > S;
- while (it != commands.end()) {
- S.push_back(it);
- it = it->previous;
- }
-
string path = OnlyPath(from_file);
Path p(path);
string to_base = ChangeExtension(to_file, "");
string infile;
string outfile = from_file;
- for (vector< vector<Command>::iterator >::reverse_iterator rit =
- S.rbegin(); rit != S.rend(); ++rit) {
- it = *rit;
- bool dummy = it->to->dummy() && it->to->name != "program";
+ for (EdgePath::const_iterator cit = edgepath.begin();
+ cit != edgepath.end(); ++cit) {
+ Converter const & conv = converterlist[*cit];
+ bool dummy = conv.To->dummy() && conv.to != "program";
if (!dummy)
lyxerr << "Converting from "
- << it->from->name << " to " << it->to->name << endl;
+ << conv.from << " to " << conv.to << endl;
infile = outfile;
- outfile = it->result_dir.empty()
- ? ChangeExtension(from_file, it->to->extension)
- : AddName(subst(it->result_dir,
- "$$BaseName", from_base),
- subst(it->result_file,
- "$$BaseName", OnlyFilename(from_base)));
-
- if (it->latex) {
- lyxrc.pdf_mode = it->to->name == "pdf";
- lyxerr << "Running " << it->command << endl;
+ outfile = conv.result_dir.empty()
+ ? ChangeExtension(from_file, conv.To->extension())
+ : AddName(subst(conv.result_dir,
+ token_base, from_base),
+ subst(conv.result_file,
+ token_base, OnlyFilename(from_base)));
+
+ if (conv.latex) {
run_latex = true;
- if (!runLaTeX(buffer, it->command))
+ string command = subst(conv.command, token_from, "");
+ lyxerr << "Running " << command << endl;
+ if (!runLaTeX(buffer, command))
return false;
} else {
- if (it->need_aux && !run_latex
+ if (conv.need_aux && !run_latex
&& !latex_command.empty()) {
lyxerr << "Running " << latex_command
<< " to update aux file"<< endl;
runLaTeX(buffer, latex_command);
}
- string infile2 = (it->original_dir)
+ string infile2 = (conv.original_dir)
? infile : MakeRelPath(infile, path);
- string outfile2 = (it->original_dir)
+ string outfile2 = (conv.original_dir)
? outfile : MakeRelPath(outfile, path);
- string command = it->command;
- command = subst(command, "$$FName", QuoteName(infile2));
- command = subst(command, "$$BaseName", QuoteName(from_base));
- command = subst(command, "$$OutName", QuoteName(outfile2));
+ string command = conv.command;
+ command = subst(command, token_from, QuoteName(infile2));
+ command = subst(command, token_base, QuoteName(from_base));
+ command = subst(command, token_to, QuoteName(outfile2));
- if (!it->parselog.empty())
+ if (!conv.parselog.empty())
command += " 2> " + QuoteName(infile2 + ".out");
- if (it->from->name == "dvi" && it->to->name == "ps")
+ if (conv.from == "dvi" && conv.to == "ps")
command = add_options(command,
dvips_options(buffer));
? Systemcalls::SystemDontWait : Systemcalls::System;
Systemcalls one;
int res;
- if (it->original_dir && buffer) {
+ if (conv.original_dir && buffer) {
Path p(buffer->filepath);
res = one.startscript(type, command);
} else
res = one.startscript(type, command);
- if (!it->parselog.empty()) {
+ if (!conv.parselog.empty()) {
string const logfile = infile2 + ".log";
- string const command2 = it->parselog +
+ string const command2 = conv.parselog +
" < " + QuoteName(infile2 + ".out") +
" > " + QuoteName(logfile);
one.startscript(Systemcalls::System, command2);
}
if (res) {
- if (it->to->name == "program")
+ if (conv.to == "program")
WriteAlert(_("There were errors during the Build process."),
_("You should try to fix them."));
else
}
}
- if (it->to->dummy())
+ Converter const & conv = converterlist[edgepath.back()];
+ if (conv.To->dummy())
return true;
- if (!it->result_dir.empty()) {
- to_file = AddName(subst(it->result_dir,
- "$$BaseName", to_base),
- subst(it->result_file,
- "$$BaseName", OnlyFilename(to_base)));
+ if (!conv.result_dir.empty()) {
+ to_file = AddName(subst(conv.result_dir, token_base, to_base),
+ subst(conv.result_file,
+ token_base, OnlyFilename(to_base)));
if (from_base != to_base) {
- string from = subst(it->result_dir,
- "$$BaseName", from_base);
- string to = subst(it->result_dir,
- "$$BaseName", to_base);
+ string from = subst(conv.result_dir,
+ token_base, from_base);
+ string to = subst(conv.result_dir,
+ token_base, to_base);
if (!lyx::rename(from, to)) {
WriteAlert(_("Error while trying to move directory:"),
from, ("to ") + to);
}
}
} else if (outfile != to_file) {
- bool moved = (it->latex)
+ bool moved = (conv.latex)
? lyx::copy(outfile, to_file)
: lyx::rename(outfile, to_file);
if (!moved) {
}
-bool Converter::Convert(Buffer const * buffer,
+bool Converters::Convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
- string const & from_format, string const & to_format,
- string const & using_format)
+ string const & from_format, string const & to_format)
{
string to_file;
return Convert(buffer, from_file, to_file_base, from_format, to_format,
- using_format, to_file);
+ to_file);
+}
+
+
+void Converters::BuildGraph()
+{
+ vertices = vector<Vertex>(formats.size());
+ visited.resize(formats.size());
+
+ for (ConverterList::iterator it = converterlist.begin();
+ it != converterlist.end(); ++it) {
+ int s = formats.GetNumber(it->from);
+ int t = formats.GetNumber(it->to);
+ vertices[t].in_vertices.push_back(s);
+ vertices[s].out_vertices.push_back(t);
+ vertices[s].out_edges.push_back(it - converterlist.begin());
+ }
}
-string const Converter::SplitFormat(string const & str, string & format)
+bool Converters::FormatIsUsed(string const & format)
{
- string const using_format = split(str, format, ':');
- if (format.empty())
- format = "dvi";
- return using_format;
+ for (ConverterList::const_iterator cit = converterlist.begin();
+ cit != converterlist.end(); ++cit)
+ if (cit->from == format || cit->to == format)
+ return true;
+ return false;
}
-bool Converter::scanLog(Buffer const * buffer, string const & command,
+bool Converters::scanLog(Buffer const * buffer, string const & command,
string const & filename)
{
if (!buffer)
}
-bool Converter::runLaTeX(Buffer const * buffer, string const & command)
+bool Converters::runLaTeX(Buffer const * buffer, string const & command)
{
if (!buffer)
return false;
}
-string const Converter::dvi_papersize(Buffer const * buffer)
+string const Converters::dvi_papersize(Buffer const * buffer)
{
char real_papersize = buffer->params.papersize;
if (real_papersize == BufferParams::PAPER_DEFAULT)
}
-string const Converter::dvips_options(Buffer const * buffer)
+string const Converters::dvips_options(Buffer const * buffer)
{
string result;
if (!buffer)
return result;
}
-
-void Converter::init()
-{
-}
-
-vector<Command> const Converter::GetAllCommands()
-{
- vector<Command> result;
- for (vector<Command>::iterator it = commands.begin();
- it != commands.end(); ++it)
- result.push_back(*it);
- return result;
-}
+vector<Converters::Vertex> Converters::vertices;
/// The global instance
Formats formats;
+Converters converters;
-// The global copy of the system lyxrc entries (everything except preferences)
+// The global copy after reading lyxrc.defaults
Formats system_formats;
+Converters system_converters;
#pragma interface
#endif
-#include <map>
#include <vector>
+#include <queue>
#include "LString.h"
+#include "support/lstrings.h"
class Buffer;
///
class Format {
public:
- ///
- Format() {}
///
Format(string const & n, string const & e, string const & p,
string const & s, string const & v) :
- name(n), extension(e), prettyname(p), shortcut(s),
- viewer(v) {};
+ name_(n), extension_(e), prettyname_(p), shortcut_(s),
+ viewer_(v) {};
+ ///
+ bool dummy() const;
///
- string name;
+ bool IsChildFormat() const;
///
- string extension;
+ string const ParentFormat() const;
///
- string prettyname;
+ string const & name() const {
+ return name_;
+ }
///
- string shortcut;
+ string const & extension() const {
+ return extension_;
+ }
///
- string viewer;
+ string const & prettyname() const {
+ return prettyname_;
+ }
///
- bool dummy() const;
+ string const & shortcut() const {
+ return shortcut_;
+ }
+ ///
+ string const & viewer() const {
+ return viewer_;
+ }
+ ///
+ void setViewer(string const & v) {
+ viewer_ = v;
+ }
+ friend bool operator<(Format const & a, Format const & b) {
+ return compare_no_case(a.prettyname(),b.prettyname()) < 0;
+ }
+private:
+ string name_;
+ ///
+ string extension_;
+ ///
+ string prettyname_;
+ ///
+ string shortcut_;
+ ///
+ string viewer_;
+};
+
+
+///
+class Formats {
+public:
+ ///
+ typedef std::vector<Format> FormatList;
+ ///
+ typedef FormatList::const_iterator const_iterator;
+ ///
+ Format const & Get(int i) const {
+ return formatlist[i];
+ }
+ ///
+ Format const * GetFormat(string const & name) const;
///
- string const getname() const {
- return name;
+ int GetNumber(string const & name) const;
+ ///
+ void Add(string const & name);
+ ///
+ void Add(string const & name, string const & extension,
+ string const & prettyname, string const & shortcut);
+ ///
+ void Delete(string const & name);
+ ///
+ void Sort();
+ ///
+ void SetViewer(string const & name, string const & command);
+ ///
+ bool View(Buffer const * buffer, string const & filename,
+ string const & format_name) const;
+ ///
+ string const PrettyName(string const & name) const;
+ ///
+ string const Extension(string const & name) const;
+ ///
+ const_iterator begin() const {
+ return formatlist.begin();
}
///
- string const getprettyname() const {
- return prettyname;
+ const_iterator end() const {
+ return formatlist.end();
}
+ ///
+ FormatList::size_type size() const {
+ return formatlist.size();
+ }
+private:
+ ///
+ FormatList formatlist;
};
+///////////////////////////////////////////////////////////////////////
+
///
-struct Command {
+class Converter {
+public:
///
- Command(Format const * f, Format const * t, string const & c)
- : from(f), to(t), command(c), importer(false),
+ Converter(string const & f, string const & t, string const & c,
+ string const & l)
+ : from(f), to(t), command(c), flags(l), From(0), To(0),
latex(false), original_dir(false), need_aux(false) {}
///
- Format const * from;
+ void ReadFlags();
+ ///
+ string from;
///
- Format const * to;
+ string to;
///
string command;
- /// The converter is used for importing
- bool importer;
+ ///
+ string flags;
+ ///
+ Format const * From;
+ ///
+ Format const * To;
+
/// The converter is latex or its derivatives
bool latex;
/// Do we need to run the converter in the original directory?
string result_file;
/// Command to convert the program output to a LaTeX log file format
string parselog;
- /// Backends in which the converter is not used
- std::vector<string> disable;
-
- /// Used by the BFS algorithm
- bool visited;
- /// Used by the BFS algorithm
- std::vector<Command>::iterator previous;
- ///
- std::pair<string, string> const getFromToPrettyname() const {
- return std::pair<string, string>(from->prettyname,
- to->prettyname);
- }
};
-class FormatPair {
-public:
- ///
- Format const * format;
- ///
- Format const * from;
- ///
- string command;
- ///
- FormatPair(Format const * f1, Format const * f2, string c)
- : format(f1), from(f2), command(c) {}
-};
///
-class Formats {
+class Converters {
public:
- ///
- typedef std::map<string, Format> FormatList;
+ typedef std::vector<Converter> ConverterList;
///
- void Add(string const & name);
- ///
- void Add(string const & name, string const & extension,
- string const & prettyname, string const & shortcut);
+ typedef ConverterList::const_iterator const_iterator;
///
- void SetViewer(string const & name, string const & command);
- ///
- bool View(Buffer const * buffer, string const & filename,
- string const & format_name);
+ typedef std::vector<int> EdgePath;
///
- Format * GetFormat(string const & name);
- ///
- string const PrettyName(string const & name);
- ///
- string const Extension(string const & name);
+ Converter const & Get(int i) const {
+ return converterlist[i];
+ }
///
- std::vector<Format> const GetAllFormats() const;
-private:
+ Converter const * GetConverter(string const & from, string const & to);
///
- FormatList formats;
-};
-
-///
-class Converter {
-public:
+ int GetNumber(string const & from, string const & to);
///
- static
void Add(string const & from, string const & to,
string const & command, string const & flags);
+ //
+ void Delete(string const & from, string const & to);
///
- static
- std::vector<FormatPair> const GetReachableTo(string const & target);
+ void Sort();
///
- static
- std::vector<FormatPair> const
- GetReachable(string const & from, bool only_viewable);
+ std::vector<Format const *> const
+ GetReachableTo(string const & target, bool clear_visited);
+ ///
+ std::vector<Format const *> const
+ GetReachable(string const & from, bool only_viewable,
+ bool clear_visited);
///
- static
bool IsReachable(string const & from, string const & to);
///
- static
+ EdgePath const GetPath(string const & from, string const & to);
+ ///
+ bool UsePdflatex(EdgePath const & path);
+ ///
bool Convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
string const & from_format, string const & to_format,
- string const & using_format, string & to_file);
+ string & to_file);
///
- static
bool Convert(Buffer const * buffer,
string const & from_file, string const & to_file_base,
- string const & from_format, string const & to_format,
- string const & using_format = string());
- ///
- static
- string const SplitFormat(string const & str, string & format);
+ string const & from_format, string const & to_format);
///
- static
string const dvi_papersize(Buffer const * buffer);
///
- static
string const dvips_options(Buffer const * buffer);
///
- static
- void init();
+ void Update(Formats const & formats);
///
- static
- std::vector<Command> const GetAllCommands();
+ void UpdateLast(Formats const & formats);
+ ///
+ void BuildGraph();
+ ///
+ bool FormatIsUsed(string const & format);
+ ///
+ const_iterator begin() const {
+ return converterlist.begin();
+ }
+ const_iterator end() const {
+ return converterlist.end();
+ }
private:
///
- static
bool scanLog(Buffer const * buffer, string const & command,
string const & filename);
///
- static
bool runLaTeX(Buffer const * buffer, string const & command);
///
- static
- std::vector<Command> commands;
+ ConverterList converterlist;
///
- static
string latex_command;
+ ///
+ struct Vertex {
+ std::vector<int> in_vertices;
+ std::vector<int> out_vertices;
+ std::vector<int> out_edges;
+ };
+ ///
+ static
+ std::vector<Vertex> vertices;
+ ///
+ std::vector<bool> visited;
+ ///
+ std::queue<int> Q;
+ ///
+ int BFS_init(string const & start, bool clear_visited = true);
};
extern Formats formats;
-extern Formats system_formats;
+extern Converters converters;
+extern Formats system_formats;
+extern Converters system_converters;
#endif
#pragma implementation
#endif
+#include <algorithm>
+
#include "exporter.h"
#include "buffer.h"
#include "lyx_cb.h" //ShowMessage()
#include "support/filetools.h"
#include "lyxrc.h"
#include "converter.h"
+#include "lyx_gui_misc.h" //WriteAlert
using std::vector;
+using std::find;
-bool Exporter::Export(Buffer * buffer, string const & format0,
+bool Exporter::Export(Buffer * buffer, string const & format,
bool put_in_tempdir, string & result_file)
{
- string format;
- string using_format = Converter::SplitFormat(format0, format);
-
- string backend_format = (format == "text")
- ? format : BufferFormat(buffer);
- bool only_backend = backend_format == format;
+ string backend_format;
+ vector<string> backends = Backends(buffer);
+ if (find(backends.begin(), backends.end(), format) == backends.end()) {
+ for (vector<string>::const_iterator it = backends.begin();
+ it != backends.end(); ++it) {
+ Converters::EdgePath p =
+ converters.GetPath(*it, format);
+ if (!p.empty()) {
+ lyxrc.pdf_mode = converters.UsePdflatex(p);
+ backend_format = *it;
+ break;
+ }
+ }
+ if (backend_format.empty()) {
+ WriteAlert(_("Can not export file"),
+ _("No information for exporting to ")
+ + formats.PrettyName(format));
+ return false;
+ }
+ } else
+ backend_format = format;
string filename = buffer->getLatexName(false);
if (!buffer->tmppath.empty())
else if (buffer->isDocBook())
buffer->makeDocBookFile(filename, true);
// LaTeX backend
- else if (only_backend)
+ else if (backend_format == format)
buffer->makeLaTeXFile(filename, string(), true);
else
buffer->makeLaTeXFile(filename, buffer->filepath, false);
string outfile_base = (put_in_tempdir)
? filename : buffer->getLatexName(false);
- if (!Converter::Convert(buffer, filename, outfile_base,
- backend_format, format, using_format,
- result_file))
+ if (!converters.Convert(buffer, filename, outfile_base,
+ backend_format, format, result_file))
return false;
if (!put_in_tempdir)
return Export(buffer, format, put_in_tempdir, result_file);
}
-bool Exporter::Preview(Buffer * buffer, string const & format0)
+bool Exporter::Preview(Buffer * buffer, string const & format)
{
string result_file;
- if (!Export(buffer, format0, true, result_file))
+ if (!Export(buffer, format, true, result_file))
return false;
- string format;
- Converter::SplitFormat(format0, format);
return formats.View(buffer, result_file, format);
}
bool Exporter::IsExportable(Buffer const * buffer, string const & format)
{
- return format == "text" ||
- Converter::IsReachable(BufferFormat(buffer), format);
+ vector<string> backends = Backends(buffer);
+ for (vector<string>::const_iterator it = backends.begin();
+ it != backends.end(); ++it)
+ if (converters.IsReachable(*it, format))
+ return true;
+ return false;
}
-vector<FormatPair> const
+vector<Format const *> const
Exporter::GetExportableFormats(Buffer const * buffer, bool only_viewable)
{
- vector<FormatPair> result =
- Converter::GetReachable(BufferFormat(buffer), only_viewable);
- Format * format = formats.GetFormat("text");
- if (format && (!only_viewable || !format->viewer.empty()))
- result.push_back(FormatPair(format , 0, ""));
+ vector<string> backends = Backends(buffer);
+ vector<Format const *> result =
+ converters.GetReachable(backends[0], only_viewable, true);
+ for (vector<string>::const_iterator it = backends.begin() + 1;
+ it != backends.end(); ++it) {
+ vector<Format const *> r =
+ converters.GetReachable(*it, only_viewable, false);
+ result.insert(result.end(), r.begin(), r.end());
+ }
return result;
}
else
return "latex";
}
+
+vector<string> const Exporter::Backends(Buffer const * buffer)
+{
+ vector<string> v;
+ v.push_back(BufferFormat(buffer));
+ v.push_back("text");
+ return v;
+}
#include "LString.h"
class Buffer;
-class FormatPair;
+class Format;
class Exporter {
public:
bool IsExportable(Buffer const * buffer, string const & format);
///
static
- std::vector<FormatPair> const
+ std::vector<Format const *> const
GetExportableFormats(Buffer const * buffer, bool only_viewable);
///
-
- ///
+private:
static
string const BufferFormat(Buffer const * buffer);
+ ///
+ static
+ std::vector<string> const Backends(Buffer const * buffer);
};
#endif
command += lyxrc.print_extra_options + ' ';
}
- command += Converter::dvips_options(buffer) + ' ';
+ command += converters.dvips_options(buffer) + ' ';
if (!Exporter::Export(buffer, "dvi", true))
return false;
*======================================================*/
#include <config.h>
+#include FORMS_H_LOCATION
#ifdef __GNUG_
#pragma implementation
#include <algorithm> // max
#include <cmath> // floor
+#include <fstream> // ofstream
#include "Color.h"
+#include "lyxlex.h"
using std::max;
using std::min;
+using std::ofstream;
static int const nohue = -1;
-RGB::RGB( HSV const & hsv )
+RGBColor::RGBColor( HSVColor const & hsv )
{
double h = hsv.h;
double s = hsv.s;
}
-HSV::HSV( RGB const & rgb )
+HSVColor::HSVColor( RGBColor const & rgb )
{
// r, g, b lie in the range 0-1, not 0-255.
double r = rgb.r / 255.0;
}
}
+
+// sorted by hand to prevent LyXLex from complaining on read().
+static
+keyword_item xformTags[] = {
+// { "\\gui_active_tab", FL_LIGHTER_COL1 },
+ { "\\gui_background", FL_COL1 },
+ { "\\gui_buttonbottom", FL_BOTTOM_BCOL },
+ { "\\gui_buttonleft", FL_LEFT_BCOL },
+ { "\\gui_buttonright", FL_RIGHT_BCOL },
+ { "\\gui_buttontop", FL_TOP_BCOL },
+ { "\\gui_inactive", FL_INACTIVE },
+ { "\\gui_push_button", FL_YELLOW },
+ { "\\gui_selected", FL_MCOL },
+ { "\\gui_text", FL_BLACK }
+};
+
+
+static const int xformCount = sizeof(xformTags) / sizeof(keyword_item);
+
+
+bool XformColor::read(string const & filename)
+{
+ LyXLex lexrc( xformTags, xformCount );
+ if( !lexrc.setFile( filename ) )
+ return false;
+
+ while( lexrc.IsOK() ) {
+ int le = lexrc.lex();
+
+ switch( le ) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown tag `$$Token'");
+ continue;
+ case LyXLex::LEX_FEOF:
+ continue;
+ default: break;
+ }
+
+ RGBColor col;
+
+ if( !lexrc.next() ) break;
+ col.r = lexrc.GetInteger();
+
+ if( !lexrc.next() ) break;
+ col.g = lexrc.GetInteger();
+
+ if( !lexrc.next() ) break;
+ col.b = lexrc.GetInteger();
+
+ fl_mapcolor(le, col.r, col.g, col.b);
+ }
+
+ return true;
+}
+
+
+bool XformColor::write(string const & filename)
+{
+ ofstream os(filename.c_str());
+ if (!os)
+ return false;
+
+ os << "### This file is part of\n"
+ << "### ========================================================\n"
+ << "### LyX, The Document Processor\n"
+ << "###\n"
+ << "### Copyright 1995 Matthias Ettrich\n"
+ << "### Copyright 1995-2000 The LyX Team.\n"
+ << "###\n"
+ << "### ========================================================\n"
+ << "\n"
+ << "# This file is written by LyX, if you want to make your own\n"
+ << "# modifications you should do them from inside LyX and save\n"
+ << "\n";
+
+ for( int i = 0; i < xformCount; ++i ) {
+ string tag = xformTags[i].tag;
+ int colorID = xformTags[i].code;
+ RGBColor color;
+
+ fl_getmcolor(colorID, &color.r, &color.g, &color.b);
+
+ os << tag + " "
+ << color.r << " " << color.g << " " << color.b << "\n";
+ }
+
+ return true;
+}
#ifndef COLOR_H
#define COLOR_H
-#include<utility> // for pair
+#include <utility> // for pair
#ifdef __GNUG_
#pragma interface
#include "LString.h"
-class HSV;
-class RGB;
+class HSVColor;
+class RGBColor;
-struct HSV {
+struct HSVColor {
double h;
double s;
double v;
- HSV() : h(0.0), s(0.0), v(0.0) {}
- HSV(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
- HSV( RGB const & );
+ HSVColor() : h(0.0), s(0.0), v(0.0) {}
+ HSVColor(double hue, double sat, double val) : h(hue), s(sat), v(val) {}
+ HSVColor( RGBColor const & );
};
-struct RGB {
+struct RGBColor {
int r;
int g;
int b;
- RGB() : r(0), g(0), b(0) {}
- RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
- RGB( HSV const & );
+ RGBColor() : r(0), g(0), b(0) {}
+ RGBColor(int red, int green, int blue) : r(red), g(green), b(blue) {}
+ RGBColor( HSVColor const & );
};
-typedef std::pair<string, RGB> X11Color;
+typedef std::pair<string, RGBColor> X11Color;
/// struct holding xform-specific colors
-struct XFormColor {
+struct XformColor {
string name;
int colorID;
- RGB col;
- XFormColor() : colorID(0) {}
+ RGBColor col;
+ XformColor() : colorID(0) {}
string const getname() { return name; }
+ static bool read( string const & );
+ static bool write( string const & );
};
inline
-bool operator==(RGB const & c1, RGB const & c2)
+bool operator==(RGBColor const & c1, RGBColor const & c2)
{
return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
}
inline
-bool operator!=(RGB const & c1, RGB const & c2)
+bool operator!=(RGBColor const & c1, RGBColor const & c2)
{
return !(c1 == c2);
}
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2000 The LyX Team.
+ *
+ * ======================================================
+ */
+
#include <config.h>
-#include FORMS_H_LOCATION
#include "Dialogs.h"
#include "FormCitation.h"
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2000 The LyX Team.
+ *
+ *======================================================*/
/* FormPreferences.C
* FormPreferences Interface Class Implementation
*/
using std::find;
using std::find_if;
using std::pair;
+using std::max;
using std::sort;
using std::vector;
+using std::endl;
extern string fmt(char const * fmtstr ...);
extern string system_lyxdir;
+extern string user_lyxdir;
extern Languages languages;
static string const colorFile("/usr/lib/X11/rgb.txt");
vector<X11Color> FormPreferences::colorDB;
-vector<XFormColor> FormPreferences::xformColorDB;
+vector<XformColor> FormPreferences::xformColorDB;
pair<vector<string>, vector<string> > FormPreferences::dirlist;
-// Two functions used to help sort a vector<Command> and a vector<Format>.
-// Only used in this file, so no need to declare them globally.
-bool CommandsCompare( Command const & a, Command const & b )
-{
- if( a.from->prettyname == b.from->prettyname )
- return( a.to->prettyname < b.to->prettyname );
- else
- return( a.from->prettyname < b.from->prettyname );
-}
-
-
-bool FormatsCompare( Format const & a, Format const & b )
-{
- return( a.name < b.name );
-}
-
+Formats local_formats;
+Converters local_converters;
FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
: FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
- warningPosted(false)
+ warningPosted(false), modifiedXformPrefs(false)
+
{
// let the dialog be shown
// This is a permanent connection so we won't bother
void FormPreferences::redraw()
{
- if( form() && form()->visible )
- fl_redraw_form( form() );
- else
+ if( !(form() && form()->visible) )
return;
+ fl_redraw_form( form() );
- FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
- if (outer_form && outer_form->visible)
- fl_redraw_form( outer_form );
- else
+ FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
+ if( !(form2 && form2->visible) )
return;
+ fl_redraw_form( form2 );
- if( outer_form == converters_tab_->form )
- outer_form =
- fl_get_active_folder(converters_tab_->tabfolder_outer);
+ FL_FORM * form3 = 0;
+ if( form2 == converters_tab_->form )
+ form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
- else if( outer_form == look_n_feel_tab_->form )
- outer_form =
- fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
+ else if( form2 == look_n_feel_tab_->form )
+ form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
- else if( outer_form == inputs_tab_->form )
- outer_form = fl_get_active_folder(inputs_tab_->tabfolder_outer);
+ else if( form2 == inputs_tab_->form )
+ form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
- else if( outer_form == outputs_tab_->form )
- outer_form =
- fl_get_active_folder(outputs_tab_->tabfolder_outer);
+ else if( form2 == outputs_tab_->form )
+ form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
- else if( outer_form == usage_tab_->form )
- outer_form = fl_get_active_folder(usage_tab_->tabfolder_outer);
+ else if( form2 == usage_tab_->form )
+ form3 = fl_get_active_folder(usage_tab_->tabfolder_outer);
- if (outer_form && outer_form->visible)
- fl_redraw_form( outer_form );
+ if (form3 && form3->visible)
+ fl_redraw_form( form3 );
}
void FormPreferences::ok()
{
FormBase::ok();
+
+ if( modifiedXformPrefs ) {
+ string filename = user_lyxdir + "/preferences.xform";
+ modifiedXformPrefs = ! XformColor::write( filename );
+ }
+
lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
}
// and other stuff which may cost us a lot on slower/high-load machines.
applyColors();
+ applyFormats(); /// Must be before applyConverters()
applyConverters();
- applyFormats();
applyInputsMisc();
applyInterface();
applyLanguage();
// read lyxrc entries
updateColors();
+ updateFormats(); /// Must be before updateConverters()
updateConverters();
- updateFormats();
updateInputsMisc();
updateInterface();
updateLanguage();
}
-void FormPreferences::applyColors() const
+void FormPreferences::applyColors()
{
- bool modifiedXForms = false;
bool modifiedText = false;
bool modifiedBackground = false;
- for( vector<XFormColor>::const_iterator cit = xformColorDB.begin();
+ for( vector<XformColor>::const_iterator cit = xformColorDB.begin();
cit != xformColorDB.end(); ++cit ) {
- RGB col;
+ RGBColor col;
fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
if( col != (*cit).col ) {
- modifiedXForms = true;
+ modifiedXformPrefs = true;
if( (*cit).colorID == FL_BLACK )
modifiedText = true;
if( (*cit).colorID == FL_COL1 )
}
}
- if( modifiedXForms ) {
- vector<XFormColor>::const_iterator cit;
+ if( modifiedXformPrefs ) {
+ vector<XformColor>::const_iterator cit;
for( cit = xformColorDB.begin();
cit != xformColorDB.end(); ++cit ) {
fl_mapcolor((*cit).colorID,
ColorsLoadBrowserLyX();
- // deactivate the browse button because it isn't implemented
- fl_deactivate_object(colors_->button_browse);
- fl_set_object_lcol(colors_->button_browse, FL_INACTIVE);
-
// set up the feedback mechanism
setPreHandler( colors_->browser_x11 );
setPreHandler( colors_->input_name );
} else if (ob == colors_->input_name) {
return ColorsDatabase();
+ } else if (ob == colors_->button_browse) {
+ return ColorsBrowseDatabase();
+
} else if (ob == colors_->browser_lyx_objs) {
return ColorsBrowserLyX();
void FormPreferences::ColorsAdjustVal( int colAdjust, int colParent,
double addVal ) const
{
- RGB rgb;
+ RGBColor rgb;
fl_getmcolor( colParent, &rgb.r, &rgb.g, &rgb.b);
- HSV hsv = HSV( rgb );
+ HSVColor hsv = HSVColor( rgb );
hsv.v += addVal;
if( hsv.v > 1.0 )
hsv.v = 1.0;
else if( hsv.v < 0.0 )
hsv.v = 0.0;
- rgb = RGB( hsv );
+ rgb = RGBColor( hsv );
fl_mapcolor( colAdjust, rgb.r, rgb.g, rgb.b );
}
string name = fl_get_browser_line( colors_->browser_lyx_objs, i );
- vector<XFormColor>::const_iterator cit =
+ vector<XformColor>::const_iterator cit =
find_if(xformColorDB.begin(), xformColorDB.end(),
- compare_memfun(&XFormColor::getname, name));
+ compare_memfun(&XformColor::getname, name));
if( cit != xformColorDB.end() ) {
fl_freeze_form( colors_->form );
fl_freeze_form( colors_->form );
- RGB col = colorDB[i-1].second;
+ RGBColor col = colorDB[i-1].second;
fl_mapcolor( FL_FREE_COL4 + i, col.r, col.g, col.b );
fl_mapcolor( FL_FREE_COL4, col.r, col.g, col.b );
}
+bool FormPreferences::ColorsBrowseDatabase() const
+{
+ return true;
+}
+
+
bool FormPreferences::ColorsDatabase() const
{
string file = fl_get_input(colors_->input_name);
void FormPreferences::ColorsLoadBrowserLyX()
{
- XFormColor xcol;
+ // First, define the modifiable xform colors
+ XformColor xcol;
xcol.name = "GUI background";
xcol.colorID = FL_COL1;
xformColorDB.push_back( xcol );
- xcol.name = "GUI active tab";
- xcol.colorID = FL_LIGHTER_COL1;
- fl_getmcolor(FL_LIGHTER_COL1, &xcol.col.r, &xcol.col.g, &xcol.col.b);
+ // FL_LIGHTER_COL1 does not exist in xforms 0.88
+// xcol.name = "GUI active tab";
+// xcol.colorID = FL_LIGHTER_COL1;
+// fl_getmcolor(FL_LIGHTER_COL1, &xcol.col.r, &xcol.col.g, &xcol.col.b);
- xformColorDB.push_back( xcol );
+// xformColorDB.push_back( xcol );
xcol.name = "GUI push button";
xcol.colorID = FL_YELLOW;
FL_OBJECT * colbr = colors_->browser_lyx_objs;
fl_clear_browser( colbr );
- for( vector<XFormColor>::const_iterator cit = xformColorDB.begin();
+ for( vector<XformColor>::const_iterator cit = xformColorDB.begin();
cit != xformColorDB.end(); ++cit ) {
fl_addto_browser(colbr, (*cit).name.c_str() );
}
- fl_deselect_browser(colors_->browser_lyx_objs);
+ // Now load the LyX LColors
+
+ // just to be safe...
+ fl_deselect_browser( colors_->browser_lyx_objs );
fl_deactivate_object( colors_->button_modify );
fl_set_object_lcol( colors_->button_modify, FL_INACTIVE );
}
if (!lex.setFile(filename))
return true;
- vector<RGB> cols;
+ vector<RGBColor> cols;
vector<string> names;
while (lex.next()) {
- RGB col;
+ RGBColor col;
col.r = lex.GetInteger();
lex.next();
col.g = lex.GetInteger();
// remove redundant entries on the fly
bool add = cols.empty();
if (!add) {
- vector<RGB>::const_iterator cit =
+ vector<RGBColor>::const_iterator cit =
find( cols.begin(), cols.end(), col );
add = (cit == cols.end());
}
if (add) {
- if( col == RGB(0,0,0) )
+ if( col == RGBColor(0,0,0) )
name = "black";
- else if( col == RGB(255,255,255) )
+ else if( col == RGBColor(255,255,255) )
name = "white";
else
name = lowercase( name );
- if ( col == RGB(0,0,0) || col == RGB(255,255,255) ) {
+ if ( col == RGBColor(0,0,0) ||
+ col == RGBColor(255,255,255) ) {
cols.insert(cols.begin(), col);
names.insert(names.begin(), name);
} else {
fl_clear_browser( colbr );
vector<string>::const_iterator sit = names.begin();
- for (vector<RGB>::const_iterator iit = cols.begin();
+ for (vector<RGBColor>::const_iterator iit = cols.begin();
iit != cols.end(); ++iit, ++sit) {
colorDB.push_back( X11Color(*sit, *iit) );
fl_addto_browser(colbr, (*sit).c_str());
string name = fl_get_browser_line( colors_->browser_lyx_objs, i );
- vector<XFormColor>::iterator it = // non-const; it's modified below
+ vector<XformColor>::iterator it = // non-const; it's modified below
find_if(xformColorDB.begin(), xformColorDB.end(),
- compare_memfun(&XFormColor::getname, name));
+ compare_memfun(&XformColor::getname, name));
if( it == xformColorDB.end() )
return true;
{
fl_freeze_form(colors_->form);
- RGB col;
+ RGBColor col;
col.r = int(fl_get_slider_value(colors_->valslider_red));
col.g = int(fl_get_slider_value(colors_->valslider_green));
col.b = int(fl_get_slider_value(colors_->valslider_blue));
}
-int FormPreferences::ColorsSearchEntry(RGB const & col) const
+int FormPreferences::ColorsSearchEntry(RGBColor const & col) const
{
int mindiff = 0x7fffffff;
vector<X11Color>::const_iterator mincit = colorDB.begin();
for (vector<X11Color>::const_iterator cit = colorDB.begin();
cit != colorDB.end(); ++cit) {
- RGB colDB = (*cit).second;
- RGB diff;
+ RGBColor colDB = (*cit).second;
+ RGBColor diff;
diff.r = col.r - colDB.r;
diff.g = col.g - colDB.g;
diff.b = col.b - colDB.b;
void FormPreferences::applyConverters() const
{
- /* Uncomment once Converter is a "real" class.
-
- vector<Command> old = Converter::GetAllCommands();
- for (vector<Command>::const_iterator cit = old.begin();
- cit != old.end(); ++cit) {
- pair<string, string> FromTo =
- pair<string, string>((*cit).from->prettyname,
- (*cit).to->prettyname);
-
- vector<Command>::const_iterator cit2 =
- find_if(commands_vec.begin(), commands_vec.end(),
- compare_memfun(&Command::getFromToPrettyname,
- FromTo));
-
- // Ie, converter exists in old, but is removed now.
- // Can't actually Delete it, because old will contain
- // system defauts.
- if (cit2 == commands_vec.end())
- commands.Add((*cit).from, (*cit).to, string());
- }
-
- // Add new converters.
- for (vector<Command>::const_iterator cit = commands_vec.begin();
- cit != commands_vec.end(); ++cit) {
- commands.Add((*cit).from, (*cit).to, (*cit).command);
- }
- */
+ converters = local_converters;
+ converters.Update(formats);
+ converters.BuildGraph();
}
} else if (ob == converters_->choice_to) {
str = N_("Convert \"to\" this format");
} else if (ob == converters_->input_converter) {
- str = N_("The conversion command. \"$$FName\" is the input file name, \"$$BaseName\" is the file name without its extension and $$OutName is the name of the output file.");
+ str = N_("The conversion command. $$i is the input file name, $$b is the file name without its extension and $$o is the name of the output file.");
} else if (ob == converters_->input_flags) {
- str = N_("I have no idea what this field is to be used for!");
+ str = N_("Flags that control the converter behavior");
} else if (ob == converters_->button_delete) {
str = N_("Remove the current converter from the list of available converters.");
} else if (ob == converters_->button_add) {
void FormPreferences::updateConverters()
{
- commands_vec = Converter::GetAllCommands();
- sort( commands_vec.begin(), commands_vec.end(), &CommandsCompare );
-
- ConvertersClear();
+ local_converters = converters;
+ local_converters.Update(local_formats);
+ ConvertersUpdateBrowser();
}
-bool FormPreferences::ConvertersAdd()
-{
- Command command( 0, 0, "" );
- if( !ConvertersSetCommand( command ) )
- return false;
+struct compare_converter {
+ int operator()(Converter const & a, Converter const & b) {
+ int i = compare_no_case(a.From->prettyname(),
+ b.From->prettyname());
+ if (i == 0)
+ return compare_no_case(a.To->prettyname(),
+ b.To->prettyname()) < 0;
+ else
+ return i < 0;
+ }
+};
- string from = command.from->prettyname;
- string to = command.to->prettyname;
- pair<string, string> FromTo = pair<string, string>(from, to);
-
- vector<Command>::iterator it = // non-const; it's modified below
- find_if(commands_vec.begin(), commands_vec.end(),
- compare_memfun(&Command::getFromToPrettyname, FromTo));
+
+void FormPreferences::ConvertersUpdateBrowser()
+{
+ local_converters.Sort();
fl_freeze_form(converters_->form);
+ fl_clear_browser(converters_->browser_all);
+ for (Converters::const_iterator cit = local_converters.begin();
+ cit != local_converters.end(); ++cit) {
+ string name = (*cit).From->prettyname() + " -> "
+ + (*cit).To->prettyname();
+ fl_addto_browser(converters_->browser_all, name.c_str());
+ }
+ ConvertersInput();
+ fl_unfreeze_form(converters_->form);
+}
- if (it == commands_vec.end()) {
- // Unable to find command. Add to list.
- commands_vec.push_back(command);
- sort( commands_vec.begin(), commands_vec.end(),
- &CommandsCompare );
- } else {
- // Command found. Modify it.
- (*it).from = command.from;
- (*it).to = command.to;
- (*it).command = command.command;
+bool FormPreferences::ConvertersAdd()
+{
+ string from = ConverterGetFrom();
+ string to = ConverterGetTo();
+ string command = fl_get_input(converters_->input_converter);
+ string flags = fl_get_input(converters_->input_flags);
+
+ Converter const * old = local_converters.GetConverter(from, to);
+ local_converters.Add(from, to, command, flags);
+ if (!old) {
+ local_converters.UpdateLast(local_formats);
+ ConvertersUpdateBrowser();
}
-
- // Clear input
- ConvertersClear();
-
- fl_unfreeze_form(converters_->form);
+ fl_deactivate_object(converters_->button_add);
+ fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
+
return true;
}
fl_freeze_form( converters_->form );
- Command const & c = commands_vec[i-1];
-
- int sel = 0;
- for( i = 1;
- i <= fl_get_choice_maxitems( converters_->choice_from ); ++i ) {
- string str =
- fl_get_choice_item_text( converters_->choice_from, i );
- str = strip( frontStrip( str ) );
-
- if( str == c.from->prettyname ) {
- sel = i;
- break;
- }
- }
+ Converter const & c = local_converters.Get(i-1);
+ int j = local_formats.GetNumber(c.from);
+ if (j >= 0)
+ fl_set_choice(converters_->choice_from, j+1);
- if( sel != 0 )
- fl_set_choice( converters_->choice_from, sel );
+ j = local_formats.GetNumber(c.to);
+ if (j >= 0)
+ fl_set_choice(converters_->choice_to, j+1);
- sel = 0;
- for( int i = 1;
- i <= fl_get_choice_maxitems( converters_->choice_to ); ++i ) {
- string str =
- fl_get_choice_item_text( converters_->choice_to, i );
- str = strip( frontStrip( str ) );
-
- if( str == c.to->prettyname ) {
- sel = i;
- break;
- }
- }
-
- if( sel != 0 )
- fl_set_choice( converters_->choice_to, sel );
-
- fl_set_input( converters_->input_converter, c.command.c_str() );
+ fl_set_input(converters_->input_converter, c.command.c_str());
+ fl_set_input(converters_->input_flags, c.flags.c_str());
fl_set_object_label( converters_->button_add, idex(_("Modify|#M")) );
fl_set_button_shortcut( converters_->button_add,
}
-void FormPreferences::ConvertersClear() const
-{
- // Re-create browser
- fl_clear_browser( converters_->browser_all );
- for (vector<Command>::const_iterator cit = commands_vec.begin();
- cit != commands_vec.end(); ++cit) {
- string from = (*cit).from->prettyname;
- string to = (*cit).to->prettyname;
- string name = from + " -> " + to;
- fl_addto_browser( converters_->browser_all, name.c_str() );
- }
-
- fl_set_input(converters_->input_converter, "");
- fl_set_input(converters_->input_flags, "");
-
- fl_deselect_browser(formats_->browser_all);
-
- fl_set_object_label( converters_->button_add, idex(_("Add|#A")) );
- fl_set_button_shortcut( converters_->button_add, scex(_("Add|#A")), 1);
-
- fl_deactivate_object(converters_->button_add);
- fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
-
- fl_deactivate_object(converters_->button_delete);
- fl_set_object_lcol(converters_->button_delete, FL_INACTIVE);
-}
-
-
-bool FormPreferences::ConvertersContainFormat( Format const & format ) const
-{
- for( vector<Command>::const_iterator cit = commands_vec.begin();
- cit != commands_vec.end(); ++cit ) {
- if( format.name == (*cit).from->name ) return true;
- if( format.name == (*cit).to->name ) return true;
- }
- return false;
-}
-
-
bool FormPreferences::ConvertersDelete()
{
- Command command( 0, 0, "" );
- if( !ConvertersSetCommand( command ) )
- return false;
-
- string from = command.from->prettyname;
- string to = command.to->prettyname;
- pair<string, string> FromTo = pair<string, string>(from, to);
-
- vector<Command>::iterator it = // non-const; it's modified below
- find_if(commands_vec.begin(), commands_vec.end(),
- compare_memfun(&Command::getFromToPrettyname, FromTo));
-
- fl_freeze_form(converters_->form);
-
- if (it == commands_vec.end()) {
- fl_deactivate_object(converters_->button_delete);
- fl_set_object_lcol(converters_->button_delete, FL_INACTIVE);
-
- fl_unfreeze_form(converters_->form);
- return false;
- }
+ string from = ConverterGetFrom();
+ string to = ConverterGetTo();
- commands_vec.erase(it);
- ConvertersClear();
-
- fl_unfreeze_form(converters_->form);
+ local_converters.Delete(from, to);
+ ConvertersUpdateBrowser();
return true;
}
bool FormPreferences::ConvertersInput()
{
- string from = fl_get_choice_text( converters_->choice_from );
- from = strip( frontStrip( from ) );
-
- string to = fl_get_choice_text( converters_->choice_to );
- to = strip( frontStrip( to ) );
-
- string name;
- if( !from.empty() && !to.empty() )
- name = from + " -> " + to;
-
- int sel = 0;
- if( !name.empty() ) {
- for( int i = 0;
- i < fl_get_browser_maxline(converters_->browser_all);
- ++i ) {
- string str =
- fl_get_browser_line( converters_->browser_all,
- i+1 );
- if( str == name ) {
- sel = i+1;
- break;
- }
- }
- }
+ string from = ConverterGetFrom();
+ string to = ConverterGetTo();
+ int sel = local_converters.GetNumber(from, to);
fl_freeze_form(converters_->form);
- if( sel == 0 ) {
+ if (sel < 0) {
fl_set_object_label( converters_->button_add,
idex(_("Add|#A")) );
fl_set_button_shortcut( converters_->button_add,
scex(_("Add|#A")), 1);
- if( name.empty() ) {
- fl_deactivate_object(converters_->button_add);
- fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
- } else {
- fl_activate_object(converters_->button_add);
- fl_set_object_lcol(converters_->button_add, FL_BLACK);
- }
-
fl_deselect_browser(converters_->browser_all);
fl_deactivate_object(converters_->button_delete);
fl_set_button_shortcut( converters_->button_add,
scex(_("Modify|#M")), 1);
- int top = sel-6;
- if( top < 1 ) top = 0;
+ int top = max(sel-5, 0);
fl_set_browser_topline(converters_->browser_all, top);
- fl_select_browser_line(converters_->browser_all, sel);
+ fl_select_browser_line(converters_->browser_all, sel+1);
- fl_activate_object(converters_->button_add);
- fl_set_object_lcol(converters_->button_add, FL_BLACK);
-
fl_activate_object(converters_->button_delete);
fl_set_object_lcol(converters_->button_delete, FL_BLACK);
}
+ string command = fl_get_input(converters_->input_converter);
+ if (command.empty() || from == to) {
+ fl_deactivate_object(converters_->button_add);
+ fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
+ } else {
+ fl_activate_object(converters_->button_add);
+ fl_set_object_lcol(converters_->button_add, FL_BLACK);
+ }
+
fl_unfreeze_form(converters_->form);
- return true;
+ return false;
}
-bool FormPreferences::ConvertersSetCommand( Command & command ) const
+string const FormPreferences::ConverterGetFrom() const
{
- string from = fl_get_choice_text( converters_->choice_from );
- from = strip( frontStrip( from ) );
- if( from.empty() )
- return false;
-
- vector<Format>::const_iterator fit =
- find_if(formats_vec.begin(), formats_vec.end(),
- compare_memfun(&Format::getprettyname, from));
- if( fit == formats_vec.end() )
- return false;
-
- string to = fl_get_choice_text( converters_->choice_to );
- to = strip( frontStrip( to ) );
- if( to.empty() )
- return false;
-
- vector<Format>::const_iterator tit =
- find_if(formats_vec.begin(), formats_vec.end(),
- compare_memfun(&Format::getprettyname, to));
- if( tit == formats_vec.end() )
- return false;
-
- string converter = fl_get_input( converters_->input_converter );
- string flags = fl_get_input( converters_->input_flags );
-
- command.from = fit;
- command.to = tit;
- command.command = converter;
+ int i = fl_get_choice(converters_->choice_from);
+ if (i > 0)
+ return local_formats.Get(i-1).name();
+ else {
+ lyxerr << "FormPreferences::ConvertersGetFrom: No choice!" << endl;
+ return "???";
+ }
+}
- return true;
+
+string const FormPreferences::ConverterGetTo() const
+{
+ int i = fl_get_choice(converters_->choice_to);
+ if (i > 0)
+ return local_formats.Get(i-1).name();
+ else {
+ lyxerr << "FormPreferences::ConvertersGetTo: No choice!" << endl;
+ return "???";
+ }
}
-void FormPreferences::ConvertersUpdateChoices()
+void FormPreferences::ConvertersUpdateChoices() const
{
string choice;
- for( vector<Format>::iterator cit = formats_vec.begin();
- cit != formats_vec.end(); ++cit ) {
- if( !choice.empty() )
+ for (Formats::const_iterator cit = local_formats.begin();
+ cit != local_formats.end(); ++cit ) {
+ if (!choice.empty())
choice += " | ";
else
choice += " ";
- choice += (*cit).prettyname;
+ choice += (*cit).prettyname();
}
choice += " ";
void FormPreferences::applyFormats() const
{
- vector<Format> old = formats.GetAllFormats();
- for (vector<Format>::const_iterator cit = old.begin();
- cit != old.end(); ++cit) {
-
- vector<Format>::const_iterator cit2 =
- find_if(formats_vec.begin(),formats_vec.end(),
- compare_memfun(&Format::getname, (*cit).name));
-
- // Ie, format exists in old, but is removed now.
- // Can't actually Delete it, because old will contain
- // system defauts.
- if (cit2 == formats_vec.end())
- formats.Add((*cit).name, string(), string(), string());
- }
-
- // Add new formats.
- for (vector<Format>::const_iterator cit = formats_vec.begin();
- cit != formats_vec.end(); ++cit) {
- formats.Add((*cit).name, (*cit).extension, (*cit).prettyname,
- (*cit).shortcut);
- formats.SetViewer((*cit).name, (*cit).viewer);
- }
+ formats = local_formats;
}
} else if (ob == formats_->input_extension) {
str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
} else if (ob == formats_->input_viewer) {
- str = N_("The command used to launch the viwer application\nE.g. \"netscape $$FName\" where $$FName is the name of the file.");
+ str = N_("The command used to launch the viewer application.");
} else if (ob == formats_->button_delete) {
str = N_("Remove the current format from the list of available formats.");
} else if (ob == formats_->button_add) {
void FormPreferences::updateFormats()
{
- formats_vec = formats.GetAllFormats();
- sort( formats_vec.begin(), formats_vec.end(), &FormatsCompare );
+ local_formats = formats;
+ FormatsUpdateBrowser();
+}
+
+
+void FormPreferences::FormatsUpdateBrowser()
+{
+ local_formats.Sort();
+
+ fl_freeze_form(formats_->form);
+ fl_deselect_browser(formats_->browser_all);
+ fl_clear_browser(formats_->browser_all);
+ for (Formats::const_iterator cit = local_formats.begin();
+ cit != local_formats.end(); ++cit)
+ fl_addto_browser(formats_->browser_all,
+ (*cit).prettyname().c_str());
+
+ FormatsInput();
+ fl_unfreeze_form(formats_->form);
// Mustn't forget to update the Formats available to the converters
ConvertersUpdateChoices();
-
- FormatsClear();
+ local_converters.Update(local_formats);
}
string extension = fl_get_input(formats_->input_extension);
string shortcut = fl_get_input(formats_->input_shrtcut);
string viewer = fl_get_input(formats_->input_viewer);
- if (prettyname.empty())
- return false;
-
- Format format(name, extension, prettyname, shortcut, viewer);
- vector<Format>::iterator it = // non-const; it's modified below
- find_if(formats_vec.begin(), formats_vec.end(),
- compare_memfun(&Format::getname, name));
- fl_freeze_form(formats_->form);
+ Format const * old = local_formats.GetFormat(name);
+ string old_prettyname = old ? old->prettyname() : string();
+ local_formats.Add(name, extension, prettyname, shortcut);
+ local_formats.SetViewer(name, viewer);
+ if (!old || prettyname != old_prettyname) {
+ FormatsUpdateBrowser();
+ if (old)
+ ConvertersUpdateBrowser();
+ }
+ fl_deactivate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
- if (it == formats_vec.end()) {
- // Unable to find format. Add to list.
- formats_vec.push_back(format);
- sort( formats_vec.begin(), formats_vec.end(), &FormatsCompare );
-
- // Mustn't forget to update the Formats available to the
- // converters
- ConvertersUpdateChoices();
-
- // Re-create browser
- fl_clear_browser( formats_->browser_all );
- for (vector<Format>::const_iterator cit = formats_vec.begin();
- cit != formats_vec.end(); ++cit)
- fl_addto_browser(formats_->browser_all,
- (*cit).name.c_str());
- } else {
- // Format found. Modify it.
- (*it).name = name;
- (*it).prettyname = prettyname;
- (*it).extension = extension;
- (*it).shortcut = shortcut;
- (*it).viewer = viewer;
- }
-
- // Clear input
- FormatsClear();
-
- fl_unfreeze_form(formats_->form);
return true;
}
fl_freeze_form(formats_->form);
- Format const & f = formats_vec[i-1];
+ Format const & f = local_formats.Get(i-1);
- fl_set_input(formats_->input_format, f.name.c_str());
- fl_set_input(formats_->input_gui_name, f.prettyname.c_str());
- fl_set_input(formats_->input_shrtcut, f.shortcut.c_str());
- fl_set_input(formats_->input_extension, f.extension.c_str());
- fl_set_input(formats_->input_viewer, f.viewer.c_str());
+ fl_set_input(formats_->input_format, f.name().c_str());
+ fl_set_input(formats_->input_gui_name, f.prettyname().c_str());
+ fl_set_input(formats_->input_shrtcut, f.shortcut().c_str());
+ fl_set_input(formats_->input_extension, f.extension().c_str());
+ fl_set_input(formats_->input_viewer, f.viewer().c_str());
fl_set_object_label( formats_->button_add, idex(_("Modify|#M")) );
fl_set_button_shortcut( formats_->button_add, scex(_("Modify|#M")), 1);
}
-void FormPreferences::FormatsClear() const
-{
- // Re-create browser
- fl_clear_browser(formats_->browser_all);
- for (vector<Format>::const_iterator cit = formats_vec.begin();
- cit != formats_vec.end(); ++cit)
- fl_addto_browser( formats_->browser_all, (*cit).name.c_str() );
-
- fl_deselect_browser(formats_->browser_all);
-
- fl_set_input(formats_->input_format, "");
- fl_set_input(formats_->input_gui_name, "");
- fl_set_input(formats_->input_shrtcut, "");
- fl_set_input(formats_->input_extension, "");
- fl_set_input(formats_->input_viewer, "");
-
- fl_set_object_label( formats_->button_add, idex(_("Add|#A")) );
- fl_set_button_shortcut( formats_->button_add, scex(_("Add|#A")), 1);
-
- fl_deactivate_object(formats_->button_add);
- fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
-
- fl_deactivate_object(formats_->button_delete);
- fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
-}
-
-
bool FormPreferences::FormatsDelete()
{
string name = fl_get_input(formats_->input_format);
- vector<Format>::iterator it = // non-const; it's modified below
- find_if(formats_vec.begin(), formats_vec.end(),
- compare_memfun(&Format::getname, name));
- fl_freeze_form(formats_->form);
-
- bool warning = ConvertersContainFormat( *it );
- if( warning ) {
- string str = N_("WARNING! Cannot remove a Format used by a Converter. Remove the converter first.");
- printWarning( str );
- }
-
- if (it == formats_vec.end() || warning) {
+ if (local_converters.FormatIsUsed(name)) {
+ printWarning(_("WARNING! Cannot remove a Format used by a Converter. Remove the converter first."));
fl_deactivate_object(formats_->button_delete);
fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
-
- fl_unfreeze_form(formats_->form);
return false;
}
- formats_vec.erase(it);
- FormatsClear();
-
- // Mustn't forget to update the Formats available to the converters
- ConvertersUpdateChoices();
-
- fl_unfreeze_form(formats_->form);
+ local_formats.Delete(name);
+ FormatsUpdateBrowser();
return true;
}
bool FormPreferences::FormatsInput()
{
string name = fl_get_input(formats_->input_format);
-
- int sel = 0;
- if( !name.empty() ) {
- for( int i = 0;
- i < fl_get_browser_maxline(formats_->browser_all); ++i ) {
- string str =
- fl_get_browser_line( formats_->browser_all,
- i+1 );
- if( str == name ) {
- sel = i+1;
- break;
- }
- }
- }
-
+ int sel = local_formats.GetNumber(name);
fl_freeze_form(formats_->form);
- if( sel == 0 ) {
+ if (sel < 0) {
fl_set_object_label( formats_->button_add,
idex(_("Add|#A")) );
fl_set_button_shortcut( formats_->button_add,
scex(_("Add|#A")), 1);
- if( name.empty() ) {
- fl_deactivate_object(formats_->button_add);
- fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
- } else {
- fl_activate_object(formats_->button_add);
- fl_set_object_lcol(formats_->button_add, FL_BLACK);
- }
-
fl_deselect_browser(formats_->browser_all);
fl_deactivate_object(formats_->button_delete);
fl_set_button_shortcut( formats_->button_add,
scex(_("Modify|#M")), 1);
- int top = sel-6;
- if( top < 1 ) top = 0;
+ int top = max(sel-5, 0);
fl_set_browser_topline(formats_->browser_all, top);
- fl_select_browser_line(formats_->browser_all, sel);
+ fl_select_browser_line(formats_->browser_all, sel+1);
fl_activate_object(formats_->button_add);
fl_set_object_lcol(formats_->button_add, FL_BLACK);
fl_set_object_lcol(formats_->button_delete, FL_BLACK);
}
+ string prettyname = fl_get_input(formats_->input_gui_name);
+ if (name.empty() || prettyname.empty()) {
+ fl_deactivate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
+ } else {
+ fl_activate_object(formats_->button_add);
+ fl_set_object_lcol(formats_->button_add, FL_BLACK);
+ }
+
fl_unfreeze_form(formats_->form);
- return true;
+ return false;
}
struct FD_form_screen_fonts;
struct FD_form_spellchecker;
+
/** This class provides an XForms implementation of the FormPreferences Dialog.
The preferences dialog allows users to set/save their preferences.
*/
*/
///
- void applyColors() const;
+ void applyColors(); // not const as modifies modifiedXformPrefs.
///
void applyConverters() const;
///
///
bool ColorsBrowserX11() const;
///
+ bool ColorsBrowseDatabase() const;
+ ///
bool ColorsDatabase() const;
///
void ColorsLoadBrowserLyX();
///
bool ColorsRGB() const;
///
- int ColorsSearchEntry(RGB const &) const;
+ int ColorsSearchEntry(RGBColor const &) const;
///
bool ConvertersAdd();
///
bool ConvertersBrowser();
///
- void ConvertersClear() const;
- ///
- bool ConvertersContainFormat( Format const &) const;
+ void ConvertersUpdateBrowser();
///
bool ConvertersDelete();
///
bool ConvertersInput();
///
- bool ConvertersSetCommand( Command & ) const;
+ string const ConverterGetFrom() const;
///
- void ConvertersUpdateChoices();
+ string const ConverterGetTo() const;
+ ///
+ void ConvertersUpdateChoices() const;
bool FormatsAdd();
///
bool FormatsBrowser();
///
- void FormatsClear() const;
+ void FormatsUpdateBrowser();
///
bool FormatsDelete();
///
///
Combox * combo_kbmap_2;
- /// A vector of Formats, to be manipulated in the Format browser.
- std::vector<Format> formats_vec;
- /// A vector of Commands, to be manipulated in the Converter browser.
- std::vector<Command> commands_vec;
/// A vector of RGB colors and associated name.
static std::vector<X11Color> colorDB;
/// A vector of xform RGB colors and associated name.
- static std::vector<XFormColor> xformColorDB;
+ static std::vector<XformColor> xformColorDB;
/** A collection of kmap files.
First entry is the file name, full path.
Second entry is the shorthand, as appears in the fl_choice.
Eg, system_lyxdir/kbd/american2.kmap, american2
*/
static std::pair<std::vector<string>, std::vector<string> > dirlist;
- ///
+ /** Flag whether a warning has been posted to the text window.
+ If so, don't redraw the window when the mouse leaves an object. */
bool warningPosted;
+ /// Flag whether Xforms colors have been changed since last file save.
+ bool modifiedXformPrefs;
};
#endif
#pragma implementation
#endif
+#include <algorithm>
+
#include "importer.h"
#include "converter.h"
#include "LyXView.h"
#include "minibuffer.h"
#include "bufferlist.h"
#include "support/filetools.h"
+#include "lyx_gui_misc.h" //WriteAlert
+
+using std::vector;
+using std::find;
extern BufferList bufferlist;
extern void InsertAsciiFile(BufferView *, string const &, bool);
-void Importer::Import(LyXView * lv, string const & filename,
+bool Importer::Import(LyXView * lv, string const & filename,
string const & format)
{
string displaypath = MakeDisplayPath(filename);
string lyxfile = ChangeExtension(filename, ".lyx");
- bool result = true;
- if (format == "text" || format == "textparagraph") {
+ string loader_format;
+ vector<string> loaders = Loaders();
+ if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
+ for (vector<string>::const_iterator it = loaders.begin();
+ it != loaders.end(); ++it) {
+ if (converters.IsReachable(format, *it)) {
+ if (!converters.Convert(0, filename, filename,
+ format, *it))
+ return false;
+ loader_format = *it;
+ break;
+ }
+ }
+ if (loader_format.empty()) {
+ WriteAlert(_("Can not import file"),
+ _("No information for importing from ")
+ + formats.PrettyName(format));
+ return false;
+ }
+ } else
+ loader_format = format;
+
+
+ if (loader_format == "lyx") {
+ Buffer * buffer = bufferlist.loadLyXFile(lyxfile);
+ if (buffer)
+ lv->view()->buffer(buffer);
+ } else {
lv->view()->buffer(bufferlist.newFile(lyxfile, string(), true));
- bool as_paragraphs = format == "textparagraph";
- InsertAsciiFile(lv->view(), filename, as_paragraphs);
+ bool as_paragraphs = loader_format == "textparagraph";
+ string filename2 = (loader_format == format) ? filename
+ : ChangeExtension(filename,
+ formats.Extension(loader_format));
+ InsertAsciiFile(lv->view(), filename2, as_paragraphs);
lv->getLyXFunc()->Dispatch(LFUN_MARK_OFF);
- } else {
- result = Converter::Convert(0, filename, filename, format, "lyx");
- if (result) {
- Buffer * buffer = bufferlist.loadLyXFile(lyxfile);
- if (buffer)
- lv->view()->buffer(buffer);
- else
- result = false;
- }
}
// we are done
- if (result)
- lv->getMiniBuffer()->Set(displaypath, _("imported."));
- else
- lv->getMiniBuffer()->Set(displaypath, _(": import failed."));
+ lv->getMiniBuffer()->Set(displaypath, _("imported."));
+ return true;
+}
+#if 0
+bool Importer::IsImportable(string const & format)
+{
+ vector<string> loaders = Loaders();
+ for (vector<string>::const_iterator it = loaders.begin();
+ it != loaders.end(); ++it)
+ if (converters.IsReachable(format, *it))
+ return true;
+ return false;
}
+#endif
+vector<Format const *> const Importer::GetImportableFormats()
+{
+ vector<string> loaders = Loaders();
+ vector<Format const *> result =
+ converters.GetReachableTo(loaders[0], true);
+ for (vector<string>::const_iterator it = loaders.begin() + 1;
+ it != loaders.end(); ++it) {
+ vector<Format const *> r =
+ converters.GetReachableTo(*it, false);
+ result.insert(result.end(), r.begin(), r.end());
+ }
+ return result;
+}
-bool Importer::IsImportable(string const & format)
+
+vector<string> const Importer::Loaders()
{
- if (format == "text" || format == "textparagraph")
- return true;
- else
- return Converter::IsReachable(format, "lyx");
+ vector<string> v;
+ v.push_back("lyx");
+ v.push_back("text");
+ v.push_back("textparagraph");
+ return v;
}
#pragma interface
#endif
+#include <vector>
#include "LString.h"
class LyXView;
+class Format;
class Importer {
public:
///
static
- void Import(LyXView * lv, string const & filename,
+ bool Import(LyXView * lv, string const & filename,
string const & format);
+#if 0
+ ///
static
bool IsImportable(string const & format);
+#endif
+ ///
+ static
+ std::vector<Format const *> const GetImportableFormats();
+private:
+ ///
+ static
+ std::vector<string> const Loaders();
};
#endif
// How do we decide to what format should we export?
string extension = GetExtension(params.filename);
- //if (pdf) {
+ if (lyxrc.pdf_mode) {
if (extension != "jpg")
- Converter::Convert(buf,
+ converters.Convert(buf,
params.filename, params.filename,
extension, "png");
- //} else
- Converter::Convert(buf, params.filename, params.filename,
+ } else
+ converters.Convert(buf, params.filename, params.filename,
extension, "eps");
return 1;
#include "language.h"
#include "ColorHandler.h"
#include "frontends/GUIRunTime.h"
+#include "frontends/xforms/Color.h"
using std::endl;
extern bool finished; // flag, that we are quitting the program
extern BufferList bufferlist;
extern GUIRunTime guiruntime;
+extern string user_lyxdir;
FL_CMD_OPT cmdopt[] =
{
fl_set_form_atclose(fd_latex_log->LaTeXLog,
CancelCloseBoxCB, 0);
+ // This is probably as good a time as any to map the xform colours,
+ // should a mapping exist.
+ {
+ string filename = user_lyxdir + "/preferences.xform";
+ XformColor::read( filename );
+ }
+
// Show the main & title form
int main_placement = FL_PLACE_CENTER | FL_FREE_SIZE;
int title_placement = FL_PLACE_CENTER;
ReadRcFile("lyxrc.defaults");
system_lyxrc = lyxrc;
system_formats = formats;
+ system_converters = converters;
// If there is a preferences file we read that instead
// of the old lyxrc file.
ReadRcFile("lyxrc");
/// Init Converter
- Converter::init();
+ converters.Update(formats);
+ converters.BuildGraph();
// Read encodings
ReadEncodingsFile("encodings");
!Exporter::IsExportable(buf, argument);
break;
#endif
- case LFUN_IMPORT:
- disable = !Importer::IsImportable(argument);
- break;
case LFUN_UNDO:
disable = buf->undostack.empty();
break;
AddPath(system_lyxdir, "examples"));
string text = _("Select ") + formats.PrettyName(format)
+ _(" file to import");
- string format2 = (format == "textparagraph") ? "text" : format;
- string extension = "*." + formats.Extension(format2);
+ string extension = "*." + formats.Extension(format);
filename = fileDlg.Select(text, initpath, extension);
AllowInput(owner->view());
command = lexrc.GetString();
if (lexrc.next())
flags = lexrc.GetString();
- Converter::Add(from, to, command, flags);
+ if (command.empty() || command == "none")
+ converters.Delete(from, to);
+ else
+ converters.Add(from, to, command, flags);
break;
}
case RC_VIEWER: {
prettyname = lexrc.GetString();
if (lexrc.next())
shortcut = lexrc.GetString();
- formats.Add(format, extension, prettyname, shortcut);
+ if (prettyname.empty()) {
+ if (converters.FormatIsUsed(format))
+ lyxerr << "Can't delete format "
+ << format << endl;
+ else
+ formats.Delete(format);
+
+ } else
+ formats.Add(format, extension, prettyname,
+ shortcut);
break;
}
case RC_DEFAULT_LANGUAGE:
<< "# FORMATS SECTION ##########################\n"
<< "#\n\n";
- case RC_FORMAT: {
- vector<Format> formats_vec = formats.GetAllFormats();
- vector<Format> sys_formats_vec = system_formats.GetAllFormats();
- for (vector<Format>::const_iterator it = formats_vec.begin();
- it != formats_vec.end(); ++it) {
- Format const * format = system_formats.GetFormat(it->name);
- if (!format || format->extension != it->extension ||
- format->prettyname != it->prettyname ||
- format->shortcut != it->shortcut)
- os << "\\format \"" << it->name << "\" \""
- << it->extension << "\" \""
- << it->prettyname << "\" \""
- << it->shortcut << "\"\n";
- }
-
- for (vector<Format>::const_iterator it = sys_formats_vec.begin();
- it != sys_formats_vec.end(); ++it)
- if (!formats.GetFormat(it->name))
- os << "\\format \"" << it->name
+ case RC_FORMAT:
+ // Look for deleted formats
+ for (Formats::const_iterator cit = formats.begin();
+ cit != formats.end(); ++cit) {
+ Format const * format =
+ system_formats.GetFormat(cit->name());
+ if (!format ||
+ format->extension() != cit->extension() ||
+ format->prettyname() != cit->prettyname() ||
+ format->shortcut() != cit->shortcut())
+ os << "\\format \"" << cit->name() << "\" \""
+ << cit->extension() << "\" \""
+ << cit->prettyname() << "\" \""
+ << cit->shortcut() << "\"\n";
+ }
+
+ // New/modifed formats
+ for (Formats::const_iterator cit = system_formats.begin();
+ cit != system_formats.end(); ++cit)
+ if (!formats.GetFormat(cit->name()))
+ os << "\\format \"" << cit->name()
<< "\" \"\" \"\" \"\"\n";
- }
- case RC_VIEWER: {
- vector<Format> formats_vec = formats.GetAllFormats();
- for (vector<Format>::const_iterator it = formats_vec.begin();
- it != formats_vec.end(); ++it) {
- Format const * format = system_formats.GetFormat(it->name);
- if ((!format || format->viewer != it->viewer) &&
- (format || !it->viewer.empty()))
- os << "\\viewer \"" << it->name << "\" \""
- << it->viewer << "\"\n";
+ case RC_VIEWER:
+ for (Formats::const_iterator cit = formats.begin();
+ cit != formats.end(); ++cit) {
+ Format const * format =
+ system_formats.GetFormat(cit->name());
+ if ((!format || format->viewer() != cit->viewer()) &&
+ (format || !cit->viewer().empty()))
+ os << "\\viewer \"" << cit->name() << "\" \""
+ << cit->viewer() << "\"\n";
}
- }
+ os << "\n#\n"
+ << "# CONVERTERS SECTION ##########################\n"
+ << "#\n\n";
+
+ case RC_CONVERTER:
+ // Look for new converters
+ for (Converters::const_iterator cit = converters.begin();
+ cit != converters.end(); ++cit) {
+ Converter const * converter =
+ system_converters.GetConverter(cit->from,
+ cit->to);
+ if (!converter ||
+ converter->command != cit->command ||
+ converter->flags != cit->flags)
+ os << "\\converter \"" << cit->from << "\" \""
+ << cit->to << "\" \""
+ << cit->command << "\" \""
+ << cit->flags << "\"\n";
+ }
+
+ // New/modifed converters
+ for (Converters::const_iterator cit = system_converters.begin();
+ cit != system_converters.end(); ++cit)
+ if (!converters.GetConverter(cit->from, cit->to))
+ os << "\\converter \"" << cit->from
+ << "\" \"" << cit->to << "\" \"\" \"\"\n";
}
os.flush();
}
bool lyx::rename(string const & from, string const & to)
{
if (::rename(from.c_str(), to.c_str()) == -1)
- return lyx::copy(from, to);
+ if (lyx::copy(from, to)) {
+ lyx::unlink(from);
+ return true;
+ } else
+ return false;
return true;
}