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)
39 extern int fast_selection;
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,
94 RC_NOMENUACCELERATORS,
106 RC_ASCIIROFF_COMMAND,
111 RC_DEFAULT_PAPERSIZE,
114 RC_VIEWPSPIC_COMMAND,
121 RC_SCREEN_FONT_SCALABLE,
126 RC_CURSOR_FOLLOWS_SCROLLBAR,
127 RC_EXIT_CONFIRMATION,
128 RC_DISPLAY_SHORTCUTS,
136 RC_PDF_TO_PS_COMMAND,
137 RC_DVI_TO_PS_COMMAND,
138 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 { "\\fast_selection", RC_FAST_SELECTION },
169 { "\\fax_command", RC_FAX_COMMAND },
170 { "\\fax_program", RC_FAXPROGRAM },
171 { "\\font_encoding", RC_FONT_ENCODING },
172 { "\\html_command", RC_HTML_COMMAND },
173 { "\\input", RC_INPUT },
174 { "\\kbmap", RC_KBMAP },
175 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
176 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
177 { "\\lastfiles", RC_LASTFILES },
178 { "\\latex_command", RC_LATEX_COMMAND },
179 { "\\literate_command", RC_LITERATE_COMMAND },
180 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
181 { "\\literate_extension", RC_LITERATE_EXTENSION },
182 { "\\make_backup", RC_MAKE_BACKUP },
183 { "\\num_lastfiles", RC_NUMLASTFILES },
184 { "\\pdf_mode", RC_PDF_MODE },
185 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
186 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
187 { "\\personal_dictionary", RC_PERS_DICT },
188 { "\\phone_book", RC_PHONEBOOK },
189 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
190 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
191 { "\\print_command", RC_PRINT_COMMAND },
192 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
193 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
194 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
195 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
196 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
197 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
198 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
199 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
200 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
201 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
202 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
203 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
204 { "\\print_to_file", RC_PRINTTOFILE },
205 { "\\print_to_printer", RC_PRINTTOPRINTER },
206 { "\\printer", RC_PRINTER },
207 { "\\ps_command", RC_PS_COMMAND },
208 { "\\relyx_command", RC_RELYX_COMMAND },
209 { "\\rtl", RC_RTL_SUPPORT },
210 { "\\screen_dpi", RC_SCREEN_DPI },
211 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
212 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
213 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
214 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
215 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
216 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
217 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
218 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
219 { "\\screen_zoom", RC_SCREEN_ZOOM },
220 { "\\selection_color", RC_SELECTION_COLOR },
221 { "\\serverpipe", RC_SERVERPIPE },
222 { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
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_pdf_command", RC_VIEWPDF_COMMAND },
233 { "\\view_ps_command", RC_VIEWPS_COMMAND },
234 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
237 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
238 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
240 // Should this be moved inside LyXAction?
242 int bindKey(char const * seq, int action)
244 return toplevel_keymap->bind(seq, action);
250 // Get printer from the environment. If fail, use default "",
251 // assuming that everything is set up correctly.
252 printer = GetEnv("PRINTER");
253 print_adapt_output = false;
254 print_command = "dvips";
255 print_evenpage_flag = "-B";
256 print_oddpage_flag = "-A";
257 print_pagerange_flag = "-pp";
258 print_copies_flag = "-c";
259 print_collcopies_flag = "-C";
260 print_reverse_flag = "-r";
261 print_landscape_flag = "-t landscape";
262 print_to_printer = "-P";
263 print_to_file = "-o ";
264 print_file_extension = ".ps";
265 print_paper_flag = "-t";
266 print_paper_dimension_flag = "-T";
267 document_path = GetEnvPath("HOME");
268 tempdir_path = "/tmp";
271 latex_command = "latex";
272 pdflatex_command = "pdflatex";
273 pdf_to_ps_command = "pdf2ps";
274 dvi_to_ps_command = "dvips";
275 literate_command = "none";
276 literate_extension = "none";
277 literate_error_filter = "cat";
278 build_command = "make";
279 build_error_filter = "cat";
280 relyx_command = "reLyX";
282 view_ps_command = "ghostview -swap";
283 view_pspic_command = "ghostview";
284 view_dvi_command = "xdvi";
285 view_pdf_command = "xpdf";
286 default_papersize = BufferParams::PAPER_USLETTER;
287 custom_export_format = "ps";
288 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
289 html_command = "tth -t";
292 // Because a screen typically is wider than a piece of paper:
294 // Default LaTeX font size:
295 font_sizes[LyXFont::SIZE_TINY] = 5.0;
296 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
297 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
298 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
299 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
300 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
301 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
302 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
303 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
304 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
305 use_scalable_fonts = true;
306 roman_font_name = "-*-times";
307 sans_font_name = "-*-helvetica";
308 typewriter_font_name = "-*-courier";
309 menu_font_name = "-*-helvetica-bold-r";
310 popup_font_name = "-*-helvetica-medium-r";
311 font_norm = "iso8859-1";
313 auto_region_delete = true;
316 check_lastfiles = true;
318 exit_confirmation = true;
319 display_shortcuts = true;
320 // Spellchecker settings:
321 isp_command = "ispell";
322 isp_accept_compound = false;
323 isp_use_input_encoding = false;
324 isp_use_alt_lang = false;
325 isp_use_pers_dict = false;
326 isp_use_esc_chars = false;
330 defaultKeyBindings();
332 date_insert_format = "%A, %e. %B %Y";
336 int LyXRC::ReadBindFile(string const & name)
339 string tmp = i18nLibFileSearch("bind", name, "bind");
340 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
341 int result = read(tmp);
343 lyxerr << "Error reading bind file: " << tmp << endl;
349 int LyXRC::read(string const & filename)
352 string bindFile = "cua";
354 LyXLex lexrc(lyxrcTags, lyxrcCount);
355 if (lyxerr.debugging(Debug::PARSER))
358 lexrc.setFile(filename);
359 if (!lexrc.IsOK()) return -2;
361 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
363 while (lexrc.IsOK()) {
364 // By using two switches we take advantage of the compiler
365 // telling us if we have missed a LyXRCTags element in
366 // the second switch.
367 // Note that this also shows a problem with LyXLex since it
368 // helps us avoid taking advantage of the strictness of the
371 int le = lexrc.lex();
373 case LyXLex::LEX_UNDEF:
374 lexrc.printError("Unknown tag `$$Token'");
376 case LyXLex::LEX_FEOF:
380 switch (static_cast<LyXRCTags>(le)) {
381 case RC_INPUT: // Include file
383 string tmp = LibFileSearch(string(),
386 lexrc.printError("Error reading "
387 "included file: "+tmp);
391 case RC_BINDFILE: // RVDK_PATCH_5
393 ReadBindFile(lexrc.GetString());
397 case RC_BEGINTOOLBAR:
398 // this toolbar should be changed to be a completely
399 // non gui toolbar. (Lgb)
405 use_kbmap = lexrc.GetBool();
408 case RC_EXIT_CONFIRMATION:
410 exit_confirmation = lexrc.GetBool();
413 case RC_DISPLAY_SHORTCUTS:
415 display_shortcuts = lexrc.GetBool();
418 case RC_KBMAP_PRIMARY:
420 primary_kbmap = lexrc.GetString();
423 case RC_KBMAP_SECONDARY:
425 secondary_kbmap = lexrc.GetString();
428 case RC_FONT_ENCODING:
430 fontenc = lexrc.GetString();
435 printer = lexrc.GetString();
438 case RC_PRINT_COMMAND:
440 print_command = lexrc.GetString();
443 case RC_PRINTEVENPAGEFLAG:
445 print_evenpage_flag = lexrc.GetString();
448 case RC_PRINTODDPAGEFLAG:
450 print_oddpage_flag = lexrc.GetString();
453 case RC_PRINTPAGERANGEFLAG:
455 print_pagerange_flag = lexrc.GetString();
458 case RC_PRINTCOPIESFLAG:
460 print_copies_flag = lexrc.GetString();
463 case RC_PRINTCOLLCOPIESFLAG:
465 print_collcopies_flag = lexrc.GetString();
468 case RC_PRINTREVERSEFLAG:
470 print_reverse_flag = lexrc.GetString();
473 case RC_PRINTLANDSCAPEFLAG:
475 print_landscape_flag = lexrc.GetString();
478 case RC_PRINTTOPRINTER:
480 print_to_printer = lexrc.GetString();
483 case RC_PRINT_ADAPTOUTPUT:
485 print_adapt_output = lexrc.GetBool();
490 print_to_file = lexrc.GetString();
493 case RC_PRINTFILEEXTENSION:
495 print_file_extension = lexrc.GetString();
498 case RC_PRINTEXSTRAOPTIONS:
500 print_extra_options = lexrc.GetString();
503 case RC_PRINTSPOOL_COMMAND:
505 print_spool_command = lexrc.GetString();
508 case RC_PRINTSPOOL_PRINTERPREFIX:
510 print_spool_printerprefix = lexrc.GetString();
513 case RC_PRINTPAPERDIMENSIONFLAG:
515 print_paper_dimension_flag = lexrc.GetString();
518 case RC_PRINTPAPERFLAG:
520 print_paper_flag = lexrc.GetString();
523 case RC_CUSTOM_EXPORT_COMMAND:
525 custom_export_command = lexrc.GetString();
528 case RC_CUSTOM_EXPORT_FORMAT:
530 custom_export_format = lexrc.GetString();
535 pdf_mode = lexrc.GetBool();
538 case RC_LATEX_COMMAND:
540 latex_command = lexrc.GetString();
543 case RC_PDFLATEX_COMMAND:
545 pdflatex_command = lexrc.GetString();
548 case RC_PDF_TO_PS_COMMAND:
550 pdf_to_ps_command = lexrc.GetString();
553 case RC_DVI_TO_PS_COMMAND:
555 dvi_to_ps_command = lexrc.GetString();
558 case RC_LITERATE_COMMAND:
560 literate_command = lexrc.GetString();
563 case RC_LITERATE_EXTENSION:
565 literate_extension = lexrc.GetString();
568 case RC_LITERATE_ERROR_FILTER:
570 literate_error_filter = lexrc.GetString();
573 case RC_BUILD_COMMAND:
575 build_command = lexrc.GetString();
578 case RC_BUILD_ERROR_FILTER:
580 build_error_filter = lexrc.GetString();
583 case RC_RELYX_COMMAND:
585 relyx_command = lexrc.GetString();
588 case RC_DEFAULT_PAPERSIZE:
590 string size = lowercase(lexrc.GetString());
591 if (size == "usletter")
593 BufferParams::PAPER_USLETTER;
594 else if (size == "legal")
596 BufferParams::PAPER_LEGALPAPER;
597 else if (size == "executive")
599 BufferParams::PAPER_EXECUTIVEPAPER;
600 else if (size == "a3")
602 BufferParams::PAPER_A3PAPER;
603 else if (size == "a4")
605 BufferParams::PAPER_A4PAPER;
606 else if (size == "a5")
608 BufferParams::PAPER_A5PAPER;
609 else if (size == "b5")
611 BufferParams::PAPER_B5PAPER;
614 case RC_VIEWDVI_COMMAND:
616 view_dvi_command = lexrc.GetString();
619 case RC_VIEWPDF_COMMAND:
621 view_pdf_command = lexrc.GetString();
626 ps_command = lexrc.GetString();
629 case RC_VIEWPS_COMMAND:
631 view_ps_command = lexrc.GetString();
634 case RC_VIEWPSPIC_COMMAND:
636 view_pspic_command = lexrc.GetString();
639 case RC_CHKTEX_COMMAND:
641 chktex_command = lexrc.GetString();
644 case RC_HTML_COMMAND:
646 html_command = lexrc.GetString();
651 dpi = lexrc.GetInteger();
656 zoom = lexrc.GetInteger();
659 case RC_SCREEN_FONT_SIZES:
661 font_sizes[LyXFont::SIZE_TINY] =
664 font_sizes[LyXFont::SIZE_SCRIPT] =
667 font_sizes[LyXFont::SIZE_FOOTNOTE] =
670 font_sizes[LyXFont::SIZE_SMALL] =
673 font_sizes[LyXFont::SIZE_NORMAL] =
676 font_sizes[LyXFont::SIZE_LARGE] =
679 font_sizes[LyXFont::SIZE_LARGER] =
682 font_sizes[LyXFont::SIZE_LARGEST] =
685 font_sizes[LyXFont::SIZE_HUGE] =
688 font_sizes[LyXFont::SIZE_HUGER] =
692 case RC_SCREEN_FONT_SCALABLE:
694 use_scalable_fonts = lexrc.GetBool();
699 autosave = lexrc.GetInteger();
702 case RC_SGML_EXTRA_OPTIONS:
704 sgml_extra_options = lexrc.GetString();
707 case RC_DOCUMENTPATH:
709 document_path = ExpandPath(lexrc.GetString());
713 case RC_TEMPLATEPATH:
715 template_path = ExpandPath(lexrc.GetString());
720 tempdir_path = ExpandPath(lexrc.GetString());
725 use_tempdir = lexrc.GetBool();
730 lastfiles = ExpandPath(lexrc.GetString());
733 case RC_NUMLASTFILES:
735 num_lastfiles = lexrc.GetInteger();
738 case RC_CHECKLASTFILES:
740 check_lastfiles = lexrc.GetBool();
743 case RC_SCREEN_FONT_ROMAN:
745 roman_font_name = lexrc.GetString();
748 case RC_SCREEN_FONT_SANS:
750 sans_font_name = lexrc.GetString();
753 case RC_SCREEN_FONT_TYPEWRITER:
755 typewriter_font_name = lexrc.GetString();
758 case RC_SCREEN_FONT_MENU:
760 menu_font_name = lexrc.GetString();
763 case RC_SCREEN_FONT_POPUP:
765 popup_font_name = lexrc.GetString();
768 case RC_SCREEN_FONT_ENCODING:
770 font_norm = lexrc.GetString();
773 case RC_AUTOREGIONDELETE:
774 // Auto region delete defaults to true
776 auto_region_delete = lexrc.GetBool();
781 // we should not do an explicit binding before
782 // loading a bind file. So, in this case, load
783 // the default bind file.
787 // !!!chb, dynamic key binding...
791 if (lexrc.lex() == LyXLex::LEX_DATA) {
792 seq = lexrc.GetString();
794 lexrc.printError("Bad key sequence: `$$Token'");
798 if (lexrc.lex() == LyXLex::LEX_DATA) {
799 cmd = lexrc.GetString();
801 lexrc.printError("Bad command: `$$Token'");
805 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
806 if (lyxerr.debugging(Debug::KEY)) {
807 lyxerr << "RC_BIND: Sequence `"
808 << seq << "' Command `"
809 << cmd << "' Action `"
810 << action << '\'' << endl;
812 res = bindKey(seq.c_str(), action);
815 "Invalid key sequence `"
818 } else {// cmd is the last token read.
820 "Unknown LyX function `$$Token'");
826 lyxpipes = ExpandPath(lexrc.GetString());
829 case RC_CURSOR_FOLLOWS_SCROLLBAR:
831 cursor_follows_scrollbar = lexrc.GetBool();
834 case RC_FAST_SELECTION:
836 fast_selection = lexrc.GetBool();
839 case RC_BACKGROUND_COLOR:
841 background_color = lexrc.GetString();
843 case RC_SELECTION_COLOR:
845 strncpy(selection_color,
846 lexrc.GetString().c_str(), 31);
850 fax_command = lexrc.GetString();
854 fax_program = lexrc.GetString();
858 string s = lexrc.GetString();
862 phone_book = user_lyxdir + s;
865 case RC_ASCIIROFF_COMMAND:
867 ascii_roff_command = lexrc.GetString();
869 case RC_ASCII_LINELEN:
871 ascii_linelen = lexrc.GetInteger();
873 // Spellchecker settings:
874 case RC_SPELL_COMMAND:
876 isp_command = lexrc.GetString();
878 case RC_ACCEPT_COMPOUND:
880 isp_accept_compound = lexrc.GetBool();
884 isp_use_input_encoding = lexrc.GetBool();
886 case RC_USE_ALT_LANG:
888 isp_use_alt_lang = lexrc.GetBool();
890 case RC_USE_PERS_DICT:
892 isp_use_pers_dict = lexrc.GetBool();
894 case RC_USE_ESC_CHARS:
896 isp_use_esc_chars = lexrc.GetBool();
900 isp_alt_lang = lexrc.GetString();
904 isp_pers_dict = lexrc.GetString();
908 isp_esc_chars = lexrc.GetString();
912 make_backup = lexrc.GetBool();
914 case RC_DATE_INSERT_FORMAT:
916 date_insert_format = lexrc.GetString();
920 rtl_support = lexrc.GetBool();
922 case RC_LAST: break; // this is just a dummy
930 void LyXRC::write(string const & filename) const
932 ofstream ofs(filename.c_str());
938 void LyXRC::print() const
940 if (lyxerr.debugging())
947 void LyXRC::output(ostream & os) const
949 os << "### This file is part of\n"
950 << "### ========================================================\n"
951 << "### LyX, The Document Processor\n"
953 << "### Copyright 1995 Matthias Ettrich\n"
954 << "### Copyright 1995-1998 The LyX Team.\n"
956 << "### ========================================================\n"
958 << "# This file is written by LyX, if you want to make your own\n"
959 << "# modifications you should do them from inside LyX and save\n"
960 << "# your preferences, or you can also make your modifications\n"
961 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
964 // Why the switch you might ask. It is a trick to ensure that all
965 // the elements in the LyXRCTags enum is handled. As you can see
966 // there are no breaks at all. So it is just a huge fall-through.
967 // The nice thing is that we will get a warning from the compiler
968 // if we forget an element.
969 LyXRCTags tag = RC_LAST;
973 // input/include files are not done here
975 // bindings is not written to the preferences file.
977 // bind files are not done here.
978 case RC_BEGINTOOLBAR:
979 // Toolbar is not written here (yet).
980 case RC_FONT_ENCODING:
981 os << "\\font_encoding \"" << fontenc << "\"\n";
983 os << "\\printer \"" << printer << "\"\n";
984 case RC_PRINT_COMMAND:
985 os << "\\print_command \"" << print_command << "\"\n";
986 case RC_PRINTEVENPAGEFLAG:
987 os << "\\print_evenpage_flag \"" << print_evenpage_flag
989 case RC_PRINTODDPAGEFLAG:
990 os << "\\print_oddpage_flag \"" << print_oddpage_flag
992 case RC_PRINTPAGERANGEFLAG:
993 os << "\\print_pagerange_flag \"" << print_pagerange_flag
995 case RC_PRINTCOPIESFLAG:
996 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
997 case RC_PRINTCOLLCOPIESFLAG:
998 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1000 case RC_PRINTREVERSEFLAG:
1001 os << "\\print_reverse_flag \"" << print_reverse_flag
1003 case RC_PRINTLANDSCAPEFLAG:
1004 os << "\\print_landscape_flag \"" << print_landscape_flag
1006 case RC_PRINTTOPRINTER:
1007 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1008 case RC_PRINT_ADAPTOUTPUT:
1009 os << "\\print_adapt_output " << tostr(print_adapt_output)
1011 case RC_PRINTTOFILE:
1012 os << "\\print_to_file \"" << print_to_file << "\"\n";
1013 case RC_PRINTFILEEXTENSION:
1014 os << "\\print_file_extension \"" << print_file_extension
1016 case RC_PRINTEXSTRAOPTIONS:
1017 os << "\\print_extra_options \"" << print_extra_options
1019 case RC_PRINTSPOOL_COMMAND:
1020 os << "\\print_spool_command \"" << print_spool_command
1022 case RC_PRINTSPOOL_PRINTERPREFIX:
1023 os << "\\print_spool_printerprefix \""
1024 << print_spool_printerprefix << "\"\n";
1025 case RC_PRINTPAPERDIMENSIONFLAG:
1026 os << "\\print_paper_dimension_flag \""
1027 << print_paper_dimension_flag << "\"\n";
1028 case RC_PRINTPAPERFLAG:
1029 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1030 case RC_CUSTOM_EXPORT_COMMAND:
1031 os << "\\custom_export_command \"" << custom_export_command
1033 case RC_CUSTOM_EXPORT_FORMAT:
1034 os << "\\custom_export_format \"" << custom_export_format
1037 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1038 case RC_LATEX_COMMAND:
1039 os << "\\latex_command \"" << latex_command << "\"\n";
1040 case RC_PDFLATEX_COMMAND:
1041 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1042 case RC_PDF_TO_PS_COMMAND:
1043 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1044 case RC_DVI_TO_PS_COMMAND:
1045 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1046 case RC_LITERATE_COMMAND:
1047 os << "\\literate_command \"" << literate_command << "\"\n";
1048 case RC_LITERATE_EXTENSION:
1049 os << "\\literate_extension \"" << literate_extension
1051 case RC_LITERATE_ERROR_FILTER:
1052 os << "\\literate_error_filter \"" << literate_error_filter
1054 case RC_BUILD_COMMAND:
1055 os << "\\build_command \"" << build_command << "\"\n";
1056 case RC_BUILD_ERROR_FILTER:
1057 os << "\\build_error_filter \"" << build_error_filter
1060 os << "\\screen_dpi " << dpi << "\n";
1061 case RC_SCREEN_ZOOM:
1062 os << "\\screen_zoom " << zoom << "\n";
1063 case RC_SCREEN_FONT_SIZES:
1064 os.setf(ios::fixed);
1066 os << "\\screen_font_sizes";
1067 os << " " << font_sizes[LyXFont::SIZE_TINY];
1068 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1069 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1070 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1071 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1072 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1073 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1074 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1075 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1076 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1078 case RC_AUTOREGIONDELETE:
1079 os << "\\auto_region_delete " << tostr(auto_region_delete)
1082 os << "\\autosave " << autosave << "\n";
1083 case RC_EXIT_CONFIRMATION:
1084 os << "\\exit_confirmation " << tostr(exit_confirmation)
1086 case RC_DISPLAY_SHORTCUTS:
1087 os << "\\display_shortcuts " << tostr(display_shortcuts)
1089 case RC_VIEWDVI_COMMAND:
1090 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1091 case RC_VIEWPDF_COMMAND:
1092 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1093 case RC_DEFAULT_PAPERSIZE:
1094 os << "\\default_papersize \"";
1095 switch (default_papersize) {
1096 case BufferParams::PAPER_USLETTER:
1097 os << "usletter"; break;
1098 case BufferParams::PAPER_LEGALPAPER:
1099 os << "legal"; break;
1100 case BufferParams::PAPER_EXECUTIVEPAPER:
1101 os << "executive"; break;
1102 case BufferParams::PAPER_A3PAPER:
1104 case BufferParams::PAPER_A4PAPER:
1106 case BufferParams::PAPER_A5PAPER:
1108 case BufferParams::PAPER_B5PAPER:
1110 case BufferParams::PAPER_DEFAULT: break;
1113 case RC_VIEWPS_COMMAND:
1114 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1115 case RC_VIEWPSPIC_COMMAND:
1116 os << "\\view_pspic_command \"" << view_pspic_command
1119 os << "\\ps_command \"" << ps_command << "\"\n";
1120 case RC_CHKTEX_COMMAND:
1121 os << "\\chktex_command \"" << chktex_command << "\"\n";
1122 case RC_HTML_COMMAND:
1123 os << "\\html_command \"" << html_command << "\"\n";
1124 case RC_SGML_EXTRA_OPTIONS:
1125 os << "\\sgml_extra_options \"" << sgml_extra_options
1128 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1129 case RC_KBMAP_PRIMARY:
1130 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1131 case RC_KBMAP_SECONDARY:
1132 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1134 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1135 case RC_RELYX_COMMAND:
1136 os << "\\relyx_command \"" << relyx_command << "\"\n";
1137 case RC_DOCUMENTPATH:
1138 os << "\\document_path \"" << document_path << "\"\n";
1139 case RC_TEMPLATEPATH:
1140 os << "\\template_path \"" << template_path << "\"\n";
1141 case RC_TEMPDIRPATH:
1142 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1144 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1146 os << "\\lastfiles \"" << lastfiles << "\"\n";
1147 case RC_NUMLASTFILES:
1148 os << "\\num_lastfiles " << num_lastfiles << "\n";
1149 case RC_CHECKLASTFILES:
1150 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1151 case RC_SCREEN_FONT_ROMAN:
1152 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1153 case RC_SCREEN_FONT_SANS:
1154 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1155 case RC_SCREEN_FONT_TYPEWRITER:
1156 os << "\\screen_font_typewriter \""
1157 << typewriter_font_name << "\"\n";
1158 case RC_SCREEN_FONT_MENU:
1159 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1160 case RC_SCREEN_FONT_POPUP:
1161 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1162 case RC_SCREEN_FONT_ENCODING:
1163 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1164 case RC_SCREEN_FONT_SCALABLE:
1165 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1167 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1168 os << "\\cursor_follows_scrollbar "
1169 << tostr(cursor_follows_scrollbar) << "\n";
1170 case RC_FAST_SELECTION:
1171 os << "\\fast_selection "
1172 << tostr(static_cast<bool>(fast_selection)) << "\n";
1173 case RC_BACKGROUND_COLOR:
1174 os << "\\background_color \"" << background_color << "\"\n";
1175 case RC_SELECTION_COLOR:
1176 os << "\\selection_color \"" << selection_color << "\"\n";
1177 case RC_FAX_COMMAND:
1178 os << "\\fax_command \"" << fax_command << "\"\n";
1180 os << "\\fax_program \"" << fax_program << "\"\n";
1182 os << "\\phone_book \"" << phone_book << "\"\n";
1183 case RC_ASCIIROFF_COMMAND:
1184 os << "\\ascii_roff_command \"" << ascii_roff_command
1186 case RC_ASCII_LINELEN:
1187 os << "\\ascii_linelen " << ascii_linelen << "\n";
1188 case RC_SPELL_COMMAND:
1189 os << "\\spell_command \"" << isp_command << "\"\n";
1190 case RC_ACCEPT_COMPOUND:
1191 os << "\\accept_compound " << tostr(isp_accept_compound)
1193 case RC_USE_INP_ENC:
1194 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1196 case RC_USE_ALT_LANG:
1197 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1198 case RC_USE_PERS_DICT:
1199 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1201 case RC_USE_ESC_CHARS:
1202 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1205 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1207 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1209 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1210 case RC_RTL_SUPPORT:
1211 os << "\\rtl " << tostr(rtl_support) << "\n";
1212 case RC_MAKE_BACKUP:
1213 os << "\\make_backup " << tostr(make_backup) << "\n";
1214 case RC_DATE_INSERT_FORMAT:
1215 os << "\\date_insert_format \"" << date_insert_format
1222 /// define the default key bindings for LyX.
1223 void LyXRC::defaultKeyBindings()
1225 bindKey("Right", LFUN_RIGHT);
1226 bindKey("Left", LFUN_LEFT);
1227 bindKey("Up", LFUN_UP);
1228 bindKey("Down", LFUN_DOWN);
1230 bindKey("Tab", LFUN_TAB);
1232 bindKey("Home", LFUN_HOME);
1233 bindKey("End", LFUN_END);
1234 bindKey("Prior", LFUN_PRIOR);
1235 bindKey("Next", LFUN_NEXT);
1237 bindKey("Return", LFUN_BREAKPARAGRAPH);
1238 bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
1240 bindKey("Delete", LFUN_DELETE);
1241 bindKey("BackSpace", LFUN_BACKSPACE);
1242 // bindKeyings for transparent handling of deadkeys
1243 // The keysyms are gotten from XFree86 X11R6
1244 bindKey("~C-~S-~M-dead_acute", LFUN_ACUTE);
1245 bindKey("~C-~S-~M-dead_breve", LFUN_BREVE);
1246 bindKey("~C-~S-~M-dead_caron", LFUN_CARON);
1247 bindKey("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
1248 bindKey("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
1249 bindKey("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
1250 bindKey("~C-~S-~M-dead_abovedot", LFUN_DOT);
1251 bindKey("~C-~S-~M-dead_grave", LFUN_GRAVE);
1252 bindKey("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
1253 bindKey("~C-~S-~M-dead_macron", LFUN_MACRON);
1254 // nothing with this name
1255 // bindKey("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
1256 bindKey("~C-~S-~M-dead_tilde", LFUN_TILDE);
1257 bindKey("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
1258 // nothing with this name either...
1259 //bindKey("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
1260 bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
1261 bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
1262 bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
1264 // bindings to utilize the use of the numeric keypad
1265 // e.g. Num Lock set
1266 bindKey("KP_0", LFUN_SELFINSERT);
1267 bindKey("KP_Decimal", LFUN_SELFINSERT);
1268 bindKey("KP_Enter", LFUN_SELFINSERT);
1269 bindKey("KP_1", LFUN_SELFINSERT);
1270 bindKey("KP_2", LFUN_SELFINSERT);
1271 bindKey("KP_3", LFUN_SELFINSERT);
1272 bindKey("KP_4", LFUN_SELFINSERT);
1273 bindKey("KP_5", LFUN_SELFINSERT);
1274 bindKey("KP_6", LFUN_SELFINSERT);
1275 bindKey("KP_Add", LFUN_SELFINSERT);
1276 bindKey("KP_7", LFUN_SELFINSERT);
1277 bindKey("KP_8", LFUN_SELFINSERT);
1278 bindKey("KP_9", LFUN_SELFINSERT);
1279 bindKey("KP_Divide", LFUN_SELFINSERT);
1280 bindKey("KP_Multiply", LFUN_SELFINSERT);
1281 bindKey("KP_Subtract", LFUN_SELFINSERT);
1283 /* Most self-insert keys are handled in the 'default:' section of
1284 * WorkAreaKeyPress - so we don't have to define them all.
1285 * However keys explicit decleared as self-insert are
1286 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1288 bindKey("C-Tab", LFUN_TABINSERT); // ale970515