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"
26 #include "LyXAction.h"
27 #include "lyxserver.h"
30 #include "tex-strings.h"
31 #include "support/path.h"
32 #include "support/filetools.h"
35 // this is crappy... why are those colors command line arguments and
36 // not in lyxrc?? (Matthias)
37 // Because nobody put them there. (Asger)
38 extern int fast_selection;
39 extern string background_color;
40 extern char selection_color[];
41 extern bool cursor_follows_scrollbar;
42 extern kb_keymap * toplevel_keymap;
43 extern LyXAction lyxaction;
52 RC_PRINTPAGERANGEFLAG,
54 RC_PRINTCOLLCOPIESFLAG,
56 RC_PRINTLANDSCAPEFLAG,
60 RC_PRINTFILEEXTENSION,
61 RC_PRINTEXSTRAOPTIONS,
62 RC_PRINTSPOOL_COMMAND,
63 RC_PRINTSPOOL_PRINTERPREFIX,
65 RC_PRINTPAPERDIMENSIONFLAG,
66 RC_CUSTOM_EXPORT_COMMAND,
67 RC_CUSTOM_EXPORT_FORMAT,
70 RC_LITERATE_EXTENSION,
71 RC_LITERATE_ERROR_FILTER,
73 RC_BUILD_ERROR_FILTER,
79 RC_SCREEN_FONT_TYPEWRITER,
82 RC_SCREEN_FONT_ENCODING,
84 RC_SGML_EXTRA_OPTIONS,
93 RC_NOMENUACCELERATORS,
105 RC_ASCIIROFF_COMMAND,
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,
142 static keyword_item lyxrcTags[] = {
143 { "\\accept_compound", RC_ACCEPT_COMPOUND },
144 { "\\alternate_language", RC_ALT_LANG },
145 { "\\ascii_linelen", RC_ASCII_LINELEN },
146 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
147 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
148 { "\\autosave", RC_AUTOSAVE },
149 { "\\background_color", RC_BACKGROUND_COLOR },
150 { "\\begin_toolbar", RC_BEGINTOOLBAR },
151 { "\\bind", RC_BIND },
152 { "\\bind_file", RC_BINDFILE },
153 { "\\build_command", RC_BUILD_COMMAND },
154 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
155 { "\\check_lastfiles", RC_CHECKLASTFILES },
156 { "\\chktex_command", RC_CHKTEX_COMMAND },
157 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
158 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
159 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
160 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
161 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
162 { "\\document_path", RC_DOCUMENTPATH },
163 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
164 { "\\escape_chars", RC_ESC_CHARS },
165 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
166 { "\\fast_selection", RC_FAST_SELECTION },
167 { "\\fax_command", RC_FAX_COMMAND },
168 { "\\fax_program", RC_FAXPROGRAM },
169 { "\\font_encoding", RC_FONT_ENCODING },
170 { "\\html_command", RC_HTML_COMMAND },
171 { "\\input", RC_INPUT },
172 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
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 { "\\spell_command", RC_SPELL_COMMAND },
223 { "\\tempdir_path", RC_TEMPDIRPATH },
224 { "\\template_path", RC_TEMPLATEPATH },
225 { "\\use_alt_language", RC_USE_ALT_LANG },
226 { "\\use_escape_chars", RC_USE_ESC_CHARS },
227 { "\\use_input_encoding", RC_USE_INP_ENC },
228 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
229 { "\\use_tempdir", RC_USETEMPDIR },
230 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
231 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
232 { "\\view_ps_command", RC_VIEWPS_COMMAND },
233 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
236 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
237 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
239 // Should this be moved inside LyXAction?
241 int bindKey(char const * seq, int action)
243 return toplevel_keymap->bind(seq, action);
249 // Get printer from the environment. If fail, use default "",
250 // assuming that everything is set up correctly.
251 printer = GetEnv("PRINTER");
252 print_adapt_output = false;
253 print_command = "dvips";
254 print_evenpage_flag = "-B";
255 print_oddpage_flag = "-A";
256 print_pagerange_flag = "-pp";
257 print_copies_flag = "-c";
258 print_collcopies_flag = "-C";
259 print_reverse_flag = "-r";
260 print_landscape_flag = "-t landscape";
261 print_to_printer = "-P";
262 print_to_file = "-o ";
263 print_file_extension = ".ps";
264 print_paper_flag = "-t";
265 print_paper_dimension_flag = "-T";
266 document_path = GetEnvPath("HOME");
267 tempdir_path = "/tmp";
270 latex_command = "latex";
271 pdflatex_command = "pdflatex";
272 pdf_to_ps_command = "pdf2ps";
273 dvi_to_ps_command = "dvips";
274 literate_command = "none";
275 literate_extension = "none";
276 literate_error_filter = "cat";
277 build_command = "make";
278 build_error_filter = "cat";
279 relyx_command = "reLyX";
281 view_ps_command = "ghostview -swap";
282 view_pspic_command = "ghostview";
283 view_dvi_command = "xdvi";
284 view_pdf_command = "xpdf";
285 default_papersize = BufferParams::PAPER_USLETTER;
286 custom_export_format = "ps";
287 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
288 html_command = "tth -t";
291 // Because a screen typically is wider than a piece of paper:
293 // Default LaTeX font size:
294 font_sizes[LyXFont::SIZE_TINY] = 5.0;
295 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
296 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
297 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
298 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
299 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
300 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
301 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
302 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
303 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
304 use_scalable_fonts = true;
305 roman_font_name = "-*-times";
306 sans_font_name = "-*-helvetica";
307 typewriter_font_name = "-*-courier";
308 menu_font_name = "-*-helvetica-bold-r";
309 popup_font_name = "-*-helvetica-medium-r";
310 font_norm = "iso8859-1";
312 auto_region_delete = true;
315 check_lastfiles = true;
317 exit_confirmation = true;
318 display_shortcuts = true;
319 // Spellchecker settings:
320 isp_command = "ispell";
321 isp_accept_compound = false;
322 isp_use_input_encoding = false;
323 isp_use_alt_lang = false;
324 isp_use_pers_dict = false;
325 isp_use_esc_chars = false;
329 defaultKeyBindings();
331 date_insert_format = "%A, %e. %B %Y";
335 int LyXRC::ReadBindFile(string const & name)
338 string tmp = i18nLibFileSearch("bind", name, "bind");
339 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
340 int result = read(tmp);
342 lyxerr << "Error reading bind file: " << tmp << endl;
348 int LyXRC::read(string const & filename)
351 string bindFile = "cua";
353 LyXLex lexrc(lyxrcTags, lyxrcCount);
354 if (lyxerr.debugging(Debug::PARSER))
357 lexrc.setFile(filename);
358 if (!lexrc.IsOK()) return -2;
360 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
362 while (lexrc.IsOK()) {
363 // By using two switches we take advantage of the compiler
364 // telling us if we have missed a LyXRCTags element in
365 // the second switch.
366 // Note that this also shows a problem with LyXLex since it
367 // helps us avoid taking advantage of the strictness of the
370 int le = lexrc.lex();
372 case LyXLex::LEX_UNDEF:
373 lexrc.printError("Unknown tag `$$Token'");
375 case LyXLex::LEX_FEOF:
379 switch (static_cast<LyXRCTags>(le)) {
380 case RC_INPUT: // Include file
382 string tmp = LibFileSearch(string(),
385 lexrc.printError("Error reading "
386 "included file: "+tmp);
390 case RC_BINDFILE: // RVDK_PATCH_5
392 ReadBindFile(lexrc.GetString());
396 case RC_BEGINTOOLBAR:
397 // this toolbar should be changed to be a completely
398 // non gui toolbar. (Lgb)
404 use_kbmap = lexrc.GetBool();
407 case RC_EXIT_CONFIRMATION:
409 exit_confirmation = lexrc.GetBool();
412 case RC_DISPLAY_SHORTCUTS:
414 display_shortcuts = lexrc.GetBool();
417 case RC_KBMAP_PRIMARY:
419 primary_kbmap = lexrc.GetString();
422 case RC_KBMAP_SECONDARY:
424 secondary_kbmap = lexrc.GetString();
427 case RC_FONT_ENCODING:
429 fontenc = lexrc.GetString();
434 printer = lexrc.GetString();
437 case RC_PRINT_COMMAND:
439 print_command = lexrc.GetString();
442 case RC_PRINTEVENPAGEFLAG:
444 print_evenpage_flag = lexrc.GetString();
447 case RC_PRINTODDPAGEFLAG:
449 print_oddpage_flag = lexrc.GetString();
452 case RC_PRINTPAGERANGEFLAG:
454 print_pagerange_flag = lexrc.GetString();
457 case RC_PRINTCOPIESFLAG:
459 print_copies_flag = lexrc.GetString();
462 case RC_PRINTCOLLCOPIESFLAG:
464 print_collcopies_flag = lexrc.GetString();
467 case RC_PRINTREVERSEFLAG:
469 print_reverse_flag = lexrc.GetString();
472 case RC_PRINTLANDSCAPEFLAG:
474 print_landscape_flag = lexrc.GetString();
477 case RC_PRINTTOPRINTER:
479 print_to_printer = lexrc.GetString();
482 case RC_PRINT_ADAPTOUTPUT:
484 print_adapt_output = lexrc.GetBool();
489 print_to_file = lexrc.GetString();
492 case RC_PRINTFILEEXTENSION:
494 print_file_extension = lexrc.GetString();
497 case RC_PRINTEXSTRAOPTIONS:
499 print_extra_options = lexrc.GetString();
502 case RC_PRINTSPOOL_COMMAND:
504 print_spool_command = lexrc.GetString();
507 case RC_PRINTSPOOL_PRINTERPREFIX:
509 print_spool_printerprefix = lexrc.GetString();
512 case RC_PRINTPAPERDIMENSIONFLAG:
514 print_paper_dimension_flag = lexrc.GetString();
517 case RC_PRINTPAPERFLAG:
519 print_paper_flag = lexrc.GetString();
522 case RC_CUSTOM_EXPORT_COMMAND:
524 custom_export_command = lexrc.GetString();
527 case RC_CUSTOM_EXPORT_FORMAT:
529 custom_export_format = lexrc.GetString();
534 pdf_mode = lexrc.GetBool();
537 case RC_LATEX_COMMAND:
539 latex_command = lexrc.GetString();
542 case RC_PDFLATEX_COMMAND:
544 pdflatex_command = lexrc.GetString();
547 case RC_PDF_TO_PS_COMMAND:
549 pdf_to_ps_command = lexrc.GetString();
552 case RC_DVI_TO_PS_COMMAND:
554 dvi_to_ps_command = lexrc.GetString();
557 case RC_LITERATE_COMMAND:
559 literate_command = lexrc.GetString();
562 case RC_LITERATE_EXTENSION:
564 literate_extension = lexrc.GetString();
567 case RC_LITERATE_ERROR_FILTER:
569 literate_error_filter = lexrc.GetString();
572 case RC_BUILD_COMMAND:
574 build_command = lexrc.GetString();
577 case RC_BUILD_ERROR_FILTER:
579 build_error_filter = lexrc.GetString();
582 case RC_RELYX_COMMAND:
584 relyx_command = lexrc.GetString();
587 case RC_DEFAULT_PAPERSIZE:
589 string size = lowercase(lexrc.GetString());
590 if (size == "usletter")
592 BufferParams::PAPER_USLETTER;
593 else if (size == "legal")
595 BufferParams::PAPER_LEGALPAPER;
596 else if (size == "executive")
598 BufferParams::PAPER_EXECUTIVEPAPER;
599 else if (size == "a3")
601 BufferParams::PAPER_A3PAPER;
602 else if (size == "a4")
604 BufferParams::PAPER_A4PAPER;
605 else if (size == "a5")
607 BufferParams::PAPER_A5PAPER;
608 else if (size == "b5")
610 BufferParams::PAPER_B5PAPER;
613 case RC_VIEWDVI_COMMAND:
615 view_dvi_command = lexrc.GetString();
618 case RC_VIEWPDF_COMMAND:
620 view_pdf_command = lexrc.GetString();
625 ps_command = lexrc.GetString();
628 case RC_VIEWPS_COMMAND:
630 view_ps_command = lexrc.GetString();
633 case RC_VIEWPSPIC_COMMAND:
635 view_pspic_command = lexrc.GetString();
638 case RC_CHKTEX_COMMAND:
640 chktex_command = lexrc.GetString();
643 case RC_HTML_COMMAND:
645 html_command = lexrc.GetString();
650 dpi = lexrc.GetInteger();
655 zoom = lexrc.GetInteger();
658 case RC_SCREEN_FONT_SIZES:
660 font_sizes[LyXFont::SIZE_TINY] =
663 font_sizes[LyXFont::SIZE_SCRIPT] =
666 font_sizes[LyXFont::SIZE_FOOTNOTE] =
669 font_sizes[LyXFont::SIZE_SMALL] =
672 font_sizes[LyXFont::SIZE_NORMAL] =
675 font_sizes[LyXFont::SIZE_LARGE] =
678 font_sizes[LyXFont::SIZE_LARGER] =
681 font_sizes[LyXFont::SIZE_LARGEST] =
684 font_sizes[LyXFont::SIZE_HUGE] =
687 font_sizes[LyXFont::SIZE_HUGER] =
691 case RC_SCREEN_FONT_SCALABLE:
693 use_scalable_fonts = lexrc.GetBool();
698 autosave = lexrc.GetInteger();
701 case RC_SGML_EXTRA_OPTIONS:
703 sgml_extra_options = lexrc.GetString();
706 case RC_DOCUMENTPATH:
708 document_path = ExpandPath(lexrc.GetString());
712 case RC_TEMPLATEPATH:
714 template_path = ExpandPath(lexrc.GetString());
719 tempdir_path = ExpandPath(lexrc.GetString());
724 use_tempdir = lexrc.GetBool();
729 lastfiles = ExpandPath(lexrc.GetString());
732 case RC_NUMLASTFILES:
734 num_lastfiles = lexrc.GetInteger();
737 case RC_CHECKLASTFILES:
739 check_lastfiles = lexrc.GetBool();
742 case RC_SCREEN_FONT_ROMAN:
744 roman_font_name = lexrc.GetString();
747 case RC_SCREEN_FONT_SANS:
749 sans_font_name = lexrc.GetString();
752 case RC_SCREEN_FONT_TYPEWRITER:
754 typewriter_font_name = lexrc.GetString();
757 case RC_SCREEN_FONT_MENU:
759 menu_font_name = lexrc.GetString();
762 case RC_SCREEN_FONT_POPUP:
764 popup_font_name = lexrc.GetString();
767 case RC_SCREEN_FONT_ENCODING:
769 font_norm = lexrc.GetString();
772 case RC_AUTOREGIONDELETE:
773 // Auto region delete defaults to true
775 auto_region_delete = lexrc.GetBool();
780 // we should not do an explicit binding before
781 // loading a bind file. So, in this case, load
782 // the default bind file.
786 // !!!chb, dynamic key binding...
790 if (lexrc.lex() == LyXLex::LEX_DATA) {
791 seq = lexrc.GetString();
793 lexrc.printError("Bad key sequence: `$$Token'");
797 if (lexrc.lex() == LyXLex::LEX_DATA) {
798 cmd = lexrc.GetString();
800 lexrc.printError("Bad command: `$$Token'");
804 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
805 if (lyxerr.debugging(Debug::KEY)) {
806 lyxerr << "RC_BIND: Sequence `"
807 << seq << "' Command `"
808 << cmd << "' Action `"
809 << action << '\'' << endl;
811 res = bindKey(seq.c_str(), action);
814 "Invalid key sequence `"
817 } else {// cmd is the last token read.
819 "Unknown LyX function `$$Token'");
825 lyxpipes = ExpandPath(lexrc.GetString());
828 case RC_CURSOR_FOLLOWS_SCROLLBAR:
830 cursor_follows_scrollbar = lexrc.GetBool();
833 case RC_FAST_SELECTION:
835 fast_selection = lexrc.GetBool();
838 case RC_BACKGROUND_COLOR:
840 background_color = lexrc.GetString();
842 case RC_SELECTION_COLOR:
844 strncpy(selection_color,
845 lexrc.GetString().c_str(), 31);
849 fax_command = lexrc.GetString();
853 fax_program = lexrc.GetString();
857 string s = lexrc.GetString();
861 phone_book = user_lyxdir + s;
864 case RC_ASCIIROFF_COMMAND:
866 ascii_roff_command = lexrc.GetString();
868 case RC_ASCII_LINELEN:
870 ascii_linelen = lexrc.GetInteger();
872 // Spellchecker settings:
873 case RC_SPELL_COMMAND:
875 isp_command = lexrc.GetString();
877 case RC_ACCEPT_COMPOUND:
879 isp_accept_compound = lexrc.GetBool();
883 isp_use_input_encoding = lexrc.GetBool();
885 case RC_USE_ALT_LANG:
887 isp_use_alt_lang = lexrc.GetBool();
889 case RC_USE_PERS_DICT:
891 isp_use_pers_dict = lexrc.GetBool();
893 case RC_USE_ESC_CHARS:
895 isp_use_esc_chars = lexrc.GetBool();
899 isp_alt_lang = lexrc.GetString();
903 isp_pers_dict = lexrc.GetString();
907 isp_esc_chars = lexrc.GetString();
911 make_backup = lexrc.GetBool();
913 case RC_DATE_INSERT_FORMAT:
915 date_insert_format = lexrc.GetString();
919 rtl_support = lexrc.GetBool();
921 case RC_LAST: break; // this is just a dummy
929 void LyXRC::write(string const & filename) const
931 ofstream ofs(filename.c_str());
937 void LyXRC::print() const
939 if (lyxerr.debugging())
946 void LyXRC::output(ostream & os) const
948 os << "### This file is part of\n"
949 << "### ========================================================\n"
950 << "### LyX, The Document Processor\n"
952 << "### Copyright 1995 Matthias Ettrich\n"
953 << "### Copyright 1995-1998 The LyX Team.\n"
955 << "### ========================================================\n"
957 << "# This file is written by LyX, if you want to make your own\n"
958 << "# modifications you should do them from inside LyX and save\n"
959 << "# your preferences, or you can also make your modifications\n"
960 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
963 // Why the switch you might ask. It is a trick to ensure that all
964 // the elements in the LyXRCTags enum is handled. As you can see
965 // there are no breaks at all. So it is just a huge fall-through.
966 // The nice thing is that we will get a warning from the compiler
967 // if we forget an element.
968 LyXRCTags tag = RC_LAST;
972 // input/include files are not done here
974 // bindings is not written to the preferences file.
976 // bind files are not done here.
977 case RC_BEGINTOOLBAR:
978 // Toolbar is not written here (yet).
979 case RC_FONT_ENCODING:
980 os << "\\font_encoding \"" << fontenc << "\"\n";
982 os << "\\printer \"" << printer << "\"\n";
983 case RC_PRINT_COMMAND:
984 os << "\\print_command \"" << print_command << "\"\n";
985 case RC_PRINTEVENPAGEFLAG:
986 os << "\\print_evenpage_flag \"" << print_evenpage_flag
988 case RC_PRINTODDPAGEFLAG:
989 os << "\\print_oddpage_flag \"" << print_oddpage_flag
991 case RC_PRINTPAGERANGEFLAG:
992 os << "\\print_pagerange_flag \"" << print_pagerange_flag
994 case RC_PRINTCOPIESFLAG:
995 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
996 case RC_PRINTCOLLCOPIESFLAG:
997 os << "\\print_collcopies_flag \"" << print_collcopies_flag
999 case RC_PRINTREVERSEFLAG:
1000 os << "\\print_reverse_flag \"" << print_reverse_flag
1002 case RC_PRINTLANDSCAPEFLAG:
1003 os << "\\print_landscape_flag \"" << print_landscape_flag
1005 case RC_PRINTTOPRINTER:
1006 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1007 case RC_PRINT_ADAPTOUTPUT:
1008 os << "\\print_adapt_output " << tostr(print_adapt_output)
1010 case RC_PRINTTOFILE:
1011 os << "\\print_to_file \"" << print_to_file << "\"\n";
1012 case RC_PRINTFILEEXTENSION:
1013 os << "\\print_file_extension \"" << print_file_extension
1015 case RC_PRINTEXSTRAOPTIONS:
1016 os << "\\print_extra_options \"" << print_extra_options
1018 case RC_PRINTSPOOL_COMMAND:
1019 os << "\\print_spool_command \"" << print_spool_command
1021 case RC_PRINTSPOOL_PRINTERPREFIX:
1022 os << "\\print_spool_printerprefix \""
1023 << print_spool_printerprefix << "\"\n";
1024 case RC_PRINTPAPERDIMENSIONFLAG:
1025 os << "\\print_paper_dimension_flag \""
1026 << print_paper_dimension_flag << "\"\n";
1027 case RC_PRINTPAPERFLAG:
1028 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1029 case RC_CUSTOM_EXPORT_COMMAND:
1030 os << "\\custom_export_command \"" << custom_export_command
1032 case RC_CUSTOM_EXPORT_FORMAT:
1033 os << "\\custom_export_format \"" << custom_export_format
1036 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1037 case RC_LATEX_COMMAND:
1038 os << "\\latex_command \"" << latex_command << "\"\n";
1039 case RC_PDFLATEX_COMMAND:
1040 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1041 case RC_PDF_TO_PS_COMMAND:
1042 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1043 case RC_DVI_TO_PS_COMMAND:
1044 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1045 case RC_LITERATE_COMMAND:
1046 os << "\\literate_command \"" << literate_command << "\"\n";
1047 case RC_LITERATE_EXTENSION:
1048 os << "\\literate_extension \"" << literate_extension
1050 case RC_LITERATE_ERROR_FILTER:
1051 os << "\\literate_error_filter \"" << literate_error_filter
1053 case RC_BUILD_COMMAND:
1054 os << "\\build_command \"" << build_command << "\"\n";
1055 case RC_BUILD_ERROR_FILTER:
1056 os << "\\build_error_filter \"" << build_error_filter
1059 os << "\\screen_dpi " << dpi << "\n";
1060 case RC_SCREEN_ZOOM:
1061 os << "\\screen_zoom " << zoom << "\n";
1062 case RC_SCREEN_FONT_SIZES:
1063 os.setf(ios::fixed);
1065 os << "\\screen_font_sizes";
1066 os << " " << font_sizes[LyXFont::SIZE_TINY];
1067 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1068 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1069 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1070 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1071 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1072 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1073 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1074 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1075 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1077 case RC_AUTOREGIONDELETE:
1078 os << "\\auto_region_delete " << tostr(auto_region_delete)
1081 os << "\\autosave " << autosave << "\n";
1082 case RC_EXIT_CONFIRMATION:
1083 os << "\\exit_confirmation " << tostr(exit_confirmation)
1085 case RC_DISPLAY_SHORTCUTS:
1086 os << "\\display_shortcuts " << tostr(display_shortcuts)
1088 case RC_VIEWDVI_COMMAND:
1089 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1090 case RC_VIEWPDF_COMMAND:
1091 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1092 case RC_DEFAULT_PAPERSIZE:
1093 os << "\\default_papersize \"";
1094 switch (default_papersize) {
1095 case BufferParams::PAPER_USLETTER:
1096 os << "usletter"; break;
1097 case BufferParams::PAPER_LEGALPAPER:
1098 os << "legal"; break;
1099 case BufferParams::PAPER_EXECUTIVEPAPER:
1100 os << "executive"; break;
1101 case BufferParams::PAPER_A3PAPER:
1103 case BufferParams::PAPER_A4PAPER:
1105 case BufferParams::PAPER_A5PAPER:
1107 case BufferParams::PAPER_B5PAPER:
1109 case BufferParams::PAPER_DEFAULT: break;
1112 case RC_VIEWPS_COMMAND:
1113 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1114 case RC_VIEWPSPIC_COMMAND:
1115 os << "\\view_pspic_command \"" << view_pspic_command
1118 os << "\\ps_command \"" << ps_command << "\"\n";
1119 case RC_CHKTEX_COMMAND:
1120 os << "\\chktex_command \"" << chktex_command << "\"\n";
1121 case RC_HTML_COMMAND:
1122 os << "\\html_command \"" << html_command << "\"\n";
1123 case RC_SGML_EXTRA_OPTIONS:
1124 os << "\\sgml_extra_options \"" << sgml_extra_options
1127 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1128 case RC_KBMAP_PRIMARY:
1129 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1130 case RC_KBMAP_SECONDARY:
1131 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1133 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1134 case RC_RELYX_COMMAND:
1135 os << "\\relyx_command \"" << relyx_command << "\"\n";
1136 case RC_DOCUMENTPATH:
1137 os << "\\document_path \"" << document_path << "\"\n";
1138 case RC_TEMPLATEPATH:
1139 os << "\\template_path \"" << template_path << "\"\n";
1140 case RC_TEMPDIRPATH:
1141 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1143 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1145 os << "\\lastfiles \"" << lastfiles << "\"\n";
1146 case RC_NUMLASTFILES:
1147 os << "\\num_lastfiles " << num_lastfiles << "\n";
1148 case RC_CHECKLASTFILES:
1149 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1150 case RC_SCREEN_FONT_ROMAN:
1151 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1152 case RC_SCREEN_FONT_SANS:
1153 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1154 case RC_SCREEN_FONT_TYPEWRITER:
1155 os << "\\screen_font_typewriter \""
1156 << typewriter_font_name << "\"\n";
1157 case RC_SCREEN_FONT_MENU:
1158 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1159 case RC_SCREEN_FONT_POPUP:
1160 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1161 case RC_SCREEN_FONT_ENCODING:
1162 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1163 case RC_SCREEN_FONT_SCALABLE:
1164 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1166 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1167 os << "\\cursor_follows_scrollbar "
1168 << tostr(cursor_follows_scrollbar) << "\n";
1169 case RC_FAST_SELECTION:
1170 os << "\\fast_selection "
1171 << tostr(static_cast<bool>(fast_selection)) << "\n";
1172 case RC_BACKGROUND_COLOR:
1173 os << "\\background_color \"" << background_color << "\"\n";
1174 case RC_SELECTION_COLOR:
1175 os << "\\selection_color \"" << selection_color << "\"\n";
1176 case RC_FAX_COMMAND:
1177 os << "\\fax_command \"" << fax_command << "\"\n";
1179 os << "\\fax_program \"" << fax_program << "\"\n";
1181 os << "\\phone_book \"" << phone_book << "\"\n";
1182 case RC_ASCIIROFF_COMMAND:
1183 os << "\\ascii_roff_command \"" << ascii_roff_command
1185 case RC_ASCII_LINELEN:
1186 os << "\\ascii_linelen " << ascii_linelen << "\n";
1187 case RC_SPELL_COMMAND:
1188 os << "\\spell_command \"" << isp_command << "\"\n";
1189 case RC_ACCEPT_COMPOUND:
1190 os << "\\accept_compound " << tostr(isp_accept_compound)
1192 case RC_USE_INP_ENC:
1193 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1195 case RC_USE_ALT_LANG:
1196 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1197 case RC_USE_PERS_DICT:
1198 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1200 case RC_USE_ESC_CHARS:
1201 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1204 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1206 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1208 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1209 case RC_RTL_SUPPORT:
1210 os << "\\rtl " << tostr(rtl_support) << "\n";
1211 case RC_MAKE_BACKUP:
1212 os << "\\make_backup " << tostr(make_backup) << "\n";
1213 case RC_DATE_INSERT_FORMAT:
1214 os << "\\date_insert_format \"" << date_insert_format
1221 /// define the default key bindings for LyX.
1222 void LyXRC::defaultKeyBindings()
1224 bindKey("Right", LFUN_RIGHT);
1225 bindKey("Left", LFUN_LEFT);
1226 bindKey("Up", LFUN_UP);
1227 bindKey("Down", LFUN_DOWN);
1229 bindKey("Tab", LFUN_TAB);
1231 bindKey("Home", LFUN_HOME);
1232 bindKey("End", LFUN_END);
1233 bindKey("Prior", LFUN_PRIOR);
1234 bindKey("Next", LFUN_NEXT);
1236 bindKey("Return", LFUN_BREAKPARAGRAPH);
1237 bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
1239 bindKey("Delete", LFUN_DELETE);
1240 bindKey("BackSpace", LFUN_BACKSPACE);
1241 // bindKeyings for transparent handling of deadkeys
1242 // The keysyms are gotten from XFree86 X11R6
1243 bindKey("~C-~S-~M-dead_acute", LFUN_ACUTE);
1244 bindKey("~C-~S-~M-dead_breve", LFUN_BREVE);
1245 bindKey("~C-~S-~M-dead_caron", LFUN_CARON);
1246 bindKey("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
1247 bindKey("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
1248 bindKey("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
1249 bindKey("~C-~S-~M-dead_abovedot", LFUN_DOT);
1250 bindKey("~C-~S-~M-dead_grave", LFUN_GRAVE);
1251 bindKey("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
1252 bindKey("~C-~S-~M-dead_macron", LFUN_MACRON);
1253 // nothing with this name
1254 // bindKey("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
1255 bindKey("~C-~S-~M-dead_tilde", LFUN_TILDE);
1256 bindKey("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
1257 // nothing with this name either...
1258 //bindKey("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
1259 bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
1260 bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
1261 bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
1263 // bindings to utilize the use of the numeric keypad
1264 // e.g. Num Lock set
1265 bindKey("KP_0", LFUN_SELFINSERT);
1266 bindKey("KP_Decimal", LFUN_SELFINSERT);
1267 bindKey("KP_Enter", LFUN_SELFINSERT);
1268 bindKey("KP_1", LFUN_SELFINSERT);
1269 bindKey("KP_2", LFUN_SELFINSERT);
1270 bindKey("KP_3", LFUN_SELFINSERT);
1271 bindKey("KP_4", LFUN_SELFINSERT);
1272 bindKey("KP_5", LFUN_SELFINSERT);
1273 bindKey("KP_6", LFUN_SELFINSERT);
1274 bindKey("KP_Add", LFUN_SELFINSERT);
1275 bindKey("KP_7", LFUN_SELFINSERT);
1276 bindKey("KP_8", LFUN_SELFINSERT);
1277 bindKey("KP_9", LFUN_SELFINSERT);
1278 bindKey("KP_Divide", LFUN_SELFINSERT);
1279 bindKey("KP_Multiply", LFUN_SELFINSERT);
1280 bindKey("KP_Subtract", LFUN_SELFINSERT);
1282 /* Most self-insert keys are handled in the 'default:' section of
1283 * WorkAreaKeyPress - so we don't have to define them all.
1284 * However keys explicit decleared as self-insert are
1285 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1287 bindKey("C-Tab", LFUN_TABINSERT); // ale970515