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