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,
94 RC_NOMENUACCELERATORS,
105 RC_ASCIIROFF_COMMAND,
110 RC_VIEWDVI_PAPEROPTION,
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 { "\\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 { "\\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_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
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_dvi_paper_option = "-paper";
286 view_pdf_command = "xpdf";
287 default_papersize = BufferParams::PAPER_USLETTER;
288 custom_export_format = "ps";
289 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
290 html_command = "tth -t";
293 // Because a screen typically is wider than a piece of paper:
295 // Default LaTeX font size:
296 font_sizes[LyXFont::SIZE_TINY] = 5.0;
297 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
298 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
299 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
300 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
301 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
302 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
303 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
304 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
305 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
306 use_scalable_fonts = true;
307 roman_font_name = "-*-times";
308 sans_font_name = "-*-helvetica";
309 typewriter_font_name = "-*-courier";
310 menu_font_name = "-*-helvetica-bold-r";
311 popup_font_name = "-*-helvetica-medium-r";
312 font_norm = "iso8859-1";
314 auto_region_delete = true;
317 check_lastfiles = true;
319 exit_confirmation = true;
320 display_shortcuts = true;
321 // Spellchecker settings:
322 isp_command = "ispell";
323 isp_accept_compound = false;
324 isp_use_input_encoding = false;
325 isp_use_alt_lang = false;
326 isp_use_pers_dict = false;
327 isp_use_esc_chars = false;
331 defaultKeyBindings();
333 date_insert_format = "%A, %e %B %Y";
337 int LyXRC::ReadBindFile(string const & name)
340 string tmp = i18nLibFileSearch("bind", name, "bind");
341 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
342 int result = read(tmp);
344 lyxerr << "Error reading bind file: " << tmp << endl;
350 int LyXRC::read(string const & filename)
353 string bindFile = "cua";
355 LyXLex lexrc(lyxrcTags, lyxrcCount);
356 if (lyxerr.debugging(Debug::PARSER))
359 lexrc.setFile(filename);
360 if (!lexrc.IsOK()) return -2;
362 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
364 while (lexrc.IsOK()) {
365 // By using two switches we take advantage of the compiler
366 // telling us if we have missed a LyXRCTags element in
367 // the second switch.
368 // Note that this also shows a problem with LyXLex since it
369 // helps us avoid taking advantage of the strictness of the
372 int le = lexrc.lex();
374 case LyXLex::LEX_UNDEF:
375 lexrc.printError("Unknown tag `$$Token'");
377 case LyXLex::LEX_FEOF:
381 switch (static_cast<LyXRCTags>(le)) {
382 case RC_INPUT: // Include file
384 string tmp = LibFileSearch(string(),
387 lexrc.printError("Error reading "
388 "included file: "+tmp);
392 case RC_BINDFILE: // RVDK_PATCH_5
394 ReadBindFile(lexrc.GetString());
398 case RC_BEGINTOOLBAR:
399 // this toolbar should be changed to be a completely
400 // non gui toolbar. (Lgb)
406 use_kbmap = lexrc.GetBool();
409 case RC_EXIT_CONFIRMATION:
411 exit_confirmation = lexrc.GetBool();
414 case RC_DISPLAY_SHORTCUTS:
416 display_shortcuts = lexrc.GetBool();
419 case RC_KBMAP_PRIMARY:
421 primary_kbmap = lexrc.GetString();
424 case RC_KBMAP_SECONDARY:
426 secondary_kbmap = lexrc.GetString();
429 case RC_FONT_ENCODING:
431 fontenc = lexrc.GetString();
436 printer = lexrc.GetString();
439 case RC_PRINT_COMMAND:
441 print_command = lexrc.GetString();
444 case RC_PRINTEVENPAGEFLAG:
446 print_evenpage_flag = lexrc.GetString();
449 case RC_PRINTODDPAGEFLAG:
451 print_oddpage_flag = lexrc.GetString();
454 case RC_PRINTPAGERANGEFLAG:
456 print_pagerange_flag = lexrc.GetString();
459 case RC_PRINTCOPIESFLAG:
461 print_copies_flag = lexrc.GetString();
464 case RC_PRINTCOLLCOPIESFLAG:
466 print_collcopies_flag = lexrc.GetString();
469 case RC_PRINTREVERSEFLAG:
471 print_reverse_flag = lexrc.GetString();
474 case RC_PRINTLANDSCAPEFLAG:
476 print_landscape_flag = lexrc.GetString();
479 case RC_PRINTTOPRINTER:
481 print_to_printer = lexrc.GetString();
484 case RC_PRINT_ADAPTOUTPUT:
486 print_adapt_output = lexrc.GetBool();
491 print_to_file = lexrc.GetString();
494 case RC_PRINTFILEEXTENSION:
496 print_file_extension = lexrc.GetString();
499 case RC_PRINTEXSTRAOPTIONS:
501 print_extra_options = lexrc.GetString();
504 case RC_PRINTSPOOL_COMMAND:
506 print_spool_command = lexrc.GetString();
509 case RC_PRINTSPOOL_PRINTERPREFIX:
511 print_spool_printerprefix = lexrc.GetString();
514 case RC_PRINTPAPERDIMENSIONFLAG:
516 print_paper_dimension_flag = lexrc.GetString();
519 case RC_PRINTPAPERFLAG:
521 print_paper_flag = lexrc.GetString();
524 case RC_CUSTOM_EXPORT_COMMAND:
526 custom_export_command = lexrc.GetString();
529 case RC_CUSTOM_EXPORT_FORMAT:
531 custom_export_format = lexrc.GetString();
536 pdf_mode = lexrc.GetBool();
539 case RC_LATEX_COMMAND:
541 latex_command = lexrc.GetString();
544 case RC_PDFLATEX_COMMAND:
546 pdflatex_command = lexrc.GetString();
549 case RC_PDF_TO_PS_COMMAND:
551 pdf_to_ps_command = lexrc.GetString();
554 case RC_DVI_TO_PS_COMMAND:
556 dvi_to_ps_command = lexrc.GetString();
559 case RC_LITERATE_COMMAND:
561 literate_command = lexrc.GetString();
564 case RC_LITERATE_EXTENSION:
566 literate_extension = lexrc.GetString();
569 case RC_LITERATE_ERROR_FILTER:
571 literate_error_filter = lexrc.GetString();
574 case RC_BUILD_COMMAND:
576 build_command = lexrc.GetString();
579 case RC_BUILD_ERROR_FILTER:
581 build_error_filter = lexrc.GetString();
584 case RC_RELYX_COMMAND:
586 relyx_command = lexrc.GetString();
589 case RC_DEFAULT_PAPERSIZE:
591 string size = lowercase(lexrc.GetString());
592 if (size == "usletter")
594 BufferParams::PAPER_USLETTER;
595 else if (size == "legal")
597 BufferParams::PAPER_LEGALPAPER;
598 else if (size == "executive")
600 BufferParams::PAPER_EXECUTIVEPAPER;
601 else if (size == "a3")
603 BufferParams::PAPER_A3PAPER;
604 else if (size == "a4")
606 BufferParams::PAPER_A4PAPER;
607 else if (size == "a5")
609 BufferParams::PAPER_A5PAPER;
610 else if (size == "b5")
612 BufferParams::PAPER_B5PAPER;
615 case RC_VIEWDVI_COMMAND:
617 view_dvi_command = lexrc.GetString();
620 case RC_VIEWDVI_PAPEROPTION:
622 view_dvi_paper_option = lexrc.GetString();
624 view_dvi_paper_option = "";
627 case RC_VIEWPDF_COMMAND:
629 view_pdf_command = lexrc.GetString();
634 ps_command = lexrc.GetString();
637 case RC_VIEWPS_COMMAND:
639 view_ps_command = lexrc.GetString();
642 case RC_VIEWPSPIC_COMMAND:
644 view_pspic_command = lexrc.GetString();
647 case RC_CHKTEX_COMMAND:
649 chktex_command = lexrc.GetString();
652 case RC_HTML_COMMAND:
654 html_command = lexrc.GetString();
659 dpi = lexrc.GetInteger();
664 zoom = lexrc.GetInteger();
667 case RC_SCREEN_FONT_SIZES:
669 font_sizes[LyXFont::SIZE_TINY] =
672 font_sizes[LyXFont::SIZE_SCRIPT] =
675 font_sizes[LyXFont::SIZE_FOOTNOTE] =
678 font_sizes[LyXFont::SIZE_SMALL] =
681 font_sizes[LyXFont::SIZE_NORMAL] =
684 font_sizes[LyXFont::SIZE_LARGE] =
687 font_sizes[LyXFont::SIZE_LARGER] =
690 font_sizes[LyXFont::SIZE_LARGEST] =
693 font_sizes[LyXFont::SIZE_HUGE] =
696 font_sizes[LyXFont::SIZE_HUGER] =
700 case RC_SCREEN_FONT_SCALABLE:
702 use_scalable_fonts = lexrc.GetBool();
707 autosave = lexrc.GetInteger();
710 case RC_SGML_EXTRA_OPTIONS:
712 sgml_extra_options = lexrc.GetString();
715 case RC_DOCUMENTPATH:
717 document_path = ExpandPath(lexrc.GetString());
721 case RC_TEMPLATEPATH:
723 template_path = ExpandPath(lexrc.GetString());
728 tempdir_path = ExpandPath(lexrc.GetString());
733 use_tempdir = lexrc.GetBool();
738 lastfiles = ExpandPath(lexrc.GetString());
741 case RC_NUMLASTFILES:
743 num_lastfiles = lexrc.GetInteger();
746 case RC_CHECKLASTFILES:
748 check_lastfiles = lexrc.GetBool();
751 case RC_SCREEN_FONT_ROMAN:
753 roman_font_name = lexrc.GetString();
756 case RC_SCREEN_FONT_SANS:
758 sans_font_name = lexrc.GetString();
761 case RC_SCREEN_FONT_TYPEWRITER:
763 typewriter_font_name = lexrc.GetString();
766 case RC_SCREEN_FONT_MENU:
768 menu_font_name = lexrc.GetString();
771 case RC_SCREEN_FONT_POPUP:
773 popup_font_name = lexrc.GetString();
776 case RC_SCREEN_FONT_ENCODING:
778 font_norm = lexrc.GetString();
781 case RC_AUTOREGIONDELETE:
782 // Auto region delete defaults to true
784 auto_region_delete = lexrc.GetBool();
789 // we should not do an explicit binding before
790 // loading a bind file. So, in this case, load
791 // the default bind file.
795 // !!!chb, dynamic key binding...
799 if (lexrc.lex() == LyXLex::LEX_DATA) {
800 seq = lexrc.GetString();
802 lexrc.printError("Bad key sequence: `$$Token'");
806 if (lexrc.lex() == LyXLex::LEX_DATA) {
807 cmd = lexrc.GetString();
809 lexrc.printError("Bad command: `$$Token'");
813 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
814 if (lyxerr.debugging(Debug::KEY)) {
815 lyxerr << "RC_BIND: Sequence `"
816 << seq << "' Command `"
817 << cmd << "' Action `"
818 << action << '\'' << endl;
820 res = bindKey(seq.c_str(), action);
823 "Invalid key sequence `"
826 } else {// cmd is the last token read.
828 "Unknown LyX function `$$Token'");
834 lyxpipes = ExpandPath(lexrc.GetString());
837 case RC_CURSOR_FOLLOWS_SCROLLBAR:
839 cursor_follows_scrollbar = lexrc.GetBool();
842 case RC_BACKGROUND_COLOR:
844 background_color = lexrc.GetString();
846 case RC_SELECTION_COLOR:
848 strncpy(selection_color,
849 lexrc.GetString().c_str(), 31);
853 fax_command = lexrc.GetString();
857 fax_program = lexrc.GetString();
861 string s = lexrc.GetString();
865 phone_book = user_lyxdir + s;
868 case RC_ASCIIROFF_COMMAND:
870 ascii_roff_command = lexrc.GetString();
872 case RC_ASCII_LINELEN:
874 ascii_linelen = lexrc.GetInteger();
876 // Spellchecker settings:
877 case RC_SPELL_COMMAND:
879 isp_command = lexrc.GetString();
881 case RC_ACCEPT_COMPOUND:
883 isp_accept_compound = lexrc.GetBool();
887 isp_use_input_encoding = lexrc.GetBool();
889 case RC_USE_ALT_LANG:
891 isp_use_alt_lang = lexrc.GetBool();
893 case RC_USE_PERS_DICT:
895 isp_use_pers_dict = lexrc.GetBool();
897 case RC_USE_ESC_CHARS:
899 isp_use_esc_chars = lexrc.GetBool();
903 isp_alt_lang = lexrc.GetString();
907 isp_pers_dict = lexrc.GetString();
911 isp_esc_chars = lexrc.GetString();
915 make_backup = lexrc.GetBool();
917 case RC_DATE_INSERT_FORMAT:
919 date_insert_format = lexrc.GetString();
923 rtl_support = lexrc.GetBool();
925 case RC_LAST: break; // this is just a dummy
933 void LyXRC::write(string const & filename) const
935 ofstream ofs(filename.c_str());
941 void LyXRC::print() const
943 if (lyxerr.debugging())
950 void LyXRC::output(ostream & os) const
952 os << "### This file is part of\n"
953 << "### ========================================================\n"
954 << "### LyX, The Document Processor\n"
956 << "### Copyright 1995 Matthias Ettrich\n"
957 << "### Copyright 1995-1998 The LyX Team.\n"
959 << "### ========================================================\n"
961 << "# This file is written by LyX, if you want to make your own\n"
962 << "# modifications you should do them from inside LyX and save\n"
963 << "# your preferences, or you can also make your modifications\n"
964 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
967 // Why the switch you might ask. It is a trick to ensure that all
968 // the elements in the LyXRCTags enum is handled. As you can see
969 // there are no breaks at all. So it is just a huge fall-through.
970 // The nice thing is that we will get a warning from the compiler
971 // if we forget an element.
972 LyXRCTags tag = RC_LAST;
976 // input/include files are not done here
978 // bindings is not written to the preferences file.
980 // bind files are not done here.
981 case RC_BEGINTOOLBAR:
982 // Toolbar is not written here (yet).
983 case RC_FONT_ENCODING:
984 os << "\\font_encoding \"" << fontenc << "\"\n";
986 os << "\\printer \"" << printer << "\"\n";
987 case RC_PRINT_COMMAND:
988 os << "\\print_command \"" << print_command << "\"\n";
989 case RC_PRINTEVENPAGEFLAG:
990 os << "\\print_evenpage_flag \"" << print_evenpage_flag
992 case RC_PRINTODDPAGEFLAG:
993 os << "\\print_oddpage_flag \"" << print_oddpage_flag
995 case RC_PRINTPAGERANGEFLAG:
996 os << "\\print_pagerange_flag \"" << print_pagerange_flag
998 case RC_PRINTCOPIESFLAG:
999 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1000 case RC_PRINTCOLLCOPIESFLAG:
1001 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1003 case RC_PRINTREVERSEFLAG:
1004 os << "\\print_reverse_flag \"" << print_reverse_flag
1006 case RC_PRINTLANDSCAPEFLAG:
1007 os << "\\print_landscape_flag \"" << print_landscape_flag
1009 case RC_PRINTTOPRINTER:
1010 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1011 case RC_PRINT_ADAPTOUTPUT:
1012 os << "\\print_adapt_output " << tostr(print_adapt_output)
1014 case RC_PRINTTOFILE:
1015 os << "\\print_to_file \"" << print_to_file << "\"\n";
1016 case RC_PRINTFILEEXTENSION:
1017 os << "\\print_file_extension \"" << print_file_extension
1019 case RC_PRINTEXSTRAOPTIONS:
1020 os << "\\print_extra_options \"" << print_extra_options
1022 case RC_PRINTSPOOL_COMMAND:
1023 os << "\\print_spool_command \"" << print_spool_command
1025 case RC_PRINTSPOOL_PRINTERPREFIX:
1026 os << "\\print_spool_printerprefix \""
1027 << print_spool_printerprefix << "\"\n";
1028 case RC_PRINTPAPERDIMENSIONFLAG:
1029 os << "\\print_paper_dimension_flag \""
1030 << print_paper_dimension_flag << "\"\n";
1031 case RC_PRINTPAPERFLAG:
1032 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1033 case RC_CUSTOM_EXPORT_COMMAND:
1034 os << "\\custom_export_command \"" << custom_export_command
1036 case RC_CUSTOM_EXPORT_FORMAT:
1037 os << "\\custom_export_format \"" << custom_export_format
1040 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1041 case RC_LATEX_COMMAND:
1042 os << "\\latex_command \"" << latex_command << "\"\n";
1043 case RC_PDFLATEX_COMMAND:
1044 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1045 case RC_PDF_TO_PS_COMMAND:
1046 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1047 case RC_DVI_TO_PS_COMMAND:
1048 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1049 case RC_LITERATE_COMMAND:
1050 os << "\\literate_command \"" << literate_command << "\"\n";
1051 case RC_LITERATE_EXTENSION:
1052 os << "\\literate_extension \"" << literate_extension
1054 case RC_LITERATE_ERROR_FILTER:
1055 os << "\\literate_error_filter \"" << literate_error_filter
1057 case RC_BUILD_COMMAND:
1058 os << "\\build_command \"" << build_command << "\"\n";
1059 case RC_BUILD_ERROR_FILTER:
1060 os << "\\build_error_filter \"" << build_error_filter
1063 os << "\\screen_dpi " << dpi << "\n";
1064 case RC_SCREEN_ZOOM:
1065 os << "\\screen_zoom " << zoom << "\n";
1066 case RC_SCREEN_FONT_SIZES:
1067 os.setf(ios::fixed);
1069 os << "\\screen_font_sizes";
1070 os << " " << font_sizes[LyXFont::SIZE_TINY];
1071 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1072 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1073 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1074 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1075 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1076 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1077 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1078 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1079 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1081 case RC_AUTOREGIONDELETE:
1082 os << "\\auto_region_delete " << tostr(auto_region_delete)
1085 os << "\\autosave " << autosave << "\n";
1086 case RC_EXIT_CONFIRMATION:
1087 os << "\\exit_confirmation " << tostr(exit_confirmation)
1089 case RC_DISPLAY_SHORTCUTS:
1090 os << "\\display_shortcuts " << tostr(display_shortcuts)
1092 case RC_VIEWDVI_COMMAND:
1093 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1094 case RC_VIEWDVI_PAPEROPTION:
1095 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1096 case RC_VIEWPDF_COMMAND:
1097 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1098 case RC_DEFAULT_PAPERSIZE:
1099 os << "\\default_papersize \"";
1100 switch (default_papersize) {
1101 case BufferParams::PAPER_USLETTER:
1102 os << "usletter"; break;
1103 case BufferParams::PAPER_LEGALPAPER:
1104 os << "legal"; break;
1105 case BufferParams::PAPER_EXECUTIVEPAPER:
1106 os << "executive"; break;
1107 case BufferParams::PAPER_A3PAPER:
1109 case BufferParams::PAPER_A4PAPER:
1111 case BufferParams::PAPER_A5PAPER:
1113 case BufferParams::PAPER_B5PAPER:
1115 case BufferParams::PAPER_DEFAULT: break;
1118 case RC_VIEWPS_COMMAND:
1119 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1120 case RC_VIEWPSPIC_COMMAND:
1121 os << "\\view_pspic_command \"" << view_pspic_command
1124 os << "\\ps_command \"" << ps_command << "\"\n";
1125 case RC_CHKTEX_COMMAND:
1126 os << "\\chktex_command \"" << chktex_command << "\"\n";
1127 case RC_HTML_COMMAND:
1128 os << "\\html_command \"" << html_command << "\"\n";
1129 case RC_SGML_EXTRA_OPTIONS:
1130 os << "\\sgml_extra_options \"" << sgml_extra_options
1133 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1134 case RC_KBMAP_PRIMARY:
1135 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1136 case RC_KBMAP_SECONDARY:
1137 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1139 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1140 case RC_RELYX_COMMAND:
1141 os << "\\relyx_command \"" << relyx_command << "\"\n";
1142 case RC_DOCUMENTPATH:
1143 os << "\\document_path \"" << document_path << "\"\n";
1144 case RC_TEMPLATEPATH:
1145 os << "\\template_path \"" << template_path << "\"\n";
1146 case RC_TEMPDIRPATH:
1147 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1149 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1151 os << "\\lastfiles \"" << lastfiles << "\"\n";
1152 case RC_NUMLASTFILES:
1153 os << "\\num_lastfiles " << num_lastfiles << "\n";
1154 case RC_CHECKLASTFILES:
1155 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1156 case RC_SCREEN_FONT_ROMAN:
1157 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1158 case RC_SCREEN_FONT_SANS:
1159 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1160 case RC_SCREEN_FONT_TYPEWRITER:
1161 os << "\\screen_font_typewriter \""
1162 << typewriter_font_name << "\"\n";
1163 case RC_SCREEN_FONT_MENU:
1164 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1165 case RC_SCREEN_FONT_POPUP:
1166 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1167 case RC_SCREEN_FONT_ENCODING:
1168 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1169 case RC_SCREEN_FONT_SCALABLE:
1170 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1172 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1173 os << "\\cursor_follows_scrollbar "
1174 << tostr(cursor_follows_scrollbar) << "\n";
1175 case RC_BACKGROUND_COLOR:
1176 os << "\\background_color \"" << background_color << "\"\n";
1177 case RC_SELECTION_COLOR:
1178 os << "\\selection_color \"" << selection_color << "\"\n";
1179 case RC_FAX_COMMAND:
1180 os << "\\fax_command \"" << fax_command << "\"\n";
1182 os << "\\fax_program \"" << fax_program << "\"\n";
1184 os << "\\phone_book \"" << phone_book << "\"\n";
1185 case RC_ASCIIROFF_COMMAND:
1186 os << "\\ascii_roff_command \"" << ascii_roff_command
1188 case RC_ASCII_LINELEN:
1189 os << "\\ascii_linelen " << ascii_linelen << "\n";
1190 case RC_SPELL_COMMAND:
1191 os << "\\spell_command \"" << isp_command << "\"\n";
1192 case RC_ACCEPT_COMPOUND:
1193 os << "\\accept_compound " << tostr(isp_accept_compound)
1195 case RC_USE_INP_ENC:
1196 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1198 case RC_USE_ALT_LANG:
1199 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1200 case RC_USE_PERS_DICT:
1201 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1203 case RC_USE_ESC_CHARS:
1204 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1207 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1209 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1211 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1212 case RC_RTL_SUPPORT:
1213 os << "\\rtl " << tostr(rtl_support) << "\n";
1214 case RC_MAKE_BACKUP:
1215 os << "\\make_backup " << tostr(make_backup) << "\n";
1216 case RC_DATE_INSERT_FORMAT:
1217 os << "\\date_insert_format \"" << date_insert_format
1224 /// define the default key bindings for LyX.
1225 void LyXRC::defaultKeyBindings()
1227 bindKey("Right", LFUN_RIGHT);
1228 bindKey("Left", LFUN_LEFT);
1229 bindKey("Up", LFUN_UP);
1230 bindKey("Down", LFUN_DOWN);
1232 bindKey("Tab", LFUN_TAB);
1234 bindKey("Home", LFUN_HOME);
1235 bindKey("End", LFUN_END);
1236 bindKey("Prior", LFUN_PRIOR);
1237 bindKey("Next", LFUN_NEXT);
1239 bindKey("Return", LFUN_BREAKPARAGRAPH);
1240 bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
1242 bindKey("Delete", LFUN_DELETE);
1243 bindKey("BackSpace", LFUN_BACKSPACE);
1244 // bindKeyings for transparent handling of deadkeys
1245 // The keysyms are gotten from XFree86 X11R6
1246 bindKey("~C-~S-~M-dead_acute", LFUN_ACUTE);
1247 bindKey("~C-~S-~M-dead_breve", LFUN_BREVE);
1248 bindKey("~C-~S-~M-dead_caron", LFUN_CARON);
1249 bindKey("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
1250 bindKey("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
1251 bindKey("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
1252 bindKey("~C-~S-~M-dead_abovedot", LFUN_DOT);
1253 bindKey("~C-~S-~M-dead_grave", LFUN_GRAVE);
1254 bindKey("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
1255 bindKey("~C-~S-~M-dead_macron", LFUN_MACRON);
1256 // nothing with this name
1257 // bindKey("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
1258 bindKey("~C-~S-~M-dead_tilde", LFUN_TILDE);
1259 bindKey("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
1260 // nothing with this name either...
1261 //bindKey("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
1262 bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
1263 bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
1264 bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
1266 // bindings to utilize the use of the numeric keypad
1267 // e.g. Num Lock set
1268 bindKey("KP_0", LFUN_SELFINSERT);
1269 bindKey("KP_Decimal", LFUN_SELFINSERT);
1270 bindKey("KP_Enter", LFUN_SELFINSERT);
1271 bindKey("KP_1", LFUN_SELFINSERT);
1272 bindKey("KP_2", LFUN_SELFINSERT);
1273 bindKey("KP_3", LFUN_SELFINSERT);
1274 bindKey("KP_4", LFUN_SELFINSERT);
1275 bindKey("KP_5", LFUN_SELFINSERT);
1276 bindKey("KP_6", LFUN_SELFINSERT);
1277 bindKey("KP_Add", LFUN_SELFINSERT);
1278 bindKey("KP_7", LFUN_SELFINSERT);
1279 bindKey("KP_8", LFUN_SELFINSERT);
1280 bindKey("KP_9", LFUN_SELFINSERT);
1281 bindKey("KP_Divide", LFUN_SELFINSERT);
1282 bindKey("KP_Multiply", LFUN_SELFINSERT);
1283 bindKey("KP_Subtract", LFUN_SELFINSERT);
1285 /* Most self-insert keys are handled in the 'default:' section of
1286 * WorkAreaKeyPress - so we don't have to define them all.
1287 * However keys explicit decleared as self-insert are
1288 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1290 bindKey("C-Tab", LFUN_TABINSERT); // ale970515