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_VIEWDVI_PAPEROPTION,
117 RC_DEFAULT_PAPERSIZE,
120 RC_VIEWPSPIC_COMMAND,
127 RC_SCREEN_FONT_SCALABLE,
132 RC_CURSOR_FOLLOWS_SCROLLBAR,
133 RC_EXIT_CONFIRMATION,
134 RC_DISPLAY_SHORTCUTS,
142 RC_PDF_TO_PS_COMMAND,
143 RC_DVI_TO_PS_COMMAND,
144 RC_DATE_INSERT_FORMAT,
149 static keyword_item lyxrcTags[] = {
150 { "\\accept_compound", RC_ACCEPT_COMPOUND },
151 { "\\alternate_language", RC_ALT_LANG },
152 { "\\ascii_linelen", RC_ASCII_LINELEN },
153 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
154 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
155 { "\\autosave", RC_AUTOSAVE },
156 { "\\background_color", RC_BACKGROUND_COLOR },
157 { "\\begin_toolbar", RC_BEGINTOOLBAR },
158 { "\\bind", RC_BIND },
159 { "\\bind_file", RC_BINDFILE },
160 { "\\build_command", RC_BUILD_COMMAND },
161 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
162 { "\\check_lastfiles", RC_CHECKLASTFILES },
163 { "\\chktex_command", RC_CHKTEX_COMMAND },
164 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
165 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
166 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
167 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
168 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
169 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
170 { "\\document_path", RC_DOCUMENTPATH },
171 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
172 { "\\escape_chars", RC_ESC_CHARS },
173 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
175 { "\\fast_selection", RC_FAST_SELECTION },
177 { "\\fax_command", RC_FAX_COMMAND },
178 { "\\fax_program", RC_FAXPROGRAM },
179 { "\\font_encoding", RC_FONT_ENCODING },
180 { "\\html_command", RC_HTML_COMMAND },
181 { "\\input", RC_INPUT },
182 { "\\kbmap", RC_KBMAP },
183 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
184 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
185 { "\\lastfiles", RC_LASTFILES },
186 { "\\latex_command", RC_LATEX_COMMAND },
187 { "\\literate_command", RC_LITERATE_COMMAND },
188 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
189 { "\\literate_extension", RC_LITERATE_EXTENSION },
190 { "\\make_backup", RC_MAKE_BACKUP },
191 { "\\num_lastfiles", RC_NUMLASTFILES },
192 { "\\pdf_mode", RC_PDF_MODE },
193 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
194 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
195 { "\\personal_dictionary", RC_PERS_DICT },
196 { "\\phone_book", RC_PHONEBOOK },
197 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
198 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
199 { "\\print_command", RC_PRINT_COMMAND },
200 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
201 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
202 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
203 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
204 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
205 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
206 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
207 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
208 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
209 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
210 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
211 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
212 { "\\print_to_file", RC_PRINTTOFILE },
213 { "\\print_to_printer", RC_PRINTTOPRINTER },
214 { "\\printer", RC_PRINTER },
215 { "\\ps_command", RC_PS_COMMAND },
216 { "\\relyx_command", RC_RELYX_COMMAND },
217 { "\\rtl", RC_RTL_SUPPORT },
218 { "\\screen_dpi", RC_SCREEN_DPI },
219 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
220 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
221 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
222 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
223 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
224 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
225 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
226 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
227 { "\\screen_zoom", RC_SCREEN_ZOOM },
228 { "\\selection_color", RC_SELECTION_COLOR },
229 { "\\serverpipe", RC_SERVERPIPE },
230 { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
231 { "\\spell_command", RC_SPELL_COMMAND },
232 { "\\tempdir_path", RC_TEMPDIRPATH },
233 { "\\template_path", RC_TEMPLATEPATH },
234 { "\\use_alt_language", RC_USE_ALT_LANG },
235 { "\\use_escape_chars", RC_USE_ESC_CHARS },
236 { "\\use_input_encoding", RC_USE_INP_ENC },
237 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
238 { "\\use_tempdir", RC_USETEMPDIR },
239 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
240 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
241 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
242 { "\\view_ps_command", RC_VIEWPS_COMMAND },
243 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND }
246 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
247 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
249 // Should this be moved inside LyXAction?
251 int bindKey(char const * seq, int action)
253 return toplevel_keymap->bind(seq, action);
259 // Get printer from the environment. If fail, use default "",
260 // assuming that everything is set up correctly.
261 printer = GetEnv("PRINTER");
262 print_adapt_output = false;
263 print_command = "dvips";
264 print_evenpage_flag = "-B";
265 print_oddpage_flag = "-A";
266 print_pagerange_flag = "-pp";
267 print_copies_flag = "-c";
268 print_collcopies_flag = "-C";
269 print_reverse_flag = "-r";
270 print_landscape_flag = "-t landscape";
271 print_to_printer = "-P";
272 print_to_file = "-o ";
273 print_file_extension = ".ps";
274 print_paper_flag = "-t";
275 print_paper_dimension_flag = "-T";
276 document_path = GetEnvPath("HOME");
277 tempdir_path = "/tmp";
280 latex_command = "latex";
281 pdflatex_command = "pdflatex";
282 pdf_to_ps_command = "pdf2ps";
283 dvi_to_ps_command = "dvips";
284 literate_command = "none";
285 literate_extension = "none";
286 literate_error_filter = "cat";
287 build_command = "make";
288 build_error_filter = "cat";
289 relyx_command = "reLyX";
291 view_ps_command = "ghostview -swap";
292 view_pspic_command = "ghostview";
293 view_dvi_command = "xdvi";
294 view_dvi_paper_option = "-paper";
295 view_pdf_command = "xpdf";
296 default_papersize = BufferParams::PAPER_USLETTER;
297 custom_export_format = "ps";
298 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
299 html_command = "tth -t";
302 // Because a screen typically is wider than a piece of paper:
304 // Default LaTeX font size:
305 font_sizes[LyXFont::SIZE_TINY] = 5.0;
306 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
307 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
308 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
309 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
310 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
311 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
312 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
313 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
314 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
315 use_scalable_fonts = true;
316 roman_font_name = "-*-times";
317 sans_font_name = "-*-helvetica";
318 typewriter_font_name = "-*-courier";
319 menu_font_name = "-*-helvetica-bold-r";
320 popup_font_name = "-*-helvetica-medium-r";
321 font_norm = "iso8859-1";
323 auto_region_delete = true;
326 check_lastfiles = true;
328 exit_confirmation = true;
329 display_shortcuts = true;
330 // Spellchecker settings:
331 isp_command = "ispell";
332 isp_accept_compound = false;
333 isp_use_input_encoding = false;
334 isp_use_alt_lang = false;
335 isp_use_pers_dict = false;
336 isp_use_esc_chars = false;
340 defaultKeyBindings();
342 date_insert_format = "%A, %e %B %Y";
346 int LyXRC::ReadBindFile(string const & name)
349 string tmp = i18nLibFileSearch("bind", name, "bind");
350 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
351 int result = read(tmp);
353 lyxerr << "Error reading bind file: " << tmp << endl;
359 int LyXRC::read(string const & filename)
362 string bindFile = "cua";
364 LyXLex lexrc(lyxrcTags, lyxrcCount);
365 if (lyxerr.debugging(Debug::PARSER))
368 lexrc.setFile(filename);
369 if (!lexrc.IsOK()) return -2;
371 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
373 while (lexrc.IsOK()) {
374 // By using two switches we take advantage of the compiler
375 // telling us if we have missed a LyXRCTags element in
376 // the second switch.
377 // Note that this also shows a problem with LyXLex since it
378 // helps us avoid taking advantage of the strictness of the
381 int le = lexrc.lex();
383 case LyXLex::LEX_UNDEF:
384 lexrc.printError("Unknown tag `$$Token'");
386 case LyXLex::LEX_FEOF:
390 switch (static_cast<LyXRCTags>(le)) {
391 case RC_INPUT: // Include file
393 string tmp = LibFileSearch(string(),
396 lexrc.printError("Error reading "
397 "included file: "+tmp);
401 case RC_BINDFILE: // RVDK_PATCH_5
403 ReadBindFile(lexrc.GetString());
407 case RC_BEGINTOOLBAR:
408 // this toolbar should be changed to be a completely
409 // non gui toolbar. (Lgb)
415 use_kbmap = lexrc.GetBool();
418 case RC_EXIT_CONFIRMATION:
420 exit_confirmation = lexrc.GetBool();
423 case RC_DISPLAY_SHORTCUTS:
425 display_shortcuts = lexrc.GetBool();
428 case RC_KBMAP_PRIMARY:
430 primary_kbmap = lexrc.GetString();
433 case RC_KBMAP_SECONDARY:
435 secondary_kbmap = lexrc.GetString();
438 case RC_FONT_ENCODING:
440 fontenc = lexrc.GetString();
445 printer = lexrc.GetString();
448 case RC_PRINT_COMMAND:
450 print_command = lexrc.GetString();
453 case RC_PRINTEVENPAGEFLAG:
455 print_evenpage_flag = lexrc.GetString();
458 case RC_PRINTODDPAGEFLAG:
460 print_oddpage_flag = lexrc.GetString();
463 case RC_PRINTPAGERANGEFLAG:
465 print_pagerange_flag = lexrc.GetString();
468 case RC_PRINTCOPIESFLAG:
470 print_copies_flag = lexrc.GetString();
473 case RC_PRINTCOLLCOPIESFLAG:
475 print_collcopies_flag = lexrc.GetString();
478 case RC_PRINTREVERSEFLAG:
480 print_reverse_flag = lexrc.GetString();
483 case RC_PRINTLANDSCAPEFLAG:
485 print_landscape_flag = lexrc.GetString();
488 case RC_PRINTTOPRINTER:
490 print_to_printer = lexrc.GetString();
493 case RC_PRINT_ADAPTOUTPUT:
495 print_adapt_output = lexrc.GetBool();
500 print_to_file = lexrc.GetString();
503 case RC_PRINTFILEEXTENSION:
505 print_file_extension = lexrc.GetString();
508 case RC_PRINTEXSTRAOPTIONS:
510 print_extra_options = lexrc.GetString();
513 case RC_PRINTSPOOL_COMMAND:
515 print_spool_command = lexrc.GetString();
518 case RC_PRINTSPOOL_PRINTERPREFIX:
520 print_spool_printerprefix = lexrc.GetString();
523 case RC_PRINTPAPERDIMENSIONFLAG:
525 print_paper_dimension_flag = lexrc.GetString();
528 case RC_PRINTPAPERFLAG:
530 print_paper_flag = lexrc.GetString();
533 case RC_CUSTOM_EXPORT_COMMAND:
535 custom_export_command = lexrc.GetString();
538 case RC_CUSTOM_EXPORT_FORMAT:
540 custom_export_format = lexrc.GetString();
545 pdf_mode = lexrc.GetBool();
548 case RC_LATEX_COMMAND:
550 latex_command = lexrc.GetString();
553 case RC_PDFLATEX_COMMAND:
555 pdflatex_command = lexrc.GetString();
558 case RC_PDF_TO_PS_COMMAND:
560 pdf_to_ps_command = lexrc.GetString();
563 case RC_DVI_TO_PS_COMMAND:
565 dvi_to_ps_command = lexrc.GetString();
568 case RC_LITERATE_COMMAND:
570 literate_command = lexrc.GetString();
573 case RC_LITERATE_EXTENSION:
575 literate_extension = lexrc.GetString();
578 case RC_LITERATE_ERROR_FILTER:
580 literate_error_filter = lexrc.GetString();
583 case RC_BUILD_COMMAND:
585 build_command = lexrc.GetString();
588 case RC_BUILD_ERROR_FILTER:
590 build_error_filter = lexrc.GetString();
593 case RC_RELYX_COMMAND:
595 relyx_command = lexrc.GetString();
598 case RC_DEFAULT_PAPERSIZE:
600 string size = lowercase(lexrc.GetString());
601 if (size == "usletter")
603 BufferParams::PAPER_USLETTER;
604 else if (size == "legal")
606 BufferParams::PAPER_LEGALPAPER;
607 else if (size == "executive")
609 BufferParams::PAPER_EXECUTIVEPAPER;
610 else if (size == "a3")
612 BufferParams::PAPER_A3PAPER;
613 else if (size == "a4")
615 BufferParams::PAPER_A4PAPER;
616 else if (size == "a5")
618 BufferParams::PAPER_A5PAPER;
619 else if (size == "b5")
621 BufferParams::PAPER_B5PAPER;
624 case RC_VIEWDVI_COMMAND:
626 view_dvi_command = lexrc.GetString();
629 case RC_VIEWDVI_PAPEROPTION:
631 view_dvi_paper_option = lexrc.GetString();
633 view_dvi_paper_option = "";
636 case RC_VIEWPDF_COMMAND:
638 view_pdf_command = lexrc.GetString();
643 ps_command = lexrc.GetString();
646 case RC_VIEWPS_COMMAND:
648 view_ps_command = lexrc.GetString();
651 case RC_VIEWPSPIC_COMMAND:
653 view_pspic_command = lexrc.GetString();
656 case RC_CHKTEX_COMMAND:
658 chktex_command = lexrc.GetString();
661 case RC_HTML_COMMAND:
663 html_command = lexrc.GetString();
668 dpi = lexrc.GetInteger();
673 zoom = lexrc.GetInteger();
676 case RC_SCREEN_FONT_SIZES:
678 font_sizes[LyXFont::SIZE_TINY] =
681 font_sizes[LyXFont::SIZE_SCRIPT] =
684 font_sizes[LyXFont::SIZE_FOOTNOTE] =
687 font_sizes[LyXFont::SIZE_SMALL] =
690 font_sizes[LyXFont::SIZE_NORMAL] =
693 font_sizes[LyXFont::SIZE_LARGE] =
696 font_sizes[LyXFont::SIZE_LARGER] =
699 font_sizes[LyXFont::SIZE_LARGEST] =
702 font_sizes[LyXFont::SIZE_HUGE] =
705 font_sizes[LyXFont::SIZE_HUGER] =
709 case RC_SCREEN_FONT_SCALABLE:
711 use_scalable_fonts = lexrc.GetBool();
716 autosave = lexrc.GetInteger();
719 case RC_SGML_EXTRA_OPTIONS:
721 sgml_extra_options = lexrc.GetString();
724 case RC_DOCUMENTPATH:
726 document_path = ExpandPath(lexrc.GetString());
730 case RC_TEMPLATEPATH:
732 template_path = ExpandPath(lexrc.GetString());
737 tempdir_path = ExpandPath(lexrc.GetString());
742 use_tempdir = lexrc.GetBool();
747 lastfiles = ExpandPath(lexrc.GetString());
750 case RC_NUMLASTFILES:
752 num_lastfiles = lexrc.GetInteger();
755 case RC_CHECKLASTFILES:
757 check_lastfiles = lexrc.GetBool();
760 case RC_SCREEN_FONT_ROMAN:
762 roman_font_name = lexrc.GetString();
765 case RC_SCREEN_FONT_SANS:
767 sans_font_name = lexrc.GetString();
770 case RC_SCREEN_FONT_TYPEWRITER:
772 typewriter_font_name = lexrc.GetString();
775 case RC_SCREEN_FONT_MENU:
777 menu_font_name = lexrc.GetString();
780 case RC_SCREEN_FONT_POPUP:
782 popup_font_name = lexrc.GetString();
785 case RC_SCREEN_FONT_ENCODING:
787 font_norm = lexrc.GetString();
790 case RC_AUTOREGIONDELETE:
791 // Auto region delete defaults to true
793 auto_region_delete = lexrc.GetBool();
798 // we should not do an explicit binding before
799 // loading a bind file. So, in this case, load
800 // the default bind file.
804 // !!!chb, dynamic key binding...
808 if (lexrc.lex() == LyXLex::LEX_DATA) {
809 seq = lexrc.GetString();
811 lexrc.printError("Bad key sequence: `$$Token'");
815 if (lexrc.lex() == LyXLex::LEX_DATA) {
816 cmd = lexrc.GetString();
818 lexrc.printError("Bad command: `$$Token'");
822 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
823 if (lyxerr.debugging(Debug::KEY)) {
824 lyxerr << "RC_BIND: Sequence `"
825 << seq << "' Command `"
826 << cmd << "' Action `"
827 << action << '\'' << endl;
829 res = bindKey(seq.c_str(), action);
832 "Invalid key sequence `"
835 } else {// cmd is the last token read.
837 "Unknown LyX function `$$Token'");
843 lyxpipes = ExpandPath(lexrc.GetString());
846 case RC_CURSOR_FOLLOWS_SCROLLBAR:
848 cursor_follows_scrollbar = lexrc.GetBool();
852 case RC_FAST_SELECTION:
854 fast_selection = lexrc.GetBool();
858 case RC_BACKGROUND_COLOR:
860 background_color = lexrc.GetString();
862 case RC_SELECTION_COLOR:
864 strncpy(selection_color,
865 lexrc.GetString().c_str(), 31);
869 fax_command = lexrc.GetString();
873 fax_program = lexrc.GetString();
877 string s = lexrc.GetString();
881 phone_book = user_lyxdir + s;
884 case RC_ASCIIROFF_COMMAND:
886 ascii_roff_command = lexrc.GetString();
888 case RC_ASCII_LINELEN:
890 ascii_linelen = lexrc.GetInteger();
892 // Spellchecker settings:
893 case RC_SPELL_COMMAND:
895 isp_command = lexrc.GetString();
897 case RC_ACCEPT_COMPOUND:
899 isp_accept_compound = lexrc.GetBool();
903 isp_use_input_encoding = lexrc.GetBool();
905 case RC_USE_ALT_LANG:
907 isp_use_alt_lang = lexrc.GetBool();
909 case RC_USE_PERS_DICT:
911 isp_use_pers_dict = lexrc.GetBool();
913 case RC_USE_ESC_CHARS:
915 isp_use_esc_chars = lexrc.GetBool();
919 isp_alt_lang = lexrc.GetString();
923 isp_pers_dict = lexrc.GetString();
927 isp_esc_chars = lexrc.GetString();
931 make_backup = lexrc.GetBool();
933 case RC_DATE_INSERT_FORMAT:
935 date_insert_format = lexrc.GetString();
939 rtl_support = lexrc.GetBool();
941 case RC_LAST: break; // this is just a dummy
949 void LyXRC::write(string const & filename) const
951 ofstream ofs(filename.c_str());
957 void LyXRC::print() const
959 if (lyxerr.debugging())
966 void LyXRC::output(ostream & os) const
968 os << "### This file is part of\n"
969 << "### ========================================================\n"
970 << "### LyX, The Document Processor\n"
972 << "### Copyright 1995 Matthias Ettrich\n"
973 << "### Copyright 1995-1998 The LyX Team.\n"
975 << "### ========================================================\n"
977 << "# This file is written by LyX, if you want to make your own\n"
978 << "# modifications you should do them from inside LyX and save\n"
979 << "# your preferences, or you can also make your modifications\n"
980 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
983 // Why the switch you might ask. It is a trick to ensure that all
984 // the elements in the LyXRCTags enum is handled. As you can see
985 // there are no breaks at all. So it is just a huge fall-through.
986 // The nice thing is that we will get a warning from the compiler
987 // if we forget an element.
988 LyXRCTags tag = RC_LAST;
992 // input/include files are not done here
994 // bindings is not written to the preferences file.
996 // bind files are not done here.
997 case RC_BEGINTOOLBAR:
998 // Toolbar is not written here (yet).
999 case RC_FONT_ENCODING:
1000 os << "\\font_encoding \"" << fontenc << "\"\n";
1002 os << "\\printer \"" << printer << "\"\n";
1003 case RC_PRINT_COMMAND:
1004 os << "\\print_command \"" << print_command << "\"\n";
1005 case RC_PRINTEVENPAGEFLAG:
1006 os << "\\print_evenpage_flag \"" << print_evenpage_flag
1008 case RC_PRINTODDPAGEFLAG:
1009 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1011 case RC_PRINTPAGERANGEFLAG:
1012 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1014 case RC_PRINTCOPIESFLAG:
1015 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1016 case RC_PRINTCOLLCOPIESFLAG:
1017 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1019 case RC_PRINTREVERSEFLAG:
1020 os << "\\print_reverse_flag \"" << print_reverse_flag
1022 case RC_PRINTLANDSCAPEFLAG:
1023 os << "\\print_landscape_flag \"" << print_landscape_flag
1025 case RC_PRINTTOPRINTER:
1026 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1027 case RC_PRINT_ADAPTOUTPUT:
1028 os << "\\print_adapt_output " << tostr(print_adapt_output)
1030 case RC_PRINTTOFILE:
1031 os << "\\print_to_file \"" << print_to_file << "\"\n";
1032 case RC_PRINTFILEEXTENSION:
1033 os << "\\print_file_extension \"" << print_file_extension
1035 case RC_PRINTEXSTRAOPTIONS:
1036 os << "\\print_extra_options \"" << print_extra_options
1038 case RC_PRINTSPOOL_COMMAND:
1039 os << "\\print_spool_command \"" << print_spool_command
1041 case RC_PRINTSPOOL_PRINTERPREFIX:
1042 os << "\\print_spool_printerprefix \""
1043 << print_spool_printerprefix << "\"\n";
1044 case RC_PRINTPAPERDIMENSIONFLAG:
1045 os << "\\print_paper_dimension_flag \""
1046 << print_paper_dimension_flag << "\"\n";
1047 case RC_PRINTPAPERFLAG:
1048 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1049 case RC_CUSTOM_EXPORT_COMMAND:
1050 os << "\\custom_export_command \"" << custom_export_command
1052 case RC_CUSTOM_EXPORT_FORMAT:
1053 os << "\\custom_export_format \"" << custom_export_format
1056 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1057 case RC_LATEX_COMMAND:
1058 os << "\\latex_command \"" << latex_command << "\"\n";
1059 case RC_PDFLATEX_COMMAND:
1060 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1061 case RC_PDF_TO_PS_COMMAND:
1062 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1063 case RC_DVI_TO_PS_COMMAND:
1064 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1065 case RC_LITERATE_COMMAND:
1066 os << "\\literate_command \"" << literate_command << "\"\n";
1067 case RC_LITERATE_EXTENSION:
1068 os << "\\literate_extension \"" << literate_extension
1070 case RC_LITERATE_ERROR_FILTER:
1071 os << "\\literate_error_filter \"" << literate_error_filter
1073 case RC_BUILD_COMMAND:
1074 os << "\\build_command \"" << build_command << "\"\n";
1075 case RC_BUILD_ERROR_FILTER:
1076 os << "\\build_error_filter \"" << build_error_filter
1079 os << "\\screen_dpi " << dpi << "\n";
1080 case RC_SCREEN_ZOOM:
1081 os << "\\screen_zoom " << zoom << "\n";
1082 case RC_SCREEN_FONT_SIZES:
1083 os.setf(ios::fixed);
1085 os << "\\screen_font_sizes";
1086 os << " " << font_sizes[LyXFont::SIZE_TINY];
1087 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1088 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1089 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1090 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1091 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1092 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1093 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1094 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1095 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1097 case RC_AUTOREGIONDELETE:
1098 os << "\\auto_region_delete " << tostr(auto_region_delete)
1101 os << "\\autosave " << autosave << "\n";
1102 case RC_EXIT_CONFIRMATION:
1103 os << "\\exit_confirmation " << tostr(exit_confirmation)
1105 case RC_DISPLAY_SHORTCUTS:
1106 os << "\\display_shortcuts " << tostr(display_shortcuts)
1108 case RC_VIEWDVI_COMMAND:
1109 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1110 case RC_VIEWDVI_PAPEROPTION:
1111 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1112 case RC_VIEWPDF_COMMAND:
1113 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1114 case RC_DEFAULT_PAPERSIZE:
1115 os << "\\default_papersize \"";
1116 switch (default_papersize) {
1117 case BufferParams::PAPER_USLETTER:
1118 os << "usletter"; break;
1119 case BufferParams::PAPER_LEGALPAPER:
1120 os << "legal"; break;
1121 case BufferParams::PAPER_EXECUTIVEPAPER:
1122 os << "executive"; break;
1123 case BufferParams::PAPER_A3PAPER:
1125 case BufferParams::PAPER_A4PAPER:
1127 case BufferParams::PAPER_A5PAPER:
1129 case BufferParams::PAPER_B5PAPER:
1131 case BufferParams::PAPER_DEFAULT: break;
1134 case RC_VIEWPS_COMMAND:
1135 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1136 case RC_VIEWPSPIC_COMMAND:
1137 os << "\\view_pspic_command \"" << view_pspic_command
1140 os << "\\ps_command \"" << ps_command << "\"\n";
1141 case RC_CHKTEX_COMMAND:
1142 os << "\\chktex_command \"" << chktex_command << "\"\n";
1143 case RC_HTML_COMMAND:
1144 os << "\\html_command \"" << html_command << "\"\n";
1145 case RC_SGML_EXTRA_OPTIONS:
1146 os << "\\sgml_extra_options \"" << sgml_extra_options
1149 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1150 case RC_KBMAP_PRIMARY:
1151 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1152 case RC_KBMAP_SECONDARY:
1153 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1155 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1156 case RC_RELYX_COMMAND:
1157 os << "\\relyx_command \"" << relyx_command << "\"\n";
1158 case RC_DOCUMENTPATH:
1159 os << "\\document_path \"" << document_path << "\"\n";
1160 case RC_TEMPLATEPATH:
1161 os << "\\template_path \"" << template_path << "\"\n";
1162 case RC_TEMPDIRPATH:
1163 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1165 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1167 os << "\\lastfiles \"" << lastfiles << "\"\n";
1168 case RC_NUMLASTFILES:
1169 os << "\\num_lastfiles " << num_lastfiles << "\n";
1170 case RC_CHECKLASTFILES:
1171 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1172 case RC_SCREEN_FONT_ROMAN:
1173 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1174 case RC_SCREEN_FONT_SANS:
1175 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1176 case RC_SCREEN_FONT_TYPEWRITER:
1177 os << "\\screen_font_typewriter \""
1178 << typewriter_font_name << "\"\n";
1179 case RC_SCREEN_FONT_MENU:
1180 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1181 case RC_SCREEN_FONT_POPUP:
1182 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1183 case RC_SCREEN_FONT_ENCODING:
1184 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1185 case RC_SCREEN_FONT_SCALABLE:
1186 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1188 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1189 os << "\\cursor_follows_scrollbar "
1190 << tostr(cursor_follows_scrollbar) << "\n";
1192 case RC_FAST_SELECTION:
1193 os << "\\fast_selection "
1194 << tostr(static_cast<bool>(fast_selection)) << "\n";
1196 case RC_BACKGROUND_COLOR:
1197 os << "\\background_color \"" << background_color << "\"\n";
1198 case RC_SELECTION_COLOR:
1199 os << "\\selection_color \"" << selection_color << "\"\n";
1200 case RC_FAX_COMMAND:
1201 os << "\\fax_command \"" << fax_command << "\"\n";
1203 os << "\\fax_program \"" << fax_program << "\"\n";
1205 os << "\\phone_book \"" << phone_book << "\"\n";
1206 case RC_ASCIIROFF_COMMAND:
1207 os << "\\ascii_roff_command \"" << ascii_roff_command
1209 case RC_ASCII_LINELEN:
1210 os << "\\ascii_linelen " << ascii_linelen << "\n";
1211 case RC_SPELL_COMMAND:
1212 os << "\\spell_command \"" << isp_command << "\"\n";
1213 case RC_ACCEPT_COMPOUND:
1214 os << "\\accept_compound " << tostr(isp_accept_compound)
1216 case RC_USE_INP_ENC:
1217 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1219 case RC_USE_ALT_LANG:
1220 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1221 case RC_USE_PERS_DICT:
1222 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1224 case RC_USE_ESC_CHARS:
1225 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1228 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1230 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1232 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1233 case RC_RTL_SUPPORT:
1234 os << "\\rtl " << tostr(rtl_support) << "\n";
1235 case RC_MAKE_BACKUP:
1236 os << "\\make_backup " << tostr(make_backup) << "\n";
1237 case RC_DATE_INSERT_FORMAT:
1238 os << "\\date_insert_format \"" << date_insert_format
1245 /// define the default key bindings for LyX.
1246 void LyXRC::defaultKeyBindings()
1248 bindKey("Right", LFUN_RIGHT);
1249 bindKey("Left", LFUN_LEFT);
1250 bindKey("Up", LFUN_UP);
1251 bindKey("Down", LFUN_DOWN);
1253 bindKey("Tab", LFUN_TAB);
1255 bindKey("Home", LFUN_HOME);
1256 bindKey("End", LFUN_END);
1257 bindKey("Prior", LFUN_PRIOR);
1258 bindKey("Next", LFUN_NEXT);
1260 bindKey("Return", LFUN_BREAKPARAGRAPH);
1261 bindKey("~C-~S-~M-nobreakspace", LFUN_PROTECTEDSPACE);
1263 bindKey("Delete", LFUN_DELETE);
1264 bindKey("BackSpace", LFUN_BACKSPACE);
1265 // bindKeyings for transparent handling of deadkeys
1266 // The keysyms are gotten from XFree86 X11R6
1267 bindKey("~C-~S-~M-dead_acute", LFUN_ACUTE);
1268 bindKey("~C-~S-~M-dead_breve", LFUN_BREVE);
1269 bindKey("~C-~S-~M-dead_caron", LFUN_CARON);
1270 bindKey("~C-~S-~M-dead_cedilla", LFUN_CEDILLA);
1271 bindKey("~C-~S-~M-dead_abovering", LFUN_CIRCLE);
1272 bindKey("~C-~S-~M-dead_circumflex", LFUN_CIRCUMFLEX);
1273 bindKey("~C-~S-~M-dead_abovedot", LFUN_DOT);
1274 bindKey("~C-~S-~M-dead_grave", LFUN_GRAVE);
1275 bindKey("~C-~S-~M-dead_doubleacute", LFUN_HUNG_UMLAUT);
1276 bindKey("~C-~S-~M-dead_macron", LFUN_MACRON);
1277 // nothing with this name
1278 // bindKey("~C-~S-~M-dead_special_caron", LFUN_SPECIAL_CARON);
1279 bindKey("~C-~S-~M-dead_tilde", LFUN_TILDE);
1280 bindKey("~C-~S-~M-dead_diaeresis", LFUN_UMLAUT);
1281 // nothing with this name either...
1282 //bindKey("~C-~S-~M-dead_underbar", LFUN_UNDERBAR);
1283 bindKey("~C-~S-~M-dead_belowdot", LFUN_UNDERDOT);
1284 bindKey("~C-~S-~M-dead_tie", LFUN_TIE);
1285 bindKey("~C-~S-~M-dead_ogonek", LFUN_OGONEK);
1287 // bindings to utilize the use of the numeric keypad
1288 // e.g. Num Lock set
1289 bindKey("KP_0", LFUN_SELFINSERT);
1290 bindKey("KP_Decimal", LFUN_SELFINSERT);
1291 bindKey("KP_Enter", LFUN_SELFINSERT);
1292 bindKey("KP_1", LFUN_SELFINSERT);
1293 bindKey("KP_2", LFUN_SELFINSERT);
1294 bindKey("KP_3", LFUN_SELFINSERT);
1295 bindKey("KP_4", LFUN_SELFINSERT);
1296 bindKey("KP_5", LFUN_SELFINSERT);
1297 bindKey("KP_6", LFUN_SELFINSERT);
1298 bindKey("KP_Add", LFUN_SELFINSERT);
1299 bindKey("KP_7", LFUN_SELFINSERT);
1300 bindKey("KP_8", LFUN_SELFINSERT);
1301 bindKey("KP_9", LFUN_SELFINSERT);
1302 bindKey("KP_Divide", LFUN_SELFINSERT);
1303 bindKey("KP_Multiply", LFUN_SELFINSERT);
1304 bindKey("KP_Subtract", LFUN_SELFINSERT);
1306 /* Most self-insert keys are handled in the 'default:' section of
1307 * WorkAreaKeyPress - so we don't have to define them all.
1308 * However keys explicit decleared as self-insert are
1309 * handled seperatly (LFUN_SELFINSERT.) Lgb. */
1311 bindKey("C-Tab", LFUN_TABINSERT); // ale970515