1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-1999 The LyX Team.
9 * ====================================================== */
14 #pragma implementation "lyxrc.h"
27 #include "LyXAction.h"
28 #include "lyxserver.h"
31 #include "tex-strings.h"
32 #include "support/path.h"
33 #include "support/filetools.h"
36 // this is crappy... why are those colors command line arguments and
37 // not in lyxrc?? (Matthias)
38 // Because nobody put them there. (Asger)
40 extern string background_color;
41 extern char selection_color[];
42 extern bool cursor_follows_scrollbar;
43 extern kb_keymap * toplevel_keymap;
44 extern LyXAction lyxaction;
53 RC_PRINTPAGERANGEFLAG,
55 RC_PRINTCOLLCOPIESFLAG,
57 RC_PRINTLANDSCAPEFLAG,
61 RC_PRINTFILEEXTENSION,
62 RC_PRINTEXSTRAOPTIONS,
63 RC_PRINTSPOOL_COMMAND,
64 RC_PRINTSPOOL_PRINTERPREFIX,
66 RC_PRINTPAPERDIMENSIONFLAG,
67 RC_CUSTOM_EXPORT_COMMAND,
68 RC_CUSTOM_EXPORT_FORMAT,
71 RC_LITERATE_EXTENSION,
72 RC_LITERATE_ERROR_FILTER,
74 RC_BUILD_ERROR_FILTER,
80 RC_SCREEN_FONT_TYPEWRITER,
83 RC_SCREEN_FONT_ENCODING,
85 RC_SGML_EXTRA_OPTIONS,
104 RC_ASCIIROFF_COMMAND,
109 RC_VIEWDVI_PAPEROPTION,
110 RC_DEFAULT_PAPERSIZE,
113 RC_VIEWPSPIC_COMMAND,
120 RC_SCREEN_FONT_SCALABLE,
125 RC_CURSOR_FOLLOWS_SCROLLBAR,
126 RC_EXIT_CONFIRMATION,
127 RC_DISPLAY_SHORTCUTS,
135 RC_PDF_TO_PS_COMMAND,
136 RC_DVI_TO_PS_COMMAND,
137 RC_DATE_INSERT_FORMAT,
143 static keyword_item lyxrcTags[] = {
144 { "\\accept_compound", RC_ACCEPT_COMPOUND },
145 { "\\alternate_language", RC_ALT_LANG },
146 { "\\ascii_linelen", RC_ASCII_LINELEN },
147 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
148 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
149 { "\\autosave", RC_AUTOSAVE },
150 { "\\background_color", RC_BACKGROUND_COLOR },
151 { "\\begin_toolbar", RC_BEGINTOOLBAR },
152 { "\\bind", RC_BIND },
153 { "\\bind_file", RC_BINDFILE },
154 { "\\build_command", RC_BUILD_COMMAND },
155 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
156 { "\\check_lastfiles", RC_CHECKLASTFILES },
157 { "\\chktex_command", RC_CHKTEX_COMMAND },
158 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
159 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
160 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
161 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
162 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
163 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
164 { "\\document_path", RC_DOCUMENTPATH },
165 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
166 { "\\escape_chars", RC_ESC_CHARS },
167 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
168 { "\\fax_command", RC_FAX_COMMAND },
169 { "\\fax_program", RC_FAXPROGRAM },
170 { "\\font_encoding", RC_FONT_ENCODING },
171 { "\\html_command", RC_HTML_COMMAND },
172 { "\\input", RC_INPUT },
173 { "\\kbmap", RC_KBMAP },
174 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
175 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
176 { "\\lastfiles", RC_LASTFILES },
177 { "\\latex_command", RC_LATEX_COMMAND },
178 { "\\literate_command", RC_LITERATE_COMMAND },
179 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
180 { "\\literate_extension", RC_LITERATE_EXTENSION },
181 { "\\make_backup", RC_MAKE_BACKUP },
182 { "\\num_lastfiles", RC_NUMLASTFILES },
183 { "\\pdf_mode", RC_PDF_MODE },
184 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
185 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
186 { "\\personal_dictionary", RC_PERS_DICT },
187 { "\\phone_book", RC_PHONEBOOK },
188 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
189 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
190 { "\\print_command", RC_PRINT_COMMAND },
191 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
192 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
193 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
194 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
195 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
196 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
197 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
198 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
199 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
200 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
201 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
202 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
203 { "\\print_to_file", RC_PRINTTOFILE },
204 { "\\print_to_printer", RC_PRINTTOPRINTER },
205 { "\\printer", RC_PRINTER },
206 { "\\ps_command", RC_PS_COMMAND },
207 { "\\relyx_command", RC_RELYX_COMMAND },
208 { "\\rtl", RC_RTL_SUPPORT },
209 { "\\screen_dpi", RC_SCREEN_DPI },
210 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
211 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
212 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
213 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
214 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
215 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
216 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
217 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
218 { "\\screen_zoom", RC_SCREEN_ZOOM },
219 { "\\selection_color", RC_SELECTION_COLOR },
220 { "\\serverpipe", RC_SERVERPIPE },
221 { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
222 { "\\show_banner", RC_SHOW_BANNER },
223 { "\\spell_command", RC_SPELL_COMMAND },
224 { "\\tempdir_path", RC_TEMPDIRPATH },
225 { "\\template_path", RC_TEMPLATEPATH },
226 { "\\use_alt_language", RC_USE_ALT_LANG },
227 { "\\use_escape_chars", RC_USE_ESC_CHARS },
228 { "\\use_input_encoding", RC_USE_INP_ENC },
229 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
230 { "\\use_tempdir", RC_USETEMPDIR },
231 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
232 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
233 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
234 { "\\view_ps_command", RC_VIEWPS_COMMAND },
235 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
238 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
239 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
241 // Should this be moved inside LyXAction?
243 int bindKey(char const * seq, int action)
245 return toplevel_keymap->bind(seq, action);
251 // Get printer from the environment. If fail, use default "",
252 // assuming that everything is set up correctly.
253 printer = GetEnv("PRINTER");
254 print_adapt_output = false;
255 print_command = "dvips";
256 print_evenpage_flag = "-B";
257 print_oddpage_flag = "-A";
258 print_pagerange_flag = "-pp";
259 print_copies_flag = "-c";
260 print_collcopies_flag = "-C";
261 print_reverse_flag = "-r";
262 print_landscape_flag = "-t landscape";
263 print_to_printer = "-P";
264 print_to_file = "-o ";
265 print_file_extension = ".ps";
266 print_paper_flag = "-t";
267 print_paper_dimension_flag = "-T";
268 document_path = GetEnvPath("HOME");
269 tempdir_path = "/tmp";
272 latex_command = "latex";
273 pdflatex_command = "pdflatex";
274 pdf_to_ps_command = "pdf2ps";
275 dvi_to_ps_command = "dvips";
276 literate_command = "none";
277 literate_extension = "none";
278 literate_error_filter = "cat";
279 build_command = "make";
280 build_error_filter = "cat";
281 relyx_command = "reLyX";
283 view_ps_command = "ghostview -swap";
284 view_pspic_command = "ghostview";
285 view_dvi_command = "xdvi";
286 view_dvi_paper_option = "-paper";
287 view_pdf_command = "xpdf";
288 default_papersize = BufferParams::PAPER_USLETTER;
289 custom_export_format = "ps";
290 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
291 html_command = "tth -t";
294 // Because a screen typically is wider than a piece of paper:
296 // Default LaTeX font size:
297 font_sizes[LyXFont::SIZE_TINY] = 5.0;
298 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
299 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
300 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
301 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
302 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
303 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
304 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
305 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
306 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
307 use_scalable_fonts = true;
308 roman_font_name = "-*-times";
309 sans_font_name = "-*-helvetica";
310 typewriter_font_name = "-*-courier";
311 menu_font_name = "-*-helvetica-bold-r";
312 popup_font_name = "-*-helvetica-medium-r";
313 font_norm = "iso8859-1";
315 auto_region_delete = true;
318 check_lastfiles = true;
320 exit_confirmation = true;
321 display_shortcuts = true;
322 // Spellchecker settings:
323 isp_command = "ispell";
324 isp_accept_compound = false;
325 isp_use_input_encoding = false;
326 isp_use_alt_lang = false;
327 isp_use_pers_dict = false;
328 isp_use_esc_chars = false;
332 date_insert_format = "%A, %e %B %Y";
335 defaultKeyBindings();
339 int LyXRC::ReadBindFile(string const & name)
342 string tmp = i18nLibFileSearch("bind", name, "bind");
343 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
344 int result = read(tmp);
346 lyxerr << "Error reading bind file: " << tmp << endl;
352 int LyXRC::read(string const & filename)
355 string bindFile = "cua";
357 LyXLex lexrc(lyxrcTags, lyxrcCount);
358 if (lyxerr.debugging(Debug::PARSER))
361 lexrc.setFile(filename);
362 if (!lexrc.IsOK()) return -2;
364 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
366 while (lexrc.IsOK()) {
367 // By using two switches we take advantage of the compiler
368 // telling us if we have missed a LyXRCTags element in
369 // the second switch.
370 // Note that this also shows a problem with LyXLex since it
371 // helps us avoid taking advantage of the strictness of the
374 int le = lexrc.lex();
376 case LyXLex::LEX_UNDEF:
377 lexrc.printError("Unknown tag `$$Token'");
379 case LyXLex::LEX_FEOF:
383 switch (static_cast<LyXRCTags>(le)) {
384 case RC_INPUT: // Include file
386 string tmp = LibFileSearch(string(),
389 lexrc.printError("Error reading "
390 "included file: "+tmp);
394 case RC_BINDFILE: // RVDK_PATCH_5
396 ReadBindFile(lexrc.GetString());
400 case RC_BEGINTOOLBAR:
401 // this toolbar should be changed to be a completely
402 // non gui toolbar. (Lgb)
408 use_kbmap = lexrc.GetBool();
411 case RC_EXIT_CONFIRMATION:
413 exit_confirmation = lexrc.GetBool();
416 case RC_DISPLAY_SHORTCUTS:
418 display_shortcuts = lexrc.GetBool();
421 case RC_KBMAP_PRIMARY:
423 primary_kbmap = lexrc.GetString();
426 case RC_KBMAP_SECONDARY:
428 secondary_kbmap = lexrc.GetString();
431 case RC_FONT_ENCODING:
433 fontenc = lexrc.GetString();
438 printer = lexrc.GetString();
441 case RC_PRINT_COMMAND:
443 print_command = lexrc.GetString();
446 case RC_PRINTEVENPAGEFLAG:
448 print_evenpage_flag = lexrc.GetString();
451 case RC_PRINTODDPAGEFLAG:
453 print_oddpage_flag = lexrc.GetString();
456 case RC_PRINTPAGERANGEFLAG:
458 print_pagerange_flag = lexrc.GetString();
461 case RC_PRINTCOPIESFLAG:
463 print_copies_flag = lexrc.GetString();
466 case RC_PRINTCOLLCOPIESFLAG:
468 print_collcopies_flag = lexrc.GetString();
471 case RC_PRINTREVERSEFLAG:
473 print_reverse_flag = lexrc.GetString();
476 case RC_PRINTLANDSCAPEFLAG:
478 print_landscape_flag = lexrc.GetString();
481 case RC_PRINTTOPRINTER:
483 print_to_printer = lexrc.GetString();
486 case RC_PRINT_ADAPTOUTPUT:
488 print_adapt_output = lexrc.GetBool();
493 print_to_file = lexrc.GetString();
496 case RC_PRINTFILEEXTENSION:
498 print_file_extension = lexrc.GetString();
501 case RC_PRINTEXSTRAOPTIONS:
503 print_extra_options = lexrc.GetString();
506 case RC_PRINTSPOOL_COMMAND:
508 print_spool_command = lexrc.GetString();
511 case RC_PRINTSPOOL_PRINTERPREFIX:
513 print_spool_printerprefix = lexrc.GetString();
516 case RC_PRINTPAPERDIMENSIONFLAG:
518 print_paper_dimension_flag = lexrc.GetString();
521 case RC_PRINTPAPERFLAG:
523 print_paper_flag = lexrc.GetString();
526 case RC_CUSTOM_EXPORT_COMMAND:
528 custom_export_command = lexrc.GetString();
531 case RC_CUSTOM_EXPORT_FORMAT:
533 custom_export_format = lexrc.GetString();
538 pdf_mode = lexrc.GetBool();
541 case RC_LATEX_COMMAND:
543 latex_command = lexrc.GetString();
546 case RC_PDFLATEX_COMMAND:
548 pdflatex_command = lexrc.GetString();
551 case RC_PDF_TO_PS_COMMAND:
553 pdf_to_ps_command = lexrc.GetString();
556 case RC_DVI_TO_PS_COMMAND:
558 dvi_to_ps_command = lexrc.GetString();
561 case RC_LITERATE_COMMAND:
563 literate_command = lexrc.GetString();
566 case RC_LITERATE_EXTENSION:
568 literate_extension = lexrc.GetString();
571 case RC_LITERATE_ERROR_FILTER:
573 literate_error_filter = lexrc.GetString();
576 case RC_BUILD_COMMAND:
578 build_command = lexrc.GetString();
581 case RC_BUILD_ERROR_FILTER:
583 build_error_filter = lexrc.GetString();
586 case RC_RELYX_COMMAND:
588 relyx_command = lexrc.GetString();
591 case RC_DEFAULT_PAPERSIZE:
593 string size = lowercase(lexrc.GetString());
594 if (size == "usletter")
596 BufferParams::PAPER_USLETTER;
597 else if (size == "legal")
599 BufferParams::PAPER_LEGALPAPER;
600 else if (size == "executive")
602 BufferParams::PAPER_EXECUTIVEPAPER;
603 else if (size == "a3")
605 BufferParams::PAPER_A3PAPER;
606 else if (size == "a4")
608 BufferParams::PAPER_A4PAPER;
609 else if (size == "a5")
611 BufferParams::PAPER_A5PAPER;
612 else if (size == "b5")
614 BufferParams::PAPER_B5PAPER;
617 case RC_VIEWDVI_COMMAND:
619 view_dvi_command = lexrc.GetString();
622 case RC_VIEWDVI_PAPEROPTION:
624 view_dvi_paper_option = lexrc.GetString();
626 view_dvi_paper_option = "";
629 case RC_VIEWPDF_COMMAND:
631 view_pdf_command = lexrc.GetString();
636 ps_command = lexrc.GetString();
639 case RC_VIEWPS_COMMAND:
641 view_ps_command = lexrc.GetString();
644 case RC_VIEWPSPIC_COMMAND:
646 view_pspic_command = lexrc.GetString();
649 case RC_CHKTEX_COMMAND:
651 chktex_command = lexrc.GetString();
654 case RC_HTML_COMMAND:
656 html_command = lexrc.GetString();
661 dpi = lexrc.GetInteger();
666 zoom = lexrc.GetInteger();
669 case RC_SCREEN_FONT_SIZES:
671 font_sizes[LyXFont::SIZE_TINY] =
674 font_sizes[LyXFont::SIZE_SCRIPT] =
677 font_sizes[LyXFont::SIZE_FOOTNOTE] =
680 font_sizes[LyXFont::SIZE_SMALL] =
683 font_sizes[LyXFont::SIZE_NORMAL] =
686 font_sizes[LyXFont::SIZE_LARGE] =
689 font_sizes[LyXFont::SIZE_LARGER] =
692 font_sizes[LyXFont::SIZE_LARGEST] =
695 font_sizes[LyXFont::SIZE_HUGE] =
698 font_sizes[LyXFont::SIZE_HUGER] =
702 case RC_SCREEN_FONT_SCALABLE:
704 use_scalable_fonts = lexrc.GetBool();
709 autosave = lexrc.GetInteger();
712 case RC_SGML_EXTRA_OPTIONS:
714 sgml_extra_options = lexrc.GetString();
717 case RC_DOCUMENTPATH:
719 document_path = ExpandPath(lexrc.GetString());
723 case RC_TEMPLATEPATH:
725 template_path = ExpandPath(lexrc.GetString());
730 tempdir_path = ExpandPath(lexrc.GetString());
735 use_tempdir = lexrc.GetBool();
740 lastfiles = ExpandPath(lexrc.GetString());
743 case RC_NUMLASTFILES:
745 num_lastfiles = lexrc.GetInteger();
748 case RC_CHECKLASTFILES:
750 check_lastfiles = lexrc.GetBool();
753 case RC_SCREEN_FONT_ROMAN:
755 roman_font_name = lexrc.GetString();
758 case RC_SCREEN_FONT_SANS:
760 sans_font_name = lexrc.GetString();
763 case RC_SCREEN_FONT_TYPEWRITER:
765 typewriter_font_name = lexrc.GetString();
768 case RC_SCREEN_FONT_MENU:
770 menu_font_name = lexrc.GetString();
773 case RC_SCREEN_FONT_POPUP:
775 popup_font_name = lexrc.GetString();
778 case RC_SCREEN_FONT_ENCODING:
780 font_norm = lexrc.GetString();
783 case RC_AUTOREGIONDELETE:
784 // Auto region delete defaults to true
786 auto_region_delete = lexrc.GetBool();
791 // we should not do an explicit binding before
792 // loading a bind file. So, in this case, load
793 // the default bind file.
797 // !!!chb, dynamic key binding...
801 if (lexrc.lex() == LyXLex::LEX_DATA) {
802 seq = lexrc.GetString();
804 lexrc.printError("Bad key sequence: `$$Token'");
808 if (lexrc.lex() == LyXLex::LEX_DATA) {
809 cmd = lexrc.GetString();
811 lexrc.printError("Bad command: `$$Token'");
815 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
816 if (lyxerr.debugging(Debug::KEY)) {
817 lyxerr << "RC_BIND: Sequence `"
818 << seq << "' Command `"
819 << cmd << "' Action `"
820 << action << '\'' << endl;
822 res = bindKey(seq.c_str(), action);
825 "Invalid key sequence `"
828 } else {// cmd is the last token read.
830 "Unknown LyX function `$$Token'");
836 lyxpipes = ExpandPath(lexrc.GetString());
839 case RC_CURSOR_FOLLOWS_SCROLLBAR:
841 cursor_follows_scrollbar = lexrc.GetBool();
844 case RC_BACKGROUND_COLOR:
846 background_color = lexrc.GetString();
848 case RC_SELECTION_COLOR:
850 strncpy(selection_color,
851 lexrc.GetString().c_str(), 31);
855 fax_command = lexrc.GetString();
859 fax_program = lexrc.GetString();
863 string s = lexrc.GetString();
867 phone_book = user_lyxdir + s;
870 case RC_ASCIIROFF_COMMAND:
872 ascii_roff_command = lexrc.GetString();
874 case RC_ASCII_LINELEN:
876 ascii_linelen = lexrc.GetInteger();
878 // Spellchecker settings:
879 case RC_SPELL_COMMAND:
881 isp_command = lexrc.GetString();
883 case RC_ACCEPT_COMPOUND:
885 isp_accept_compound = lexrc.GetBool();
889 isp_use_input_encoding = lexrc.GetBool();
891 case RC_USE_ALT_LANG:
893 isp_use_alt_lang = lexrc.GetBool();
895 case RC_USE_PERS_DICT:
897 isp_use_pers_dict = lexrc.GetBool();
899 case RC_USE_ESC_CHARS:
901 isp_use_esc_chars = lexrc.GetBool();
905 isp_alt_lang = lexrc.GetString();
909 isp_pers_dict = lexrc.GetString();
913 isp_esc_chars = lexrc.GetString();
917 make_backup = lexrc.GetBool();
919 case RC_DATE_INSERT_FORMAT:
921 date_insert_format = lexrc.GetString();
925 rtl_support = lexrc.GetBool();
929 show_banner = lexrc.GetBool();
931 case RC_LAST: break; // this is just a dummy
939 void LyXRC::write(string const & filename) const
941 ofstream ofs(filename.c_str());
947 void LyXRC::print() const
949 if (lyxerr.debugging())
956 void LyXRC::output(ostream & os) const
958 os << "### This file is part of\n"
959 << "### ========================================================\n"
960 << "### LyX, The Document Processor\n"
962 << "### Copyright 1995 Matthias Ettrich\n"
963 << "### Copyright 1995-1998 The LyX Team.\n"
965 << "### ========================================================\n"
967 << "# This file is written by LyX, if you want to make your own\n"
968 << "# modifications you should do them from inside LyX and save\n"
969 << "# your preferences, or you can also make your modifications\n"
970 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
973 // Why the switch you might ask. It is a trick to ensure that all
974 // the elements in the LyXRCTags enum is handled. As you can see
975 // there are no breaks at all. So it is just a huge fall-through.
976 // The nice thing is that we will get a warning from the compiler
977 // if we forget an element.
978 LyXRCTags tag = RC_LAST;
982 // input/include files are not done here
984 // bindings is not written to the preferences file.
986 // bind files are not done here.
987 case RC_BEGINTOOLBAR:
988 // Toolbar is not written here (yet).
989 case RC_FONT_ENCODING:
990 os << "\\font_encoding \"" << fontenc << "\"\n";
992 os << "\\printer \"" << printer << "\"\n";
993 case RC_PRINT_COMMAND:
994 os << "\\print_command \"" << print_command << "\"\n";
995 case RC_PRINTEVENPAGEFLAG:
996 os << "\\print_evenpage_flag \"" << print_evenpage_flag
998 case RC_PRINTODDPAGEFLAG:
999 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1001 case RC_PRINTPAGERANGEFLAG:
1002 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1004 case RC_PRINTCOPIESFLAG:
1005 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1006 case RC_PRINTCOLLCOPIESFLAG:
1007 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1009 case RC_PRINTREVERSEFLAG:
1010 os << "\\print_reverse_flag \"" << print_reverse_flag
1012 case RC_PRINTLANDSCAPEFLAG:
1013 os << "\\print_landscape_flag \"" << print_landscape_flag
1015 case RC_PRINTTOPRINTER:
1016 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1017 case RC_PRINT_ADAPTOUTPUT:
1018 os << "\\print_adapt_output " << tostr(print_adapt_output)
1020 case RC_PRINTTOFILE:
1021 os << "\\print_to_file \"" << print_to_file << "\"\n";
1022 case RC_PRINTFILEEXTENSION:
1023 os << "\\print_file_extension \"" << print_file_extension
1025 case RC_PRINTEXSTRAOPTIONS:
1026 os << "\\print_extra_options \"" << print_extra_options
1028 case RC_PRINTSPOOL_COMMAND:
1029 os << "\\print_spool_command \"" << print_spool_command
1031 case RC_PRINTSPOOL_PRINTERPREFIX:
1032 os << "\\print_spool_printerprefix \""
1033 << print_spool_printerprefix << "\"\n";
1034 case RC_PRINTPAPERDIMENSIONFLAG:
1035 os << "\\print_paper_dimension_flag \""
1036 << print_paper_dimension_flag << "\"\n";
1037 case RC_PRINTPAPERFLAG:
1038 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1039 case RC_CUSTOM_EXPORT_COMMAND:
1040 os << "\\custom_export_command \"" << custom_export_command
1042 case RC_CUSTOM_EXPORT_FORMAT:
1043 os << "\\custom_export_format \"" << custom_export_format
1046 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1047 case RC_LATEX_COMMAND:
1048 os << "\\latex_command \"" << latex_command << "\"\n";
1049 case RC_PDFLATEX_COMMAND:
1050 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1051 case RC_PDF_TO_PS_COMMAND:
1052 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1053 case RC_DVI_TO_PS_COMMAND:
1054 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1055 case RC_LITERATE_COMMAND:
1056 os << "\\literate_command \"" << literate_command << "\"\n";
1057 case RC_LITERATE_EXTENSION:
1058 os << "\\literate_extension \"" << literate_extension
1060 case RC_LITERATE_ERROR_FILTER:
1061 os << "\\literate_error_filter \"" << literate_error_filter
1063 case RC_BUILD_COMMAND:
1064 os << "\\build_command \"" << build_command << "\"\n";
1065 case RC_BUILD_ERROR_FILTER:
1066 os << "\\build_error_filter \"" << build_error_filter
1069 os << "\\screen_dpi " << dpi << "\n";
1070 case RC_SCREEN_ZOOM:
1071 os << "\\screen_zoom " << zoom << "\n";
1072 case RC_SCREEN_FONT_SIZES:
1073 os.setf(ios::fixed);
1075 os << "\\screen_font_sizes";
1076 os << " " << font_sizes[LyXFont::SIZE_TINY];
1077 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1078 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1079 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1080 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1081 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1082 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1083 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1084 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1085 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1087 case RC_AUTOREGIONDELETE:
1088 os << "\\auto_region_delete " << tostr(auto_region_delete)
1091 os << "\\autosave " << autosave << "\n";
1092 case RC_EXIT_CONFIRMATION:
1093 os << "\\exit_confirmation " << tostr(exit_confirmation)
1095 case RC_DISPLAY_SHORTCUTS:
1096 os << "\\display_shortcuts " << tostr(display_shortcuts)
1098 case RC_VIEWDVI_COMMAND:
1099 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1100 case RC_VIEWDVI_PAPEROPTION:
1101 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1102 case RC_VIEWPDF_COMMAND:
1103 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1104 case RC_DEFAULT_PAPERSIZE:
1105 os << "\\default_papersize \"";
1106 switch (default_papersize) {
1107 case BufferParams::PAPER_USLETTER:
1108 os << "usletter"; break;
1109 case BufferParams::PAPER_LEGALPAPER:
1110 os << "legal"; break;
1111 case BufferParams::PAPER_EXECUTIVEPAPER:
1112 os << "executive"; break;
1113 case BufferParams::PAPER_A3PAPER:
1115 case BufferParams::PAPER_A4PAPER:
1117 case BufferParams::PAPER_A5PAPER:
1119 case BufferParams::PAPER_B5PAPER:
1121 case BufferParams::PAPER_DEFAULT: break;
1124 case RC_VIEWPS_COMMAND:
1125 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1126 case RC_VIEWPSPIC_COMMAND:
1127 os << "\\view_pspic_command \"" << view_pspic_command
1130 os << "\\ps_command \"" << ps_command << "\"\n";
1131 case RC_CHKTEX_COMMAND:
1132 os << "\\chktex_command \"" << chktex_command << "\"\n";
1133 case RC_HTML_COMMAND:
1134 os << "\\html_command \"" << html_command << "\"\n";
1135 case RC_SGML_EXTRA_OPTIONS:
1136 os << "\\sgml_extra_options \"" << sgml_extra_options
1139 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1140 case RC_KBMAP_PRIMARY:
1141 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1142 case RC_KBMAP_SECONDARY:
1143 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1145 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1146 case RC_RELYX_COMMAND:
1147 os << "\\relyx_command \"" << relyx_command << "\"\n";
1148 case RC_DOCUMENTPATH:
1149 os << "\\document_path \"" << document_path << "\"\n";
1150 case RC_TEMPLATEPATH:
1151 os << "\\template_path \"" << template_path << "\"\n";
1152 case RC_TEMPDIRPATH:
1153 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1155 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1157 os << "\\lastfiles \"" << lastfiles << "\"\n";
1158 case RC_NUMLASTFILES:
1159 os << "\\num_lastfiles " << num_lastfiles << "\n";
1160 case RC_CHECKLASTFILES:
1161 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1162 case RC_SCREEN_FONT_ROMAN:
1163 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1164 case RC_SCREEN_FONT_SANS:
1165 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1166 case RC_SCREEN_FONT_TYPEWRITER:
1167 os << "\\screen_font_typewriter \""
1168 << typewriter_font_name << "\"\n";
1169 case RC_SCREEN_FONT_MENU:
1170 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1171 case RC_SCREEN_FONT_POPUP:
1172 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1173 case RC_SCREEN_FONT_ENCODING:
1174 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1175 case RC_SCREEN_FONT_SCALABLE:
1176 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1178 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1179 os << "\\cursor_follows_scrollbar "
1180 << tostr(cursor_follows_scrollbar) << "\n";
1181 case RC_BACKGROUND_COLOR:
1182 os << "\\background_color \"" << background_color << "\"\n";
1183 case RC_SELECTION_COLOR:
1184 os << "\\selection_color \"" << selection_color << "\"\n";
1185 case RC_FAX_COMMAND:
1186 os << "\\fax_command \"" << fax_command << "\"\n";
1188 os << "\\fax_program \"" << fax_program << "\"\n";
1190 os << "\\phone_book \"" << phone_book << "\"\n";
1191 case RC_ASCIIROFF_COMMAND:
1192 os << "\\ascii_roff_command \"" << ascii_roff_command
1194 case RC_ASCII_LINELEN:
1195 os << "\\ascii_linelen " << ascii_linelen << "\n";
1196 case RC_SPELL_COMMAND:
1197 os << "\\spell_command \"" << isp_command << "\"\n";
1198 case RC_ACCEPT_COMPOUND:
1199 os << "\\accept_compound " << tostr(isp_accept_compound)
1201 case RC_USE_INP_ENC:
1202 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1204 case RC_USE_ALT_LANG:
1205 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1206 case RC_USE_PERS_DICT:
1207 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1209 case RC_USE_ESC_CHARS:
1210 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1213 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1215 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1217 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1218 case RC_RTL_SUPPORT:
1219 os << "\\rtl " << tostr(rtl_support) << "\n";
1220 case RC_MAKE_BACKUP:
1221 os << "\\make_backup " << tostr(make_backup) << "\n";
1222 case RC_DATE_INSERT_FORMAT:
1223 os << "\\date_insert_format \"" << date_insert_format
1225 case RC_SHOW_BANNER:
1226 os << "\\show_banner " << tostr(show_banner) << "\n";
1232 /// define the default key bindings for LyX.
1233 void LyXRC::defaultKeyBindings()
1235 bindKey("Right", LFUN_RIGHT);
1236 bindKey("Left", LFUN_LEFT);
1237 bindKey("Up", LFUN_UP);
1238 bindKey("Down", LFUN_DOWN);
1240 bindKey("Tab", LFUN_TAB);
1242 bindKey("Home", LFUN_HOME);
1243 bindKey("End", LFUN_END);
1244 bindKey("Prior", LFUN_PRIOR);
1245 bindKey("Next", LFUN_NEXT);
1247 bindKey("Return", LFUN_BREAKPARAGRAPH);
1248 bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
1250 bindKey("Delete", LFUN_DELETE);
1251 bindKey("BackSpace", LFUN_BACKSPACE);
1252 // bindKeyings for transparent handling of deadkeys
1253 // The keysyms are gotten from XFree86 X11R6
1254 bindKey("~C-~S-~M-dead_acute", LFUN_ACUTE);
1255 bindKey("~C-~S-~M-dead_breve", LFUN_BREVE);
1256 bindKey("~C-~S-~M-dead_caron", LFUN_CARON);
1257 bindKey("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
1258 bindKey("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
1259 bindKey("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
1260 bindKey("~C-~S-~M-dead_abovedot", LFUN_DOT);
1261 bindKey("~C-~S-~M-dead_grave", LFUN_GRAVE);
1262 bindKey("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
1263 bindKey("~C-~S-~M-dead_macron", LFUN_MACRON);
1264 // nothing with this name
1265 // bindKey("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
1266 bindKey("~C-~S-~M-dead_tilde", LFUN_TILDE);
1267 bindKey("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
1268 // nothing with this name either...
1269 //bindKey("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
1270 bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
1271 bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
1272 bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
1274 // bindings to utilize the use of the numeric keypad
1275 // e.g. Num Lock set
1276 bindKey("KP_0", LFUN_SELFINSERT);
1277 bindKey("KP_Decimal", LFUN_SELFINSERT);
1278 bindKey("KP_Enter", LFUN_SELFINSERT);
1279 bindKey("KP_1", LFUN_SELFINSERT);
1280 bindKey("KP_2", LFUN_SELFINSERT);
1281 bindKey("KP_3", LFUN_SELFINSERT);
1282 bindKey("KP_4", LFUN_SELFINSERT);
1283 bindKey("KP_5", LFUN_SELFINSERT);
1284 bindKey("KP_6", LFUN_SELFINSERT);
1285 bindKey("KP_Add", LFUN_SELFINSERT);
1286 bindKey("KP_7", LFUN_SELFINSERT);
1287 bindKey("KP_8", LFUN_SELFINSERT);
1288 bindKey("KP_9", LFUN_SELFINSERT);
1289 bindKey("KP_Divide", LFUN_SELFINSERT);
1290 bindKey("KP_Multiply", LFUN_SELFINSERT);
1291 bindKey("KP_Subtract", LFUN_SELFINSERT);
1293 /* Most self-insert keys are handled in the 'default:' section of
1294 * WorkAreaKeyPress - so we don't have to define them all.
1295 * However keys explicit decleared as self-insert are
1296 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1298 bindKey("C-Tab", LFUN_TABINSERT); // ale970515