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,
104 RC_ASCIIROFF_COMMAND,
109 RC_VIEWDVI_PAPEROPTION,
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,
144 keyword_item lyxrcTags[] = {
145 { "\\accept_compound", RC_ACCEPT_COMPOUND },
146 { "\\alternate_language", RC_ALT_LANG },
147 { "\\ascii_linelen", RC_ASCII_LINELEN },
148 { "\\ascii_roff_command", RC_ASCIIROFF_COMMAND },
149 { "\\auto_region_delete", RC_AUTOREGIONDELETE },
150 { "\\autosave", RC_AUTOSAVE },
151 { "\\background_color", RC_BACKGROUND_COLOR },
152 { "\\begin_toolbar", RC_BEGINTOOLBAR },
153 { "\\bind", RC_BIND },
154 { "\\bind_file", RC_BINDFILE },
155 { "\\build_command", RC_BUILD_COMMAND },
156 { "\\build_error_filter", RC_BUILD_ERROR_FILTER },
157 { "\\check_lastfiles", RC_CHECKLASTFILES },
158 { "\\chktex_command", RC_CHKTEX_COMMAND },
159 { "\\cursor_follows_scrollbar", RC_CURSOR_FOLLOWS_SCROLLBAR },
160 { "\\custom_export_command", RC_CUSTOM_EXPORT_COMMAND },
161 { "\\custom_export_format", RC_CUSTOM_EXPORT_FORMAT },
162 { "\\date_insert_format", RC_DATE_INSERT_FORMAT },
163 { "\\default_papersize", RC_DEFAULT_PAPERSIZE },
164 { "\\display_shortcuts", RC_DISPLAY_SHORTCUTS },
165 { "\\document_path", RC_DOCUMENTPATH },
166 { "\\dvi_to_ps_command", RC_DVI_TO_PS_COMMAND },
167 { "\\escape_chars", RC_ESC_CHARS },
168 { "\\exit_confirmation", RC_EXIT_CONFIRMATION },
169 { "\\fax_command", RC_FAX_COMMAND },
170 { "\\fax_program", RC_FAXPROGRAM },
171 { "\\font_encoding", RC_FONT_ENCODING },
172 { "\\html_command", RC_HTML_COMMAND },
173 { "\\input", RC_INPUT },
174 { "\\kbmap", RC_KBMAP },
175 { "\\kbmap_primary", RC_KBMAP_PRIMARY },
176 { "\\kbmap_secondary", RC_KBMAP_SECONDARY },
177 { "\\lastfiles", RC_LASTFILES },
178 { "\\latex_command", RC_LATEX_COMMAND },
179 { "\\literate_command", RC_LITERATE_COMMAND },
180 { "\\literate_error_filter", RC_LITERATE_ERROR_FILTER },
181 { "\\literate_extension", RC_LITERATE_EXTENSION },
182 { "\\make_backup", RC_MAKE_BACKUP },
183 { "\\num_lastfiles", RC_NUMLASTFILES },
184 { "\\pdf_mode", RC_PDF_MODE },
185 { "\\pdf_to_ps_command", RC_PDF_TO_PS_COMMAND },
186 { "\\pdflatex_command", RC_PDFLATEX_COMMAND },
187 { "\\personal_dictionary", RC_PERS_DICT },
188 { "\\phone_book", RC_PHONEBOOK },
189 { "\\print_adapt_output", RC_PRINT_ADAPTOUTPUT },
190 { "\\print_collcopies_flag", RC_PRINTCOLLCOPIESFLAG },
191 { "\\print_command", RC_PRINT_COMMAND },
192 { "\\print_copies_flag", RC_PRINTCOPIESFLAG },
193 { "\\print_evenpage_flag", RC_PRINTEVENPAGEFLAG },
194 { "\\print_extra_options", RC_PRINTEXSTRAOPTIONS },
195 { "\\print_file_extension", RC_PRINTFILEEXTENSION },
196 { "\\print_landscape_flag", RC_PRINTLANDSCAPEFLAG },
197 { "\\print_oddpage_flag", RC_PRINTODDPAGEFLAG },
198 { "\\print_pagerange_flag", RC_PRINTPAGERANGEFLAG },
199 { "\\print_paper_dimension_flag", RC_PRINTPAPERDIMENSIONFLAG },
200 { "\\print_paper_flag", RC_PRINTPAPERFLAG },
201 { "\\print_reverse_flag", RC_PRINTREVERSEFLAG },
202 { "\\print_spool_command", RC_PRINTSPOOL_COMMAND },
203 { "\\print_spool_printerprefix", RC_PRINTSPOOL_PRINTERPREFIX },
204 { "\\print_to_file", RC_PRINTTOFILE },
205 { "\\print_to_printer", RC_PRINTTOPRINTER },
206 { "\\printer", RC_PRINTER },
207 { "\\ps_command", RC_PS_COMMAND },
208 { "\\relyx_command", RC_RELYX_COMMAND },
209 { "\\rtl", RC_RTL_SUPPORT },
210 { "\\screen_dpi", RC_SCREEN_DPI },
211 { "\\screen_font_encoding", RC_SCREEN_FONT_ENCODING },
212 { "\\screen_font_menu", RC_SCREEN_FONT_MENU },
213 { "\\screen_font_popup", RC_SCREEN_FONT_POPUP },
214 { "\\screen_font_roman", RC_SCREEN_FONT_ROMAN },
215 { "\\screen_font_sans", RC_SCREEN_FONT_SANS },
216 { "\\screen_font_scalable", RC_SCREEN_FONT_SCALABLE },
217 { "\\screen_font_sizes", RC_SCREEN_FONT_SIZES },
218 { "\\screen_font_typewriter", RC_SCREEN_FONT_TYPEWRITER },
219 { "\\screen_zoom", RC_SCREEN_ZOOM },
220 { "\\selection_color", RC_SELECTION_COLOR },
221 { "\\serverpipe", RC_SERVERPIPE },
222 { "\\sgml_extra_options", RC_SGML_EXTRA_OPTIONS },
223 { "\\show_banner", RC_SHOW_BANNER },
224 { "\\spell_command", RC_SPELL_COMMAND },
225 { "\\tempdir_path", RC_TEMPDIRPATH },
226 { "\\template_path", RC_TEMPLATEPATH },
227 { "\\use_alt_language", RC_USE_ALT_LANG },
228 { "\\use_escape_chars", RC_USE_ESC_CHARS },
229 { "\\use_input_encoding", RC_USE_INP_ENC },
230 { "\\use_personal_dictionary", RC_USE_PERS_DICT },
231 { "\\use_tempdir", RC_USETEMPDIR },
232 { "\\view_dvi_command", RC_VIEWDVI_COMMAND },
233 { "\\view_dvi_paper_option", RC_VIEWDVI_PAPEROPTION },
234 { "\\view_pdf_command", RC_VIEWPDF_COMMAND },
235 { "\\view_pspic_command", RC_VIEWPSPIC_COMMAND },
236 { "\\view_ps_command", RC_VIEWPS_COMMAND }
239 /* Let the range depend of the size of lyxrcTags. Alejandro 240596 */
240 static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
242 // Should this be moved inside LyXAction?
244 int bindKey(char const * seq, int action)
246 return toplevel_keymap->bind(seq, action);
252 // Get printer from the environment. If fail, use default "",
253 // assuming that everything is set up correctly.
254 printer = GetEnv("PRINTER");
255 print_adapt_output = false;
256 print_command = "dvips";
257 print_evenpage_flag = "-B";
258 print_oddpage_flag = "-A";
259 print_pagerange_flag = "-pp";
260 print_copies_flag = "-c";
261 print_collcopies_flag = "-C";
262 print_reverse_flag = "-r";
263 print_landscape_flag = "-t landscape";
264 print_to_printer = "-P";
265 print_to_file = "-o ";
266 print_file_extension = ".ps";
267 print_paper_flag = "-t";
268 print_paper_dimension_flag = "-T";
269 document_path = GetEnvPath("HOME");
270 tempdir_path = "/tmp";
273 latex_command = "latex";
274 pdflatex_command = "pdflatex";
275 pdf_to_ps_command = "pdf2ps";
276 dvi_to_ps_command = "dvips";
277 literate_command = "none";
278 literate_extension = "none";
279 literate_error_filter = "cat";
280 build_command = "make";
281 build_error_filter = "cat";
282 relyx_command = "reLyX";
284 view_ps_command = "ghostview -swap";
285 view_pspic_command = "ghostview";
286 view_dvi_command = "xdvi";
287 view_dvi_paper_option = "-paper";
288 view_pdf_command = "xpdf";
289 default_papersize = BufferParams::PAPER_USLETTER;
290 custom_export_format = "ps";
291 chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
292 html_command = "tth -t";
295 // Because a screen typically is wider than a piece of paper:
297 // Default LaTeX font size:
298 font_sizes[LyXFont::SIZE_TINY] = 5.0;
299 font_sizes[LyXFont::SIZE_SCRIPT] = 7.0;
300 font_sizes[LyXFont::SIZE_FOOTNOTE] = 8.0;
301 font_sizes[LyXFont::SIZE_SMALL] = 9.0;
302 font_sizes[LyXFont::SIZE_NORMAL] = 10.0;
303 font_sizes[LyXFont::SIZE_LARGE] = 12.0;
304 font_sizes[LyXFont::SIZE_LARGER] = 14.4;
305 font_sizes[LyXFont::SIZE_LARGEST] = 17.26;
306 font_sizes[LyXFont::SIZE_HUGE] = 20.74;
307 font_sizes[LyXFont::SIZE_HUGER] = 24.88;
308 use_scalable_fonts = true;
309 roman_font_name = "-*-times";
310 sans_font_name = "-*-helvetica";
311 typewriter_font_name = "-*-courier";
312 menu_font_name = "-*-helvetica-bold-r";
313 popup_font_name = "-*-helvetica-medium-r";
314 font_norm = "iso8859-1";
316 auto_region_delete = true;
319 check_lastfiles = true;
321 exit_confirmation = true;
322 display_shortcuts = true;
323 // Spellchecker settings:
324 isp_command = "ispell";
325 isp_accept_compound = false;
326 isp_use_input_encoding = false;
327 isp_use_alt_lang = false;
328 isp_use_pers_dict = false;
329 isp_use_esc_chars = false;
333 date_insert_format = "%A, %e %B %Y";
336 defaultKeyBindings();
340 int LyXRC::ReadBindFile(string const & name)
343 string tmp = i18nLibFileSearch("bind", name, "bind");
344 lyxerr[Debug::LYXRC] << "Reading bindfile:" << tmp << endl;
345 int result = read(tmp);
347 lyxerr << "Error reading bind file: " << tmp << endl;
353 int LyXRC::read(string const & filename)
356 string bindFile = "cua";
358 LyXLex lexrc(lyxrcTags, lyxrcCount);
359 if (lyxerr.debugging(Debug::PARSER))
360 lexrc.printTable(lyxerr);
362 lexrc.setFile(filename);
363 if (!lexrc.IsOK()) return -2;
365 lyxerr[Debug::INIT] << "Reading '" << filename << "'..." << endl;
367 while (lexrc.IsOK()) {
368 // By using two switches we take advantage of the compiler
369 // telling us if we have missed a LyXRCTags element in
370 // the second switch.
371 // Note that this also shows a problem with LyXLex since it
372 // helps us avoid taking advantage of the strictness of the
375 int le = lexrc.lex();
377 case LyXLex::LEX_UNDEF:
378 lexrc.printError("Unknown tag `$$Token'");
380 case LyXLex::LEX_FEOF:
384 switch (static_cast<LyXRCTags>(le)) {
385 case RC_INPUT: // Include file
387 string tmp = LibFileSearch(string(),
390 lexrc.printError("Error reading "
391 "included file: "+tmp);
395 case RC_BINDFILE: // RVDK_PATCH_5
397 ReadBindFile(lexrc.GetString());
401 case RC_BEGINTOOLBAR:
402 // this toolbar should be changed to be a completely
403 // non gui toolbar. (Lgb)
409 use_kbmap = lexrc.GetBool();
412 case RC_EXIT_CONFIRMATION:
414 exit_confirmation = lexrc.GetBool();
417 case RC_DISPLAY_SHORTCUTS:
419 display_shortcuts = lexrc.GetBool();
422 case RC_KBMAP_PRIMARY:
424 primary_kbmap = lexrc.GetString();
427 case RC_KBMAP_SECONDARY:
429 secondary_kbmap = lexrc.GetString();
432 case RC_FONT_ENCODING:
434 fontenc = lexrc.GetString();
439 printer = lexrc.GetString();
442 case RC_PRINT_COMMAND:
444 print_command = lexrc.GetString();
447 case RC_PRINTEVENPAGEFLAG:
449 print_evenpage_flag = lexrc.GetString();
452 case RC_PRINTODDPAGEFLAG:
454 print_oddpage_flag = lexrc.GetString();
457 case RC_PRINTPAGERANGEFLAG:
459 print_pagerange_flag = lexrc.GetString();
462 case RC_PRINTCOPIESFLAG:
464 print_copies_flag = lexrc.GetString();
467 case RC_PRINTCOLLCOPIESFLAG:
469 print_collcopies_flag = lexrc.GetString();
472 case RC_PRINTREVERSEFLAG:
474 print_reverse_flag = lexrc.GetString();
477 case RC_PRINTLANDSCAPEFLAG:
479 print_landscape_flag = lexrc.GetString();
482 case RC_PRINTTOPRINTER:
484 print_to_printer = lexrc.GetString();
487 case RC_PRINT_ADAPTOUTPUT:
489 print_adapt_output = lexrc.GetBool();
494 print_to_file = lexrc.GetString();
497 case RC_PRINTFILEEXTENSION:
499 print_file_extension = lexrc.GetString();
502 case RC_PRINTEXSTRAOPTIONS:
504 print_extra_options = lexrc.GetString();
507 case RC_PRINTSPOOL_COMMAND:
509 print_spool_command = lexrc.GetString();
512 case RC_PRINTSPOOL_PRINTERPREFIX:
514 print_spool_printerprefix = lexrc.GetString();
517 case RC_PRINTPAPERDIMENSIONFLAG:
519 print_paper_dimension_flag = lexrc.GetString();
522 case RC_PRINTPAPERFLAG:
524 print_paper_flag = lexrc.GetString();
527 case RC_CUSTOM_EXPORT_COMMAND:
529 custom_export_command = lexrc.GetString();
532 case RC_CUSTOM_EXPORT_FORMAT:
534 custom_export_format = lexrc.GetString();
539 pdf_mode = lexrc.GetBool();
542 case RC_LATEX_COMMAND:
544 latex_command = lexrc.GetString();
547 case RC_PDFLATEX_COMMAND:
549 pdflatex_command = lexrc.GetString();
552 case RC_PDF_TO_PS_COMMAND:
554 pdf_to_ps_command = lexrc.GetString();
557 case RC_DVI_TO_PS_COMMAND:
559 dvi_to_ps_command = lexrc.GetString();
562 case RC_LITERATE_COMMAND:
564 literate_command = lexrc.GetString();
567 case RC_LITERATE_EXTENSION:
569 literate_extension = lexrc.GetString();
572 case RC_LITERATE_ERROR_FILTER:
574 literate_error_filter = lexrc.GetString();
577 case RC_BUILD_COMMAND:
579 build_command = lexrc.GetString();
582 case RC_BUILD_ERROR_FILTER:
584 build_error_filter = lexrc.GetString();
587 case RC_RELYX_COMMAND:
589 relyx_command = lexrc.GetString();
592 case RC_DEFAULT_PAPERSIZE:
594 string size = lowercase(lexrc.GetString());
595 if (size == "usletter")
597 BufferParams::PAPER_USLETTER;
598 else if (size == "legal")
600 BufferParams::PAPER_LEGALPAPER;
601 else if (size == "executive")
603 BufferParams::PAPER_EXECUTIVEPAPER;
604 else if (size == "a3")
606 BufferParams::PAPER_A3PAPER;
607 else if (size == "a4")
609 BufferParams::PAPER_A4PAPER;
610 else if (size == "a5")
612 BufferParams::PAPER_A5PAPER;
613 else if (size == "b5")
615 BufferParams::PAPER_B5PAPER;
618 case RC_VIEWDVI_COMMAND:
620 view_dvi_command = lexrc.GetString();
623 case RC_VIEWDVI_PAPEROPTION:
625 view_dvi_paper_option = lexrc.GetString();
627 view_dvi_paper_option = "";
630 case RC_VIEWPDF_COMMAND:
632 view_pdf_command = lexrc.GetString();
637 ps_command = lexrc.GetString();
640 case RC_VIEWPS_COMMAND:
642 view_ps_command = lexrc.GetString();
645 case RC_VIEWPSPIC_COMMAND:
647 view_pspic_command = lexrc.GetString();
650 case RC_CHKTEX_COMMAND:
652 chktex_command = lexrc.GetString();
655 case RC_HTML_COMMAND:
657 html_command = lexrc.GetString();
662 dpi = lexrc.GetInteger();
667 zoom = lexrc.GetInteger();
670 case RC_SCREEN_FONT_SIZES:
672 font_sizes[LyXFont::SIZE_TINY] =
675 font_sizes[LyXFont::SIZE_SCRIPT] =
678 font_sizes[LyXFont::SIZE_FOOTNOTE] =
681 font_sizes[LyXFont::SIZE_SMALL] =
684 font_sizes[LyXFont::SIZE_NORMAL] =
687 font_sizes[LyXFont::SIZE_LARGE] =
690 font_sizes[LyXFont::SIZE_LARGER] =
693 font_sizes[LyXFont::SIZE_LARGEST] =
696 font_sizes[LyXFont::SIZE_HUGE] =
699 font_sizes[LyXFont::SIZE_HUGER] =
703 case RC_SCREEN_FONT_SCALABLE:
705 use_scalable_fonts = lexrc.GetBool();
710 autosave = lexrc.GetInteger();
713 case RC_SGML_EXTRA_OPTIONS:
715 sgml_extra_options = lexrc.GetString();
718 case RC_DOCUMENTPATH:
720 document_path = ExpandPath(lexrc.GetString());
724 case RC_TEMPLATEPATH:
726 template_path = ExpandPath(lexrc.GetString());
731 tempdir_path = ExpandPath(lexrc.GetString());
736 use_tempdir = lexrc.GetBool();
741 lastfiles = ExpandPath(lexrc.GetString());
744 case RC_NUMLASTFILES:
746 num_lastfiles = lexrc.GetInteger();
749 case RC_CHECKLASTFILES:
751 check_lastfiles = lexrc.GetBool();
754 case RC_SCREEN_FONT_ROMAN:
756 roman_font_name = lexrc.GetString();
759 case RC_SCREEN_FONT_SANS:
761 sans_font_name = lexrc.GetString();
764 case RC_SCREEN_FONT_TYPEWRITER:
766 typewriter_font_name = lexrc.GetString();
769 case RC_SCREEN_FONT_MENU:
771 menu_font_name = lexrc.GetString();
774 case RC_SCREEN_FONT_POPUP:
776 popup_font_name = lexrc.GetString();
779 case RC_SCREEN_FONT_ENCODING:
781 font_norm = lexrc.GetString();
784 case RC_AUTOREGIONDELETE:
785 // Auto region delete defaults to true
787 auto_region_delete = lexrc.GetBool();
792 // we should not do an explicit binding before
793 // loading a bind file. So, in this case, load
794 // the default bind file.
798 // !!!chb, dynamic key binding...
802 if (lexrc.lex() == LyXLex::LEX_DATA) {
803 seq = lexrc.GetString();
805 lexrc.printError("Bad key sequence: `$$Token'");
809 if (lexrc.lex() == LyXLex::LEX_DATA) {
810 cmd = lexrc.GetString();
812 lexrc.printError("Bad command: `$$Token'");
816 if ((action = lyxaction.LookupFunc(cmd.c_str()))>= 0) {
817 if (lyxerr.debugging(Debug::KEY)) {
818 lyxerr << "RC_BIND: Sequence `"
819 << seq << "' Command `"
820 << cmd << "' Action `"
821 << action << '\'' << endl;
823 res = bindKey(seq.c_str(), action);
826 "Invalid key sequence `"
829 } else {// cmd is the last token read.
831 "Unknown LyX function `$$Token'");
837 lyxpipes = ExpandPath(lexrc.GetString());
840 case RC_CURSOR_FOLLOWS_SCROLLBAR:
842 cursor_follows_scrollbar = lexrc.GetBool();
845 case RC_BACKGROUND_COLOR:
847 background_color = lexrc.GetString();
849 case RC_SELECTION_COLOR:
851 strncpy(selection_color,
852 lexrc.GetString().c_str(), 31);
856 fax_command = lexrc.GetString();
860 fax_program = lexrc.GetString();
864 string s = lexrc.GetString();
868 phone_book = user_lyxdir + s;
871 case RC_ASCIIROFF_COMMAND:
873 ascii_roff_command = lexrc.GetString();
875 case RC_ASCII_LINELEN:
877 ascii_linelen = lexrc.GetInteger();
879 // Spellchecker settings:
880 case RC_SPELL_COMMAND:
882 isp_command = lexrc.GetString();
884 case RC_ACCEPT_COMPOUND:
886 isp_accept_compound = lexrc.GetBool();
890 isp_use_input_encoding = lexrc.GetBool();
892 case RC_USE_ALT_LANG:
894 isp_use_alt_lang = lexrc.GetBool();
896 case RC_USE_PERS_DICT:
898 isp_use_pers_dict = lexrc.GetBool();
900 case RC_USE_ESC_CHARS:
902 isp_use_esc_chars = lexrc.GetBool();
906 isp_alt_lang = lexrc.GetString();
910 isp_pers_dict = lexrc.GetString();
914 isp_esc_chars = lexrc.GetString();
918 make_backup = lexrc.GetBool();
920 case RC_DATE_INSERT_FORMAT:
922 date_insert_format = lexrc.GetString();
926 rtl_support = lexrc.GetBool();
930 show_banner = lexrc.GetBool();
932 case RC_LAST: break; // this is just a dummy
940 void LyXRC::write(string const & filename) const
942 ofstream ofs(filename.c_str());
948 void LyXRC::print() const
950 if (lyxerr.debugging())
957 void LyXRC::output(ostream & os) const
959 os << "### This file is part of\n"
960 << "### ========================================================\n"
961 << "### LyX, The Document Processor\n"
963 << "### Copyright 1995 Matthias Ettrich\n"
964 << "### Copyright 1995-1998 The LyX Team.\n"
966 << "### ========================================================\n"
968 << "# This file is written by LyX, if you want to make your own\n"
969 << "# modifications you should do them from inside LyX and save\n"
970 << "# your preferences, or you can also make your modifications\n"
971 << "# to lyxrc by hand. It is not advisable to edit this file.\n"
974 // Why the switch you might ask. It is a trick to ensure that all
975 // the elements in the LyXRCTags enum is handled. As you can see
976 // there are no breaks at all. So it is just a huge fall-through.
977 // The nice thing is that we will get a warning from the compiler
978 // if we forget an element.
979 LyXRCTags tag = RC_LAST;
983 // input/include files are not done here
985 // bindings is not written to the preferences file.
987 // bind files are not done here.
988 case RC_BEGINTOOLBAR:
989 // Toolbar is not written here (yet).
990 case RC_FONT_ENCODING:
991 os << "\\font_encoding \"" << fontenc << "\"\n";
993 os << "\\printer \"" << printer << "\"\n";
994 case RC_PRINT_COMMAND:
995 os << "\\print_command \"" << print_command << "\"\n";
996 case RC_PRINTEVENPAGEFLAG:
997 os << "\\print_evenpage_flag \"" << print_evenpage_flag
999 case RC_PRINTODDPAGEFLAG:
1000 os << "\\print_oddpage_flag \"" << print_oddpage_flag
1002 case RC_PRINTPAGERANGEFLAG:
1003 os << "\\print_pagerange_flag \"" << print_pagerange_flag
1005 case RC_PRINTCOPIESFLAG:
1006 os << "\\print_copies_flag \"" << print_copies_flag << "\"\n";
1007 case RC_PRINTCOLLCOPIESFLAG:
1008 os << "\\print_collcopies_flag \"" << print_collcopies_flag
1010 case RC_PRINTREVERSEFLAG:
1011 os << "\\print_reverse_flag \"" << print_reverse_flag
1013 case RC_PRINTLANDSCAPEFLAG:
1014 os << "\\print_landscape_flag \"" << print_landscape_flag
1016 case RC_PRINTTOPRINTER:
1017 os << "\\print_to_printer \"" << print_to_printer << "\"\n";
1018 case RC_PRINT_ADAPTOUTPUT:
1019 os << "\\print_adapt_output " << tostr(print_adapt_output)
1021 case RC_PRINTTOFILE:
1022 os << "\\print_to_file \"" << print_to_file << "\"\n";
1023 case RC_PRINTFILEEXTENSION:
1024 os << "\\print_file_extension \"" << print_file_extension
1026 case RC_PRINTEXSTRAOPTIONS:
1027 os << "\\print_extra_options \"" << print_extra_options
1029 case RC_PRINTSPOOL_COMMAND:
1030 os << "\\print_spool_command \"" << print_spool_command
1032 case RC_PRINTSPOOL_PRINTERPREFIX:
1033 os << "\\print_spool_printerprefix \""
1034 << print_spool_printerprefix << "\"\n";
1035 case RC_PRINTPAPERDIMENSIONFLAG:
1036 os << "\\print_paper_dimension_flag \""
1037 << print_paper_dimension_flag << "\"\n";
1038 case RC_PRINTPAPERFLAG:
1039 os << "\\print_paper_flag \"" << print_paper_flag << "\"\n";
1040 case RC_CUSTOM_EXPORT_COMMAND:
1041 os << "\\custom_export_command \"" << custom_export_command
1043 case RC_CUSTOM_EXPORT_FORMAT:
1044 os << "\\custom_export_format \"" << custom_export_format
1047 os << "\\pdf_mode " << tostr(pdf_mode) << "\n";
1048 case RC_LATEX_COMMAND:
1049 os << "\\latex_command \"" << latex_command << "\"\n";
1050 case RC_PDFLATEX_COMMAND:
1051 os << "\\pdflatex_command \"" << pdflatex_command << "\"\n";
1052 case RC_PDF_TO_PS_COMMAND:
1053 os << "\\pdf_to_ps_command \"" << pdf_to_ps_command << "\"\n";
1054 case RC_DVI_TO_PS_COMMAND:
1055 os << "\\dvi_to_ps_command \"" << dvi_to_ps_command << "\"\n";
1056 case RC_LITERATE_COMMAND:
1057 os << "\\literate_command \"" << literate_command << "\"\n";
1058 case RC_LITERATE_EXTENSION:
1059 os << "\\literate_extension \"" << literate_extension
1061 case RC_LITERATE_ERROR_FILTER:
1062 os << "\\literate_error_filter \"" << literate_error_filter
1064 case RC_BUILD_COMMAND:
1065 os << "\\build_command \"" << build_command << "\"\n";
1066 case RC_BUILD_ERROR_FILTER:
1067 os << "\\build_error_filter \"" << build_error_filter
1070 os << "\\screen_dpi " << dpi << "\n";
1071 case RC_SCREEN_ZOOM:
1072 os << "\\screen_zoom " << zoom << "\n";
1073 case RC_SCREEN_FONT_SIZES:
1074 os.setf(ios::fixed);
1076 os << "\\screen_font_sizes";
1077 os << " " << font_sizes[LyXFont::SIZE_TINY];
1078 os << " " << font_sizes[LyXFont::SIZE_SCRIPT];
1079 os << " " << font_sizes[LyXFont::SIZE_FOOTNOTE];
1080 os << " " << font_sizes[LyXFont::SIZE_SMALL];
1081 os << " " << font_sizes[LyXFont::SIZE_NORMAL];
1082 os << " " << font_sizes[LyXFont::SIZE_LARGE];
1083 os << " " << font_sizes[LyXFont::SIZE_LARGER];
1084 os << " " << font_sizes[LyXFont::SIZE_LARGEST];
1085 os << " " << font_sizes[LyXFont::SIZE_HUGE];
1086 os << " " << font_sizes[LyXFont::SIZE_HUGER];
1088 case RC_AUTOREGIONDELETE:
1089 os << "\\auto_region_delete " << tostr(auto_region_delete)
1092 os << "\\autosave " << autosave << "\n";
1093 case RC_EXIT_CONFIRMATION:
1094 os << "\\exit_confirmation " << tostr(exit_confirmation)
1096 case RC_DISPLAY_SHORTCUTS:
1097 os << "\\display_shortcuts " << tostr(display_shortcuts)
1099 case RC_VIEWDVI_COMMAND:
1100 os << "\\view_dvi_command \"" << view_dvi_command << "\"\n";
1101 case RC_VIEWDVI_PAPEROPTION:
1102 os << "\\view_dvi_paper_option \"" << view_dvi_paper_option << "\"\n";
1103 case RC_VIEWPDF_COMMAND:
1104 os << "\\view_pdf_command \"" << view_pdf_command << "\"\n";
1105 case RC_DEFAULT_PAPERSIZE:
1106 os << "\\default_papersize \"";
1107 switch (default_papersize) {
1108 case BufferParams::PAPER_USLETTER:
1109 os << "usletter"; break;
1110 case BufferParams::PAPER_LEGALPAPER:
1111 os << "legal"; break;
1112 case BufferParams::PAPER_EXECUTIVEPAPER:
1113 os << "executive"; break;
1114 case BufferParams::PAPER_A3PAPER:
1116 case BufferParams::PAPER_A4PAPER:
1118 case BufferParams::PAPER_A5PAPER:
1120 case BufferParams::PAPER_B5PAPER:
1122 case BufferParams::PAPER_DEFAULT: break;
1125 case RC_VIEWPS_COMMAND:
1126 os << "\\view_ps_command \"" << view_ps_command << "\"\n";
1127 case RC_VIEWPSPIC_COMMAND:
1128 os << "\\view_pspic_command \"" << view_pspic_command
1131 os << "\\ps_command \"" << ps_command << "\"\n";
1132 case RC_CHKTEX_COMMAND:
1133 os << "\\chktex_command \"" << chktex_command << "\"\n";
1134 case RC_HTML_COMMAND:
1135 os << "\\html_command \"" << html_command << "\"\n";
1136 case RC_SGML_EXTRA_OPTIONS:
1137 os << "\\sgml_extra_options \"" << sgml_extra_options
1140 os << "\\kbmap " << tostr(use_kbmap) << "\n";
1141 case RC_KBMAP_PRIMARY:
1142 os << "\\kbmap_primary \"" << primary_kbmap << "\"\n";
1143 case RC_KBMAP_SECONDARY:
1144 os << "\\kbmap_secondary \"" << secondary_kbmap << "\"\n";
1146 os << "\\serverpipe \"" << lyxpipes << "\"\n";
1147 case RC_RELYX_COMMAND:
1148 os << "\\relyx_command \"" << relyx_command << "\"\n";
1149 case RC_DOCUMENTPATH:
1150 os << "\\document_path \"" << document_path << "\"\n";
1151 case RC_TEMPLATEPATH:
1152 os << "\\template_path \"" << template_path << "\"\n";
1153 case RC_TEMPDIRPATH:
1154 os << "\\tempdir_path \"" << tempdir_path << "\"\n";
1156 os << "\\use_tempdir " << tostr(use_tempdir) << "\n";
1158 os << "\\lastfiles \"" << lastfiles << "\"\n";
1159 case RC_NUMLASTFILES:
1160 os << "\\num_lastfiles " << num_lastfiles << "\n";
1161 case RC_CHECKLASTFILES:
1162 os << "\\check_lastfiles " << tostr(check_lastfiles) << "\n";
1163 case RC_SCREEN_FONT_ROMAN:
1164 os << "\\screen_font_roman \"" << roman_font_name << "\"\n";
1165 case RC_SCREEN_FONT_SANS:
1166 os << "\\screen_font_sans \"" << sans_font_name << "\"\n";
1167 case RC_SCREEN_FONT_TYPEWRITER:
1168 os << "\\screen_font_typewriter \""
1169 << typewriter_font_name << "\"\n";
1170 case RC_SCREEN_FONT_MENU:
1171 os << "\\screen_font_menu \"" << menu_font_name << "\"\n";
1172 case RC_SCREEN_FONT_POPUP:
1173 os << "\\screen_font_popup \"" << popup_font_name << "\"\n";
1174 case RC_SCREEN_FONT_ENCODING:
1175 os << "\\screen_font_encoding \"" << font_norm << "\"\n";
1176 case RC_SCREEN_FONT_SCALABLE:
1177 os << "\\screen_font_scalable " << tostr(use_scalable_fonts)
1179 case RC_CURSOR_FOLLOWS_SCROLLBAR:
1180 os << "\\cursor_follows_scrollbar "
1181 << tostr(cursor_follows_scrollbar) << "\n";
1182 case RC_BACKGROUND_COLOR:
1183 os << "\\background_color \"" << background_color << "\"\n";
1184 case RC_SELECTION_COLOR:
1185 os << "\\selection_color \"" << selection_color << "\"\n";
1186 case RC_FAX_COMMAND:
1187 os << "\\fax_command \"" << fax_command << "\"\n";
1189 os << "\\fax_program \"" << fax_program << "\"\n";
1191 os << "\\phone_book \"" << phone_book << "\"\n";
1192 case RC_ASCIIROFF_COMMAND:
1193 os << "\\ascii_roff_command \"" << ascii_roff_command
1195 case RC_ASCII_LINELEN:
1196 os << "\\ascii_linelen " << ascii_linelen << "\n";
1197 case RC_SPELL_COMMAND:
1198 os << "\\spell_command \"" << isp_command << "\"\n";
1199 case RC_ACCEPT_COMPOUND:
1200 os << "\\accept_compound " << tostr(isp_accept_compound)
1202 case RC_USE_INP_ENC:
1203 os << "\\use_input_encoding " << tostr(isp_use_input_encoding)
1205 case RC_USE_ALT_LANG:
1206 os << "\\use_alt_language " << tostr(isp_use_alt_lang) << "\n";
1207 case RC_USE_PERS_DICT:
1208 os << "\\use_personal_dictionary " << tostr(isp_use_pers_dict)
1210 case RC_USE_ESC_CHARS:
1211 os << "\\use_escape_chars " << tostr(isp_use_esc_chars)
1214 os << "\\alternate_language \"" << isp_alt_lang << "\"\n";
1216 os << "\\personal_dictionary \"" << isp_pers_dict << "\"\n";
1218 os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
1219 case RC_RTL_SUPPORT:
1220 os << "\\rtl " << tostr(rtl_support) << "\n";
1221 case RC_MAKE_BACKUP:
1222 os << "\\make_backup " << tostr(make_backup) << "\n";
1223 case RC_DATE_INSERT_FORMAT:
1224 os << "\\date_insert_format \"" << date_insert_format
1226 case RC_SHOW_BANNER:
1227 os << "\\show_banner " << tostr(show_banner) << "\n";
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