]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
revert accidental commit.
[lyx.git] / src / LyXRC.cpp
1 /**
2  * \file LyXRC.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  * \author John Levon
10  * \author André Pönitz
11  * \author Allan Rae
12  * \author Dekel Tsur
13  *
14  * Full author contact details are available in file CREDITS.
15  */
16
17 #include <config.h>
18
19 #include <fstream>
20 #include <iostream>
21
22 #include "LyXRC.h"
23
24 #include "Color.h"
25 #include "Converter.h"
26 #include "Format.h"
27 #include "Session.h"
28 #include "Lexer.h"
29 #include "FontEnums.h"
30 #include "Mover.h"
31
32 #include "graphics/GraphicsTypes.h"
33
34 #include "support/convert.h"
35 #include "support/debug.h"
36 #include "support/environment.h"
37 #include "support/filetools.h"
38 #include "support/gettext.h"
39 #include "support/lstrings.h"
40 #include "support/os.h"
41 #include "support/userinfo.h"
42
43 using namespace std;
44 using namespace lyx::support;
45
46 namespace lyx {
47
48 namespace os = support::os;
49
50 namespace {
51
52 // when adding something to this array keep it sorted!
53 LexerKeyword lyxrcTags[] = {
54         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
55         { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
56         { "\\alternate_language", LyXRC::RC_ALT_LANG },
57         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
58         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
59         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
60         { "\\autosave", LyXRC::RC_AUTOSAVE },
61         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
62         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
63         { "\\bind_file", LyXRC::RC_BINDFILE },
64         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
65         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
66         { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
67         { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
68         { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
69         { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
70         { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
71         { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
72         { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
73         { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
74         { "\\completion_popup_text", LyXRC::RC_COMPLETION_POPUP_TEXT },
75         { "\\converter", LyXRC::RC_CONVERTER },
76         { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
77         { "\\copier", LyXRC::RC_COPIER },
78         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
79         { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
80         { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
81         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
82         { "\\def_file", LyXRC::RC_DEFFILE },
83         { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
84         { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
85         { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
86         { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
87         { "\\document_path", LyXRC::RC_DOCUMENTPATH },
88         { "\\escape_chars", LyXRC::RC_ESC_CHARS },
89         { "\\example_path", LyXRC::RC_EXAMPLEPATH },
90         { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
91         { "\\format", LyXRC::RC_FORMAT },
92         { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
93         { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
94         { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
95         { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
96         { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
97         { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
98         { "\\index_command", LyXRC::RC_INDEX_COMMAND },
99         { "\\input", LyXRC::RC_INPUT },
100         { "\\kbmap", LyXRC::RC_KBMAP },
101         { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
102         { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
103         { "\\label_init_length", LyXRC::RC_LABEL_INIT_LENGTH },
104         { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
105         { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
106         { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
107         { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
108         { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
109         { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
110         { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
111         { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
112         { "\\load_session", LyXRC::RC_LOADSESSION },
113         { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
114         { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
115         { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
116         { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
117         { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
118         { "\\open_buffers_in_tabs", LyXRC::RC_OPEN_BUFFERS_IN_TABS },
119         { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
120         { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
121         { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
122         { "\\plaintext_roff_command", LyXRC::RC_PLAINTEXT_ROFF_COMMAND },
123         { "\\preview", LyXRC::RC_PREVIEW },
124         { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
125         { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
126         { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
127         { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
128         { "\\print_command", LyXRC::RC_PRINT_COMMAND },
129         { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
130         { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
131         { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
132         { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
133         { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
134         { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
135         { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
136         { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
137         { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
138         { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
139         { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
140         { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
141         { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
142         { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
143         { "\\printer", LyXRC::RC_PRINTER },
144         { "\\rtl", LyXRC::RC_RTL_SUPPORT },
145         { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
146         { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
147         { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
148         { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
149         { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
150         { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
151         { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
152         { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
153         { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
154         { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
155         { "\\serverpipe", LyXRC::RC_SERVERPIPE },
156         { "\\set_color", LyXRC::RC_SET_COLOR },
157         { "\\show_banner", LyXRC::RC_SHOW_BANNER },
158         { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
159         { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
160         { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
161         { "\\template_path", LyXRC::RC_TEMPLATEPATH },
162         { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
163         { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
164         { "\\ui_file", LyXRC::RC_UIFILE },
165         { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
166         { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
167         { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
168         { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
169         { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
170         { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
171         { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
172         // compatibility with versions older than 1.4.0 only
173         { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
174         { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
175         // compatibility with versions older than 1.4.0 only
176         { "\\use_tempdir", LyXRC::RC_USETEMPDIR },
177         { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
178         { "\\user_email", LyXRC::RC_USER_EMAIL },
179         { "\\user_name", LyXRC::RC_USER_NAME },
180         { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
181         // compatibility with versions older than 1.4.0 only
182         { "\\viewer", LyXRC::RC_VIEWER},
183         { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
184 };
185
186 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]);
187
188 } // namespace anon
189
190
191 LyXRC::LyXRC()
192 {
193         setDefaults();
194 }
195
196
197 void LyXRC::setDefaults()
198 {
199         bind_file = "cua";
200         def_file = "default";
201         ui_file = "default";
202         // Get printer from the environment. If fail, use default "",
203         // assuming that everything is set up correctly.
204         printer = getEnv("PRINTER");
205         print_adapt_output = false;
206         print_command = "dvips";
207         print_evenpage_flag = "-B";
208         print_oddpage_flag = "-A";
209         print_pagerange_flag = "-pp";
210         print_copies_flag = "-c";
211         print_collcopies_flag = "-C";
212         print_reverse_flag = "-r";
213         print_landscape_flag = "-t landscape";
214         print_to_printer = "-P";
215         print_to_file = "-o ";
216         print_file_extension = ".ps";
217         print_paper_flag = "-t";
218         print_paper_dimension_flag = "-T";
219         document_path.erase();
220         view_dvi_paper_option.erase();
221         default_papersize = PAPER_DEFAULT;
222         custom_export_format = "ps";
223         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
224         bibtex_command = "bibtex";
225         fontenc = "default";
226         index_command = "makeindex -c -q";
227         dpi = 75;
228         // Because a screen typically is wider than a piece of paper:
229         zoom = 150;
230         allow_geometry_session = true;
231         // Default LaTeX font size:
232         font_sizes[FONT_SIZE_TINY] = "5.0";
233         font_sizes[FONT_SIZE_SCRIPT] = "7.0";
234         font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
235         font_sizes[FONT_SIZE_SMALL] = "9.0";
236         font_sizes[FONT_SIZE_NORMAL] = "10.0";
237         font_sizes[FONT_SIZE_LARGE] = "12.0";
238         font_sizes[FONT_SIZE_LARGER] = "14.4";
239         font_sizes[FONT_SIZE_LARGEST] = "17.26";
240         font_sizes[FONT_SIZE_HUGE] = "20.74";
241         font_sizes[FONT_SIZE_HUGER] = "24.88";
242         use_scalable_fonts = true;
243         roman_font_name = "";
244         sans_font_name = "";
245         typewriter_font_name = "";
246         autosave = 300;
247         auto_region_delete = true;
248         auto_reset_options = false;
249         plaintext_linelen = 65;
250         mouse_wheel_speed = 1.0;
251         num_lastfiles = maxlastfiles;
252         check_lastfiles = true;
253         use_lastfilepos = true;
254         load_session = false;
255         make_backup = true;
256         backupdir_path.erase();
257         display_graphics = graphics::ColorDisplay;
258         // Spellchecker settings:
259         use_spell_lib = true;
260         isp_command = "ispell";
261         isp_accept_compound = false;
262         isp_use_input_encoding = false;
263         isp_use_alt_lang = false;
264         isp_use_pers_dict = false;
265         isp_use_esc_chars = false;
266         use_kbmap = false;
267         rtl_support = true;
268         visual_cursor = false;
269         auto_number = true;
270         mark_foreign_language = true;
271         language_auto_begin = true;
272         language_auto_end = true;
273         language_global_options = true;
274         language_use_babel = true;
275         language_package = "\\usepackage{babel}";
276         language_command_begin = "\\selectlanguage{$$lang}";
277         language_command_local = "\\foreignlanguage{$$lang}{";
278         sort_layouts = false;
279         group_layouts = true;
280         default_language = "english";
281         show_banner = true;
282         windows_style_tex_paths = false;
283         tex_allows_spaces = false;
284         date_insert_format = "%x";
285         cursor_follows_scrollbar = false;
286         macro_edit_style = MACRO_EDIT_INLINE_BOX;
287         dialogs_iconify_with_main = false;
288         label_init_length = 3;
289         preview = PREVIEW_OFF;
290         preview_hashed_labels  = false;
291         preview_scale_factor = "0.9";
292         use_converter_cache = true;
293         use_tooltip = true;
294         use_pixmap_cache = false;
295         converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
296         user_name = to_utf8(support::user_name());
297         user_email = to_utf8(support::user_email());
298         open_buffers_in_tabs = true;
299
300         // Fullscreen settings
301         full_screen_limit = false;
302         full_screen_toolbars = true;
303         full_screen_tabbar = true;
304         full_screen_scrollbar = true;
305         full_screen_width = 700;
306
307         completion_cursor_text = true;
308         completion_popup_math = true;
309         completion_popup_text = false;
310         completion_popup_delay = 2.0;
311         completion_popup_after_complete = true;
312         completion_inline_math = true;
313         completion_inline_text = false;
314         completion_inline_dots = -1;
315         completion_inline_delay = 0.2;
316 }
317
318
319 namespace {
320
321 void oldFontFormat(string & family, string & foundry)
322 {
323         if (family.empty() || family[0] != '-')
324                 return;
325         foundry = token(family, '-', 1);
326         family = token(family, '-', 2);
327         if (foundry == "*")
328                 foundry.erase();
329 }
330
331 } // namespace anon
332
333
334 int LyXRC::read(FileName const & filename)
335 {
336         Lexer lexrc(lyxrcTags);
337         if (lyxerr.debugging(Debug::PARSER))
338                 lexrc.printTable(lyxerr);
339
340         lexrc.setFile(filename);
341         if (!lexrc.isOK())
342                 return -2;
343
344         LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
345
346         return read(lexrc);
347 }
348
349
350 int LyXRC::read(istream & is)
351 {
352         Lexer lexrc(lyxrcTags);
353         if (lyxerr.debugging(Debug::PARSER))
354                 lexrc.printTable(lyxerr);
355
356         lexrc.setStream(is);
357         if (!lexrc.isOK())
358                 return -2;
359
360         LYXERR(Debug::LYXRC, "Reading istream...");
361
362         return read(lexrc);
363 }
364
365
366 int LyXRC::read(Lexer & lexrc)
367 {
368         if (!lexrc.isOK()) return -2;
369
370         while (lexrc.isOK()) {
371                 // By using two switches we take advantage of the compiler
372                 // telling us if we have missed a LyXRCTags element in
373                 // the second switch.
374                 // Note that this also shows a problem with Lexer since it
375                 // helps us avoid taking advantage of the strictness of the
376                 // compiler.
377
378                 int le = lexrc.lex();
379                 switch (le) {
380                 case Lexer::LEX_UNDEF:
381                         lexrc.printError("Unknown tag `$$Token'");
382                         continue;
383                 case Lexer::LEX_FEOF:
384                         continue;
385                 default: break;
386                 }
387                 switch (static_cast<LyXRCTags>(le)) {
388                 case RC_INPUT: // Include file
389                         if (lexrc.next()) {
390                                 FileName const tmp =
391                                         libFileSearch(string(),
392                                                       lexrc.getString());
393                                 if (read(tmp)) {
394                                         lexrc.printError("Error reading "
395                                                          "included file: " + tmp.absFilename());
396                                 }
397                         }
398                         break;
399                 case RC_BINDFILE:
400                         if (lexrc.next()) {
401                                 bind_file = os::internal_path(lexrc.getString());
402                         }
403                         break;
404
405                 case RC_DEFFILE:
406                         if (lexrc.next()) {
407                                 def_file = os::internal_path(lexrc.getString());
408                         }
409                         break;
410
411                 case RC_UIFILE:
412                         if (lexrc.next()) {
413                                 ui_file = os::internal_path(lexrc.getString());
414                         }
415                         break;
416
417                 case RC_AUTORESET_OPTIONS:
418                         lexrc >> auto_reset_options;
419                         break;
420
421                 case RC_DISPLAY_GRAPHICS:
422                         if (lexrc.next())
423                                 display_graphics = graphics::displayTranslator().find(lexrc.getString());
424                         break;
425
426                 case RC_TEX_EXPECTS_WINDOWS_PATHS:
427                         lexrc >> windows_style_tex_paths;
428                         break;
429
430                 case RC_TEX_ALLOWS_SPACES:
431                         lexrc >> tex_allows_spaces;
432                         break;
433
434                 case RC_KBMAP:
435                         lexrc >> use_kbmap;
436                         break;
437
438                 case RC_KBMAP_PRIMARY:
439                         if (lexrc.next()) {
440                                 string const kmap(os::internal_path(lexrc.getString()));
441                                 if (kmap.empty()) {
442                                         // nothing
443                                 } else if (!libFileSearch("kbd", kmap,
444                                                           "kmap").empty()) {
445                                         primary_kbmap = kmap;
446                                 } else {
447                                         lexrc.printError("LyX: Keymap `$$Token' not found");
448                                 }
449                         }
450                         break;
451
452                 case RC_KBMAP_SECONDARY:
453                         if (lexrc.next()) {
454                                 string const kmap(os::internal_path(lexrc.getString()));
455                                 if (kmap.empty()) {
456                                         // nothing
457                                 } else if (!libFileSearch("kbd", kmap,
458                                                           "kmap").empty()) {
459                                         secondary_kbmap = kmap;
460                                 } else {
461                                         lexrc.printError("LyX: Keymap `$$Token' not found");
462                                 }
463                         }
464                         break;
465
466                 case RC_FONT_ENCODING:
467                         lexrc >> fontenc;
468                         break;
469
470                 case RC_PRINTER:
471                         lexrc >> printer;
472                         break;
473
474                 case RC_PRINT_COMMAND:
475                         if (lexrc.next(true)) {
476                                 print_command = lexrc.getString();
477                         }
478                         break;
479
480                 case RC_PRINTEVENPAGEFLAG:
481                         lexrc >> print_evenpage_flag;
482                         break;
483
484                 case RC_PRINTODDPAGEFLAG:
485                         lexrc >> print_oddpage_flag;
486                         break;
487
488                 case RC_PRINTPAGERANGEFLAG:
489                         lexrc >> print_pagerange_flag;
490                         break;
491
492                 case RC_PRINTCOPIESFLAG:
493                         lexrc >> print_copies_flag;
494                         break;
495
496                 case RC_PRINTCOLLCOPIESFLAG:
497                         lexrc >> print_collcopies_flag;
498                         break;
499
500                 case RC_PRINTREVERSEFLAG:
501                         lexrc >> print_reverse_flag;
502                         break;
503
504                 case RC_PRINTLANDSCAPEFLAG:
505                         lexrc >> print_landscape_flag;
506                         break;
507
508                 case RC_PRINTTOPRINTER:
509                         lexrc >> print_to_printer;
510                         break;
511
512                 case RC_PRINT_ADAPTOUTPUT:
513                         lexrc >> print_adapt_output;
514                         break;
515
516                 case RC_PRINTTOFILE:
517                         if (lexrc.next()) {
518                                 print_to_file = os::internal_path(lexrc.getString());
519                         }
520                         break;
521
522                 case RC_PRINTFILEEXTENSION:
523                         lexrc >> print_file_extension;
524                         break;
525
526                 case RC_PRINTEXSTRAOPTIONS:
527                         lexrc >> print_extra_options;
528                         break;
529
530                 case RC_PRINTSPOOL_COMMAND:
531                         if (lexrc.next(true)) {
532                                 print_spool_command = lexrc.getString();
533                         }
534                         break;
535
536                 case RC_PRINTSPOOL_PRINTERPREFIX:
537                         lexrc >> print_spool_printerprefix;
538                         break;
539
540                 case RC_PRINTPAPERDIMENSIONFLAG:
541                         lexrc >> print_paper_dimension_flag;
542                         break;
543
544                 case RC_PRINTPAPERFLAG:
545                         lexrc >> print_paper_flag;
546                         break;
547
548                 case RC_CUSTOM_EXPORT_COMMAND:
549                         lexrc >> custom_export_command;
550                         break;
551
552                 case RC_CUSTOM_EXPORT_FORMAT:
553                         lexrc >> custom_export_format;
554                         break;
555
556                 case RC_DEFAULT_PAPERSIZE:
557                         if (lexrc.next()) {
558                                 string const size = ascii_lowercase(lexrc.getString());
559                                 if (size == "usletter")
560                                         default_papersize = PAPER_USLETTER;
561                                 else if (size == "legal")
562                                         default_papersize = PAPER_USLEGAL;
563                                 else if (size == "executive")
564                                         default_papersize = PAPER_USEXECUTIVE;
565                                 else if (size == "a3")
566                                         default_papersize = PAPER_A3;
567                                 else if (size == "a4")
568                                         default_papersize = PAPER_A4;
569                                 else if (size == "a5")
570                                         default_papersize = PAPER_A5;
571                                 else if (size == "b5")
572                                         default_papersize = PAPER_B5;
573                                 else if (size == "default")
574                                         default_papersize = PAPER_DEFAULT;
575                         }
576                         break;
577
578                 case RC_VIEWDVI_PAPEROPTION:
579                         if (lexrc.next())
580                                 view_dvi_paper_option = lexrc.getString();
581                         else
582                                 view_dvi_paper_option.erase();
583                         break;
584
585                 case RC_CHKTEX_COMMAND:
586                         if (lexrc.next(true)) {
587                                 chktex_command = lexrc.getString();
588                         }
589                         break;
590
591                 case RC_BIBTEX_COMMAND:
592                         if (lexrc.next(true)) {
593                                 bibtex_command = lexrc.getString();
594                         }
595                         break;
596
597                 case RC_INDEX_COMMAND:
598                         if (lexrc.next(true)) {
599                                 index_command = lexrc.getString();
600                         }
601                         break;
602
603                 case RC_SCREEN_DPI:
604                         lexrc >> dpi;
605                         break;
606
607                 case RC_SCREEN_ZOOM:
608                         lexrc >> zoom;
609                         break;
610
611                 case RC_GEOMETRY_SESSION:
612                         lexrc >> allow_geometry_session;
613                         break;
614
615                 case RC_SCREEN_FONT_SIZES:
616                         lexrc >> font_sizes[FONT_SIZE_TINY];
617                         lexrc >> font_sizes[FONT_SIZE_SCRIPT];
618                         lexrc >> font_sizes[FONT_SIZE_FOOTNOTE];
619                         lexrc >> font_sizes[FONT_SIZE_SMALL];
620                         lexrc >> font_sizes[FONT_SIZE_NORMAL];
621                         lexrc >> font_sizes[FONT_SIZE_LARGE];
622                         lexrc >> font_sizes[FONT_SIZE_LARGER];
623                         lexrc >> font_sizes[FONT_SIZE_LARGEST];
624                         lexrc >> font_sizes[FONT_SIZE_HUGE];
625                         lexrc >> font_sizes[FONT_SIZE_HUGER];
626                         break;
627
628                 case RC_SCREEN_FONT_SCALABLE:
629                         lexrc >> use_scalable_fonts;
630                         break;
631
632                 case RC_AUTOSAVE:
633                         lexrc >> autosave;
634                         break;
635
636                 case RC_DOCUMENTPATH:
637                         if (lexrc.next()) {
638                                 document_path = os::internal_path(lexrc.getString());
639                                 document_path = expandPath(document_path);
640                         }
641                         break;
642
643                 case RC_EXAMPLEPATH:
644                         if (lexrc.next()) {
645                                 example_path = os::internal_path(lexrc.getString());
646                                 example_path = expandPath(example_path);
647                         }
648                         break;
649
650                 case RC_TEMPLATEPATH:
651                         if (lexrc.next()) {
652                                 template_path = os::internal_path(lexrc.getString());
653                                 template_path = expandPath(template_path);
654                         }
655                         break;
656
657                 case RC_TEMPDIRPATH:
658                         if (lexrc.next()) {
659                                 tempdir_path = os::internal_path(lexrc.getString());
660                                 tempdir_path = expandPath(tempdir_path);
661                         }
662                         break;
663
664                 case RC_USETEMPDIR:
665                         if (lexrc.next())
666                                 lyxerr << "Ignoring obsolete use_tempdir flag." << endl;
667                         break;
668
669                 case RC_USELASTFILEPOS:
670                         lexrc >> use_lastfilepos;
671                         break;
672
673                 case RC_LOADSESSION:
674                         lexrc >> load_session;
675                         break;
676
677                 case RC_MOUSE_WHEEL_SPEED:
678                         lexrc >> mouse_wheel_speed;
679                         break;
680
681                 case RC_COMPLETION_INLINE_DELAY:
682                         lexrc >> completion_inline_delay;
683                         break;
684
685                 case RC_COMPLETION_INLINE_MATH:
686                         lexrc >> completion_inline_math;
687                         break;
688
689                 case RC_COMPLETION_INLINE_TEXT:
690                         lexrc >> completion_inline_text;
691                         break;
692
693                 case RC_COMPLETION_INLINE_DOTS:
694                         lexrc >> completion_inline_dots;
695                         break;
696
697                 case RC_COMPLETION_POPUP_DELAY:
698                         lexrc >> completion_popup_delay;
699                         break;
700
701                 case RC_COMPLETION_POPUP_MATH:
702                         lexrc >> completion_popup_math;
703                         break;
704
705                 case RC_COMPLETION_POPUP_TEXT:
706                         lexrc >> completion_popup_text;
707                         break;
708
709                 case RC_COMPLETION_CURSOR_TEXT:
710                         lexrc >> completion_cursor_text;
711                         break;
712
713                 case RC_COMPLETION_POPUP_AFTER_COMPLETE:
714                         lexrc >> completion_popup_after_complete;
715                         break;
716
717                 case RC_NUMLASTFILES:
718                         lexrc >> num_lastfiles;
719                         break;
720
721                 case RC_CHECKLASTFILES:
722                         lexrc >> check_lastfiles;
723                         break;
724
725                 case RC_SCREEN_FONT_ROMAN:
726                         if (lexrc.next()) {
727                                 roman_font_name = lexrc.getString();
728                                 oldFontFormat(roman_font_name,
729                                               roman_font_foundry);
730                         }
731                         break;
732
733                 case RC_SCREEN_FONT_SANS:
734                         if (lexrc.next()) {
735                                 sans_font_name = lexrc.getString();
736                                 oldFontFormat(sans_font_name, sans_font_foundry);
737                         }
738                         break;
739
740                 case RC_SCREEN_FONT_TYPEWRITER:
741                         if (lexrc.next()) {
742                                 typewriter_font_name = lexrc.getString();
743                                 oldFontFormat(typewriter_font_name,
744                                               typewriter_font_foundry);
745                         }
746                         break;
747
748                 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
749                         lexrc >> roman_font_foundry;
750                         break;
751
752                 case RC_SCREEN_FONT_SANS_FOUNDRY:
753                         lexrc >> sans_font_foundry;
754                         break;
755
756                 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
757                         lexrc >> typewriter_font_foundry;
758                         break;
759
760                 case RC_SET_COLOR:
761                 {
762                         string lyx_name, x11_name;
763
764                         if (lexrc.next()) {
765                                 lyx_name = lexrc.getString();
766                         } else {
767                                 lexrc.printError("Missing color tag.");
768                                 break;
769                         }
770
771                         if (lexrc.next()) {
772                                 x11_name = lexrc.getString();
773                         } else {
774                                 lexrc.printError("Missing color name for color: `$$Token'");
775                                 break;
776                         }
777
778                         ColorCode const col =
779                                 lcolor.getFromLyXName(lyx_name);
780                         if (col == Color_none ||
781                             col == Color_inherit ||
782                             col == Color_ignore)
783                                 break;
784
785                         if (!lcolor.setColor(col, x11_name)) {
786                                 lyxerr << "Bad lyxrc set_color for "
787                                         << lyx_name << endl;
788
789                         }
790                         break;
791                 }
792                 case RC_AUTOREGIONDELETE:
793                         // Auto region delete defaults to true
794                         lexrc >> auto_region_delete;
795                         break;
796
797                 case RC_SERVERPIPE:
798                         if (lexrc.next()) {
799                                 lyxpipes = os::internal_path(lexrc.getString());
800                                 lyxpipes = expandPath(lyxpipes);
801                         }
802                         break;
803
804                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
805                         lexrc >> cursor_follows_scrollbar;
806                         break;
807
808                 case RC_MACRO_EDIT_STYLE:
809                         if (lexrc.next()) {
810                                 switch (lexrc.getInteger()) {
811                                 case 0: macro_edit_style = MACRO_EDIT_INLINE_BOX; break;
812                                 case 1: macro_edit_style = MACRO_EDIT_INLINE; break;
813                                 case 2: macro_edit_style = MACRO_EDIT_LIST; break;
814                                 }
815                         }
816                         break;
817
818                 case RC_DIALOGS_ICONIFY_WITH_MAIN:
819                         lexrc >> dialogs_iconify_with_main;
820                         break;
821
822                 case RC_PLAINTEXT_ROFF_COMMAND:
823                         if (lexrc.next(true)) {
824                                 plaintext_roff_command = lexrc.getString();
825                         }
826                         break;
827                 case RC_PLAINTEXT_LINELEN:
828                         lexrc >> plaintext_linelen;
829                         break;
830                         // Spellchecker settings:
831                 case RC_USE_SPELL_LIB:
832                         lexrc >> use_spell_lib;
833                         break;
834                 case RC_SPELL_COMMAND:
835                         if (lexrc.next(true)) {
836                                 isp_command = lexrc.getString();
837                         }
838                         break;
839                 case RC_ACCEPT_COMPOUND:
840                         lexrc >> isp_accept_compound;
841                         break;
842                 case RC_USE_INP_ENC:
843                         lexrc >> isp_use_input_encoding;
844                         break;
845                 case RC_USE_ALT_LANG:
846                         lexrc >> isp_use_alt_lang;
847                         break;
848                 case RC_USE_PERS_DICT:
849                         lexrc >> isp_use_pers_dict;
850                         break;
851                 case RC_USE_TOOLTIP:
852                         lexrc >> use_tooltip;
853                         break;
854                 case RC_USE_PIXMAP_CACHE:
855                         lexrc >> use_pixmap_cache;
856                         break;
857                 case RC_USE_ESC_CHARS:
858                         lexrc >> isp_use_esc_chars;
859                         break;
860                 case RC_ALT_LANG:
861                         lexrc >> isp_alt_lang;
862                         break;
863                 case RC_PERS_DICT:
864                         if (lexrc.next())
865                                 isp_pers_dict = os::internal_path(lexrc.getString());
866                         break;
867                 case RC_ESC_CHARS:
868                         lexrc >> isp_esc_chars;
869                         break;
870                 case RC_MAKE_BACKUP:
871                         lexrc >> make_backup;
872                         break;
873                 case RC_BACKUPDIR_PATH:
874                         if (lexrc.next()) {
875                                 backupdir_path = os::internal_path(lexrc.getString());
876                                 backupdir_path = expandPath(backupdir_path);
877                         }
878                         break;
879                 case RC_DATE_INSERT_FORMAT:
880                         lexrc >> date_insert_format;
881                         break;
882                 case RC_LANGUAGE_PACKAGE:
883                         lexrc >> language_package;
884                         break;
885                 case RC_LANGUAGE_AUTO_BEGIN:
886                         lexrc >> language_auto_begin;
887                         break;
888                 case RC_LANGUAGE_AUTO_END:
889                         lexrc >> language_auto_end;
890                         break;
891                 case RC_LANGUAGE_GLOBAL_OPTIONS:
892                         lexrc >> language_global_options;
893                         break;
894                 case RC_LANGUAGE_USE_BABEL:
895                         lexrc >> language_use_babel;
896                         break;
897                 case RC_LANGUAGE_COMMAND_BEGIN:
898                         lexrc >> language_command_begin;
899                         break;
900                 case RC_LANGUAGE_COMMAND_END:
901                         lexrc >> language_command_end;
902                         break;
903                 case RC_LANGUAGE_COMMAND_LOCAL:
904                         lexrc >> language_command_local;
905                         break;
906                 case RC_RTL_SUPPORT:
907                         lexrc >> rtl_support;
908                         break;
909                 case RC_VISUAL_CURSOR:
910                         lexrc >> visual_cursor;
911                         break;
912                 case RC_AUTO_NUMBER:
913                         lexrc >> auto_number;
914                         break;
915                 case RC_MARK_FOREIGN_LANGUAGE:
916                         lexrc >> mark_foreign_language;
917                         break;
918
919                 case RC_COPIER: {
920                         string fmt, command;
921                         if (lexrc.next()) {
922                                 fmt = lexrc.getString();
923                         }
924                         if (lexrc.next(true)) {
925                                 command = lexrc.getString();
926                         }
927                         setMover(fmt, command);
928                         break;
929                 }
930
931                 case RC_CONVERTER: {
932                         string from, to, command, flags;
933                         if (lexrc.next()) {
934                                 from = lexrc.getString();
935                         }
936                         if (lexrc.next()) {
937                                 to = lexrc.getString();
938                         }
939                         if (lexrc.next(true)) {
940                                 command = lexrc.getString();
941                         }
942                         if (lexrc.next()) {
943                                 flags = lexrc.getString();
944                         }
945                         if (command.empty())
946                                 theConverters().erase(from, to);
947                         else
948                                 theConverters().add(from, to, command, flags);
949                         break;
950                 }
951                 // compatibility with versions older than 1.4.0 only
952                 case RC_VIEWER: {
953                         string format, command;
954                         lexrc >> format >> command;
955                         formats.setViewer(format, command);
956                         break;
957                 }
958                 case RC_FORMAT: {
959                         string format, extension, prettyname, shortcut;
960                         lexrc >> format >> extension >> prettyname >> shortcut;
961                         string viewer, editor;
962                         if (lexrc.next(true))
963                                 viewer = lexrc.getString();
964                         if (lexrc.next(true))
965                                 editor = lexrc.getString();
966                         string flags;
967                         // Hack to ensure compatibility with versions older
968                         // than 1.5.0
969                         int le = lexrc.lex();
970                         if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
971                                 flags = lexrc.getString();
972                                 if (le != Lexer::LEX_DATA) {
973                                         // We have got a known token.
974                                         // Therefore this is an old style
975                                         // format definition without
976                                         // flags.
977                                         lexrc.pushToken(flags);
978                                         flags.erase();
979                                 }
980                         }
981                         int flgs = Format::none;
982                         while (!flags.empty()) {
983                                 string flag;
984                                 flags = split(flags, flag, ',');
985                                 if (flag == "document")
986                                         flgs |= Format::document;
987                                 else if (flag == "vector")
988                                         flgs |= Format::vector;
989                                 else
990                                         lyxerr << "Ignoring unknown flag `"
991                                                << flag << "' for format `"
992                                                << format << "'." << endl;
993                         }
994                         if (prettyname.empty()) {
995                                 if (theConverters().formatIsUsed(format))
996                                         LYXERR0( "Can't delete format " << format);
997                                 else
998                                         formats.erase(format);
999                         } else {
1000                                 formats.add(format, extension, prettyname,
1001                                             shortcut, viewer, editor, flgs);
1002                         }
1003                         break;
1004                 }
1005                 case RC_DEFAULT_LANGUAGE:
1006                         lexrc >> default_language;
1007                         break;
1008
1009                 case RC_LABEL_INIT_LENGTH:
1010                         lexrc >> label_init_length;
1011                         break;
1012
1013                 case RC_SHOW_BANNER:
1014                         lexrc >> show_banner;
1015                         break;
1016
1017                 case RC_PREVIEW:
1018                         if (lexrc.next()) {
1019                                 string const tmp = lexrc.getString();
1020                                 if (tmp == "true" || tmp == "on")
1021                                         preview = PREVIEW_ON;
1022                                 else if (tmp == "no_math")
1023                                         preview = PREVIEW_NO_MATH;
1024                                 else {
1025                                         preview = PREVIEW_OFF;
1026                                         if (tmp != "false" && tmp != "off")
1027                                                 lyxerr << "Unrecognized "
1028                                                         "preview status \""
1029                                                        << tmp << '\n' << endl;
1030                                 }
1031                         }
1032                         break;
1033
1034                 case RC_PREVIEW_HASHED_LABELS:
1035                         lexrc >> preview_hashed_labels;
1036                         break;
1037
1038                 case RC_PREVIEW_SCALE_FACTOR:
1039                         lexrc >> preview_scale_factor;
1040                         break;
1041
1042                 case RC_USER_NAME:
1043                         lexrc >> user_name;
1044                         break;
1045                 case RC_USER_EMAIL:
1046                         lexrc >> user_email;
1047                         break;
1048
1049                 case RC_PATH_PREFIX:
1050                         lexrc >> path_prefix;
1051                         break;
1052
1053                 case RC_USE_CONVERTER_CACHE:
1054                         lexrc >> use_converter_cache;
1055                         break;
1056                 case RC_CONVERTER_CACHE_MAXAGE:
1057                         lexrc >> converter_cache_maxage;
1058                         break;
1059
1060                 case RC_SORT_LAYOUTS:
1061                         lexrc >> sort_layouts;
1062                         break;
1063                 case RC_GROUP_LAYOUTS:
1064                         lexrc >> group_layouts;
1065                         break;
1066                 case RC_FULL_SCREEN_LIMIT:
1067                         lexrc >> full_screen_limit;
1068                         break;
1069                 case RC_FULL_SCREEN_TOOLBARS:
1070                         lexrc >> full_screen_toolbars;
1071                         break;
1072                 case RC_FULL_SCREEN_SCROLLBAR:
1073                         lexrc >> full_screen_scrollbar;
1074                         break;
1075                 case RC_FULL_SCREEN_TABBAR:
1076                         lexrc >> full_screen_tabbar;
1077                         break;
1078                 case RC_FULL_SCREEN_WIDTH:
1079                         lexrc >> full_screen_width;
1080                         break;
1081                 case RC_OPEN_BUFFERS_IN_TABS:
1082                         lexrc >> open_buffers_in_tabs;
1083                         break;
1084
1085                 case RC_LAST:
1086                         break; // this is just a dummy
1087                 }
1088         }
1089
1090         /// Update converters data-structures
1091         theConverters().update(formats);
1092         theConverters().buildGraph();
1093
1094         return 0;
1095 }
1096
1097
1098 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1099 {
1100         ofstream ofs(filename.toFilesystemEncoding().c_str());
1101         if (ofs)
1102                 write(ofs, ignore_system_lyxrc);
1103 }
1104
1105
1106 void LyXRC::print() const
1107 {
1108         if (lyxerr.debugging())
1109                 write(lyxerr, false);
1110         else
1111                 write(cout, false);
1112 }
1113
1114
1115 class SameMover {
1116 public:
1117         typedef pair<string, SpecialisedMover> Data;
1118
1119         SameMover(Data const & comparison)
1120                 : comparison_(comparison) {}
1121
1122         bool operator()(Data const & data) const
1123         {
1124                 return data.first == comparison_.first &&
1125                         data.second.command() == comparison_.second.command();
1126         }
1127
1128 private:
1129         Data comparison_;
1130 };
1131
1132
1133 namespace {
1134
1135         // Escape \ and " so that LyXLex can read the string later
1136         string escapeCommand(string const & str) {
1137                 return subst(subst(str , "\\", "\\\\"), 
1138                              "\"", "\\\"");
1139         }
1140
1141 }
1142
1143
1144 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1145 {
1146         LyXRCTags tag = RC_LAST;
1147         
1148         if (!name.empty()) {
1149                 for (int i = 0; i != lyxrcCount; ++i)
1150                         if ("\\" + name == lyxrcTags[i].tag)
1151                                 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1152         }
1153
1154         if (tag == RC_LAST)
1155                 os << "# This file is written by LyX, if you want to make your own\n"
1156                    << "# modifications you should do them from inside LyX and save\n"
1157                    << "\n";
1158
1159         // Why the switch you might ask. It is a trick to ensure that all
1160         // the elements in the LyXRCTags enum are handled. As you can see
1161         // there are no breaks at all. So it is just a huge fall-through.
1162         // The nice thing is that we will get a warning from the compiler
1163         // if we forget an element.
1164         switch (tag) {
1165         case RC_LAST:
1166         case RC_INPUT:
1167                 // input/include files are not done here
1168         case RC_BINDFILE:
1169                 if (ignore_system_lyxrc ||
1170                     bind_file != system_lyxrc.bind_file) {
1171                         string const path = os::external_path(bind_file);
1172                         os << "\\bind_file \"" << path << "\"\n";
1173                 }
1174                 if (tag != RC_LAST)
1175                         break;
1176
1177         case RC_DEFFILE:
1178                 if (ignore_system_lyxrc ||
1179                     def_file != system_lyxrc.def_file) {
1180                         string const path = os::external_path(def_file);
1181                         os << "\\def_file \"" << path << "\"\n";
1182                 }
1183                 if (tag != RC_LAST)
1184                         break;
1185
1186                 //
1187                 // Misc Section
1188                 //
1189                 os << "\n#\n"
1190                    << "# MISC SECTION ######################################\n"
1191                    << "#\n\n";
1192                 // bind files are not done here.
1193
1194         case RC_PATH_PREFIX:
1195                 if (ignore_system_lyxrc ||
1196                     path_prefix != system_lyxrc.path_prefix) {
1197                         os << "\\path_prefix \"" << path_prefix << "\"\n";
1198                 }
1199                 if (tag != RC_LAST)
1200                         break;
1201         case RC_UIFILE:
1202                 if (ignore_system_lyxrc ||
1203                     ui_file != system_lyxrc.ui_file) {
1204                         string const path = os::external_path(ui_file);
1205                         os << "\\ui_file \"" << path << "\"\n";
1206                 }
1207                 if (tag != RC_LAST)
1208                         break;
1209         case RC_AUTOREGIONDELETE:
1210                 if (ignore_system_lyxrc ||
1211                     auto_region_delete != system_lyxrc.auto_region_delete) {
1212                         os << "# Set to false to inhibit automatic replacement of\n"
1213                            << "# the current selection.\n"
1214                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1215                            << '\n';
1216                 }
1217                 if (tag != RC_LAST)
1218                         break;
1219         case RC_AUTORESET_OPTIONS:
1220                 if (ignore_system_lyxrc ||
1221                     auto_reset_options != system_lyxrc.auto_reset_options) {
1222                         os << "# Set to false to inhibit automatic reset of\n"
1223                            << "# the class options to defaults on class change.\n"
1224                            << "\\auto_reset_options "
1225                            << convert<string>(auto_reset_options)
1226                            << '\n';
1227                 }
1228                 if (tag != RC_LAST)
1229                         break;
1230         case RC_AUTOSAVE:
1231                 if (ignore_system_lyxrc ||
1232                     autosave != system_lyxrc.autosave) {
1233                         os << "# The time interval between auto-saves in seconds.\n"
1234                            << "\\autosave " << autosave << '\n';
1235                 }
1236                 if (tag != RC_LAST)
1237                         break;
1238         case RC_DISPLAY_GRAPHICS:
1239                 if (ignore_system_lyxrc ||
1240                     display_graphics != system_lyxrc.display_graphics) {
1241                         os << "# Display graphics within LyX\n"
1242                            << "# monochrome|grayscale|color|none\n"
1243                            << "\\display_graphics "
1244                            << graphics::displayTranslator().find(
1245                                  graphics::DisplayType(display_graphics))
1246                            << '\n';
1247                 }
1248                 if (tag != RC_LAST)
1249                         break;
1250         case RC_SORT_LAYOUTS:
1251                 if (ignore_system_lyxrc ||
1252                     sort_layouts != system_lyxrc.sort_layouts) {
1253                         os << "# Sort layouts alphabetically.\n"
1254                            << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
1255                 }
1256                 if (tag != RC_LAST)
1257                         break;
1258         case RC_GROUP_LAYOUTS:
1259                 if (ignore_system_lyxrc ||
1260                     group_layouts != system_lyxrc.group_layouts) {
1261                         os << "# Group layouts by their category.\n"
1262                            << "\\group_layouts " << convert<string>(group_layouts) << '\n';
1263                 }
1264                 if (tag != RC_LAST)
1265                         break;
1266         case RC_VIEWDVI_PAPEROPTION:
1267                 if (ignore_system_lyxrc ||
1268                     view_dvi_paper_option
1269                     != system_lyxrc.view_dvi_paper_option) {
1270                         os << "# Options used to specify paper size to the\n"
1271                            << "# view_dvi_command (e.g. -paper)\n"
1272                            << "\\view_dvi_paper_option \""
1273                            << view_dvi_paper_option << "\"\n";
1274                 }
1275                 if (tag != RC_LAST)
1276                         break;
1277         case RC_DEFAULT_PAPERSIZE:
1278                 if (ignore_system_lyxrc ||
1279                     default_papersize != system_lyxrc.default_papersize) {
1280                         os << "# The default papersize to use.\n"
1281                            << "\\default_papersize \"";
1282                         switch (default_papersize) {
1283                         case PAPER_DEFAULT:
1284                                 os << "default"; break;
1285                         case PAPER_USLETTER:
1286                                 os << "usletter"; break;
1287                         case PAPER_USLEGAL:
1288                                 os << "legal"; break;
1289                         case PAPER_USEXECUTIVE:
1290                                 os << "executive"; break;
1291                         case PAPER_A3:
1292                                 os << "a3"; break;
1293                         case PAPER_A4:
1294                                 os << "a4"; break;
1295                         case PAPER_A5:
1296                                 os << "a5"; break;
1297                         case PAPER_B5:
1298                                 os << "b5"; break;
1299                         case PAPER_CUSTOM:
1300                         case PAPER_B3:
1301                         case PAPER_B4: break;
1302                         }
1303                         os << "\"\n";
1304                 }
1305                 if (tag != RC_LAST)
1306                         break;
1307         case RC_CHKTEX_COMMAND:
1308                 if (ignore_system_lyxrc ||
1309                     chktex_command != system_lyxrc.chktex_command) {
1310                         os << "\\chktex_command \"" << escapeCommand(chktex_command) << "\"\n";
1311                 }
1312                 if (tag != RC_LAST)
1313                         break;
1314         case RC_BIBTEX_COMMAND:
1315                 if (ignore_system_lyxrc ||
1316                     bibtex_command != system_lyxrc.bibtex_command) {
1317                         os << "\\bibtex_command \"" << escapeCommand(bibtex_command) << "\"\n";
1318                 }
1319                 if (tag != RC_LAST)
1320                         break;
1321         case RC_INDEX_COMMAND:
1322                 if (ignore_system_lyxrc ||
1323                     index_command != system_lyxrc.index_command) {
1324                         os << "\\index_command \"" << escapeCommand(index_command) << "\"\n";
1325                 }
1326                 if (tag != RC_LAST)
1327                         break;
1328         case RC_TEX_EXPECTS_WINDOWS_PATHS:
1329                 if (ignore_system_lyxrc ||
1330                     windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1331                         os << "\\tex_expects_windows_paths "
1332                            << convert<string>(windows_style_tex_paths) << '\n';
1333                 }
1334                 if (tag != RC_LAST)
1335                         break;
1336         case RC_TEX_ALLOWS_SPACES:
1337                 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1338                         os << "\\tex_allows_spaces "
1339                            << convert<string>(tex_allows_spaces) << '\n';
1340                 }
1341                 if (tag != RC_LAST)
1342                         break;
1343         case RC_KBMAP:
1344                 if (ignore_system_lyxrc ||
1345                     use_kbmap != system_lyxrc.use_kbmap) {
1346                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1347                 }
1348                 if (tag != RC_LAST)
1349                         break;
1350         case RC_KBMAP_PRIMARY:
1351                 if (ignore_system_lyxrc ||
1352                     primary_kbmap != system_lyxrc.primary_kbmap) {
1353                         string const path = os::external_path(primary_kbmap);
1354                         os << "\\kbmap_primary \"" << path << "\"\n";
1355                 }
1356                 if (tag != RC_LAST)
1357                         break;
1358         case RC_KBMAP_SECONDARY:
1359                 if (ignore_system_lyxrc ||
1360                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1361                         string const path = os::external_path(secondary_kbmap);
1362                         os << "\\kbmap_secondary \"" << path << "\"\n";
1363                 }
1364                 if (tag != RC_LAST)
1365                         break;
1366         case RC_SERVERPIPE:
1367                 if (ignore_system_lyxrc ||
1368                     lyxpipes != system_lyxrc.lyxpipes) {
1369                         string const path = os::external_path(lyxpipes);
1370                         os << "\\serverpipe \"" << path << "\"\n";
1371                 }
1372                 if (tag != RC_LAST)
1373                         break;
1374         case RC_DATE_INSERT_FORMAT:
1375                 if (ignore_system_lyxrc ||
1376                     date_insert_format != system_lyxrc.date_insert_format) {
1377                         os << "\\date_insert_format \"" << date_insert_format
1378                            << "\"\n";
1379                 }
1380                 if (tag != RC_LAST)
1381                         break;
1382         case RC_LABEL_INIT_LENGTH:
1383                 if (ignore_system_lyxrc ||
1384                     label_init_length != system_lyxrc.label_init_length) {
1385                         os << "\\label_init_length " << label_init_length
1386                            << '\n';
1387                 }
1388                 if (tag != RC_LAST)
1389                         break;
1390
1391         case RC_USER_NAME:
1392                 os << "\\user_name \"" << user_name << "\"\n";
1393                 if (tag != RC_LAST)
1394                         break;
1395
1396         case RC_USER_EMAIL:
1397                 os << "\\user_email \"" << user_email << "\"\n";
1398                 if (tag != RC_LAST)
1399                         break;
1400
1401         case RC_SHOW_BANNER:
1402                 if (ignore_system_lyxrc ||
1403                     show_banner != system_lyxrc.show_banner) {
1404                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1405                 }
1406                 if (tag != RC_LAST)
1407                         break;
1408
1409         case RC_PREVIEW:
1410                 if (ignore_system_lyxrc ||
1411                     preview != system_lyxrc.preview) {
1412                         string status;
1413                         switch (preview) {
1414                         case PREVIEW_ON:
1415                                 status = "on";
1416                                 break;
1417                         case PREVIEW_NO_MATH:
1418                                 status = "no_math";
1419                                 break;
1420                         case PREVIEW_OFF:
1421                                 status = "off";
1422                                 break;
1423                         }
1424                         os << "\\preview " << status << '\n';
1425                 }
1426                 if (tag != RC_LAST)
1427                         break;
1428
1429         case RC_PREVIEW_HASHED_LABELS:
1430                 if (ignore_system_lyxrc ||
1431                     preview_hashed_labels !=
1432                     system_lyxrc.preview_hashed_labels) {
1433                         os << "\\preview_hashed_labels "
1434                            << convert<string>(preview_hashed_labels) << '\n';
1435                 }
1436                 if (tag != RC_LAST)
1437                         break;
1438
1439         case RC_PREVIEW_SCALE_FACTOR:
1440                 if (ignore_system_lyxrc ||
1441                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1442                         os << "\\preview_scale_factor "
1443                            << preview_scale_factor << '\n';
1444                 }
1445                 if (tag != RC_LAST)
1446                         break;
1447
1448         case RC_USE_CONVERTER_CACHE:
1449                 if (ignore_system_lyxrc ||
1450                     use_converter_cache != system_lyxrc.use_converter_cache) {
1451                         os << "\\use_converter_cache "
1452                            << convert<string>(use_converter_cache) << '\n';
1453                 }
1454                 if (tag != RC_LAST)
1455                         break;
1456
1457         case RC_CONVERTER_CACHE_MAXAGE:
1458                 if (ignore_system_lyxrc ||
1459                     converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1460                         os << "\\converter_cache_maxage "
1461                            << converter_cache_maxage << '\n';
1462                 }
1463                 if (tag != RC_LAST)
1464                         break;
1465
1466                 os << "\n#\n"
1467                    << "# SCREEN & FONTS SECTION ############################\n"
1468                    << "#\n\n";
1469
1470         case RC_SCREEN_DPI:
1471                 if (ignore_system_lyxrc ||
1472                     dpi != system_lyxrc.dpi) {
1473                         os << "\\screen_dpi " << dpi << '\n';
1474                 }
1475                 if (tag != RC_LAST)
1476                         break;
1477         case RC_SCREEN_ZOOM:
1478                 if (ignore_system_lyxrc ||
1479                     zoom != system_lyxrc.zoom) {
1480                         os << "\\screen_zoom " << zoom << '\n';
1481                 }
1482                 if (tag != RC_LAST)
1483                         break;
1484         case RC_GEOMETRY_SESSION:
1485                 if (ignore_system_lyxrc ||
1486                     allow_geometry_session != system_lyxrc.allow_geometry_session) {
1487                         os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
1488                            << '\n';
1489                 }
1490                 if (tag != RC_LAST)
1491                         break;
1492         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1493                 if (ignore_system_lyxrc ||
1494                     cursor_follows_scrollbar
1495                     != system_lyxrc.cursor_follows_scrollbar) {
1496                         os << "\\cursor_follows_scrollbar "
1497                            << convert<string>(cursor_follows_scrollbar) << '\n';
1498                 }
1499                 if (tag != RC_LAST)
1500                         break;
1501         case RC_MACRO_EDIT_STYLE:
1502                 if (ignore_system_lyxrc ||
1503                     macro_edit_style
1504                     != system_lyxrc.macro_edit_style) {
1505                         os << "\\macro_edit_style ";
1506                         switch (macro_edit_style) {
1507                         case MACRO_EDIT_INLINE_BOX: os << "0\n"; break;
1508                         case MACRO_EDIT_INLINE: os << "1\n"; break;
1509                         case MACRO_EDIT_LIST: os << "2\n"; break;
1510                         }
1511                 }
1512                 if (tag != RC_LAST)
1513                         break;
1514         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1515                 if (ignore_system_lyxrc ||
1516                     dialogs_iconify_with_main
1517                    != system_lyxrc.dialogs_iconify_with_main) {
1518                         os << "\\dialogs_iconify_with_main "
1519                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1520                 }
1521                 if (tag != RC_LAST)
1522                         break;
1523         case RC_SCREEN_FONT_ROMAN:
1524                 if (ignore_system_lyxrc ||
1525                     roman_font_name != system_lyxrc.roman_font_name) {
1526                         os << "\\screen_font_roman \"" << roman_font_name
1527                            << "\"\n";
1528                 }
1529                 if (tag != RC_LAST)
1530                         break;
1531         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1532                 if (ignore_system_lyxrc ||
1533                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1534                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1535                            << "\"\n";
1536                 }
1537                 if (tag != RC_LAST)
1538                         break;
1539         case RC_SCREEN_FONT_SANS:
1540                 if (ignore_system_lyxrc ||
1541                     sans_font_name != system_lyxrc.sans_font_name) {
1542                         os << "\\screen_font_sans \"" << sans_font_name
1543                            << "\"\n";
1544                 }
1545                 if (tag != RC_LAST)
1546                         break;
1547         case RC_SCREEN_FONT_SANS_FOUNDRY:
1548                 if (ignore_system_lyxrc ||
1549                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1550                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1551                            << "\"\n";
1552                 }
1553                 if (tag != RC_LAST)
1554                         break;
1555         case RC_SCREEN_FONT_TYPEWRITER:
1556                 if (ignore_system_lyxrc ||
1557                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1558                         os << "\\screen_font_typewriter \""
1559                            << typewriter_font_name << "\"\n";
1560                 }
1561                 if (tag != RC_LAST)
1562                         break;
1563         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1564                 if (ignore_system_lyxrc ||
1565                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1566                         os << "\\screen_font_typewriter_foundry \""
1567                            << typewriter_font_foundry << "\"\n";
1568                 }
1569                 if (tag != RC_LAST)
1570                         break;
1571
1572         case RC_SCREEN_FONT_SCALABLE:
1573                 if (ignore_system_lyxrc ||
1574                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1575                         os << "\\screen_font_scalable "
1576                            << convert<string>(use_scalable_fonts)
1577                            << '\n';
1578                 }
1579                 if (tag != RC_LAST)
1580                         break;
1581         case RC_SCREEN_FONT_SIZES:
1582                 if (ignore_system_lyxrc ||
1583                     font_sizes[FONT_SIZE_TINY]
1584                     != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
1585                     font_sizes[FONT_SIZE_SCRIPT]
1586                     != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
1587                     font_sizes[FONT_SIZE_FOOTNOTE]
1588                     != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
1589                     font_sizes[FONT_SIZE_SMALL]
1590                     != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
1591                     font_sizes[FONT_SIZE_NORMAL]
1592                     != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
1593                     font_sizes[FONT_SIZE_LARGE]
1594                     != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
1595                     font_sizes[FONT_SIZE_LARGER]
1596                     != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
1597                     font_sizes[FONT_SIZE_LARGEST]
1598                     != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
1599                     font_sizes[FONT_SIZE_HUGE]
1600                     != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
1601                     font_sizes[FONT_SIZE_HUGER]
1602                     != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
1603                         os.setf(ios::fixed);
1604                         os.precision(2);
1605                         os << "\\screen_font_sizes"
1606                            << ' ' << font_sizes[FONT_SIZE_TINY]
1607                            << ' ' << font_sizes[FONT_SIZE_SCRIPT]
1608                            << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
1609                            << ' ' << font_sizes[FONT_SIZE_SMALL]
1610                            << ' ' << font_sizes[FONT_SIZE_NORMAL]
1611                            << ' ' << font_sizes[FONT_SIZE_LARGE]
1612                            << ' ' << font_sizes[FONT_SIZE_LARGER]
1613                            << ' ' << font_sizes[FONT_SIZE_LARGEST]
1614                            << ' ' << font_sizes[FONT_SIZE_HUGE]
1615                            << ' ' << font_sizes[FONT_SIZE_HUGER]
1616                            << '\n';
1617                 }
1618                 if (tag != RC_LAST)
1619                         break;
1620         case RC_FULL_SCREEN_LIMIT:
1621                 if (ignore_system_lyxrc ||
1622                     full_screen_limit != system_lyxrc.full_screen_limit) {
1623                         os << "\\fullscreen_limit "
1624                            << convert<string>(full_screen_limit)
1625                            << '\n';
1626                 }
1627                 if (tag != RC_LAST)
1628                         break;
1629         case RC_FULL_SCREEN_TOOLBARS:
1630                 if (ignore_system_lyxrc ||
1631                     full_screen_toolbars != system_lyxrc.full_screen_toolbars) {
1632                         os << "\\fullscreen_toolbars "
1633                            << convert<string>(full_screen_toolbars)
1634                            << '\n';
1635                 }
1636                 if (tag != RC_LAST)
1637                         break;
1638         case RC_FULL_SCREEN_SCROLLBAR:
1639                 if (ignore_system_lyxrc ||
1640                     full_screen_scrollbar != system_lyxrc.full_screen_scrollbar) {
1641                         os << "\\fullscreen_scrollbar "
1642                            << convert<string>(full_screen_scrollbar)
1643                            << '\n';
1644                 }
1645                 if (tag != RC_LAST)
1646                         break;
1647         case RC_FULL_SCREEN_TABBAR:
1648                 if (ignore_system_lyxrc ||
1649                     full_screen_tabbar != system_lyxrc.full_screen_tabbar) {
1650                         os << "\\fullscreen_tabbar "
1651                            << convert<string>(full_screen_tabbar)
1652                            << '\n';
1653                 }
1654                 if (tag != RC_LAST)
1655                         break;
1656         case RC_FULL_SCREEN_WIDTH:
1657                 if (ignore_system_lyxrc ||
1658                     full_screen_width != system_lyxrc.full_screen_width) {
1659                         os << "\\fullscreen_width "
1660                            << convert<string>(full_screen_width)
1661                            << '\n';
1662                 }
1663                 if (tag != RC_LAST)
1664                         break;
1665         case RC_OPEN_BUFFERS_IN_TABS:
1666                 if (ignore_system_lyxrc ||
1667                     open_buffers_in_tabs != system_lyxrc.open_buffers_in_tabs) {
1668                         os << "\\open_buffers_in_tabs "
1669                            << convert<string>(open_buffers_in_tabs)
1670                            << '\n';
1671                 }
1672                 if (tag != RC_LAST)
1673                         break;
1674
1675         os << "\n#\n"
1676                         << "# COLOR SECTION ###################################\n"
1677                         << "#\n\n";
1678
1679         case RC_SET_COLOR:
1680                 for (int i = 0; i < Color_ignore; ++i) {
1681                         ColorCode lc = static_cast<ColorCode>(i);
1682
1683                         string const col(lcolor.getX11Name(lc));
1684                         if (ignore_system_lyxrc ||
1685                             col != system_lcolor.getX11Name(lc)) {
1686                                 os << "\\set_color \""
1687                                    << lcolor.getLyXName(lc) << "\" \""
1688                                    << col << "\"\n";
1689                         }
1690                 }
1691                 if (tag != RC_LAST)
1692                         break;
1693
1694                 os << "\n#\n"
1695                    << "# PRINTER SECTION ###################################\n"
1696                    << "#\n\n";
1697
1698         case RC_PRINTER:
1699                 if (ignore_system_lyxrc ||
1700                     printer != system_lyxrc.printer) {
1701                         os << "\\printer \"" << printer << "\"\n";
1702                 }
1703                 if (tag != RC_LAST)
1704                         break;
1705         case RC_PRINT_ADAPTOUTPUT:
1706                 if (ignore_system_lyxrc ||
1707                     print_adapt_output != system_lyxrc.print_adapt_output) {
1708                         os << "\\print_adapt_output "
1709                            << convert<string>(print_adapt_output)
1710                            << '\n';
1711                 }
1712                 if (tag != RC_LAST)
1713                         break;
1714         case RC_PRINT_COMMAND:
1715                 if (ignore_system_lyxrc ||
1716                     print_command != system_lyxrc.print_command) {
1717                         os << "\\print_command \"" << escapeCommand(print_command) << "\"\n";
1718                 }
1719                 if (tag != RC_LAST)
1720                         break;
1721         case RC_PRINTEXSTRAOPTIONS:
1722                 if (ignore_system_lyxrc ||
1723                     print_extra_options != system_lyxrc.print_extra_options) {
1724                         os << "\\print_extra_options \"" << print_extra_options
1725                            << "\"\n";
1726                 }
1727                 if (tag != RC_LAST)
1728                         break;
1729         case RC_PRINTSPOOL_COMMAND:
1730                 if (ignore_system_lyxrc ||
1731                     print_spool_command != system_lyxrc.print_spool_command) {
1732                         os << "\\print_spool_command \"" << escapeCommand(print_spool_command)
1733                            << "\"\n";
1734                 }
1735                 if (tag != RC_LAST)
1736                         break;
1737         case RC_PRINTSPOOL_PRINTERPREFIX:
1738                 if (ignore_system_lyxrc ||
1739                     print_spool_printerprefix
1740                     != system_lyxrc.print_spool_printerprefix) {
1741                         os << "\\print_spool_printerprefix \""
1742                            << print_spool_printerprefix << "\"\n";
1743                 }
1744                 if (tag != RC_LAST)
1745                         break;
1746         case RC_PRINTEVENPAGEFLAG:
1747                 if (ignore_system_lyxrc ||
1748                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
1749                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
1750                            << "\"\n";
1751                 }
1752                 if (tag != RC_LAST)
1753                         break;
1754         case RC_PRINTODDPAGEFLAG:
1755                 if (ignore_system_lyxrc ||
1756                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
1757                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
1758                            << "\"\n";
1759                 }
1760                 if (tag != RC_LAST)
1761                         break;
1762         case RC_PRINTREVERSEFLAG:
1763                 if (ignore_system_lyxrc ||
1764                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
1765                         os << "\\print_reverse_flag \"" << print_reverse_flag
1766                            << "\"\n";
1767                 }
1768                 if (tag != RC_LAST)
1769                         break;
1770         case RC_PRINTLANDSCAPEFLAG:
1771                 if (ignore_system_lyxrc ||
1772                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
1773                         os << "\\print_landscape_flag \"" << print_landscape_flag
1774                            << "\"\n";
1775                 }
1776                 if (tag != RC_LAST)
1777                         break;
1778         case RC_PRINTPAGERANGEFLAG:
1779                 if (ignore_system_lyxrc ||
1780                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
1781                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
1782                            << "\"\n";
1783                 }
1784                 if (tag != RC_LAST)
1785                         break;
1786         case RC_PRINTCOPIESFLAG:
1787                 if (ignore_system_lyxrc ||
1788                     print_copies_flag != system_lyxrc.print_copies_flag) {
1789                         os << "\\print_copies_flag \"" << print_copies_flag
1790                            << "\"\n";
1791                 }
1792                 if (tag != RC_LAST)
1793                         break;
1794         case RC_PRINTCOLLCOPIESFLAG:
1795                 if (ignore_system_lyxrc ||
1796                     print_collcopies_flag
1797                     != system_lyxrc.print_collcopies_flag) {
1798                         os << "\\print_collcopies_flag \""
1799                            << print_collcopies_flag
1800                            << "\"\n";
1801                 }
1802                 if (tag != RC_LAST)
1803                         break;
1804         case RC_PRINTPAPERFLAG:
1805                 if (ignore_system_lyxrc ||
1806                     print_paper_flag != system_lyxrc.print_paper_flag) {
1807                         os << "\\print_paper_flag \"" << print_paper_flag
1808                            << "\"\n";
1809                 }
1810                 if (tag != RC_LAST)
1811                         break;
1812         case RC_PRINTPAPERDIMENSIONFLAG:
1813                 if (ignore_system_lyxrc ||
1814                     print_paper_dimension_flag
1815                     != system_lyxrc.print_paper_dimension_flag) {
1816                         os << "\\print_paper_dimension_flag \""
1817                            << print_paper_dimension_flag << "\"\n";
1818                 }
1819                 if (tag != RC_LAST)
1820                         break;
1821         case RC_PRINTTOPRINTER:
1822                 if (ignore_system_lyxrc ||
1823                     print_to_printer != system_lyxrc.print_to_printer) {
1824                         os << "\\print_to_printer \"" << print_to_printer
1825                            << "\"\n";
1826                 }
1827                 if (tag != RC_LAST)
1828                         break;
1829         case RC_PRINTTOFILE:
1830                 if (ignore_system_lyxrc ||
1831                     print_to_file != system_lyxrc.print_to_file) {
1832                         string const path = os::external_path(print_to_file);
1833                         os << "\\print_to_file \"" << path << "\"\n";
1834                 }
1835                 if (tag != RC_LAST)
1836                         break;
1837         case RC_PRINTFILEEXTENSION:
1838                 if (ignore_system_lyxrc ||
1839                     print_file_extension != system_lyxrc.print_file_extension) {
1840                         os << "\\print_file_extension \""
1841                            << print_file_extension
1842                            << "\"\n";
1843                 }
1844                 if (tag != RC_LAST)
1845                         break;
1846
1847                 os << "\n#\n"
1848                    << "# EXPORT SECTION ####################################\n"
1849                    << "#\n\n";
1850
1851         case RC_CUSTOM_EXPORT_COMMAND:
1852                 if (ignore_system_lyxrc ||
1853                     custom_export_command
1854                     != system_lyxrc.custom_export_command) {
1855                         os << "\\custom_export_command \""
1856                            << custom_export_command
1857                            << "\"\n";
1858                 }
1859                 if (tag != RC_LAST)
1860                         break;
1861         case RC_CUSTOM_EXPORT_FORMAT:
1862                 if (ignore_system_lyxrc ||
1863                     custom_export_format
1864                     != system_lyxrc.custom_export_format) {
1865                         os << "\\custom_export_format \"" << custom_export_format
1866                            << "\"\n";
1867                 }
1868                 if (tag != RC_LAST)
1869                         break;
1870
1871                 os << "\n#\n"
1872                    << "# TEX SECTION #######################################\n"
1873                    << "#\n\n";
1874
1875         case RC_FONT_ENCODING:
1876                 if (ignore_system_lyxrc ||
1877                     fontenc != system_lyxrc.fontenc) {
1878                         os << "\\font_encoding \"" << fontenc << "\"\n";
1879                 }
1880                 if (tag != RC_LAST)
1881                         break;
1882
1883                 os << "\n#\n"
1884                    << "# FILE SECTION ######################################\n"
1885                    << "#\n\n";
1886
1887         case RC_DOCUMENTPATH:
1888                 if (ignore_system_lyxrc ||
1889                     document_path != system_lyxrc.document_path) {
1890                         string const path = os::external_path(document_path);
1891                         os << "\\document_path \"" << path << "\"\n";
1892                 }
1893                 if (tag != RC_LAST)
1894                         break;
1895         case RC_USELASTFILEPOS:
1896                 if (ignore_system_lyxrc ||
1897                     use_lastfilepos != system_lyxrc.use_lastfilepos) {
1898                         os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
1899                            << '\n';
1900                 }
1901                 if (tag != RC_LAST)
1902                         break;
1903         case RC_LOADSESSION:
1904                 if (ignore_system_lyxrc ||
1905                     load_session != system_lyxrc.load_session) {
1906                         os << "\\load_session " << convert<string>(load_session)
1907                            << "\n";
1908                 }
1909                 if (tag != RC_LAST)
1910                         break;
1911         case RC_MOUSE_WHEEL_SPEED:
1912                 if (ignore_system_lyxrc ||
1913                     mouse_wheel_speed != system_lyxrc.mouse_wheel_speed) {
1914                         os << "\\mouse_wheel_speed " << mouse_wheel_speed << '\n';
1915                 }
1916                 if (tag != RC_LAST)
1917                         break;
1918         case RC_COMPLETION_INLINE_DELAY:
1919                 if (ignore_system_lyxrc ||
1920                     completion_inline_delay != system_lyxrc.completion_inline_delay) {
1921                         os << "\\completion_inline_delay " << completion_inline_delay << '\n';
1922                 }
1923                 if (tag != RC_LAST)
1924                         break;
1925         case RC_COMPLETION_INLINE_MATH:
1926                 if (ignore_system_lyxrc ||
1927                     completion_inline_math != system_lyxrc.completion_inline_math) {
1928                         os << "\\completion_inline_math "
1929                                 << convert<string>(completion_inline_math) << '\n';
1930                 }
1931                 if (tag != RC_LAST)
1932                         break;
1933         case RC_COMPLETION_INLINE_TEXT:
1934                 if (ignore_system_lyxrc ||
1935                     completion_inline_text != system_lyxrc.completion_inline_text) {
1936                         os << "\\completion_inline_text "
1937                                 << convert<string>(completion_inline_text) << '\n';
1938                 }
1939                 if (tag != RC_LAST)
1940                         break;
1941         case RC_COMPLETION_INLINE_DOTS:
1942                 if (ignore_system_lyxrc ||
1943                     completion_inline_dots != system_lyxrc.completion_inline_dots) {
1944                         os << "\\completion_inline_dots "
1945                                 << convert<string>(completion_inline_dots) << '\n';
1946                 }
1947                 if (tag != RC_LAST)
1948                         break;
1949         case RC_COMPLETION_POPUP_DELAY:
1950                 if (ignore_system_lyxrc ||
1951                     completion_popup_delay != system_lyxrc.completion_popup_delay) {
1952                         os << "\\completion_popup_delay " << completion_popup_delay << '\n';
1953                 }
1954                 if (tag != RC_LAST)
1955                         break;
1956         case RC_COMPLETION_POPUP_MATH:
1957                 if (ignore_system_lyxrc ||
1958                     completion_popup_math != system_lyxrc.completion_popup_math) {
1959                         os << "\\completion_popup_math "
1960                                 << convert<string>(completion_popup_math) << '\n';
1961                 }
1962                 if (tag != RC_LAST)
1963                         break;
1964         case RC_COMPLETION_POPUP_TEXT:
1965                 if (ignore_system_lyxrc ||
1966                     completion_popup_text != system_lyxrc.completion_popup_text) {
1967                         os << "\\completion_popup_text "
1968                                 << convert<string>(completion_popup_text) << '\n';
1969                 }
1970                 if (tag != RC_LAST)
1971                         break;
1972         case RC_COMPLETION_CURSOR_TEXT:
1973                 if (ignore_system_lyxrc ||
1974                     completion_cursor_text != system_lyxrc.completion_cursor_text) {
1975                         os << "\\completion_cursor_text "
1976                            << convert<string>(completion_cursor_text) << '\n';
1977                 }
1978                 if (tag != RC_LAST)
1979                         break;
1980         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
1981                 if (ignore_system_lyxrc ||
1982                     completion_popup_after_complete
1983                     != system_lyxrc.completion_popup_after_complete) {
1984                         os << "\\completion_popup_after_complete "
1985                                 << convert<string>(completion_popup_after_complete) << '\n';
1986                 }
1987                 if (tag != RC_LAST)
1988                         break;
1989         case RC_NUMLASTFILES:
1990                 if (ignore_system_lyxrc ||
1991                     num_lastfiles != system_lyxrc.num_lastfiles) {
1992                         os << "\\num_lastfiles " << num_lastfiles << '\n';
1993                 }
1994                 if (tag != RC_LAST)
1995                         break;
1996         case RC_CHECKLASTFILES:
1997                 if (ignore_system_lyxrc ||
1998                     check_lastfiles != system_lyxrc.check_lastfiles) {
1999                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
2000                            << '\n';
2001                 }
2002                 if (tag != RC_LAST)
2003                         break;
2004         case RC_EXAMPLEPATH:
2005                 if (ignore_system_lyxrc ||
2006                     example_path != system_lyxrc.example_path) {
2007                         string const path = os::external_path(example_path);
2008                         os << "\\example_path \"" << path << "\"\n";
2009                 }
2010                 if (tag != RC_LAST)
2011                         break;
2012         case RC_TEMPLATEPATH:
2013                 if (ignore_system_lyxrc ||
2014                     template_path != system_lyxrc.template_path) {
2015                         string const path = os::external_path(template_path);
2016                         os << "\\template_path \"" << path << "\"\n";
2017                 }
2018                 if (tag != RC_LAST)
2019                         break;
2020         case RC_TEMPDIRPATH:
2021                 if (ignore_system_lyxrc ||
2022                     tempdir_path != system_lyxrc.tempdir_path) {
2023                         string const path = os::external_path(tempdir_path);
2024                         os << "\\tempdir_path \"" << path << "\"\n";
2025                 }
2026                 if (tag != RC_LAST)
2027                         break;
2028         case RC_USETEMPDIR:
2029                 if (tag != RC_LAST)
2030                         break;
2031                 // Ignore it
2032         case RC_PLAINTEXT_LINELEN:
2033                 if (ignore_system_lyxrc ||
2034                     plaintext_linelen != system_lyxrc.plaintext_linelen) {
2035                         os << "\\plaintext_linelen " << plaintext_linelen << '\n';
2036                 }
2037                 if (tag != RC_LAST)
2038                         break;
2039         case RC_MAKE_BACKUP:
2040                 if (ignore_system_lyxrc ||
2041                     make_backup != system_lyxrc.make_backup) {
2042                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
2043                 }
2044                 if (tag != RC_LAST)
2045                         break;
2046         case RC_BACKUPDIR_PATH:
2047                 if (ignore_system_lyxrc ||
2048                     backupdir_path != system_lyxrc.backupdir_path) {
2049                         string const path = os::external_path(backupdir_path);
2050                         os << "\\backupdir_path \"" << path << "\"\n";
2051                 }
2052                 if (tag != RC_LAST)
2053                         break;
2054
2055                 os << "\n#\n"
2056                    << "# PLAIN TEXT EXPORT SECTION ##############################\n"
2057                    << "#\n\n";
2058
2059         case RC_PLAINTEXT_ROFF_COMMAND:
2060                 if (ignore_system_lyxrc ||
2061                     plaintext_roff_command != system_lyxrc.plaintext_roff_command) {
2062                         os << "\\plaintext_roff_command \"" << escapeCommand(plaintext_roff_command)
2063                            << "\"\n";
2064                 }
2065                 if (tag != RC_LAST)
2066                         break;
2067
2068                 os << "\n#\n"
2069                    << "# SPELLCHECKER SECTION ##############################\n"
2070                    << "#\n\n";
2071         case RC_USE_SPELL_LIB:
2072                 if (ignore_system_lyxrc ||
2073                     use_spell_lib != system_lyxrc.use_spell_lib) {
2074                         os << "\\use_spell_lib " << convert<string>(use_spell_lib) << '\n';
2075                 }
2076                 if (tag != RC_LAST)
2077                         break;
2078         case RC_SPELL_COMMAND:
2079                 if (ignore_system_lyxrc ||
2080                     isp_command != system_lyxrc.isp_command) {
2081                         os << "\\spell_command \"" << escapeCommand(isp_command) << "\"\n";
2082                 }
2083                 if (tag != RC_LAST)
2084                         break;
2085         case RC_ACCEPT_COMPOUND:
2086                 if (ignore_system_lyxrc ||
2087                     isp_accept_compound != system_lyxrc.isp_accept_compound) {
2088                         os << "\\accept_compound " << convert<string>(isp_accept_compound)
2089                            << '\n';
2090                 }
2091                 if (tag != RC_LAST)
2092                         break;
2093         case RC_USE_ALT_LANG:
2094                 if (ignore_system_lyxrc ||
2095                     isp_use_alt_lang != system_lyxrc.isp_use_alt_lang) {
2096                         os << "\\use_alt_language " << convert<string>(isp_use_alt_lang)
2097                            << '\n';
2098                 }
2099                 if (tag != RC_LAST)
2100                         break;
2101         case RC_ALT_LANG:
2102                 if (ignore_system_lyxrc ||
2103                     isp_alt_lang != system_lyxrc.isp_alt_lang) {
2104                         os << "\\alternate_language \"" << isp_alt_lang
2105                            << "\"\n";
2106                 }
2107                 if (tag != RC_LAST)
2108                         break;
2109         case RC_USE_ESC_CHARS:
2110                 if (ignore_system_lyxrc ||
2111                     isp_use_esc_chars != system_lyxrc.isp_use_esc_chars) {
2112                         os << "\\use_escape_chars " << convert<string>(isp_use_esc_chars)
2113                            << '\n';
2114                 }
2115                 if (tag != RC_LAST)
2116                         break;
2117         case RC_ESC_CHARS:
2118                 if (ignore_system_lyxrc ||
2119                     isp_esc_chars != system_lyxrc.isp_esc_chars) {
2120                         os << "\\escape_chars \"" << isp_esc_chars << "\"\n";
2121                 }
2122                 if (tag != RC_LAST)
2123                         break;
2124         case RC_USE_PERS_DICT:
2125                 if (ignore_system_lyxrc ||
2126                     isp_use_pers_dict != system_lyxrc.isp_use_pers_dict) {
2127                         os << "\\use_personal_dictionary "
2128                            << convert<string>(isp_use_pers_dict)
2129                            << '\n';
2130                 }
2131                 if (tag != RC_LAST)
2132                         break;
2133         case RC_USE_TOOLTIP:
2134                 if (ignore_system_lyxrc ||
2135                     use_tooltip != system_lyxrc.use_tooltip) {
2136                         os << "\\use_tooltip "
2137                            << convert<string>(use_tooltip)
2138                            << '\n';
2139                 }
2140         case RC_USE_PIXMAP_CACHE:
2141                 if (ignore_system_lyxrc ||
2142                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2143                         os << "\\use_pixmap_cache "
2144                            << convert<string>(use_pixmap_cache)
2145                            << '\n';
2146                 }
2147         case RC_PERS_DICT:
2148                 if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
2149                         string const path = os::external_path(isp_pers_dict);
2150                         os << "\\personal_dictionary \"" << path << "\"\n";
2151                 }
2152                 if (tag != RC_LAST)
2153                         break;
2154         case RC_USE_INP_ENC:
2155                 if (ignore_system_lyxrc ||
2156                     isp_use_input_encoding
2157                     != system_lyxrc.isp_use_input_encoding) {
2158                         os << "\\use_input_encoding "
2159                            << convert<string>(isp_use_input_encoding)
2160                            << '\n';
2161                 }
2162                 if (tag != RC_LAST)
2163                         break;
2164
2165                 os << "\n#\n"
2166                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2167                    << "#\n\n";
2168
2169         case RC_RTL_SUPPORT:
2170                 if (ignore_system_lyxrc ||
2171                     rtl_support != system_lyxrc.rtl_support) {
2172                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
2173                 }
2174                 if (tag != RC_LAST)
2175                         break;
2176         case RC_VISUAL_CURSOR:
2177                 if (ignore_system_lyxrc ||
2178                         visual_cursor != system_lyxrc.visual_cursor) {
2179                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2180                 }
2181                 if (tag != RC_LAST)
2182                         break;
2183         case RC_LANGUAGE_PACKAGE:
2184                 if (ignore_system_lyxrc ||
2185                     language_package != system_lyxrc.language_package) {
2186                         os << "\\language_package \"" << language_package
2187                            << "\"\n";
2188                 }
2189                 if (tag != RC_LAST)
2190                         break;
2191         case RC_LANGUAGE_GLOBAL_OPTIONS:
2192                 if (ignore_system_lyxrc ||
2193                     language_global_options
2194                     != system_lyxrc.language_global_options) {
2195                         os << "\\language_global_options \""
2196                            << convert<string>(language_global_options)
2197                            << "\"\n";
2198                 }
2199                 if (tag != RC_LAST)
2200                         break;
2201         case RC_LANGUAGE_USE_BABEL:
2202                 if (ignore_system_lyxrc ||
2203                     language_use_babel != system_lyxrc.language_use_babel) {
2204                         os << "\\language_use_babel \""
2205                            << convert<string>(language_use_babel)
2206                            << "\"\n";
2207                 }
2208                 if (tag != RC_LAST)
2209                         break;
2210         case RC_LANGUAGE_COMMAND_BEGIN:
2211                 if (ignore_system_lyxrc ||
2212                     language_command_begin
2213                     != system_lyxrc.language_command_begin) {
2214                         os << "\\language_command_begin \""
2215                            << language_command_begin
2216                            << "\"\n";
2217                 }
2218                 if (tag != RC_LAST)
2219                         break;
2220         case RC_LANGUAGE_COMMAND_END:
2221                 if (ignore_system_lyxrc ||
2222                     language_command_end
2223                     != system_lyxrc.language_command_end) {
2224                         os << "\\language_command_end \"" << language_command_end
2225                            << "\"\n";
2226                 }
2227                 if (tag != RC_LAST)
2228                         break;
2229         case RC_LANGUAGE_COMMAND_LOCAL:
2230                 if (ignore_system_lyxrc ||
2231                     language_command_local
2232                     != system_lyxrc.language_command_local) {
2233                         os << "\\language_command_local \""
2234                            << language_command_local
2235                            << "\"\n";
2236                 }
2237                 if (tag != RC_LAST)
2238                         break;
2239         case RC_LANGUAGE_AUTO_BEGIN:
2240                 if (ignore_system_lyxrc ||
2241                     language_auto_begin != system_lyxrc.language_auto_begin) {
2242                         os << "\\language_auto_begin "
2243                            << convert<string>(language_auto_begin) << '\n';
2244                 }
2245                 if (tag != RC_LAST)
2246                         break;
2247         case RC_LANGUAGE_AUTO_END:
2248                 if (ignore_system_lyxrc ||
2249                     language_auto_end != system_lyxrc.language_auto_end) {
2250                         os << "\\language_auto_end "
2251                            << convert<string>(language_auto_end) << '\n';
2252                 }
2253                 if (tag != RC_LAST)
2254                         break;
2255         case RC_MARK_FOREIGN_LANGUAGE:
2256                 if (ignore_system_lyxrc ||
2257                     mark_foreign_language
2258                     != system_lyxrc.mark_foreign_language) {
2259                         os << "\\mark_foreign_language " <<
2260                                 convert<string>(mark_foreign_language) << '\n';
2261                 }
2262                 if (tag != RC_LAST)
2263                         break;
2264
2265                 os << "\n#\n"
2266                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2267                    << "#\n\n";
2268
2269         case RC_AUTO_NUMBER:
2270                 if (ignore_system_lyxrc ||
2271                     auto_number != system_lyxrc.auto_number) {
2272                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2273                 }
2274                 if (tag != RC_LAST)
2275                         break;
2276         case RC_DEFAULT_LANGUAGE:
2277                 if (ignore_system_lyxrc ||
2278                     default_language != system_lyxrc.default_language) {
2279                         os << "\\default_language " << default_language << '\n';
2280                 }
2281                 if (tag != RC_LAST)
2282                         break;
2283
2284                 os << "\n#\n"
2285                    << "# FORMATS SECTION ##########################\n"
2286                    << "#\n\n";
2287
2288         case RC_FORMAT:
2289                 // New/modified formats
2290                 for (Formats::const_iterator cit = formats.begin();
2291                      cit != formats.end(); ++cit) {
2292                         Format const * format =
2293                                 system_formats.getFormat(cit->name());
2294                         if (!format ||
2295                             format->extension() != cit->extension() ||
2296                             format->prettyname() != cit->prettyname() ||
2297                             format->shortcut() != cit->shortcut() ||
2298                             format->viewer() != cit->viewer() ||
2299                             format->editor() != cit->editor() ||
2300                             format->documentFormat() != cit->documentFormat() ||
2301                             format->vectorFormat() != cit->vectorFormat()) {
2302                                 os << "\\format \"" << cit->name() << "\" \""
2303                                    << cit->extension() << "\" \""
2304                                    << cit->prettyname() << "\" \""
2305                                    << cit->shortcut() << "\" \""
2306                                    << escapeCommand(cit->viewer()) << "\" \""
2307                                    << escapeCommand(cit->editor()) << "\" \"";
2308                                 vector<string> flags;
2309                                 if (cit->documentFormat())
2310                                         flags.push_back("document");
2311                                 if (cit->vectorFormat())
2312                                         flags.push_back("vector");
2313                                 os << getStringFromVector(flags);
2314                                 os << "\"\n";
2315                         }
2316                 }
2317
2318                 // Look for deleted formats
2319                 for (Formats::const_iterator cit = system_formats.begin();
2320                      cit != system_formats.end(); ++cit)
2321                         if (!formats.getFormat(cit->name()))
2322                                 os << "\\format \"" << cit->name()
2323                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2324                 if (tag != RC_LAST)
2325                         break;
2326         case RC_VIEWER:
2327                 // Ignore it
2328                 if (tag != RC_LAST)
2329                         break;
2330
2331                 os << "\n#\n"
2332                    << "# CONVERTERS SECTION ##########################\n"
2333                    << "#\n\n";
2334
2335         case RC_CONVERTER:
2336                 // Look for new converters
2337                 for (Converters::const_iterator cit = theConverters().begin();
2338                      cit != theConverters().end(); ++cit) {
2339                         Converter const * converter =
2340                                 theSystemConverters().getConverter(cit->from,
2341                                                                cit->to);
2342                         if (!converter ||
2343                             converter->command != cit->command ||
2344                             converter->flags != cit->flags)
2345                                 os << "\\converter \"" << cit->from << "\" \""
2346                                    << cit->to << "\" \""
2347                                    << escapeCommand(cit->command) << "\" \""
2348                                    << cit->flags << "\"\n";
2349                 }
2350
2351                 // New/modifed converters
2352                 for (Converters::const_iterator cit = theSystemConverters().begin();
2353                      cit != theSystemConverters().end(); ++cit)
2354                         if (!theConverters().getConverter(cit->from, cit->to))
2355                                 os << "\\converter \"" << cit->from
2356                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
2357                 if (tag != RC_LAST)
2358                         break;
2359
2360         case RC_COPIER:
2361                 if (tag == RC_LAST)
2362                         os << "\n#\n"
2363                            << "# COPIERS SECTION ##########################\n"
2364                            << "#\n\n";
2365
2366                 // Look for new movers
2367                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2368                 Movers::const_iterator const sysend = theSystemMovers().end();
2369                 Movers::const_iterator it = theMovers().begin();
2370                 Movers::const_iterator end = theMovers().end();
2371
2372                 for (; it != end; ++it) {
2373                         Movers::const_iterator const sysit =
2374                                 find_if(sysbegin, sysend, SameMover(*it));
2375                         if (sysit == sysend) {
2376                                 string const & fmt = it->first;
2377                                 string const & command =
2378                                         it->second.command();
2379
2380                                 os << "\\copier " << fmt
2381                                    << " \"" << escapeCommand(command) << "\"\n";
2382                         }
2383                 }
2384                 if (tag != RC_LAST)
2385                         break;
2386
2387                 // We don't actually delete SpecialisedMover(s) from the
2388                 // map, just clear their 'command', so there's no need
2389                 // to test for anything else.
2390         }
2391
2392         os.flush();
2393 }
2394
2395
2396 #if 0
2397 string const LyXRC::getDescription(LyXRCTags tag)
2398 {
2399         docstring str;
2400
2401         switch (tag) {
2402         case RC_ACCEPT_COMPOUND:
2403                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
2404                 break;
2405
2406         case RC_ALT_LANG:
2407         case RC_USE_ALT_LANG:
2408                 str = _("Specify an alternate language. The default is to use the language of the document.");
2409                 break;
2410
2411         case RC_PLAINTEXT_ROFF_COMMAND:
2412                 str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"\" is specified, an internal routine is used.");
2413                 break;
2414
2415         case RC_PLAINTEXT_LINELEN:
2416                 str = _("The maximum line length of exported plain text/LaTeX/SGML files. If set to 0, paragraphs are output in a single line; if the line length is > 0, paragraphs are separated by a blank line.");
2417                 break;
2418
2419         case RC_AUTOREGIONDELETE:
2420                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
2421                 break;
2422
2423         case RC_AUTORESET_OPTIONS:
2424                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
2425                 break;
2426
2427         case RC_AUTOSAVE:
2428                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
2429                 break;
2430
2431         case RC_AUTO_NUMBER:
2432                 break;
2433
2434         case RC_BACKUPDIR_PATH:
2435                 str = _("The path for storing backup files. If it is an empty string, LyX will store the backup file in the same directory as the original file.");
2436                 break;
2437
2438         case RC_BIBTEX_COMMAND:
2439                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
2440                 break;
2441
2442         case RC_BINDFILE:
2443                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
2444                 break;
2445
2446         case RC_CHECKLASTFILES:
2447                 str = _("Select to check whether the lastfiles still exist.");
2448                 break;
2449
2450         case RC_CHKTEX_COMMAND:
2451                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
2452                 break;
2453
2454         case RC_CONVERTER:
2455                 break;
2456
2457         case RC_COPIER:
2458                 break;
2459
2460         case RC_CURSOR_FOLLOWS_SCROLLBAR:
2461                 str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen.");
2462                 break;
2463
2464         case RC_SHOW_MACRO_LABEL:
2465                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
2466                 break;
2467
2468         case RC_CUSTOM_EXPORT_COMMAND:
2469                 break;
2470
2471         case RC_CUSTOM_EXPORT_FORMAT:
2472                 break;
2473
2474         case RC_DATE_INSERT_FORMAT:
2475                 //xgettext:no-c-format
2476                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
2477                 break;
2478
2479         case RC_DEFFILE:
2480                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
2481                 break;
2482
2483         case RC_DEFAULT_LANGUAGE:
2484                 str = _("New documents will be assigned this language.");
2485                 break;
2486
2487         case RC_DEFAULT_PAPERSIZE:
2488                 str = _("Specify the default paper size.");
2489                 break;
2490
2491         case RC_DIALOGS_ICONIFY_WITH_MAIN:
2492                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
2493                 break;
2494
2495         case RC_DISPLAY_GRAPHICS:
2496                 str = _("Select how LyX will display any graphics.");
2497                 break;
2498
2499         case RC_DOCUMENTPATH:
2500                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
2501                 break;
2502
2503         case RC_ESC_CHARS:
2504         case RC_USE_ESC_CHARS:
2505                 str = _("Specify additional chars that can be part of a word.");
2506                 break;
2507
2508         case RC_EXAMPLEPATH:
2509                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
2510                 break;
2511
2512         case RC_FONT_ENCODING:
2513                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
2514                 break;
2515
2516         case RC_FORMAT:
2517                 break;
2518
2519         case RC_INDEX_COMMAND:
2520                 str = _("Define the options of makeindex (cf. man makeindex) or select an alternative compiler. E.g., using xindy/make-rules, the command string would be \"makeindex.sh -m $$lang\".");
2521                 break;
2522
2523         case RC_INPUT:
2524                 break;
2525
2526         case RC_KBMAP:
2527         case RC_KBMAP_PRIMARY:
2528         case RC_KBMAP_SECONDARY:
2529                 str = _("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard.");
2530                 break;
2531
2532         case RC_LABEL_INIT_LENGTH:
2533                 str = _("Maximum number of words in the initialization string for a new label");
2534                 break;
2535
2536         case RC_LANGUAGE_AUTO_BEGIN:
2537                 str = _("Select if a language switching command is needed at the beginning of the document.");
2538                 break;
2539
2540         case RC_LANGUAGE_AUTO_END:
2541                 str = _("Select if a language switching command is needed at the end of the document.");
2542                 break;
2543
2544         case RC_LANGUAGE_COMMAND_BEGIN:
2545                 str = _("The LaTeX command for changing from the language of the document to another language. E.g. \\selectlanguage{$$lang} where $$lang is substituted by the name of the second language.");
2546                 break;
2547
2548         case RC_LANGUAGE_COMMAND_END:
2549                 str = _("The LaTeX command for changing back to the language of the document.");
2550                 break;
2551
2552         case RC_LANGUAGE_COMMAND_LOCAL:
2553                 str = _("The LaTeX command for local changing of the language.");
2554                 break;
2555
2556         case RC_LANGUAGE_GLOBAL_OPTIONS:
2557                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
2558                 break;
2559
2560         case RC_LANGUAGE_PACKAGE:
2561                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
2562                 break;
2563
2564         case RC_LANGUAGE_USE_BABEL:
2565                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
2566                 break;
2567
2568         case RC_USELASTFILEPOS:
2569                 str = _("De-select if you do not want LyX to scroll to saved position.");
2570                 break;
2571
2572         case RC_LOADSESSION:
2573                 str = _("De-select to prevent loading files opened from the last LyX session.");
2574                 break;
2575
2576         case RC_MAKE_BACKUP:
2577                 str = _("De-select if you don't want LyX to create backup files.");
2578                 break;
2579
2580         case RC_MARK_FOREIGN_LANGUAGE:
2581                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
2582                 break;
2583
2584         case RC_MOUSE_WHEEL_SPEED:
2585                 str = bformat(_("The scrolling speed of the mouse wheel."),
2586                       maxlastfiles);
2587                 break;
2588
2589         case RC_COMPLETION_POPUP_DELAY:
2590                 str = _("The completion popup delay.");
2591                 break;
2592
2593         case RC_COMPLETION_POPUP_MATH:
2594                 str = _("Select to display the completion popup in math mode.");
2595                 break;
2596
2597         case RC_COMPLETION_POPUP_TEXT:
2598                 str = _("Select to display the completion popup in text mode.");
2599                 break;
2600
2601         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
2602                 str = _("Show the completion popup without delay after non-unique completion attempt.");
2603                 break;
2604
2605         case RC_COMPLETION_POPUP_TEXT:
2606                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
2607                 break;
2608
2609         case RC_COMPLETION_POPUP_DELAY:
2610                 str = _("The inline completion delay.");
2611                 break;
2612
2613         case RC_COMPLETION_INLINE_MATH:
2614                 str = _("Select to display the inline completion in math mode.");
2615                 break;
2616
2617         case RC_COMPLETION_INLINE_TEXT:
2618                 str = _("Select to display the inline completion in text mode.");
2619                 break;
2620
2621         case RC_COMPLETION_INLINE_DOTS:
2622                 str = _("Use \"...\" to shorten long completions.");
2623                 break;
2624
2625         case RC_NUMLASTFILES:
2626                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
2627                         maxlastfiles);
2628                 break;
2629
2630         case RC_PATH_PREFIX:
2631                 str = _("Specify those directories which should be "
2632                          "prepended to the PATH environment variable. "
2633                          "Use the OS native format.");
2634                 break;
2635
2636         case RC_PERS_DICT:
2637         case RC_USE_PERS_DICT:
2638                 str = _("Specify an alternate personal dictionary file. E.g. \".ispell_english\".");
2639                 break;
2640
2641         case RC_PREVIEW:
2642                 str = _("Shows a typeset preview of things such as math");
2643                 break;
2644
2645         case RC_PREVIEW_HASHED_LABELS:
2646                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
2647                 break;
2648
2649         case RC_PREVIEW_SCALE_FACTOR:
2650                 str = _("Scale the preview size to suit.");
2651                 break;
2652
2653         case RC_PRINTCOLLCOPIESFLAG:
2654                 str = _("The option for specifying whether the copies should be collated.");
2655                 break;
2656
2657         case RC_PRINTCOPIESFLAG:
2658                 str = _("The option for specifying the number of copies to print.");
2659                 break;
2660
2661         case RC_PRINTER:
2662                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
2663                 break;
2664
2665         case RC_PRINTEVENPAGEFLAG:
2666                 str = _("The option to print only even pages.");
2667                 break;
2668
2669         case RC_PRINTEXSTRAOPTIONS:
2670                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
2671                 break;
2672
2673         case RC_PRINTFILEEXTENSION:
2674                 str = _("Extension of printer program output file. Usually \".ps\".");
2675                 break;
2676
2677         case RC_PRINTLANDSCAPEFLAG:
2678                 str = _("The option to print out in landscape.");
2679                 break;
2680
2681         case RC_PRINTODDPAGEFLAG:
2682                 str = _("The option to print only odd pages.");
2683                 break;
2684
2685         case RC_PRINTPAGERANGEFLAG:
2686                 str = _("The option for specifying a comma-separated list of pages to print.");
2687                 break;
2688
2689         case RC_PRINTPAPERDIMENSIONFLAG:
2690                                    str = _("Option to specify the dimensions of the print paper.");
2691                 break;
2692
2693         case RC_PRINTPAPERFLAG:
2694                 str = _("The option to specify paper type.");
2695                 break;
2696
2697         case RC_PRINTREVERSEFLAG:
2698                 str = _("The option to reverse the order of the pages printed.");
2699                 break;
2700
2701         case RC_PRINTSPOOL_COMMAND:
2702                 str = _("When set, this printer option automatically prints to a file and then calls a separate print spooling program on that file with the given name and arguments.");
2703                 break;
2704
2705         case RC_PRINTSPOOL_PRINTERPREFIX:
2706                 str = _("If you specify a printer name in the print dialog, the following argument is prepended along with the printer name after the spool command.");
2707                 break;
2708
2709         case RC_PRINTTOFILE:
2710                 str = _("Option to pass to the print program to print to a file.");
2711                 break;
2712
2713         case RC_PRINTTOPRINTER:
2714                 str = _("Option to pass to the print program to print on a specific printer.");
2715                 break;
2716
2717         case RC_PRINT_ADAPTOUTPUT:
2718                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
2719                 break;
2720
2721         case RC_PRINT_COMMAND:
2722                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
2723                 break;
2724
2725         case RC_RTL_SUPPORT:
2726                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
2727                 break;
2728
2729         case RC_VISUAL_CURSOR:
2730                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
2731                 break;
2732
2733         case RC_SCREEN_DPI:
2734                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
2735                 break;
2736
2737         case RC_SCREEN_FONT_ROMAN:
2738         case RC_SCREEN_FONT_SANS:
2739         case RC_SCREEN_FONT_TYPEWRITER:
2740                 str = _("The screen fonts used to display the text while editing.");
2741                 break;
2742
2743         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
2744         case RC_SCREEN_FONT_SANS_FOUNDRY:
2745         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2746                 break;
2747
2748         case RC_SCREEN_FONT_SCALABLE:
2749                 str = _("Allow bitmap fonts to be resized. If you are using a bitmap font, selecting this option may make some fonts look blocky in LyX. Deselecting this option makes LyX use the nearest bitmap font size available, instead of scaling.");
2750                 break;
2751
2752         case RC_SCREEN_FONT_SIZES:
2753                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
2754                 break;
2755
2756         case RC_SCREEN_ZOOM:
2757                 //xgettext:no-c-format
2758                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
2759                 break;
2760
2761         case RC_GEOMETRY_SESSION:
2762                 str = _("Allow session manager to save and restore windows geometry.");
2763                 break;
2764
2765         case RC_SERVERPIPE:
2766                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
2767                 break;
2768
2769         case RC_SET_COLOR:
2770                 break;
2771
2772         case RC_SHOW_BANNER:
2773                 str = _("De-select if you don't want the startup banner.");
2774                 break;
2775
2776         case RC_SPELL_COMMAND:
2777                 str = _("What command runs the spellchecker?");
2778                 break;
2779
2780         case RC_TEMPDIRPATH:
2781                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
2782                 break;
2783
2784         case RC_TEMPLATEPATH:
2785                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
2786                 break;
2787
2788         case RC_TEX_ALLOWS_SPACES:
2789                 break;
2790
2791         case RC_TEX_EXPECTS_WINDOWS_PATHS:
2792                 break;
2793
2794         case RC_UIFILE:
2795                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
2796                 break;
2797
2798         case RC_USER_EMAIL:
2799                 break;
2800
2801         case RC_USER_NAME:
2802                 break;
2803
2804         case RC_USETEMPDIR:
2805                 break;
2806
2807         case RC_USE_INP_ENC:
2808                 str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you cannot check the spelling of words containing accented letters. This may not work with all dictionaries.");
2809                 break;
2810
2811         case RC_USE_TOOLTIP:
2812                 str = _("Enable the automatic appearance of tool tips in the work area.");
2813                 break;
2814
2815         case RC_USE_PIXMAP_CACHE:
2816                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
2817                 break;
2818
2819         case RC_USE_SPELL_LIB:
2820                 break;
2821
2822         case RC_VIEWDVI_PAPEROPTION:
2823                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
2824                 break;
2825
2826         case RC_VIEWER:
2827                 break;
2828
2829         case RC_LAST:
2830                 break;
2831         }
2832
2833         return str;
2834 }
2835 #endif
2836
2837
2838 // The global instance
2839 LyXRC lyxrc;
2840
2841 // The global copy of the system lyxrc entries (everything except preferences)
2842 LyXRC system_lyxrc;
2843
2844
2845 } // namespace lyx