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 int fast_selection;
43 extern string background_color;
44 extern char selection_color[];
45 extern bool cursor_follows_scrollbar;
46 extern kb_keymap * toplevel_keymap;
47 extern LyXAction lyxaction;
56 RC_PRINTPAGERANGEFLAG,
58 RC_PRINTCOLLCOPIESFLAG,
60 RC_PRINTLANDSCAPEFLAG,
64 RC_PRINTFILEEXTENSION,
65 RC_PRINTEXSTRAOPTIONS,
66 RC_PRINTSPOOL_COMMAND,
67 RC_PRINTSPOOL_PRINTERPREFIX,
69 RC_PRINTPAPERDIMENSIONFLAG,
70 RC_CUSTOM_EXPORT_COMMAND,
71 RC_CUSTOM_EXPORT_FORMAT,
74 RC_LITERATE_EXTENSION,
75 RC_LITERATE_ERROR_FILTER,
77 RC_BUILD_ERROR_FILTER,
83 RC_SCREEN_FONT_TYPEWRITER,
86 RC_SCREEN_FONT_ENCODING,
88 RC_SGML_EXTRA_OPTIONS,
97 RC_NOMENUACCELERATORS,
111 RC_ASCIIROFF_COMMAND,
116 RC_DEFAULT_PAPERSIZE,
119 RC_VIEWPSPIC_COMMAND,
126 RC_SCREEN_FONT_SCALABLE,
131 RC_CURSOR_FOLLOWS_SCROLLBAR,
132 RC_EXIT_CONFIRMATION,
133 RC_DISPLAY_SHORTCUTS,
141 RC_PDF_TO_PS_COMMAND,
142 RC_DVI_TO_PS_COMMAND,
143 RC_DATE_INSERT_FORMAT,
148 static keyword_item lyxrcTags[] = {
149 { "\\accept_compound", RC_ACCEPT_COMPOUND },
150 { "\\alternate_language", RC_ALT_LANG },
151 { "\\ascii_linelen", RC_ASCII_LINELEN },
152 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
153 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
154 { "\\autosave", RC_AUTOSAVE },
155 { "\\background_color", RC_BACKGROUND_COLOR },
156 { "\\begin_toolbar", RC_BEGINTOOLBAR },
157 { "\\bind", RC_BIND },
158 { "\\bind_file", RC_BINDFILE },
159 { "\\build_command", RC_BUILD_COMMAND },
160 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
161 { "\\check_lastfiles", RC_CHECKLASTFILES },
162 { "\\chktex_command", RC_CHKTEX_COMMAND },
163 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
164 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
165 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
166 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
167 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
168 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
169 { "\\document_path", RC_DOCUMENTPATH },
170 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
171 { "\\escape_chars", RC_ESC_CHARS },
172 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
174 { "\\fast_selection", RC_FAST_SELECTION },
176 { "\\fax_command", RC_FAX_COMMAND },
177 { "\\fax_program", RC_FAXPROGRAM },
178 { "\\font_encoding", RC_FONT_ENCODING },
179 { "\\html_command", RC_HTML_COMMAND },
180 { "\\input", RC_INPUT },
181 { "\\kbmap", RC_KBMAP },
182 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
183 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
184 { "\\lastfiles", RC_LASTFILES },
185 { "\\latex_command", RC_LATEX_COMMAND },
186 { "\\literate_command", RC_LITERATE_COMMAND },
187 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
188 { "\\literate_extension", RC_LITERATE_EXTENSION },
189 { "\\make_backup", RC_MAKE_BACKUP },
190 { "\\num_lastfiles", RC_NUMLASTFILES },
191 { "\\pdf_mode", RC_PDF_MODE },
192 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
193 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
194 { "\\personal_dictionary", RC_PERS_DICT },
195 { "\\phone_book", RC_PHONEBOOK },
196 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
197 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
198 { "\\print_command", RC_PRINT_COMMAND },
199 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
200 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
201 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
202 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
203 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
204 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
205 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
206 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
207 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
208 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
209 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
210 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
211 { "\\print_to_file", RC_PRINTTOFILE },
212 { "\\print_to_printer", RC_PRINTTOPRINTER },
213 { "\\printer", RC_PRINTER },
214 { "\\ps_command", RC_PS_COMMAND },
215 { "\\relyx_command", RC_RELYX_COMMAND },
216 { "\\rtl", RC_RTL_SUPPORT },
217 { "\\screen_dpi", RC_SCREEN_DPI },
218 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
219 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
220 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
221 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
222 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
223 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
224 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
225 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
226 { "\\screen_zoom", RC_SCREEN_ZOOM },
227 { "\\selection_color", RC_SELECTION_COLOR },
228 { "\\serverpipe", RC_SERVERPIPE },
229 { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
230 { "\\spell_command", RC_SPELL_COMMAND },
231 { "\\tempdir_path", RC_TEMPDIRPATH },
232 { "\\template_path", RC_TEMPLATEPATH },
233 { "\\use_alt_language", RC_USE_ALT_LANG },
234 { "\\use_escape_chars", RC_USE_ESC_CHARS },
235 { "\\use_input_encoding", RC_USE_INP_ENC },
236 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
237 { "\\use_tempdir", RC_USETEMPDIR },
238 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
239 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
240 { "\\view_ps_command", RC_VIEWPS_COMMAND },
241 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
244 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
245 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
247 // Should this be moved inside LyXAction?
249 int bindKey(char const * seq, int action)
251 return toplevel_keymap->bind(seq, action);
257 // Get printer from the environment. If fail, use default "",
258 // assuming that everything is set up correctly.
259 printer = GetEnv("PRINTER");
260 print_adapt_output = false;
261 print_command = "dvips";
262 print_evenpage_flag = "-B";
263 print_oddpage_flag = "-A";
264 print_pagerange_flag = "-pp";
265 print_copies_flag = "-c";
266 print_collcopies_flag = "-C";
267 print_reverse_flag = "-r";
268 print_landscape_flag = "-t landscape";
269 print_to_printer = "-P";
270 print_to_file = "-o ";
271 print_file_extension = ".ps";
272 print_paper_flag = "-t";
273 print_paper_dimension_flag = "-T";
274 document_path = GetEnvPath("HOME");
275 tempdir_path = "/tmp";
278 latex_command = "latex";
279 pdflatex_command = "pdflatex";
280 pdf_to_ps_command = "pdf2ps";
281 dvi_to_ps_command = "dvips";
282 literate_command = "none";
283 literate_extension = "none";
284 literate_error_filter = "cat";
285 build_command = "make";
286 build_error_filter = "cat";
287 relyx_command = "reLyX";
289 view_ps_command = "ghostview -swap";
290 view_pspic_command = "ghostview";
291 view_dvi_command = "xdvi";
292 view_pdf_command = "xpdf";
293 default_papersize = BufferParams::PAPER_USLETTER;
294 custom_export_format = "ps";
295 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
296 html_command = "tth -t";
299 // Because a screen typically is wider than a piece of paper:
301 // Default LaTeX font size:
302 font_sizes[LyXFont::SIZE_TINY] = 5.0;
303 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
304 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
305 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
306 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
307 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
308 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
309 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
310 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
311 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
312 use_scalable_fonts = true;
313 roman_font_name = "-*-times";
314 sans_font_name = "-*-helvetica";
315 typewriter_font_name = "-*-courier";
316 menu_font_name = "-*-helvetica-bold-r";
317 popup_font_name = "-*-helvetica-medium-r";
318 font_norm = "iso8859-1";
320 auto_region_delete = true;
323 check_lastfiles = true;
325 exit_confirmation = true;
326 display_shortcuts = true;
327 // Spellchecker settings:
328 isp_command = "ispell";
329 isp_accept_compound = false;
330 isp_use_input_encoding = false;
331 isp_use_alt_lang = false;
332 isp_use_pers_dict = false;
333 isp_use_esc_chars = false;
337 defaultKeyBindings();
339 date_insert_format = "%A, %e %B %Y";
343 int LyXRC::ReadBindFile(string const & name)
346 string tmp = i18nLibFileSearch("bind", name, "bind");
347 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
348 int result = read(tmp);
350 lyxerr << "Error reading bind file: " << tmp << endl;
356 int LyXRC::read(string const & filename)
359 string bindFile = "cua";
361 LyXLex lexrc(lyxrcTags, lyxrcCount);
362 if (lyxerr.debugging(Debug::PARSER))
365 lexrc.setFile(filename);
366 if (!lexrc.IsOK()) return -2;
368 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
370 while (lexrc.IsOK()) {
371 // By using two switches we take advantage of the compiler
372 // telling us if we have missed a LyXRCTags element in
373 // the second switch.
374 // Note that this also shows a problem with LyXLex since it
375 // helps us avoid taking advantage of the strictness of the
378 int le = lexrc.lex();
380 case LyXLex::LEX_UNDEF:
381 lexrc.printError("Unknown tag `$$Token'");
383 case LyXLex::LEX_FEOF:
387 switch (static_cast<LyXRCTags>(le)) {
388 case RC_INPUT: // Include file
390 string tmp = LibFileSearch(string(),
393 lexrc.printError("Error reading "
394 "included file: "+tmp);
398 case RC_BINDFILE: // RVDK_PATCH_5
400 ReadBindFile(lexrc.GetString());
404 case RC_BEGINTOOLBAR:
405 // this toolbar should be changed to be a completely
406 // non gui toolbar. (Lgb)
412 use_kbmap = lexrc.GetBool();
415 case RC_EXIT_CONFIRMATION:
417 exit_confirmation = lexrc.GetBool();
420 case RC_DISPLAY_SHORTCUTS:
422 display_shortcuts = lexrc.GetBool();
425 case RC_KBMAP_PRIMARY:
427 primary_kbmap = lexrc.GetString();
430 case RC_KBMAP_SECONDARY:
432 secondary_kbmap = lexrc.GetString();
435 case RC_FONT_ENCODING:
437 fontenc = lexrc.GetString();
442 printer = lexrc.GetString();
445 case RC_PRINT_COMMAND:
447 print_command = lexrc.GetString();
450 case RC_PRINTEVENPAGEFLAG:
452 print_evenpage_flag = lexrc.GetString();
455 case RC_PRINTODDPAGEFLAG:
457 print_oddpage_flag = lexrc.GetString();
460 case RC_PRINTPAGERANGEFLAG:
462 print_pagerange_flag = lexrc.GetString();
465 case RC_PRINTCOPIESFLAG:
467 print_copies_flag = lexrc.GetString();
470 case RC_PRINTCOLLCOPIESFLAG:
472 print_collcopies_flag = lexrc.GetString();
475 case RC_PRINTREVERSEFLAG:
477 print_reverse_flag = lexrc.GetString();
480 case RC_PRINTLANDSCAPEFLAG:
482 print_landscape_flag = lexrc.GetString();
485 case RC_PRINTTOPRINTER:
487 print_to_printer = lexrc.GetString();
490 case RC_PRINT_ADAPTOUTPUT:
492 print_adapt_output = lexrc.GetBool();
497 print_to_file = lexrc.GetString();
500 case RC_PRINTFILEEXTENSION:
502 print_file_extension = lexrc.GetString();
505 case RC_PRINTEXSTRAOPTIONS:
507 print_extra_options = lexrc.GetString();
510 case RC_PRINTSPOOL_COMMAND:
512 print_spool_command = lexrc.GetString();
515 case RC_PRINTSPOOL_PRINTERPREFIX:
517 print_spool_printerprefix = lexrc.GetString();
520 case RC_PRINTPAPERDIMENSIONFLAG:
522 print_paper_dimension_flag = lexrc.GetString();
525 case RC_PRINTPAPERFLAG:
527 print_paper_flag = lexrc.GetString();
530 case RC_CUSTOM_EXPORT_COMMAND:
532 custom_export_command = lexrc.GetString();
535 case RC_CUSTOM_EXPORT_FORMAT:
537 custom_export_format = lexrc.GetString();
542 pdf_mode = lexrc.GetBool();
545 case RC_LATEX_COMMAND:
547 latex_command = lexrc.GetString();
550 case RC_PDFLATEX_COMMAND:
552 pdflatex_command = lexrc.GetString();
555 case RC_PDF_TO_PS_COMMAND:
557 pdf_to_ps_command = lexrc.GetString();
560 case RC_DVI_TO_PS_COMMAND:
562 dvi_to_ps_command = lexrc.GetString();
565 case RC_LITERATE_COMMAND:
567 literate_command = lexrc.GetString();
570 case RC_LITERATE_EXTENSION:
572 literate_extension = lexrc.GetString();
575 case RC_LITERATE_ERROR_FILTER:
577 literate_error_filter = lexrc.GetString();
580 case RC_BUILD_COMMAND:
582 build_command = lexrc.GetString();
585 case RC_BUILD_ERROR_FILTER:
587 build_error_filter = lexrc.GetString();
590 case RC_RELYX_COMMAND:
592 relyx_command = lexrc.GetString();
595 case RC_DEFAULT_PAPERSIZE:
597 string size = lowercase(lexrc.GetString());
598 if (size == "usletter")
600 BufferParams::PAPER_USLETTER;
601 else if (size == "legal")
603 BufferParams::PAPER_LEGALPAPER;
604 else if (size == "executive")
606 BufferParams::PAPER_EXECUTIVEPAPER;
607 else if (size == "a3")
609 BufferParams::PAPER_A3PAPER;
610 else if (size == "a4")
612 BufferParams::PAPER_A4PAPER;
613 else if (size == "a5")
615 BufferParams::PAPER_A5PAPER;
616 else if (size == "b5")
618 BufferParams::PAPER_B5PAPER;
621 case RC_VIEWDVI_COMMAND:
623 view_dvi_command = lexrc.GetString();
626 case RC_VIEWPDF_COMMAND:
628 view_pdf_command = lexrc.GetString();
633 ps_command = lexrc.GetString();
636 case RC_VIEWPS_COMMAND:
638 view_ps_command = lexrc.GetString();
641 case RC_VIEWPSPIC_COMMAND:
643 view_pspic_command = lexrc.GetString();
646 case RC_CHKTEX_COMMAND:
648 chktex_command = lexrc.GetString();
651 case RC_HTML_COMMAND:
653 html_command = lexrc.GetString();
658 dpi = lexrc.GetInteger();
663 zoom = lexrc.GetInteger();
666 case RC_SCREEN_FONT_SIZES:
668 font_sizes[LyXFont::SIZE_TINY] =
671 font_sizes[LyXFont::SIZE_SCRIPT] =
674 font_sizes[LyXFont::SIZE_FOOTNOTE] =
677 font_sizes[LyXFont::SIZE_SMALL] =
680 font_sizes[LyXFont::SIZE_NORMAL] =
683 font_sizes[LyXFont::SIZE_LARGE] =
686 font_sizes[LyXFont::SIZE_LARGER] =
689 font_sizes[LyXFont::SIZE_LARGEST] =
692 font_sizes[LyXFont::SIZE_HUGE] =
695 font_sizes[LyXFont::SIZE_HUGER] =
699 case RC_SCREEN_FONT_SCALABLE:
701 use_scalable_fonts = lexrc.GetBool();
706 autosave = lexrc.GetInteger();
709 case RC_SGML_EXTRA_OPTIONS:
711 sgml_extra_options = lexrc.GetString();
714 case RC_DOCUMENTPATH:
716 document_path = ExpandPath(lexrc.GetString());
720 case RC_TEMPLATEPATH:
722 template_path = ExpandPath(lexrc.GetString());
727 tempdir_path = ExpandPath(lexrc.GetString());
732 use_tempdir = lexrc.GetBool();
737 lastfiles = ExpandPath(lexrc.GetString());
740 case RC_NUMLASTFILES:
742 num_lastfiles = lexrc.GetInteger();
745 case RC_CHECKLASTFILES:
747 check_lastfiles = lexrc.GetBool();
750 case RC_SCREEN_FONT_ROMAN:
752 roman_font_name = lexrc.GetString();
755 case RC_SCREEN_FONT_SANS:
757 sans_font_name = lexrc.GetString();
760 case RC_SCREEN_FONT_TYPEWRITER:
762 typewriter_font_name = lexrc.GetString();
765 case RC_SCREEN_FONT_MENU:
767 menu_font_name = lexrc.GetString();
770 case RC_SCREEN_FONT_POPUP:
772 popup_font_name = lexrc.GetString();
775 case RC_SCREEN_FONT_ENCODING:
777 font_norm = lexrc.GetString();
780 case RC_AUTOREGIONDELETE:
781 // Auto region delete defaults to true
783 auto_region_delete = lexrc.GetBool();
788 // we should not do an explicit binding before
789 // loading a bind file. So, in this case, load
790 // the default bind file.
794 // !!!chb, dynamic key binding...
798 if (lexrc.lex() == LyXLex::LEX_DATA) {
799 seq = lexrc.GetString();
801 lexrc.printError("Bad key sequence: `$$Token'");
805 if (lexrc.lex() == LyXLex::LEX_DATA) {
806 cmd = lexrc.GetString();
808 lexrc.printError("Bad command: `$$Token'");
812 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
813 if (lyxerr.debugging(Debug::KEY)) {
814 lyxerr << "RC_BIND: Sequence `"
815 << seq << "' Command `"
816 << cmd << "' Action `"
817 << action << '\'' << endl;
819 res = bindKey(seq.c_str(), action);
822 "Invalid key sequence `"
825 } else {// cmd is the last token read.
827 "Unknown LyX function `$$Token'");
833 lyxpipes = ExpandPath(lexrc.GetString());
836 case RC_CURSOR_FOLLOWS_SCROLLBAR:
838 cursor_follows_scrollbar = lexrc.GetBool();
842 case RC_FAST_SELECTION:
844 fast_selection = lexrc.GetBool();
848 case RC_BACKGROUND_COLOR:
850 background_color = lexrc.GetString();
852 case RC_SELECTION_COLOR:
854 strncpy(selection_color,
855 lexrc.GetString().c_str(), 31);
859 fax_command = lexrc.GetString();
863 fax_program = lexrc.GetString();
867 string s = lexrc.GetString();
871 phone_book = user_lyxdir + s;
874 case RC_ASCIIROFF_COMMAND:
876 ascii_roff_command = lexrc.GetString();
878 case RC_ASCII_LINELEN:
880 ascii_linelen = lexrc.GetInteger();
882 // Spellchecker settings:
883 case RC_SPELL_COMMAND:
885 isp_command = lexrc.GetString();
887 case RC_ACCEPT_COMPOUND:
889 isp_accept_compound = lexrc.GetBool();
893 isp_use_input_encoding = lexrc.GetBool();
895 case RC_USE_ALT_LANG:
897 isp_use_alt_lang = lexrc.GetBool();
899 case RC_USE_PERS_DICT:
901 isp_use_pers_dict = lexrc.GetBool();
903 case RC_USE_ESC_CHARS:
905 isp_use_esc_chars = lexrc.GetBool();
909 isp_alt_lang = lexrc.GetString();
913 isp_pers_dict = lexrc.GetString();
917 isp_esc_chars = lexrc.GetString();
921 make_backup = lexrc.GetBool();
923 case RC_DATE_INSERT_FORMAT:
925 date_insert_format = lexrc.GetString();
929 rtl_support = 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_VIEWPDF_COMMAND:
1101 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1102 case RC_DEFAULT_PAPERSIZE:
1103 os << "\\default_papersize \"";
1104 switch (default_papersize) {
1105 case BufferParams::PAPER_USLETTER:
1106 os << "usletter"; break;
1107 case BufferParams::PAPER_LEGALPAPER:
1108 os << "legal"; break;
1109 case BufferParams::PAPER_EXECUTIVEPAPER:
1110 os << "executive"; break;
1111 case BufferParams::PAPER_A3PAPER:
1113 case BufferParams::PAPER_A4PAPER:
1115 case BufferParams::PAPER_A5PAPER:
1117 case BufferParams::PAPER_B5PAPER:
1119 case BufferParams::PAPER_DEFAULT: break;
1122 case RC_VIEWPS_COMMAND:
1123 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1124 case RC_VIEWPSPIC_COMMAND:
1125 os << "\\view_pspic_command \"" << view_pspic_command
1128 os << "\\ps_command \"" << ps_command << "\"\n";
1129 case RC_CHKTEX_COMMAND:
1130 os << "\\chktex_command \"" << chktex_command << "\"\n";
1131 case RC_HTML_COMMAND:
1132 os << "\\html_command \"" << html_command << "\"\n";
1133 case RC_SGML_EXTRA_OPTIONS:
1134 os << "\\sgml_extra_options \"" << sgml_extra_options
1137 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1138 case RC_KBMAP_PRIMARY:
1139 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1140 case RC_KBMAP_SECONDARY:
1141 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1143 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1144 case RC_RELYX_COMMAND:
1145 os << "\\relyx_command \"" << relyx_command << "\"\n";
1146 case RC_DOCUMENTPATH:
1147 os << "\\document_path \"" << document_path << "\"\n";
1148 case RC_TEMPLATEPATH:
1149 os << "\\template_path \"" << template_path << "\"\n";
1150 case RC_TEMPDIRPATH:
1151 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1153 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1155 os << "\\lastfiles \"" << lastfiles << "\"\n";
1156 case RC_NUMLASTFILES:
1157 os << "\\num_lastfiles " << num_lastfiles << "\n";
1158 case RC_CHECKLASTFILES:
1159 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1160 case RC_SCREEN_FONT_ROMAN:
1161 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1162 case RC_SCREEN_FONT_SANS:
1163 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1164 case RC_SCREEN_FONT_TYPEWRITER:
1165 os << "\\screen_font_typewriter \""
1166 << typewriter_font_name << "\"\n";
1167 case RC_SCREEN_FONT_MENU:
1168 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1169 case RC_SCREEN_FONT_POPUP:
1170 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1171 case RC_SCREEN_FONT_ENCODING:
1172 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1173 case RC_SCREEN_FONT_SCALABLE:
1174 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1176 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1177 os << "\\cursor_follows_scrollbar "
1178 << tostr(cursor_follows_scrollbar) << "\n";
1180 case RC_FAST_SELECTION:
1181 os << "\\fast_selection "
1182 << tostr(static_cast<bool>(fast_selection)) << "\n";
1184 case RC_BACKGROUND_COLOR:
1185 os << "\\background_color \"" << background_color << "\"\n";
1186 case RC_SELECTION_COLOR:
1187 os << "\\selection_color \"" << selection_color << "\"\n";
1188 case RC_FAX_COMMAND:
1189 os << "\\fax_command \"" << fax_command << "\"\n";
1191 os << "\\fax_program \"" << fax_program << "\"\n";
1193 os << "\\phone_book \"" << phone_book << "\"\n";
1194 case RC_ASCIIROFF_COMMAND:
1195 os << "\\ascii_roff_command \"" << ascii_roff_command
1197 case RC_ASCII_LINELEN:
1198 os << "\\ascii_linelen " << ascii_linelen << "\n";
1199 case RC_SPELL_COMMAND:
1200 os << "\\spell_command \"" << isp_command << "\"\n";
1201 case RC_ACCEPT_COMPOUND:
1202 os << "\\accept_compound " << tostr(isp_accept_compound)
1204 case RC_USE_INP_ENC:
1205 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1207 case RC_USE_ALT_LANG:
1208 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1209 case RC_USE_PERS_DICT:
1210 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1212 case RC_USE_ESC_CHARS:
1213 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1216 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1218 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1220 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1221 case RC_RTL_SUPPORT:
1222 os << "\\rtl " << tostr(rtl_support) << "\n";
1223 case RC_MAKE_BACKUP:
1224 os << "\\make_backup " << tostr(make_backup) << "\n";
1225 case RC_DATE_INSERT_FORMAT:
1226 os << "\\date_insert_format \"" << date_insert_format
1233 /// define the default key bindings for LyX.
1234 void LyXRC::defaultKeyBindings()
1236 bindKey("Right", LFUN_RIGHT);
1237 bindKey("Left", LFUN_LEFT);
1238 bindKey("Up", LFUN_UP);
1239 bindKey("Down", LFUN_DOWN);
1241 bindKey("Tab", LFUN_TAB);
1243 bindKey("Home", LFUN_HOME);
1244 bindKey("End", LFUN_END);
1245 bindKey("Prior", LFUN_PRIOR);
1246 bindKey("Next", LFUN_NEXT);
1248 bindKey("Return", LFUN_BREAKPARAGRAPH);
1249 bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
1251 bindKey("Delete", LFUN_DELETE);
1252 bindKey("BackSpace", LFUN_BACKSPACE);
1253 // bindKeyings for transparent handling of deadkeys
1254 // The keysyms are gotten from XFree86 X11R6
1255 bindKey("~C-~S-~M-dead_acute", LFUN_ACUTE);
1256 bindKey("~C-~S-~M-dead_breve", LFUN_BREVE);
1257 bindKey("~C-~S-~M-dead_caron", LFUN_CARON);
1258 bindKey("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
1259 bindKey("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
1260 bindKey("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
1261 bindKey("~C-~S-~M-dead_abovedot", LFUN_DOT);
1262 bindKey("~C-~S-~M-dead_grave", LFUN_GRAVE);
1263 bindKey("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
1264 bindKey("~C-~S-~M-dead_macron", LFUN_MACRON);
1265 // nothing with this name
1266 // bindKey("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
1267 bindKey("~C-~S-~M-dead_tilde", LFUN_TILDE);
1268 bindKey("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
1269 // nothing with this name either...
1270 //bindKey("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
1271 bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
1272 bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
1273 bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
1275 // bindings to utilize the use of the numeric keypad
1276 // e.g. Num Lock set
1277 bindKey("KP_0", LFUN_SELFINSERT);
1278 bindKey("KP_Decimal", LFUN_SELFINSERT);
1279 bindKey("KP_Enter", LFUN_SELFINSERT);
1280 bindKey("KP_1", LFUN_SELFINSERT);
1281 bindKey("KP_2", LFUN_SELFINSERT);
1282 bindKey("KP_3", LFUN_SELFINSERT);
1283 bindKey("KP_4", LFUN_SELFINSERT);
1284 bindKey("KP_5", LFUN_SELFINSERT);
1285 bindKey("KP_6", LFUN_SELFINSERT);
1286 bindKey("KP_Add", LFUN_SELFINSERT);
1287 bindKey("KP_7", LFUN_SELFINSERT);
1288 bindKey("KP_8", LFUN_SELFINSERT);
1289 bindKey("KP_9", LFUN_SELFINSERT);
1290 bindKey("KP_Divide", LFUN_SELFINSERT);
1291 bindKey("KP_Multiply", LFUN_SELFINSERT);
1292 bindKey("KP_Subtract", LFUN_SELFINSERT);
1294 /* Most self-insert keys are handled in the 'default:' section of
1295 * WorkAreaKeyPress - so we don't have to define them all.
1296 * However keys explicit decleared as self-insert are
1297 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1299 bindKey("C-Tab", LFUN_TABINSERT); // ale970515