]> git.lyx.org Git - lyx.git/blob - src/LyXRC.cpp
* de/UserGuide: some translation work.
[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 "LyXRC.h"
20
21 #include "ColorSet.h"
22 #include "Converter.h"
23 #include "FontEnums.h"
24 #include "Format.h"
25 #include "Lexer.h"
26 #include "LyX.h"
27 #include "Mover.h"
28 #include "Session.h"
29 #include "version.h"
30
31 #include "graphics/GraphicsTypes.h"
32
33 #include "support/convert.h"
34 #include "support/debug.h"
35 #include "support/environment.h"
36 #include "support/FileName.h"
37 #include "support/filetools.h"
38 #include "support/gettext.h"
39 #include "support/lstrings.h"
40 #include "support/os.h"
41 #include "support/Package.h"
42 #include "support/userinfo.h"
43
44 #include <fstream>
45 #include <iostream>
46 #include <algorithm>
47
48 using namespace std;
49 using namespace lyx::support;
50
51 namespace lyx {
52
53 namespace os = support::os;
54
55 namespace {
56
57 static unsigned int const LYXRC_FILEFORMAT = 1;
58
59 // when adding something to this array keep it sorted!
60 LexerKeyword lyxrcTags[] = {
61         { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
62         { "\\allow_geometry_session", LyXRC::RC_GEOMETRY_SESSION },
63         { "\\alternate_language", LyXRC::RC_ALT_LANG },
64         { "\\auto_number", LyXRC::RC_AUTO_NUMBER },
65         { "\\auto_region_delete", LyXRC::RC_AUTOREGIONDELETE },
66         { "\\auto_reset_options", LyXRC::RC_AUTORESET_OPTIONS },
67         { "\\autocorrection_math", LyXRC::RC_AUTOCORRECTION_MATH },
68         { "\\autosave", LyXRC::RC_AUTOSAVE },
69         { "\\backupdir_path", LyXRC::RC_BACKUPDIR_PATH },
70         { "\\bibtex_alternatives", LyXRC::RC_BIBTEX_ALTERNATIVES },
71         { "\\bibtex_command", LyXRC::RC_BIBTEX_COMMAND },
72         { "\\bind_file", LyXRC::RC_BINDFILE },
73         { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
74         { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
75         { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
76         { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
77         { "\\completion_inline_dots", LyXRC::RC_COMPLETION_INLINE_DOTS },
78         { "\\completion_inline_math", LyXRC::RC_COMPLETION_INLINE_MATH },
79         { "\\completion_inline_text", LyXRC::RC_COMPLETION_INLINE_TEXT },
80         { "\\completion_popup_after_complete", LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE },
81         { "\\completion_popup_delay", LyXRC::RC_COMPLETION_POPUP_DELAY },
82         { "\\completion_popup_math", LyXRC::RC_COMPLETION_POPUP_MATH },
83         { "\\completion_popup_text", LyXRC::RC_COMPLETION_POPUP_TEXT },
84         { "\\converter", LyXRC::RC_CONVERTER },
85         { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
86         { "\\copier", LyXRC::RC_COPIER },
87         { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
88         { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
89         { "\\def_file", LyXRC::RC_DEFFILE },
90         { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
91         { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
92         { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
93         { "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT },
94         { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
95         { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
96         { "\\document_path", LyXRC::RC_DOCUMENTPATH },
97         { "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
98         { "\\escape_chars", LyXRC::RC_ESC_CHARS },
99         { "\\example_path", LyXRC::RC_EXAMPLEPATH },
100         { "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
101         { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
102         { "\\force_paint_single_char", LyXRC::RC_FORCE_PAINT_SINGLE_CHAR },
103         { "\\format", LyXRC::RC_FILEFORMAT },
104         { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
105         { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
106         { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
107         { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR },
108         { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
109         { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
110         { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
111         { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
112         { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
113         { "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
114         { "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH },
115         { "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES },
116         { "\\index_command", LyXRC::RC_INDEX_COMMAND },
117         { "\\input", LyXRC::RC_INPUT },
118         { "\\jbibtex_command", LyXRC::RC_JBIBTEX_COMMAND },
119         { "\\jindex_command", LyXRC::RC_JINDEX_COMMAND },
120         { "\\kbmap", LyXRC::RC_KBMAP },
121         { "\\kbmap_primary", LyXRC::RC_KBMAP_PRIMARY },
122         { "\\kbmap_secondary", LyXRC::RC_KBMAP_SECONDARY },
123         { "\\language_auto_begin", LyXRC::RC_LANGUAGE_AUTO_BEGIN },
124         { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
125         { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
126         { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
127         { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
128         { "\\language_custom_package", LyXRC::RC_LANGUAGE_CUSTOM_PACKAGE },
129         { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
130         { "\\language_package_selection", LyXRC::RC_LANGUAGE_PACKAGE_SELECTION },
131         { "\\load_session", LyXRC::RC_LOADSESSION },
132         { "\\mac_dontswap_ctrl_meta", LyXRC::RC_MAC_DONTSWAP_CTRL_META },
133         { "\\mac_like_word_movement", LyXRC::RC_MAC_LIKE_WORD_MOVEMENT },
134         { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
135         { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
136         { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
137         { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
138         { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
139         { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
140         { "\\open_buffers_in_tabs", LyXRC::RC_OPEN_BUFFERS_IN_TABS },
141         { "\\paragraph_markers", LyXRC::RC_PARAGRAPH_MARKERS },
142         { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
143         { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
144         { "\\preview", LyXRC::RC_PREVIEW },
145         { "\\preview_hashed_labels", LyXRC::RC_PREVIEW_HASHED_LABELS },
146         { "\\preview_scale_factor", LyXRC::RC_PREVIEW_SCALE_FACTOR },
147         { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
148         { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
149         { "\\print_command", LyXRC::RC_PRINT_COMMAND },
150         { "\\print_copies_flag", LyXRC::RC_PRINTCOPIESFLAG },
151         { "\\print_evenpage_flag", LyXRC::RC_PRINTEVENPAGEFLAG },
152         { "\\print_extra_options", LyXRC::RC_PRINTEXSTRAOPTIONS },
153         { "\\print_file_extension", LyXRC::RC_PRINTFILEEXTENSION },
154         { "\\print_landscape_flag", LyXRC::RC_PRINTLANDSCAPEFLAG },
155         { "\\print_oddpage_flag", LyXRC::RC_PRINTODDPAGEFLAG },
156         { "\\print_pagerange_flag", LyXRC::RC_PRINTPAGERANGEFLAG },
157         { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
158         { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
159         { "\\print_reverse_flag", LyXRC::RC_PRINTREVERSEFLAG },
160         { "\\print_spool_command", LyXRC::RC_PRINTSPOOL_COMMAND },
161         { "\\print_spool_printerprefix", LyXRC::RC_PRINTSPOOL_PRINTERPREFIX },
162         { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
163         { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
164         { "\\printer", LyXRC::RC_PRINTER },
165         { "\\rtl", LyXRC::RC_RTL_SUPPORT },
166         { "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
167         { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
168         { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
169         { "\\screen_font_roman_foundry", LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY },
170         { "\\screen_font_sans", LyXRC::RC_SCREEN_FONT_SANS },
171         { "\\screen_font_sans_foundry", LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY },
172         { "\\screen_font_scalable", LyXRC::RC_SCREEN_FONT_SCALABLE },
173         { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
174         { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
175         { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
176         { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
177         { "\\scroll_below_document", LyXRC::RC_SCROLL_BELOW_DOCUMENT },
178         { "\\scroll_wheel_zoom", LyXRC::RC_SCROLL_WHEEL_ZOOM },
179         { "\\serverpipe", LyXRC::RC_SERVERPIPE },
180         { "\\set_color", LyXRC::RC_SET_COLOR },
181         { "\\show_banner", LyXRC::RC_SHOW_BANNER },
182         { "\\single_close_tab_button", LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON },
183         { "\\single_instance", LyXRC::RC_SINGLE_INSTANCE },
184         { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
185         { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
186         { "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES },
187         { "\\spellchecker", LyXRC::RC_SPELLCHECKER },
188         { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
189         { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
190         { "\\template_path", LyXRC::RC_TEMPLATEPATH },
191         { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
192         { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
193         { "\\thesaurusdir_path", LyXRC::RC_THESAURUSDIRPATH },
194         { "\\ui_file", LyXRC::RC_UIFILE },
195         { "\\use_converter_cache", LyXRC::RC_USE_CONVERTER_CACHE },
196         { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
197         { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
198         // compatibility with versions older than 1.4.0 only
199         { "\\use_system_colors", LyXRC::RC_USE_SYSTEM_COLORS },
200         { "\\use_tooltip", LyXRC::RC_USE_TOOLTIP },
201         { "\\user_email", LyXRC::RC_USER_EMAIL },
202         { "\\user_name", LyXRC::RC_USER_NAME },
203         { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
204         // compatibility with versions older than 1.4.0 only
205         { "\\viewer", LyXRC::RC_VIEWER},
206         { "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES },
207         { "\\visual_cursor", LyXRC::RC_VISUAL_CURSOR },
208         { "format", LyXRC::RC_LYXRCFORMAT }
209 };
210
211 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(lyxrcTags[0]);
212
213 } // namespace anon
214
215
216 LyXRC::LyXRC()
217 {
218         setDefaults();
219 }
220
221
222 void LyXRC::setDefaults()
223 {
224         bind_file = "cua";
225         def_file = "default";
226         ui_file = "default";
227         // Get printer from the environment. If fail, use default "",
228         // assuming that everything is set up correctly.
229         printer = getEnv("PRINTER");
230         print_adapt_output = false;
231         print_command = "dvips";
232         print_evenpage_flag = "-B";
233         print_oddpage_flag = "-A";
234         print_pagerange_flag = "-pp";
235         print_copies_flag = "-c";
236         print_collcopies_flag = "-C";
237         print_reverse_flag = "-r";
238         print_landscape_flag = "-t landscape";
239         print_to_printer = "-P";
240         print_to_file = "-o ";
241         print_file_extension = ".ps";
242         print_paper_flag = "-t";
243         print_paper_dimension_flag = "-T";
244         document_path.erase();
245         view_dvi_paper_option.erase();
246         default_papersize = PAPER_DEFAULT;
247         default_view_format = "pdf2";
248         chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38";
249         bibtex_command = "bibtex";
250         fontenc = "default";
251         index_command = "makeindex -c -q";
252         nomencl_command = "makeindex -s nomencl.ist";
253         dpi = 75;
254         // Because a screen is typically wider than a piece of paper:
255         zoom = 150;
256         allow_geometry_session = true;
257         // Default LaTeX font size:
258         font_sizes[FONT_SIZE_TINY] = "5.0";
259         font_sizes[FONT_SIZE_SCRIPT] = "7.0";
260         font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
261         font_sizes[FONT_SIZE_SMALL] = "9.0";
262         font_sizes[FONT_SIZE_NORMAL] = "10.0";
263         font_sizes[FONT_SIZE_LARGE] = "12.0";
264         font_sizes[FONT_SIZE_LARGER] = "14.4";
265         font_sizes[FONT_SIZE_LARGEST] = "17.26";
266         font_sizes[FONT_SIZE_HUGE] = "20.74";
267         font_sizes[FONT_SIZE_HUGER] = "24.88";
268         use_scalable_fonts = true;
269         roman_font_name = "";
270         sans_font_name = "";
271         typewriter_font_name = "";
272         autosave = 300;
273         auto_region_delete = true;
274         auto_reset_options = false;
275         plaintext_linelen = 65;
276         mouse_wheel_speed = 1.0;
277         num_lastfiles = maxlastfiles;
278         check_lastfiles = true;
279         use_lastfilepos = true;
280         load_session = false;
281         make_backup = true;
282         save_compressed = false;
283         backupdir_path.erase();
284         display_graphics = true;
285         // Spellchecker settings:
286 // FIXME: this check should test the target platform (darwin)
287 #if defined(USE_MACOSX_PACKAGING)
288         spellchecker = "native";
289 #elif defined(USE_ASPELL)
290         spellchecker = "aspell";
291 #elif defined(USE_HUNSPELL)
292         spellchecker = "hunspell";
293 #else
294         spellchecker = "aspell";
295 #endif
296         spellchecker_accept_compound = false;
297         spellcheck_continuously = false;
298         spellcheck_notes = true;
299         use_kbmap = false;
300         rtl_support = true;
301         visual_cursor = false;
302         auto_number = true;
303         mark_foreign_language = true;
304         language_auto_begin = true;
305         language_auto_end = true;
306         language_global_options = true;
307         language_package_selection = LP_AUTO;
308         language_custom_package = "\\usepackage{babel}";
309         language_command_begin = "\\selectlanguage{$$lang}";
310         language_command_local = "\\foreignlanguage{$$lang}{";
311         sort_layouts = false;
312         group_layouts = true;
313         default_language = "english";
314         gui_language = "auto";
315         show_banner = true;
316         windows_style_tex_paths = false;
317         tex_allows_spaces = false;
318         date_insert_format = "%x";
319         cursor_follows_scrollbar = false;
320         scroll_below_document = false;
321         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
322         paragraph_markers = false;
323         mac_dontswap_ctrl_meta = false;
324         mac_like_word_movement = false;
325         macro_edit_style = MACRO_EDIT_INLINE_BOX;
326         dialogs_iconify_with_main = false;
327         preview = PREVIEW_OFF;
328         preview_hashed_labels  = false;
329         preview_scale_factor = 1.0;
330         use_converter_cache = true;
331         use_system_colors = false;
332         use_tooltip = true;
333         use_pixmap_cache = false;
334         converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
335         user_name = to_utf8(support::user_name());
336         user_email = to_utf8(support::user_email());
337         open_buffers_in_tabs = true;
338         single_close_tab_button = false;
339         single_instance = true;
340         forward_search_dvi = string();
341         forward_search_pdf = string();
342         export_overwrite = NO_FILES;
343
344         // Fullscreen settings
345         full_screen_limit = false;
346         full_screen_toolbars = true;
347         full_screen_tabbar = true;
348         full_screen_menubar = true;
349         full_screen_scrollbar = true;
350         full_screen_width = 700;
351
352         completion_cursor_text = true;
353         completion_popup_math = true;
354         completion_popup_text = false;
355         completion_popup_delay = 2.0;
356         completion_popup_after_complete = true;
357         autocorrection_math = false;
358         completion_inline_math = true;
359         completion_inline_text = false;
360         completion_inline_dots = -1;
361         completion_inline_delay = 0.2;
362         default_decimal_point = ".";
363 }
364
365
366 namespace {
367
368 void oldFontFormat(string & family, string & foundry)
369 {
370         if (family.empty() || family[0] != '-')
371                 return;
372         foundry = token(family, '-', 1);
373         family = token(family, '-', 2);
374         if (foundry == "*")
375                 foundry.erase();
376 }
377
378 } // namespace anon
379
380
381 bool LyXRC::read(FileName const & filename, bool check_format)
382 {
383         Lexer lexrc(lyxrcTags);
384         lexrc.setFile(filename);
385         LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
386         ReturnValues retval = read(lexrc, check_format);
387         if (!check_format || retval != FormatMismatch)
388                 return retval == ReadOK;
389
390         LYXERR(Debug::FILES, "Converting LyXRC file to " << LYXRC_FILEFORMAT);
391         FileName const tempfile = FileName::tempName("convert_lyxrc");
392         bool const success = prefs2prefs(filename, tempfile, false);
393         if (!success) {
394                 LYXERR0 ("Unable to convert " << filename.absFileName() <<
395                         " to format " << LYXRC_FILEFORMAT);
396                 return false;
397         }
398         Lexer lexrc2(lyxrcTags);
399         lexrc2.setFile(tempfile);
400         LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
401         retval = read(lexrc2, check_format);
402         tempfile.removeFile();
403         return retval == ReadOK;
404 }
405
406
407 // don't need to worry about conversion, because this is always
408 // from an internal source
409 bool LyXRC::read(istream & is)
410 {
411         Lexer lexrc(lyxrcTags);
412         lexrc.setStream(is);
413         LYXERR(Debug::LYXRC, "Reading istream...");
414         return read(lexrc, false) == ReadOK;
415 }
416
417
418 LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
419 {
420         if (lyxerr.debugging(Debug::PARSER))
421                 lexrc.printTable(lyxerr);
422
423         if (!lexrc.isOK())
424                 return ReadError;
425
426         // default for current rowpainter capabilities
427         force_paint_single_char = true;
428
429         // format prior to 2.0 and introduction of format tag
430         unsigned int format = 0;
431
432         while (lexrc.isOK()) {
433                 // By using two switches we take advantage of the compiler
434                 // telling us if we have missed a LyXRCTags element in
435                 // the second switch.
436                 // Note that this also shows a problem with Lexer since it
437                 // helps us avoid taking advantage of the strictness of the
438                 // compiler.
439
440                 int le = lexrc.lex();
441                 switch (le) {
442                 case Lexer::LEX_UNDEF:
443                         lexrc.printError("Unknown tag `$$Token'");
444                         continue;
445                 case Lexer::LEX_FEOF:
446                         continue;
447                 default:
448                         break;
449                 }
450                 switch (static_cast<LyXRCTags>(le)) {
451                 case RC_LYXRCFORMAT:
452                         if (lexrc.next())
453                                 format = lexrc.getInteger();
454                         break;
455                 case RC_INPUT: // Include file
456                         if (lexrc.next()) {
457                                 FileName const tmp =
458                                         libFileSearch(string(),
459                                                       lexrc.getString());
460                                 if (read(tmp, check_format)) {
461                                         lexrc.printError(
462                                             "Error reading included file: " + tmp.absFileName());
463                                 }
464                         }
465                         break;
466                 case RC_BINDFILE:
467                         if (lexrc.next())
468                                 bind_file = os::internal_path(lexrc.getString());
469                         break;
470
471                 case RC_DEFFILE:
472                         if (lexrc.next())
473                                 def_file = os::internal_path(lexrc.getString());
474                         break;
475
476                 case RC_UIFILE:
477                         if (lexrc.next())
478                                 ui_file = os::internal_path(lexrc.getString());
479                         break;
480
481                 case RC_AUTORESET_OPTIONS:
482                         lexrc >> auto_reset_options;
483                         break;
484
485                 case RC_DISPLAY_GRAPHICS:
486                         if (lexrc.next())
487                                 display_graphics = lexrc.getString() == "true";
488                         break;
489
490                 case RC_TEX_EXPECTS_WINDOWS_PATHS:
491                         lexrc >> windows_style_tex_paths;
492                         break;
493
494                 case RC_TEX_ALLOWS_SPACES:
495                         lexrc >> tex_allows_spaces;
496                         break;
497
498                 case RC_KBMAP:
499                         lexrc >> use_kbmap;
500                         break;
501
502                 case RC_KBMAP_PRIMARY:
503                         if (lexrc.next()) {
504                                 string const kmap(os::internal_path(lexrc.getString()));
505                                 if (!libFileSearch("kbd", kmap, "kmap").empty()
506                                           || kmap.empty()) {
507                                         primary_kbmap = kmap;
508                                 } else {
509                                         lexrc.printError("LyX: Keymap `$$Token' not found");
510                                 }
511                         }
512                         break;
513
514                 case RC_KBMAP_SECONDARY:
515                         if (lexrc.next()) {
516                                 string const kmap(os::internal_path(lexrc.getString()));
517                                 if (!libFileSearch("kbd", kmap, "kmap").empty()
518                                           || kmap.empty()) {
519                                         secondary_kbmap = kmap;
520                                 } else {
521                                         lexrc.printError("LyX: Keymap `$$Token' not found");
522                                 }
523                         }
524                         break;
525
526                 case RC_FONT_ENCODING:
527                         lexrc >> fontenc;
528                         break;
529
530                 case RC_FORCE_PAINT_SINGLE_CHAR:
531                         lexrc >> force_paint_single_char;
532                         break;
533                                 
534                 case RC_PRINTER:
535                         lexrc >> printer;
536                         break;
537
538                 case RC_PRINT_COMMAND:
539                         if (lexrc.next(true)) {
540                                 print_command = lexrc.getString();
541                         }
542                         break;
543
544                 case RC_PRINTEVENPAGEFLAG:
545                         lexrc >> print_evenpage_flag;
546                         break;
547
548                 case RC_PRINTODDPAGEFLAG:
549                         lexrc >> print_oddpage_flag;
550                         break;
551
552                 case RC_PRINTPAGERANGEFLAG:
553                         lexrc >> print_pagerange_flag;
554                         break;
555
556                 case RC_PRINTCOPIESFLAG:
557                         lexrc >> print_copies_flag;
558                         break;
559
560                 case RC_PRINTCOLLCOPIESFLAG:
561                         lexrc >> print_collcopies_flag;
562                         break;
563
564                 case RC_PRINTREVERSEFLAG:
565                         lexrc >> print_reverse_flag;
566                         break;
567
568                 case RC_PRINTLANDSCAPEFLAG:
569                         lexrc >> print_landscape_flag;
570                         break;
571
572                 case RC_PRINTTOPRINTER:
573                         lexrc >> print_to_printer;
574                         break;
575
576                 case RC_PRINT_ADAPTOUTPUT:
577                         lexrc >> print_adapt_output;
578                         break;
579
580                 case RC_PRINTTOFILE:
581                         if (lexrc.next()) {
582                                 print_to_file = os::internal_path(lexrc.getString());
583                         }
584                         break;
585
586                 case RC_PRINTFILEEXTENSION:
587                         lexrc >> print_file_extension;
588                         break;
589
590                 case RC_PRINTEXSTRAOPTIONS:
591                         lexrc >> print_extra_options;
592                         break;
593
594                 case RC_PRINTSPOOL_COMMAND:
595                         if (lexrc.next(true)) {
596                                 print_spool_command = lexrc.getString();
597                         }
598                         break;
599
600                 case RC_PRINTSPOOL_PRINTERPREFIX:
601                         lexrc >> print_spool_printerprefix;
602                         break;
603
604                 case RC_PRINTPAPERDIMENSIONFLAG:
605                         lexrc >> print_paper_dimension_flag;
606                         break;
607
608                 case RC_PRINTPAPERFLAG:
609                         lexrc >> print_paper_flag;
610                         break;
611
612                 case RC_DEFAULT_PAPERSIZE:
613                         if (lexrc.next()) {
614                                 string const size = ascii_lowercase(lexrc.getString());
615                                 if (size == "usletter")
616                                         default_papersize = PAPER_USLETTER;
617                                 else if (size == "legal")
618                                         default_papersize = PAPER_USLEGAL;
619                                 else if (size == "executive")
620                                         default_papersize = PAPER_USEXECUTIVE;
621                                 else if (size == "a3")
622                                         default_papersize = PAPER_A3;
623                                 else if (size == "a4")
624                                         default_papersize = PAPER_A4;
625                                 else if (size == "a5")
626                                         default_papersize = PAPER_A5;
627                                 else if (size == "b5")
628                                         default_papersize = PAPER_B5;
629                                 else if (size == "default")
630                                         default_papersize = PAPER_DEFAULT;
631                         }
632                         break;
633
634                 case RC_VIEWDVI_PAPEROPTION:
635                         if (lexrc.next())
636                                 view_dvi_paper_option = lexrc.getString();
637                         else
638                                 view_dvi_paper_option.erase();
639                         break;
640
641                 case RC_CHKTEX_COMMAND:
642                         if (lexrc.next(true)) {
643                                 chktex_command = lexrc.getString();
644                         }
645                         break;
646
647                 case RC_BIBTEX_ALTERNATIVES:
648                         if (lexrc.next(true)) {
649                                 bibtex_alternatives.insert(lexrc.getString());
650                         }
651                         break;
652
653                 case RC_BIBTEX_COMMAND:
654                         if (lexrc.next(true)) {
655                                 bibtex_command = lexrc.getString();
656                         }
657                         break;
658
659                 case RC_JBIBTEX_COMMAND:
660                         if (lexrc.next(true)) {
661                                 jbibtex_command = lexrc.getString();
662                         }
663                         break;
664
665                 case RC_INDEX_ALTERNATIVES:
666                         if (lexrc.next(true)) {
667                                 index_alternatives.insert(lexrc.getString());
668                         }
669                         break;
670
671                 case RC_INDEX_COMMAND:
672                         if (lexrc.next(true)) {
673                                 index_command = lexrc.getString();
674                         }
675                         break;
676
677                 case RC_JINDEX_COMMAND:
678                         if (lexrc.next(true)) {
679                                 jindex_command = lexrc.getString();
680                         }
681                         break;
682
683                 case RC_SPLITINDEX_COMMAND:
684                         if (lexrc.next(true)) {
685                                 splitindex_command = lexrc.getString();
686                         }
687                         break;
688
689                 case RC_NOMENCL_COMMAND:
690                         if (lexrc.next(true)) {
691                                 nomencl_command = lexrc.getString();
692                         }
693                         break;
694
695                 case RC_SCREEN_DPI:
696                         lexrc >> dpi;
697                         break;
698
699                 case RC_SCREEN_ZOOM:
700                         lexrc >> zoom;
701                         break;
702
703                 case RC_GEOMETRY_SESSION:
704                         lexrc >> allow_geometry_session;
705                         break;
706
707                 case RC_SCREEN_FONT_SIZES:
708                         lexrc >> font_sizes[FONT_SIZE_TINY];
709                         lexrc >> font_sizes[FONT_SIZE_SCRIPT];
710                         lexrc >> font_sizes[FONT_SIZE_FOOTNOTE];
711                         lexrc >> font_sizes[FONT_SIZE_SMALL];
712                         lexrc >> font_sizes[FONT_SIZE_NORMAL];
713                         lexrc >> font_sizes[FONT_SIZE_LARGE];
714                         lexrc >> font_sizes[FONT_SIZE_LARGER];
715                         lexrc >> font_sizes[FONT_SIZE_LARGEST];
716                         lexrc >> font_sizes[FONT_SIZE_HUGE];
717                         lexrc >> font_sizes[FONT_SIZE_HUGER];
718                         break;
719
720                 case RC_SCREEN_FONT_SCALABLE:
721                         lexrc >> use_scalable_fonts;
722                         break;
723
724                 case RC_AUTOSAVE:
725                         lexrc >> autosave;
726                         break;
727
728                 case RC_DOCUMENTPATH:
729                         if (lexrc.next()) {
730                                 document_path = os::internal_path(lexrc.getString());
731                                 document_path = expandPath(document_path);
732                         }
733                         break;
734
735                 case RC_EXAMPLEPATH:
736                         if (lexrc.next()) {
737                                 example_path = os::internal_path(lexrc.getString());
738                                 example_path = expandPath(example_path);
739                         }
740                         break;
741
742                 case RC_TEMPLATEPATH:
743                         if (lexrc.next()) {
744                                 template_path = os::internal_path(lexrc.getString());
745                                 template_path = expandPath(template_path);
746                         }
747                         break;
748
749                 case RC_TEMPDIRPATH:
750                         if (lexrc.next()) {
751                                 tempdir_path = os::internal_path(lexrc.getString());
752                                 tempdir_path = expandPath(tempdir_path);
753                         }
754                         break;
755
756                 case RC_THESAURUSDIRPATH:
757                         if (lexrc.next()) {
758                                 thesaurusdir_path = os::internal_path(lexrc.getString());
759                                 thesaurusdir_path = expandPath(thesaurusdir_path);
760                         }
761                         break;
762
763                 case RC_HUNSPELLDIR_PATH:
764                         if (lexrc.next()) {
765                                 hunspelldir_path = os::internal_path(lexrc.getString());
766                                 hunspelldir_path = expandPath(hunspelldir_path);
767                         }
768                         break;
769
770                 case RC_USELASTFILEPOS:
771                         lexrc >> use_lastfilepos;
772                         break;
773
774                 case RC_LOADSESSION:
775                         lexrc >> load_session;
776                         break;
777
778                 case RC_MOUSE_WHEEL_SPEED:
779                         lexrc >> mouse_wheel_speed;
780                         break;
781
782                 case RC_COMPLETION_INLINE_DELAY:
783                         lexrc >> completion_inline_delay;
784                         break;
785
786                 case RC_COMPLETION_INLINE_MATH:
787                         lexrc >> completion_inline_math;
788                         break;
789
790                 case RC_COMPLETION_INLINE_TEXT:
791                         lexrc >> completion_inline_text;
792                         break;
793
794                 case RC_COMPLETION_INLINE_DOTS:
795                         lexrc >> completion_inline_dots;
796                         break;
797
798                 case RC_AUTOCORRECTION_MATH:
799                         lexrc >> autocorrection_math;
800                         break;
801
802                 case RC_COMPLETION_POPUP_DELAY:
803                         lexrc >> completion_popup_delay;
804                         break;
805
806                 case RC_COMPLETION_POPUP_MATH:
807                         lexrc >> completion_popup_math;
808                         break;
809
810                 case RC_COMPLETION_POPUP_TEXT:
811                         lexrc >> completion_popup_text;
812                         break;
813
814                 case RC_COMPLETION_CURSOR_TEXT:
815                         lexrc >> completion_cursor_text;
816                         break;
817
818                 case RC_COMPLETION_POPUP_AFTER_COMPLETE:
819                         lexrc >> completion_popup_after_complete;
820                         break;
821
822                 case RC_NUMLASTFILES:
823                         lexrc >> num_lastfiles;
824                         break;
825
826                 case RC_CHECKLASTFILES:
827                         lexrc >> check_lastfiles;
828                         break;
829
830                 case RC_SCREEN_FONT_ROMAN:
831                         if (lexrc.next()) {
832                                 roman_font_name = lexrc.getString();
833                                 oldFontFormat(roman_font_name,
834                                               roman_font_foundry);
835                         }
836                         break;
837
838                 case RC_SCREEN_FONT_SANS:
839                         if (lexrc.next()) {
840                                 sans_font_name = lexrc.getString();
841                                 oldFontFormat(sans_font_name, sans_font_foundry);
842                         }
843                         break;
844
845                 case RC_SCREEN_FONT_TYPEWRITER:
846                         if (lexrc.next()) {
847                                 typewriter_font_name = lexrc.getString();
848                                 oldFontFormat(typewriter_font_name,
849                                               typewriter_font_foundry);
850                         }
851                         break;
852
853                 case RC_SCREEN_FONT_ROMAN_FOUNDRY:
854                         lexrc >> roman_font_foundry;
855                         break;
856
857                 case RC_SCREEN_FONT_SANS_FOUNDRY:
858                         lexrc >> sans_font_foundry;
859                         break;
860
861                 case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
862                         lexrc >> typewriter_font_foundry;
863                         break;
864
865                 case RC_SET_COLOR: {
866                         if (!lexrc.next()) {
867                                 lexrc.printError("Missing color tag.");
868                                 break;
869                         }
870                         string lyx_name = lexrc.getString();
871
872                         if (!lexrc.next()) {
873                                 lexrc.printError("Missing color name for color: `$$Token'");
874                                 break;
875                         }
876                         string x11_name = lexrc.getString();
877
878                         ColorCode const col =
879                                 lcolor.getFromLyXName(lyx_name);
880                         if (col == Color_none ||
881                             col == Color_inherit ||
882                             col == Color_ignore)
883                                 break;
884
885                         if (!lcolor.setColor(col, x11_name))
886                                 LYXERR0("Bad lyxrc set_color for " << lyx_name);
887                         break;
888                 }
889
890                 case RC_AUTOREGIONDELETE:
891                         // Auto region delete defaults to true
892                         lexrc >> auto_region_delete;
893                         break;
894
895                 case RC_SERVERPIPE:
896                         if (lexrc.next()) {
897                                 lyxpipes = os::internal_path(lexrc.getString());
898                                 lyxpipes = expandPath(lyxpipes);
899                         }
900                         break;
901
902                 case RC_CURSOR_FOLLOWS_SCROLLBAR:
903                         lexrc >> cursor_follows_scrollbar;
904                         break;
905
906                 case RC_SCROLL_BELOW_DOCUMENT:
907                         lexrc >> scroll_below_document;
908                         break;
909
910                 case RC_PARAGRAPH_MARKERS:
911                         lexrc >> paragraph_markers;
912                         break;
913
914                 case RC_MAC_DONTSWAP_CTRL_META:
915                         lexrc >> mac_dontswap_ctrl_meta;
916                         break;
917
918                 case RC_MAC_LIKE_WORD_MOVEMENT:
919                         lexrc >> mac_like_word_movement;
920                         break;
921
922                 case RC_MACRO_EDIT_STYLE:
923                         if (lexrc.next()) {
924                                 switch (lexrc.getInteger()) {
925                                 case 0: macro_edit_style = MACRO_EDIT_INLINE_BOX; break;
926                                 case 1: macro_edit_style = MACRO_EDIT_INLINE; break;
927                                 case 2: macro_edit_style = MACRO_EDIT_LIST; break;
928                                 }
929                         }
930                         break;
931
932                 case RC_DIALOGS_ICONIFY_WITH_MAIN:
933                         lexrc >> dialogs_iconify_with_main;
934                         break;
935
936                 case RC_PLAINTEXT_LINELEN:
937                         lexrc >> plaintext_linelen;
938                         break;
939                         // Spellchecker settings:
940                 case RC_ACCEPT_COMPOUND:
941                         lexrc >> spellchecker_accept_compound;
942                         break;
943                 case RC_USE_SYSTEM_COLORS:
944                         lexrc >> use_system_colors;
945                         break;
946                 case RC_USE_TOOLTIP:
947                         lexrc >> use_tooltip;
948                         break;
949                 case RC_USE_PIXMAP_CACHE:
950                         lexrc >> use_pixmap_cache;
951                         break;
952                 case RC_SPELLCHECKER:
953                         lexrc >> spellchecker;
954                         break;
955                 case RC_ALT_LANG:
956                         lexrc >> spellchecker_alt_lang;
957                         break;
958                 case RC_ESC_CHARS:
959                         lexrc >> spellchecker_esc_chars;
960                         break;
961                 case RC_SPELLCHECK_CONTINUOUSLY:
962                         lexrc >> spellcheck_continuously;
963                         break;
964                 case RC_SPELLCHECK_NOTES:
965                         lexrc >> spellcheck_notes;
966                         break;
967                 case RC_MAKE_BACKUP:
968                         lexrc >> make_backup;
969                         break;
970                 case RC_SAVE_COMPRESSED:
971                         lexrc >> save_compressed;
972                         break;
973                 case RC_BACKUPDIR_PATH:
974                         if (lexrc.next()) {
975                                 backupdir_path = os::internal_path(lexrc.getString());
976                                 backupdir_path = expandPath(backupdir_path);
977                         }
978                         break;
979                 case RC_DEFAULT_DECIMAL_POINT:
980                         lexrc >> default_decimal_point;
981                         break;
982                 case RC_DATE_INSERT_FORMAT:
983                         lexrc >> date_insert_format;
984                         break;
985                 case RC_LANGUAGE_CUSTOM_PACKAGE:
986                         lexrc >> language_custom_package;
987                         break;
988                 case RC_LANGUAGE_AUTO_BEGIN:
989                         lexrc >> language_auto_begin;
990                         break;
991                 case RC_LANGUAGE_AUTO_END:
992                         lexrc >> language_auto_end;
993                         break;
994                 case RC_LANGUAGE_GLOBAL_OPTIONS:
995                         lexrc >> language_global_options;
996                         break;
997                 case RC_LANGUAGE_PACKAGE_SELECTION:
998                         if (lexrc.next()) {
999                                 switch (lexrc.getInteger()) {
1000                                 case 0:
1001                                         language_package_selection = LP_AUTO;
1002                                         break;
1003                                 case 1:
1004                                         language_package_selection = LP_BABEL;
1005                                         break;
1006                                 case 2:
1007                                         language_package_selection = LP_CUSTOM;
1008                                         break;
1009                                 case 3:
1010                                         language_package_selection = LP_NONE;
1011                                         break;
1012                                 }
1013                         }
1014                         break;
1015                 case RC_LANGUAGE_COMMAND_BEGIN:
1016                         lexrc >> language_command_begin;
1017                         break;
1018                 case RC_LANGUAGE_COMMAND_END:
1019                         lexrc >> language_command_end;
1020                         break;
1021                 case RC_LANGUAGE_COMMAND_LOCAL:
1022                         lexrc >> language_command_local;
1023                         break;
1024                 case RC_RTL_SUPPORT:
1025                         lexrc >> rtl_support;
1026                         break;
1027                 case RC_VISUAL_CURSOR:
1028                         lexrc >> visual_cursor;
1029                         break;
1030                 case RC_AUTO_NUMBER:
1031                         lexrc >> auto_number;
1032                         break;
1033                 case RC_MARK_FOREIGN_LANGUAGE:
1034                         lexrc >> mark_foreign_language;
1035                         break;
1036
1037                 case RC_COPIER: {
1038                         string fmt, command;
1039                         if (lexrc.next())
1040                                 fmt = lexrc.getString();
1041                         if (lexrc.next(true))
1042                                 command = lexrc.getString();
1043                         setMover(fmt, command);
1044                         break;
1045                 }
1046
1047                 case RC_CONVERTER: {
1048                         string from, to, command, flags;
1049                         if (lexrc.next())
1050                                 from = lexrc.getString();
1051                         if (lexrc.next())
1052                                 to = lexrc.getString();
1053                         if (lexrc.next(true))
1054                                 command = lexrc.getString();
1055                         if (lexrc.next())
1056                                 flags = lexrc.getString();
1057                         if (command.empty())
1058                                 theConverters().erase(from, to);
1059                         else
1060                                 theConverters().add(from, to, command, flags);
1061                         break;
1062                 }
1063                 // compatibility with versions older than 1.4.0 only
1064                 case RC_VIEWER: {
1065                         string format, command;
1066                         lexrc >> format >> command;
1067                         formats.setViewer(format, command);
1068                         break;
1069                 }
1070                 case RC_FILEFORMAT: {
1071                         string format, extension, prettyname, shortcut;
1072                         lexrc >> format >> extension >> prettyname >> shortcut;
1073                         string viewer, editor;
1074                         if (lexrc.next(true))
1075                                 viewer = lexrc.getString();
1076                         if (lexrc.next(true))
1077                                 editor = lexrc.getString();
1078                         string flags;
1079                         // Hack to ensure compatibility with versions older
1080                         // than 1.5.0
1081                         int le = lexrc.lex();
1082                         if (le != Lexer::LEX_FEOF && le != Lexer::LEX_UNDEF) {
1083                                 flags = lexrc.getString();
1084                                 if (le != Lexer::LEX_DATA) {
1085                                         // We have got a known token.
1086                                         // Therefore this is an old style
1087                                         // format definition without
1088                                         // flags.
1089                                         lexrc.pushToken(flags);
1090                                         flags.erase();
1091                                 }
1092                         }
1093                         int flgs = Format::none;
1094                         while (!flags.empty()) {
1095                                 string flag;
1096                                 flags = split(flags, flag, ',');
1097                                 if (flag == "document")
1098                                         flgs |= Format::document;
1099                                 else if (flag == "vector")
1100                                         flgs |= Format::vector;
1101                                 else if (flag == "menu=export")
1102                                         flgs |= Format::export_menu;
1103                                 else
1104                                         LYXERR0("Ignoring unknown flag `"
1105                                                << flag << "' for format `"
1106                                                << format << "'.");
1107                         }
1108                         if (prettyname.empty()) {
1109                                 if (theConverters().formatIsUsed(format))
1110                                         LYXERR0("Can't delete format " << format);
1111                                 else
1112                                         formats.erase(format);
1113                         } else {
1114                                 formats.add(format, extension, prettyname,
1115                                             shortcut, viewer, editor, flgs);
1116                         }
1117                         break;
1118                 }
1119                 case RC_VIEWER_ALTERNATIVES:  {
1120                         string format, command;
1121                         if (lexrc.next())
1122                                 format = lexrc.getString();
1123                         if (lexrc.eatLine())
1124                                 command = lexrc.getString();
1125                         viewer_alternatives[format].insert(command);
1126                         break;
1127                 }
1128                 case RC_EDITOR_ALTERNATIVES:  {
1129                         string format, command;
1130                         lexrc >> format >> command;
1131                         editor_alternatives[format].insert(command);
1132                         break;
1133                 }
1134
1135                 case RC_DEFAULT_VIEW_FORMAT:
1136                         lexrc >> default_view_format;
1137                         break;
1138                         
1139                 case RC_DEFAULT_LANGUAGE:
1140                         lexrc >> default_language;
1141                         break;
1142
1143                 case RC_GUI_LANGUAGE:
1144                         lexrc >> gui_language;
1145                         break;
1146
1147                 case RC_SHOW_BANNER:
1148                         lexrc >> show_banner;
1149                         break;
1150
1151                 case RC_PREVIEW:
1152                         if (lexrc.next()) {
1153                                 string const tmp = lexrc.getString();
1154                                 if (tmp == "true" || tmp == "on")
1155                                         preview = PREVIEW_ON;
1156                                 else if (tmp == "no_math")
1157                                         preview = PREVIEW_NO_MATH;
1158                                 else {
1159                                         preview = PREVIEW_OFF;
1160                                         if (tmp != "false" && tmp != "off")
1161                                                 LYXERR0("Unrecognized preview status \""
1162                                                        << tmp << '\n');
1163                                 }
1164                         }
1165                         break;
1166
1167                 case RC_PREVIEW_HASHED_LABELS:
1168                         lexrc >> preview_hashed_labels;
1169                         break;
1170
1171                 case RC_PREVIEW_SCALE_FACTOR:
1172                         lexrc >> preview_scale_factor;
1173                         break;
1174
1175                 case RC_USER_NAME:
1176                         lexrc >> user_name;
1177                         break;
1178                 case RC_USER_EMAIL:
1179                         lexrc >> user_email;
1180                         break;
1181
1182                 case RC_PATH_PREFIX:
1183                         lexrc >> path_prefix;
1184                         break;
1185
1186                 case RC_USE_CONVERTER_CACHE:
1187                         lexrc >> use_converter_cache;
1188                         break;
1189                 case RC_CONVERTER_CACHE_MAXAGE:
1190                         lexrc >> converter_cache_maxage;
1191                         break;
1192
1193                 case RC_SORT_LAYOUTS:
1194                         lexrc >> sort_layouts;
1195                         break;
1196                 case RC_GROUP_LAYOUTS:
1197                         lexrc >> group_layouts;
1198                         break;
1199                 case RC_FULL_SCREEN_LIMIT:
1200                         lexrc >> full_screen_limit;
1201                         break;
1202                 case RC_FULL_SCREEN_TOOLBARS:
1203                         lexrc >> full_screen_toolbars;
1204                         break;
1205                 case RC_FULL_SCREEN_SCROLLBAR:
1206                         lexrc >> full_screen_scrollbar;
1207                         break;
1208                 case RC_FULL_SCREEN_TABBAR:
1209                         lexrc >> full_screen_tabbar;
1210                         break;
1211                 case RC_FULL_SCREEN_MENUBAR:
1212                         lexrc >> full_screen_menubar;
1213                         break;
1214                 case RC_FULL_SCREEN_WIDTH:
1215                         lexrc >> full_screen_width;
1216                         break;
1217                 case RC_OPEN_BUFFERS_IN_TABS:
1218                         lexrc >> open_buffers_in_tabs;
1219                         break;
1220                 case RC_SINGLE_CLOSE_TAB_BUTTON:
1221                         lexrc >> single_close_tab_button;
1222                         break;
1223                 case RC_SINGLE_INSTANCE:
1224                         lexrc >> single_instance;
1225                         if (run_mode == PREFERRED)
1226                                 run_mode = single_instance ? USE_REMOTE : NEW_INSTANCE;
1227                         break;
1228                 case RC_FORWARD_SEARCH_DVI:
1229                         if (lexrc.next(true)) 
1230                                 forward_search_dvi = lexrc.getString();
1231                         break;
1232                 case RC_FORWARD_SEARCH_PDF:
1233                         if (lexrc.next(true)) 
1234                                 forward_search_pdf = lexrc.getString();
1235                         break;
1236                 case RC_EXPORT_OVERWRITE:
1237                         if (lexrc.next()) {
1238                                 string const tmp = lexrc.getString();
1239                                 if (tmp == "all" || tmp == "true")
1240                                         export_overwrite = ALL_FILES;
1241                                 else if (tmp == "main")
1242                                         export_overwrite = MAIN_FILE;
1243                                 else {
1244                                         export_overwrite = NO_FILES;
1245                                         if (tmp != "ask" && tmp != "false")
1246                                                 LYXERR0("Unrecognized export_overwrite status \""
1247                                                        << tmp << '"');
1248                                 }
1249                         }
1250                         break;
1251                 case RC_SCROLL_WHEEL_ZOOM:
1252                         if (lexrc.next()) {
1253                                 string const tmp = lexrc.getString();
1254                                 if (tmp == "ctrl")
1255                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_CTRL;
1256                                 else if (tmp == "shift")
1257                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_SHIFT;
1258                                 else if (tmp == "alt")
1259                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_ALT;
1260                                 else {
1261                                         scroll_wheel_zoom = SCROLL_WHEEL_ZOOM_OFF;
1262                                         if (tmp != "off" && tmp != "false")
1263                                                 LYXERR0("Unrecognized scroll_wheel_zoom status \""
1264                                                        << tmp << '"');
1265                                 }
1266                         }
1267                         break;
1268
1269                 case RC_LAST:
1270                         break; // this is just a dummy
1271                 }
1272
1273                 // This is triggered the first time through the loop unless
1274                 // we hit a format tag.
1275                 if (check_format && format != LYXRC_FILEFORMAT)
1276                         return FormatMismatch;
1277         }
1278
1279         /// Update converters data-structures
1280         theConverters().update(formats);
1281         theConverters().buildGraph();
1282
1283         return ReadOK;
1284 }
1285
1286
1287 void LyXRC::write(FileName const & filename, bool ignore_system_lyxrc) const
1288 {
1289         ofstream ofs(filename.toFilesystemEncoding().c_str());
1290         if (ofs)
1291                 write(ofs, ignore_system_lyxrc);
1292 }
1293
1294
1295 void LyXRC::print() const
1296 {
1297         if (lyxerr.debugging())
1298                 write(lyxerr, false);
1299         else
1300                 write(cout, false);
1301 }
1302
1303
1304 class SameMover {
1305 public:
1306         typedef pair<string, SpecialisedMover> Data;
1307
1308         SameMover(Data const & comparison)
1309                 : comparison_(comparison) {}
1310
1311         bool operator()(Data const & data) const
1312         {
1313                 return data.first == comparison_.first &&
1314                         data.second.command() == comparison_.second.command();
1315         }
1316
1317 private:
1318         Data comparison_;
1319 };
1320
1321
1322 namespace {
1323
1324         // Escape \ and " so that LyXLex can read the string later
1325         string escapeCommand(string const & str) {
1326                 return subst(subst(str , "\\", "\\\\"), 
1327                              "\"", "\\\"");
1328         }
1329
1330 }
1331
1332
1333 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
1334 {
1335         LyXRCTags tag = RC_LAST;
1336         
1337         if (!name.empty()) {
1338                 for (int i = 0; i != lyxrcCount; ++i)
1339                         if ("\\" + name == lyxrcTags[i].tag)
1340                                 tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
1341         }
1342
1343         if (tag == RC_LAST)
1344                 os << "# LyX " << lyx_version
1345                    << " generated this file. If you want to make your own\n"
1346                    << "# modifications you should do them from inside LyX and save.\n\n"
1347                    << "Format " << LYXRC_FILEFORMAT << "\n\n";
1348
1349         // Why the switch you might ask. It is a trick to ensure that all
1350         // the elements in the LyXRCTags enum are handled. As you can see
1351         // there are no breaks at all. So it is just a huge fall-through.
1352         // The nice thing is that we will get a warning from the compiler
1353         // if we forget an element.
1354         switch (tag) {
1355         case RC_LAST:
1356         case RC_INPUT:
1357                 // input/include files are not done here
1358         case RC_LYXRCFORMAT:
1359         case RC_BINDFILE:
1360                 if (ignore_system_lyxrc ||
1361                     bind_file != system_lyxrc.bind_file) {
1362                         string const path = os::external_path(bind_file);
1363                         os << "\\bind_file \"" << path << "\"\n";
1364                 }
1365                 if (tag != RC_LAST)
1366                         break;
1367
1368         case RC_DEFFILE:
1369                 if (ignore_system_lyxrc ||
1370                     def_file != system_lyxrc.def_file) {
1371                         string const path = os::external_path(def_file);
1372                         os << "\\def_file \"" << path << "\"\n";
1373                 }
1374                 if (tag != RC_LAST)
1375                         break;
1376
1377                 //
1378                 // Misc Section
1379                 //
1380                 os << "\n#\n"
1381                    << "# MISC SECTION ######################################\n"
1382                    << "#\n\n";
1383                 // bind files are not done here.
1384
1385         case RC_PATH_PREFIX:
1386                 if (ignore_system_lyxrc ||
1387                     path_prefix != system_lyxrc.path_prefix) {
1388                         os << "\\path_prefix \"" << path_prefix << "\"\n";
1389                 }
1390                 if (tag != RC_LAST)
1391                         break;
1392         case RC_UIFILE:
1393                 if (ignore_system_lyxrc ||
1394                     ui_file != system_lyxrc.ui_file) {
1395                         string const path = os::external_path(ui_file);
1396                         os << "\\ui_file \"" << path << "\"\n";
1397                 }
1398                 if (tag != RC_LAST)
1399                         break;
1400         case RC_AUTOREGIONDELETE:
1401                 if (ignore_system_lyxrc ||
1402                     auto_region_delete != system_lyxrc.auto_region_delete) {
1403                         os << "# Set to false to inhibit automatic replacement of\n"
1404                            << "# the current selection.\n"
1405                            << "\\auto_region_delete " << convert<string>(auto_region_delete)
1406                            << '\n';
1407                 }
1408                 if (tag != RC_LAST)
1409                         break;
1410         case RC_AUTORESET_OPTIONS:
1411                 if (ignore_system_lyxrc ||
1412                     auto_reset_options != system_lyxrc.auto_reset_options) {
1413                         os << "# Set to false to inhibit automatic reset of\n"
1414                            << "# the class options to defaults on class change.\n"
1415                            << "\\auto_reset_options "
1416                            << convert<string>(auto_reset_options)
1417                            << '\n';
1418                 }
1419                 if (tag != RC_LAST)
1420                         break;
1421         case RC_AUTOSAVE:
1422                 if (ignore_system_lyxrc ||
1423                     autosave != system_lyxrc.autosave) {
1424                         os << "# The time interval between auto-saves in seconds.\n"
1425                            << "\\autosave " << autosave << '\n';
1426                 }
1427                 if (tag != RC_LAST)
1428                         break;
1429         case RC_DISPLAY_GRAPHICS:
1430                 if (ignore_system_lyxrc ||
1431                     display_graphics != system_lyxrc.display_graphics) {
1432                         os << "# Display graphics within LyX\n"
1433                            << "# true|false\n"
1434                            << "\\display_graphics "
1435                            << (display_graphics ? "true" : "false")
1436                            << '\n';
1437                 }
1438                 if (tag != RC_LAST)
1439                         break;
1440         case RC_SORT_LAYOUTS:
1441                 if (ignore_system_lyxrc ||
1442                     sort_layouts != system_lyxrc.sort_layouts) {
1443                         os << "# Sort layouts alphabetically.\n"
1444                            << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
1445                 }
1446                 if (tag != RC_LAST)
1447                         break;
1448         case RC_GROUP_LAYOUTS:
1449                 if (ignore_system_lyxrc ||
1450                     group_layouts != system_lyxrc.group_layouts) {
1451                         os << "# Group layouts by their category.\n"
1452                            << "\\group_layouts " << convert<string>(group_layouts) << '\n';
1453                 }
1454                 if (tag != RC_LAST)
1455                         break;
1456         case RC_VIEWDVI_PAPEROPTION:
1457                 if (ignore_system_lyxrc ||
1458                     view_dvi_paper_option
1459                     != system_lyxrc.view_dvi_paper_option) {
1460                         os << "# Options used to specify paper size to the\n"
1461                            << "# view_dvi_command (e.g. -paper)\n"
1462                            << "\\view_dvi_paper_option \""
1463                            << view_dvi_paper_option << "\"\n";
1464                 }
1465                 if (tag != RC_LAST)
1466                         break;
1467         case RC_DEFAULT_PAPERSIZE:
1468                 if (ignore_system_lyxrc ||
1469                     default_papersize != system_lyxrc.default_papersize) {
1470                         os << "# The default papersize to use.\n"
1471                            << "\\default_papersize \"";
1472                         switch (default_papersize) {
1473                         case PAPER_DEFAULT:
1474                                 os << "default"; break;
1475                         case PAPER_USLETTER:
1476                                 os << "usletter"; break;
1477                         case PAPER_USLEGAL:
1478                                 os << "legal"; break;
1479                         case PAPER_USEXECUTIVE:
1480                                 os << "executive"; break;
1481                         case PAPER_A3:
1482                                 os << "a3"; break;
1483                         case PAPER_A4:
1484                                 os << "a4"; break;
1485                         case PAPER_A5:
1486                                 os << "a5"; break;
1487                         case PAPER_B5:
1488                                 os << "b5"; break;
1489                         case PAPER_CUSTOM:
1490                         case PAPER_A0:
1491                         case PAPER_A1:
1492                         case PAPER_A2:
1493                         case PAPER_A6:
1494                         case PAPER_B0:
1495                         case PAPER_B1:
1496                         case PAPER_B2:
1497                         case PAPER_B3:
1498                         case PAPER_B4:
1499                         case PAPER_B6:
1500                         case PAPER_C0:
1501                         case PAPER_C1:
1502                         case PAPER_C2:
1503                         case PAPER_C3:
1504                         case PAPER_C4:
1505                         case PAPER_C5:
1506                         case PAPER_C6:
1507                         case PAPER_JISB0:
1508                         case PAPER_JISB1:
1509                         case PAPER_JISB2:
1510                         case PAPER_JISB3:
1511                         case PAPER_JISB4:
1512                         case PAPER_JISB5:
1513                         case PAPER_JISB6: break;
1514                         }
1515                         os << "\"\n";
1516                 }
1517                 if (tag != RC_LAST)
1518                         break;
1519         case RC_CHKTEX_COMMAND:
1520                 if (ignore_system_lyxrc ||
1521                     chktex_command != system_lyxrc.chktex_command) {
1522                         os << "\\chktex_command \"" << escapeCommand(chktex_command) << "\"\n";
1523                 }
1524                 if (tag != RC_LAST)
1525                         break;
1526         case RC_BIBTEX_ALTERNATIVES: {
1527                 CommandSet::const_iterator it = bibtex_alternatives.begin();
1528                 CommandSet::const_iterator end = bibtex_alternatives.end();
1529                 for ( ; it != end; ++it) {
1530                         if (ignore_system_lyxrc
1531                             || !system_lyxrc.bibtex_alternatives.count(*it))
1532                                 os << "\\bibtex_alternatives \""
1533                                    << *it << "\"\n";
1534                 }
1535                 if (tag != RC_LAST)
1536                         break;
1537         }
1538         case RC_BIBTEX_COMMAND:
1539                 if (ignore_system_lyxrc ||
1540                     bibtex_command != system_lyxrc.bibtex_command) {
1541                         os << "\\bibtex_command \"" << escapeCommand(bibtex_command) << "\"\n";
1542                 }
1543                 if (tag != RC_LAST)
1544                         break;
1545         case RC_JBIBTEX_COMMAND:
1546                 if (ignore_system_lyxrc ||
1547                     jbibtex_command != system_lyxrc.jbibtex_command) {
1548                         os << "\\jbibtex_command \"" << escapeCommand(jbibtex_command) << "\"\n";
1549                 }
1550                 if (tag != RC_LAST)
1551                         break;
1552         case RC_INDEX_ALTERNATIVES: {
1553                 CommandSet::const_iterator it = index_alternatives.begin();
1554                 CommandSet::const_iterator end = index_alternatives.end();
1555                 for ( ; it != end; ++it) {
1556                         if (ignore_system_lyxrc
1557                             || !system_lyxrc.index_alternatives.count(*it))
1558                                 os << "\\index_alternatives \""
1559                                    << *it << "\"\n";
1560                 }
1561                 if (tag != RC_LAST)
1562                         break;
1563         }
1564         case RC_INDEX_COMMAND:
1565                 if (ignore_system_lyxrc ||
1566                     index_command != system_lyxrc.index_command) {
1567                         os << "\\index_command \"" << escapeCommand(index_command) << "\"\n";
1568                 }
1569                 if (tag != RC_LAST)
1570                         break;
1571         case RC_JINDEX_COMMAND:
1572                 if (ignore_system_lyxrc ||
1573                     jindex_command != system_lyxrc.jindex_command) {
1574                         os << "\\jindex_command \"" << escapeCommand(jindex_command) << "\"\n";
1575                 }
1576                 if (tag != RC_LAST)
1577                         break;
1578         case RC_SPLITINDEX_COMMAND:
1579                 if (ignore_system_lyxrc ||
1580                     splitindex_command != system_lyxrc.splitindex_command) {
1581                         os << "\\splitindex_command \"" << escapeCommand(splitindex_command) << "\"\n";
1582                 }
1583                 if (tag != RC_LAST)
1584                         break;
1585         case RC_NOMENCL_COMMAND:
1586                 if (ignore_system_lyxrc ||
1587                     nomencl_command != system_lyxrc.nomencl_command) {
1588                         os << "\\nomencl_command \"" << escapeCommand(nomencl_command) << "\"\n";
1589                 }
1590                 if (tag != RC_LAST)
1591                         break;
1592         case RC_TEX_EXPECTS_WINDOWS_PATHS:
1593                 if (ignore_system_lyxrc ||
1594                     windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
1595                         os << "\\tex_expects_windows_paths "
1596                            << convert<string>(windows_style_tex_paths) << '\n';
1597                 }
1598                 if (tag != RC_LAST)
1599                         break;
1600         case RC_TEX_ALLOWS_SPACES:
1601                 if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
1602                         os << "\\tex_allows_spaces "
1603                            << convert<string>(tex_allows_spaces) << '\n';
1604                 }
1605                 if (tag != RC_LAST)
1606                         break;
1607         case RC_KBMAP:
1608                 if (ignore_system_lyxrc ||
1609                     use_kbmap != system_lyxrc.use_kbmap) {
1610                         os << "\\kbmap " << convert<string>(use_kbmap) << '\n';
1611                 }
1612                 if (tag != RC_LAST)
1613                         break;
1614         case RC_KBMAP_PRIMARY:
1615                 if (ignore_system_lyxrc ||
1616                     primary_kbmap != system_lyxrc.primary_kbmap) {
1617                         string const path = os::external_path(primary_kbmap);
1618                         os << "\\kbmap_primary \"" << path << "\"\n";
1619                 }
1620                 if (tag != RC_LAST)
1621                         break;
1622         case RC_KBMAP_SECONDARY:
1623                 if (ignore_system_lyxrc ||
1624                     secondary_kbmap != system_lyxrc.secondary_kbmap) {
1625                         string const path = os::external_path(secondary_kbmap);
1626                         os << "\\kbmap_secondary \"" << path << "\"\n";
1627                 }
1628                 if (tag != RC_LAST)
1629                         break;
1630         case RC_SERVERPIPE:
1631                 if (ignore_system_lyxrc ||
1632                     lyxpipes != system_lyxrc.lyxpipes) {
1633                         string const path = os::external_path(lyxpipes);
1634                         os << "\\serverpipe \"" << path << "\"\n";
1635                 }
1636                 if (tag != RC_LAST)
1637                         break;
1638         case RC_DATE_INSERT_FORMAT:
1639                 if (ignore_system_lyxrc ||
1640                     date_insert_format != system_lyxrc.date_insert_format) {
1641                         os << "\\date_insert_format \"" << date_insert_format
1642                            << "\"\n";
1643                 }
1644                 if (tag != RC_LAST)
1645                         break;
1646
1647         case RC_USER_NAME:
1648                 os << "\\user_name \"" << user_name << "\"\n";
1649                 if (tag != RC_LAST)
1650                         break;
1651
1652         case RC_USER_EMAIL:
1653                 os << "\\user_email \"" << user_email << "\"\n";
1654                 if (tag != RC_LAST)
1655                         break;
1656
1657         case RC_SHOW_BANNER:
1658                 if (ignore_system_lyxrc ||
1659                     show_banner != system_lyxrc.show_banner) {
1660                         os << "\\show_banner " << convert<string>(show_banner) << '\n';
1661                 }
1662                 if (tag != RC_LAST)
1663                         break;
1664
1665         case RC_PREVIEW:
1666                 if (ignore_system_lyxrc ||
1667                     preview != system_lyxrc.preview) {
1668                         string status;
1669                         switch (preview) {
1670                         case PREVIEW_ON:
1671                                 status = "on";
1672                                 break;
1673                         case PREVIEW_NO_MATH:
1674                                 status = "no_math";
1675                                 break;
1676                         case PREVIEW_OFF:
1677                                 status = "off";
1678                                 break;
1679                         }
1680                         os << "\\preview " << status << '\n';
1681                 }
1682                 if (tag != RC_LAST)
1683                         break;
1684
1685         case RC_PREVIEW_HASHED_LABELS:
1686                 if (ignore_system_lyxrc ||
1687                     preview_hashed_labels !=
1688                     system_lyxrc.preview_hashed_labels) {
1689                         os << "\\preview_hashed_labels "
1690                            << convert<string>(preview_hashed_labels) << '\n';
1691                 }
1692                 if (tag != RC_LAST)
1693                         break;
1694
1695         case RC_PREVIEW_SCALE_FACTOR:
1696                 if (ignore_system_lyxrc ||
1697                     preview_scale_factor != system_lyxrc.preview_scale_factor) {
1698                         os << "\\preview_scale_factor "
1699                            << preview_scale_factor << '\n';
1700                 }
1701                 if (tag != RC_LAST)
1702                         break;
1703
1704         case RC_USE_CONVERTER_CACHE:
1705                 if (ignore_system_lyxrc ||
1706                     use_converter_cache != system_lyxrc.use_converter_cache) {
1707                         os << "\\use_converter_cache "
1708                            << convert<string>(use_converter_cache) << '\n';
1709                 }
1710                 if (tag != RC_LAST)
1711                         break;
1712
1713         case RC_CONVERTER_CACHE_MAXAGE:
1714                 if (ignore_system_lyxrc ||
1715                     converter_cache_maxage != system_lyxrc.converter_cache_maxage) {
1716                         os << "\\converter_cache_maxage "
1717                            << converter_cache_maxage << '\n';
1718                 }
1719                 if (tag != RC_LAST)
1720                         break;
1721
1722                 os << "\n#\n"
1723                    << "# SCREEN & FONTS SECTION ############################\n"
1724                    << "#\n\n";
1725
1726         case RC_SCREEN_DPI:
1727                 if (ignore_system_lyxrc ||
1728                     dpi != system_lyxrc.dpi) {
1729                         os << "\\screen_dpi " << dpi << '\n';
1730                 }
1731                 if (tag != RC_LAST)
1732                         break;
1733         case RC_SCREEN_ZOOM:
1734                 if (ignore_system_lyxrc ||
1735                     zoom != system_lyxrc.zoom) {
1736                         os << "\\screen_zoom " << zoom << '\n';
1737                 }
1738                 if (tag != RC_LAST)
1739                         break;
1740         case RC_GEOMETRY_SESSION:
1741                 if (ignore_system_lyxrc ||
1742                     allow_geometry_session != system_lyxrc.allow_geometry_session) {
1743                         os << "\\allow_geometry_session " << convert<string>(allow_geometry_session)
1744                            << '\n';
1745                 }
1746                 if (tag != RC_LAST)
1747                         break;
1748         case RC_CURSOR_FOLLOWS_SCROLLBAR:
1749                 if (ignore_system_lyxrc ||
1750                     cursor_follows_scrollbar
1751                     != system_lyxrc.cursor_follows_scrollbar) {
1752                         os << "\\cursor_follows_scrollbar "
1753                            << convert<string>(cursor_follows_scrollbar) << '\n';
1754                 }
1755                 if (tag != RC_LAST)
1756                         break;
1757         case RC_SCROLL_BELOW_DOCUMENT:
1758                 if (ignore_system_lyxrc ||
1759                     scroll_below_document
1760                     != system_lyxrc.scroll_below_document) {
1761                         os << "\\scroll_below_document "
1762                            << convert<string>(scroll_below_document) << '\n';
1763                 }
1764                 if (tag != RC_LAST)
1765                         break;
1766         case RC_PARAGRAPH_MARKERS:
1767                 if (ignore_system_lyxrc ||
1768                         paragraph_markers
1769                     != system_lyxrc.paragraph_markers) {
1770                         os << "\\paragraph_markers "
1771                            << convert<string>(paragraph_markers) << '\n';
1772                 }
1773                 if (tag != RC_LAST)
1774                         break;
1775         case RC_MAC_DONTSWAP_CTRL_META:
1776                 if (ignore_system_lyxrc ||
1777                     mac_dontswap_ctrl_meta
1778                     != system_lyxrc.mac_dontswap_ctrl_meta) {
1779                         os << "\\mac_dontswap_ctrl_meta "
1780                            << convert<string>(mac_dontswap_ctrl_meta) << '\n';
1781                 }
1782                 if (tag != RC_LAST)
1783                         break;
1784         case RC_MAC_LIKE_WORD_MOVEMENT:
1785                 if (ignore_system_lyxrc ||
1786                     mac_like_word_movement
1787                     != system_lyxrc.mac_like_word_movement) {
1788                         os << "\\mac_like_word_movement "
1789                            << convert<string>(mac_like_word_movement) << '\n';
1790                 }
1791                 if (tag != RC_LAST)
1792                         break;
1793         case RC_MACRO_EDIT_STYLE:
1794                 if (ignore_system_lyxrc ||
1795                     macro_edit_style
1796                     != system_lyxrc.macro_edit_style) {
1797                         os << "\\macro_edit_style ";
1798                         switch (macro_edit_style) {
1799                         case MACRO_EDIT_INLINE_BOX: os << "0\n"; break;
1800                         case MACRO_EDIT_INLINE: os << "1\n"; break;
1801                         case MACRO_EDIT_LIST: os << "2\n"; break;
1802                         }
1803                 }
1804                 if (tag != RC_LAST)
1805                         break;
1806         case RC_DIALOGS_ICONIFY_WITH_MAIN:
1807                 if (ignore_system_lyxrc ||
1808                     dialogs_iconify_with_main
1809                    != system_lyxrc.dialogs_iconify_with_main) {
1810                         os << "\\dialogs_iconify_with_main "
1811                           <<  convert<string>(dialogs_iconify_with_main) << '\n';
1812                 }
1813                 if (tag != RC_LAST)
1814                         break;
1815         case RC_SCREEN_FONT_ROMAN:
1816                 if (ignore_system_lyxrc ||
1817                     roman_font_name != system_lyxrc.roman_font_name) {
1818                         os << "\\screen_font_roman \"" << roman_font_name
1819                            << "\"\n";
1820                 }
1821                 if (tag != RC_LAST)
1822                         break;
1823         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
1824                 if (ignore_system_lyxrc ||
1825                     roman_font_foundry != system_lyxrc.roman_font_foundry) {
1826                         os << "\\screen_font_roman_foundry \"" << roman_font_foundry
1827                            << "\"\n";
1828                 }
1829                 if (tag != RC_LAST)
1830                         break;
1831         case RC_SCREEN_FONT_SANS:
1832                 if (ignore_system_lyxrc ||
1833                     sans_font_name != system_lyxrc.sans_font_name) {
1834                         os << "\\screen_font_sans \"" << sans_font_name
1835                            << "\"\n";
1836                 }
1837                 if (tag != RC_LAST)
1838                         break;
1839         case RC_SCREEN_FONT_SANS_FOUNDRY:
1840                 if (ignore_system_lyxrc ||
1841                     sans_font_foundry != system_lyxrc.sans_font_foundry) {
1842                         os << "\\screen_font_sans_foundry \"" << sans_font_foundry
1843                            << "\"\n";
1844                 }
1845                 if (tag != RC_LAST)
1846                         break;
1847         case RC_SCREEN_FONT_TYPEWRITER:
1848                 if (ignore_system_lyxrc ||
1849                     typewriter_font_name != system_lyxrc.typewriter_font_name) {
1850                         os << "\\screen_font_typewriter \""
1851                            << typewriter_font_name << "\"\n";
1852                 }
1853                 if (tag != RC_LAST)
1854                         break;
1855         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
1856                 if (ignore_system_lyxrc ||
1857                     typewriter_font_foundry != system_lyxrc.typewriter_font_foundry) {
1858                         os << "\\screen_font_typewriter_foundry \""
1859                            << typewriter_font_foundry << "\"\n";
1860                 }
1861                 if (tag != RC_LAST)
1862                         break;
1863
1864         case RC_SCREEN_FONT_SCALABLE:
1865                 if (ignore_system_lyxrc ||
1866                     use_scalable_fonts != system_lyxrc.use_scalable_fonts) {
1867                         os << "\\screen_font_scalable "
1868                            << convert<string>(use_scalable_fonts)
1869                            << '\n';
1870                 }
1871                 if (tag != RC_LAST)
1872                         break;
1873         case RC_SCREEN_FONT_SIZES:
1874                 if (ignore_system_lyxrc ||
1875                     font_sizes[FONT_SIZE_TINY]
1876                     != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
1877                     font_sizes[FONT_SIZE_SCRIPT]
1878                     != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
1879                     font_sizes[FONT_SIZE_FOOTNOTE]
1880                     != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
1881                     font_sizes[FONT_SIZE_SMALL]
1882                     != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
1883                     font_sizes[FONT_SIZE_NORMAL]
1884                     != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
1885                     font_sizes[FONT_SIZE_LARGE]
1886                     != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
1887                     font_sizes[FONT_SIZE_LARGER]
1888                     != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
1889                     font_sizes[FONT_SIZE_LARGEST]
1890                     != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
1891                     font_sizes[FONT_SIZE_HUGE]
1892                     != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
1893                     font_sizes[FONT_SIZE_HUGER]
1894                     != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
1895                         os.setf(ios::fixed);
1896                         os.precision(2);
1897                         os << "\\screen_font_sizes"
1898                            << ' ' << font_sizes[FONT_SIZE_TINY]
1899                            << ' ' << font_sizes[FONT_SIZE_SCRIPT]
1900                            << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
1901                            << ' ' << font_sizes[FONT_SIZE_SMALL]
1902                            << ' ' << font_sizes[FONT_SIZE_NORMAL]
1903                            << ' ' << font_sizes[FONT_SIZE_LARGE]
1904                            << ' ' << font_sizes[FONT_SIZE_LARGER]
1905                            << ' ' << font_sizes[FONT_SIZE_LARGEST]
1906                            << ' ' << font_sizes[FONT_SIZE_HUGE]
1907                            << ' ' << font_sizes[FONT_SIZE_HUGER]
1908                            << '\n';
1909                 }
1910                 if (tag != RC_LAST)
1911                         break;
1912         case RC_FULL_SCREEN_LIMIT:
1913                 if (ignore_system_lyxrc ||
1914                     full_screen_limit != system_lyxrc.full_screen_limit) {
1915                         os << "\\fullscreen_limit "
1916                            << convert<string>(full_screen_limit)
1917                            << '\n';
1918                 }
1919                 if (tag != RC_LAST)
1920                         break;
1921         case RC_FULL_SCREEN_TOOLBARS:
1922                 if (ignore_system_lyxrc ||
1923                     full_screen_toolbars != system_lyxrc.full_screen_toolbars) {
1924                         os << "\\fullscreen_toolbars "
1925                            << convert<string>(full_screen_toolbars)
1926                            << '\n';
1927                 }
1928                 if (tag != RC_LAST)
1929                         break;
1930         case RC_FULL_SCREEN_SCROLLBAR:
1931                 if (ignore_system_lyxrc ||
1932                     full_screen_scrollbar != system_lyxrc.full_screen_scrollbar) {
1933                         os << "\\fullscreen_scrollbar "
1934                            << convert<string>(full_screen_scrollbar)
1935                            << '\n';
1936                 }
1937                 if (tag != RC_LAST)
1938                         break;
1939         case RC_FULL_SCREEN_TABBAR:
1940                 if (ignore_system_lyxrc ||
1941                     full_screen_tabbar != system_lyxrc.full_screen_tabbar) {
1942                         os << "\\fullscreen_tabbar "
1943                            << convert<string>(full_screen_tabbar)
1944                            << '\n';
1945                 }
1946                 if (tag != RC_LAST)
1947                         break;
1948         case RC_FULL_SCREEN_MENUBAR:
1949                 if (ignore_system_lyxrc ||
1950                     full_screen_menubar != system_lyxrc.full_screen_menubar) {
1951                         os << "\\fullscreen_menubar "
1952                            << convert<string>(full_screen_menubar)
1953                            << '\n';
1954                 }
1955                 if (tag != RC_LAST)
1956                         break;
1957         case RC_FULL_SCREEN_WIDTH:
1958                 if (ignore_system_lyxrc ||
1959                     full_screen_width != system_lyxrc.full_screen_width) {
1960                         os << "\\fullscreen_width "
1961                            << convert<string>(full_screen_width)
1962                            << '\n';
1963                 }
1964                 if (tag != RC_LAST)
1965                         break;
1966         case RC_OPEN_BUFFERS_IN_TABS:
1967                 if (ignore_system_lyxrc ||
1968                     open_buffers_in_tabs != system_lyxrc.open_buffers_in_tabs) {
1969                         os << "\\open_buffers_in_tabs "
1970                            << convert<string>(open_buffers_in_tabs)
1971                            << '\n';
1972                 }
1973                 if (tag != RC_LAST)
1974                         break;
1975         case RC_SINGLE_CLOSE_TAB_BUTTON:
1976                 if (ignore_system_lyxrc ||
1977                     single_close_tab_button != system_lyxrc.single_close_tab_button) {
1978                         os << "\\single_close_tab_button "
1979                            << convert<string>(single_close_tab_button)
1980                            << '\n';
1981                 }
1982                 if (tag != RC_LAST)
1983                         break;
1984         case RC_SINGLE_INSTANCE:
1985                 if (ignore_system_lyxrc ||
1986                     single_instance != system_lyxrc.single_instance) {
1987                         os << "\\single_instance "
1988                            << convert<string>(single_instance)
1989                            << '\n';
1990                 }
1991                 if (tag != RC_LAST)
1992                         break;
1993         case RC_FORWARD_SEARCH_DVI:
1994                 if (ignore_system_lyxrc ||
1995                     forward_search_dvi != system_lyxrc.forward_search_dvi) {
1996                         os << "\\forward_search_dvi \"" << escapeCommand(forward_search_dvi) << "\"\n";
1997                 }
1998                 if (tag != RC_LAST)
1999                         break;
2000         case RC_FORWARD_SEARCH_PDF:
2001                 if (ignore_system_lyxrc ||
2002                     forward_search_pdf != system_lyxrc.forward_search_pdf) {
2003                         os << "\\forward_search_pdf \"" << escapeCommand(forward_search_pdf) << "\"\n";
2004                 }
2005                 if (tag != RC_LAST)
2006                         break;
2007
2008         os << "\n#\n"
2009                         << "# COLOR SECTION ###################################\n"
2010                         << "#\n\n";
2011
2012         case RC_SET_COLOR:
2013                 for (int i = 0; i < Color_ignore; ++i) {
2014                         ColorCode lc = static_cast<ColorCode>(i);
2015                         string const col = lcolor.getX11Name(lc);
2016                         if (ignore_system_lyxrc
2017                             || col != system_lcolor.getX11Name(lc)) {
2018                                 os << "\\set_color \""
2019                                    << lcolor.getLyXName(lc) << "\" \""
2020                                    << col << "\"\n";
2021                         }
2022                 }
2023                 if (tag != RC_LAST)
2024                         break;
2025
2026                 os << "\n#\n"
2027                    << "# PRINTER SECTION ###################################\n"
2028                    << "#\n\n";
2029
2030         case RC_PRINTER:
2031                 if (ignore_system_lyxrc ||
2032                     printer != system_lyxrc.printer) {
2033                         os << "\\printer \"" << printer << "\"\n";
2034                 }
2035                 if (tag != RC_LAST)
2036                         break;
2037         case RC_PRINT_ADAPTOUTPUT:
2038                 if (ignore_system_lyxrc ||
2039                     print_adapt_output != system_lyxrc.print_adapt_output) {
2040                         os << "\\print_adapt_output "
2041                            << convert<string>(print_adapt_output)
2042                            << '\n';
2043                 }
2044                 if (tag != RC_LAST)
2045                         break;
2046         case RC_PRINT_COMMAND:
2047                 if (ignore_system_lyxrc ||
2048                     print_command != system_lyxrc.print_command) {
2049                         os << "\\print_command \"" << escapeCommand(print_command) << "\"\n";
2050                 }
2051                 if (tag != RC_LAST)
2052                         break;
2053         case RC_PRINTEXSTRAOPTIONS:
2054                 if (ignore_system_lyxrc ||
2055                     print_extra_options != system_lyxrc.print_extra_options) {
2056                         os << "\\print_extra_options \"" << print_extra_options
2057                            << "\"\n";
2058                 }
2059                 if (tag != RC_LAST)
2060                         break;
2061         case RC_PRINTSPOOL_COMMAND:
2062                 if (ignore_system_lyxrc ||
2063                     print_spool_command != system_lyxrc.print_spool_command) {
2064                         os << "\\print_spool_command \"" << escapeCommand(print_spool_command)
2065                            << "\"\n";
2066                 }
2067                 if (tag != RC_LAST)
2068                         break;
2069         case RC_PRINTSPOOL_PRINTERPREFIX:
2070                 if (ignore_system_lyxrc ||
2071                     print_spool_printerprefix
2072                     != system_lyxrc.print_spool_printerprefix) {
2073                         os << "\\print_spool_printerprefix \""
2074                            << print_spool_printerprefix << "\"\n";
2075                 }
2076                 if (tag != RC_LAST)
2077                         break;
2078         case RC_PRINTEVENPAGEFLAG:
2079                 if (ignore_system_lyxrc ||
2080                     print_evenpage_flag != system_lyxrc.print_evenpage_flag) {
2081                         os << "\\print_evenpage_flag \"" << print_evenpage_flag
2082                            << "\"\n";
2083                 }
2084                 if (tag != RC_LAST)
2085                         break;
2086         case RC_PRINTODDPAGEFLAG:
2087                 if (ignore_system_lyxrc ||
2088                     print_oddpage_flag != system_lyxrc.print_oddpage_flag) {
2089                         os << "\\print_oddpage_flag \"" << print_oddpage_flag
2090                            << "\"\n";
2091                 }
2092                 if (tag != RC_LAST)
2093                         break;
2094         case RC_PRINTREVERSEFLAG:
2095                 if (ignore_system_lyxrc ||
2096                     print_reverse_flag != system_lyxrc.print_reverse_flag) {
2097                         os << "\\print_reverse_flag \"" << print_reverse_flag
2098                            << "\"\n";
2099                 }
2100                 if (tag != RC_LAST)
2101                         break;
2102         case RC_PRINTLANDSCAPEFLAG:
2103                 if (ignore_system_lyxrc ||
2104                     print_landscape_flag != system_lyxrc.print_landscape_flag) {
2105                         os << "\\print_landscape_flag \"" << print_landscape_flag
2106                            << "\"\n";
2107                 }
2108                 if (tag != RC_LAST)
2109                         break;
2110         case RC_PRINTPAGERANGEFLAG:
2111                 if (ignore_system_lyxrc ||
2112                     print_pagerange_flag != system_lyxrc.print_pagerange_flag) {
2113                         os << "\\print_pagerange_flag \"" << print_pagerange_flag
2114                            << "\"\n";
2115                 }
2116                 if (tag != RC_LAST)
2117                         break;
2118         case RC_PRINTCOPIESFLAG:
2119                 if (ignore_system_lyxrc ||
2120                     print_copies_flag != system_lyxrc.print_copies_flag) {
2121                         os << "\\print_copies_flag \"" << print_copies_flag
2122                            << "\"\n";
2123                 }
2124                 if (tag != RC_LAST)
2125                         break;
2126         case RC_PRINTCOLLCOPIESFLAG:
2127                 if (ignore_system_lyxrc ||
2128                     print_collcopies_flag
2129                     != system_lyxrc.print_collcopies_flag) {
2130                         os << "\\print_collcopies_flag \""
2131                            << print_collcopies_flag
2132                            << "\"\n";
2133                 }
2134                 if (tag != RC_LAST)
2135                         break;
2136         case RC_PRINTPAPERFLAG:
2137                 if (ignore_system_lyxrc ||
2138                     print_paper_flag != system_lyxrc.print_paper_flag) {
2139                         os << "\\print_paper_flag \"" << print_paper_flag
2140                            << "\"\n";
2141                 }
2142                 if (tag != RC_LAST)
2143                         break;
2144         case RC_PRINTPAPERDIMENSIONFLAG:
2145                 if (ignore_system_lyxrc ||
2146                     print_paper_dimension_flag
2147                     != system_lyxrc.print_paper_dimension_flag) {
2148                         os << "\\print_paper_dimension_flag \""
2149                            << print_paper_dimension_flag << "\"\n";
2150                 }
2151                 if (tag != RC_LAST)
2152                         break;
2153         case RC_PRINTTOPRINTER:
2154                 if (ignore_system_lyxrc ||
2155                     print_to_printer != system_lyxrc.print_to_printer) {
2156                         os << "\\print_to_printer \"" << print_to_printer
2157                            << "\"\n";
2158                 }
2159                 if (tag != RC_LAST)
2160                         break;
2161         case RC_PRINTTOFILE:
2162                 if (ignore_system_lyxrc ||
2163                     print_to_file != system_lyxrc.print_to_file) {
2164                         string const path = os::external_path(print_to_file);
2165                         os << "\\print_to_file \"" << path << "\"\n";
2166                 }
2167                 if (tag != RC_LAST)
2168                         break;
2169         case RC_PRINTFILEEXTENSION:
2170                 if (ignore_system_lyxrc ||
2171                     print_file_extension != system_lyxrc.print_file_extension) {
2172                         os << "\\print_file_extension \""
2173                            << print_file_extension
2174                            << "\"\n";
2175                 }
2176                 if (tag != RC_LAST)
2177                         break;
2178
2179                 os << "\n#\n"
2180                    << "# TEX SECTION #######################################\n"
2181                    << "#\n\n";
2182
2183         case RC_FONT_ENCODING:
2184                 if (ignore_system_lyxrc ||
2185                     fontenc != system_lyxrc.fontenc) {
2186                         os << "\\font_encoding \"" << fontenc << "\"\n";
2187                 }
2188                 if (tag != RC_LAST)
2189                         break;
2190
2191         case RC_FORCE_PAINT_SINGLE_CHAR:
2192                 if (ignore_system_lyxrc ||
2193                     force_paint_single_char != system_lyxrc.force_paint_single_char) {
2194                         os << "\\force_paint_single_char \"" << force_paint_single_char << "\"\n";
2195                 }
2196                 if (tag != RC_LAST)
2197                         break;
2198
2199                 os << "\n#\n"
2200                    << "# FILE SECTION ######################################\n"
2201                    << "#\n\n";
2202
2203         case RC_DOCUMENTPATH:
2204                 if (ignore_system_lyxrc ||
2205                     document_path != system_lyxrc.document_path) {
2206                         string const path = os::external_path(document_path);
2207                         os << "\\document_path \"" << path << "\"\n";
2208                 }
2209                 if (tag != RC_LAST)
2210                         break;
2211         case RC_USELASTFILEPOS:
2212                 if (ignore_system_lyxrc ||
2213                     use_lastfilepos != system_lyxrc.use_lastfilepos) {
2214                         os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
2215                            << '\n';
2216                 }
2217                 if (tag != RC_LAST)
2218                         break;
2219         case RC_LOADSESSION:
2220                 if (ignore_system_lyxrc ||
2221                     load_session != system_lyxrc.load_session) {
2222                         os << "\\load_session " << convert<string>(load_session)
2223                            << "\n";
2224                 }
2225                 if (tag != RC_LAST)
2226                         break;
2227         case RC_MOUSE_WHEEL_SPEED:
2228                 if (ignore_system_lyxrc ||
2229                     mouse_wheel_speed != system_lyxrc.mouse_wheel_speed) {
2230                         os << "\\mouse_wheel_speed " << mouse_wheel_speed << '\n';
2231                 }
2232                 if (tag != RC_LAST)
2233                         break;
2234         case RC_COMPLETION_INLINE_DELAY:
2235                 if (ignore_system_lyxrc ||
2236                     completion_inline_delay != system_lyxrc.completion_inline_delay) {
2237                         os << "\\completion_inline_delay " << completion_inline_delay << '\n';
2238                 }
2239                 if (tag != RC_LAST)
2240                         break;
2241         case RC_COMPLETION_INLINE_MATH:
2242                 if (ignore_system_lyxrc ||
2243                     completion_inline_math != system_lyxrc.completion_inline_math) {
2244                         os << "\\completion_inline_math "
2245                                 << convert<string>(completion_inline_math) << '\n';
2246                 }
2247                 if (tag != RC_LAST)
2248                         break;
2249         case RC_COMPLETION_INLINE_TEXT:
2250                 if (ignore_system_lyxrc ||
2251                     completion_inline_text != system_lyxrc.completion_inline_text) {
2252                         os << "\\completion_inline_text "
2253                                 << convert<string>(completion_inline_text) << '\n';
2254                 }
2255                 if (tag != RC_LAST)
2256                         break;
2257         case RC_COMPLETION_INLINE_DOTS:
2258                 if (ignore_system_lyxrc ||
2259                     completion_inline_dots != system_lyxrc.completion_inline_dots) {
2260                         os << "\\completion_inline_dots "
2261                                 << convert<string>(completion_inline_dots) << '\n';
2262                 }
2263                 if (tag != RC_LAST)
2264                         break;
2265         case RC_AUTOCORRECTION_MATH:
2266                 if (ignore_system_lyxrc ||
2267                     autocorrection_math != system_lyxrc.autocorrection_math) {
2268                         os << "\\autocorrection_math "
2269                                 << convert<string>(autocorrection_math) << '\n';
2270                 }
2271                 if (tag != RC_LAST)
2272                         break;
2273         case RC_COMPLETION_POPUP_DELAY:
2274                 if (ignore_system_lyxrc ||
2275                     completion_popup_delay != system_lyxrc.completion_popup_delay) {
2276                         os << "\\completion_popup_delay " << completion_popup_delay << '\n';
2277                 }
2278                 if (tag != RC_LAST)
2279                         break;
2280         case RC_COMPLETION_POPUP_MATH:
2281                 if (ignore_system_lyxrc ||
2282                     completion_popup_math != system_lyxrc.completion_popup_math) {
2283                         os << "\\completion_popup_math "
2284                                 << convert<string>(completion_popup_math) << '\n';
2285                 }
2286                 if (tag != RC_LAST)
2287                         break;
2288         case RC_COMPLETION_POPUP_TEXT:
2289                 if (ignore_system_lyxrc ||
2290                     completion_popup_text != system_lyxrc.completion_popup_text) {
2291                         os << "\\completion_popup_text "
2292                                 << convert<string>(completion_popup_text) << '\n';
2293                 }
2294                 if (tag != RC_LAST)
2295                         break;
2296         case RC_COMPLETION_CURSOR_TEXT:
2297                 if (ignore_system_lyxrc ||
2298                     completion_cursor_text != system_lyxrc.completion_cursor_text) {
2299                         os << "\\completion_cursor_text "
2300                            << convert<string>(completion_cursor_text) << '\n';
2301                 }
2302                 if (tag != RC_LAST)
2303                         break;
2304         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
2305                 if (ignore_system_lyxrc ||
2306                     completion_popup_after_complete
2307                     != system_lyxrc.completion_popup_after_complete) {
2308                         os << "\\completion_popup_after_complete "
2309                                 << convert<string>(completion_popup_after_complete) << '\n';
2310                 }
2311                 if (tag != RC_LAST)
2312                         break;
2313         case RC_NUMLASTFILES:
2314                 if (ignore_system_lyxrc ||
2315                     num_lastfiles != system_lyxrc.num_lastfiles) {
2316                         os << "\\num_lastfiles " << num_lastfiles << '\n';
2317                 }
2318                 if (tag != RC_LAST)
2319                         break;
2320         case RC_CHECKLASTFILES:
2321                 if (ignore_system_lyxrc ||
2322                     check_lastfiles != system_lyxrc.check_lastfiles) {
2323                         os << "\\check_lastfiles " << convert<string>(check_lastfiles)
2324                            << '\n';
2325                 }
2326                 if (tag != RC_LAST)
2327                         break;
2328         case RC_EXAMPLEPATH:
2329                 if (ignore_system_lyxrc ||
2330                     example_path != system_lyxrc.example_path) {
2331                         string const path = os::external_path(example_path);
2332                         os << "\\example_path \"" << path << "\"\n";
2333                 }
2334                 if (tag != RC_LAST)
2335                         break;
2336         case RC_TEMPLATEPATH:
2337                 if (ignore_system_lyxrc ||
2338                     template_path != system_lyxrc.template_path) {
2339                         string const path = os::external_path(template_path);
2340                         os << "\\template_path \"" << path << "\"\n";
2341                 }
2342                 if (tag != RC_LAST)
2343                         break;
2344         case RC_TEMPDIRPATH:
2345                 if (ignore_system_lyxrc ||
2346                     tempdir_path != system_lyxrc.tempdir_path) {
2347                         string const path = os::external_path(tempdir_path);
2348                         os << "\\tempdir_path \"" << path << "\"\n";
2349                 }
2350                 if (tag != RC_LAST)
2351                         break;
2352         case RC_THESAURUSDIRPATH:
2353                 if (ignore_system_lyxrc ||
2354                     thesaurusdir_path != system_lyxrc.thesaurusdir_path) {
2355                         string const path = os::external_path(thesaurusdir_path);
2356                         os << "\\thesaurusdir_path \"" << path << "\"\n";
2357                 }
2358                 if (tag != RC_LAST)
2359                         break;
2360         case RC_HUNSPELLDIR_PATH:
2361                 if (ignore_system_lyxrc ||
2362                     hunspelldir_path != system_lyxrc.hunspelldir_path) {
2363                         string const path = os::external_path(hunspelldir_path);
2364                         os << "\\hunspelldir_path \"" << path << "\"\n";
2365                 }
2366                 if (tag != RC_LAST)
2367                         break;
2368         case RC_PLAINTEXT_LINELEN:
2369                 if (ignore_system_lyxrc ||
2370                     plaintext_linelen != system_lyxrc.plaintext_linelen) {
2371                         os << "\\plaintext_linelen " << plaintext_linelen << '\n';
2372                 }
2373                 if (tag != RC_LAST)
2374                         break;
2375         case RC_MAKE_BACKUP:
2376                 if (ignore_system_lyxrc ||
2377                     make_backup != system_lyxrc.make_backup) {
2378                         os << "\\make_backup " << convert<string>(make_backup) << '\n';
2379                 }
2380                 if (tag != RC_LAST)
2381                         break;
2382         case RC_SAVE_COMPRESSED:
2383                 if (ignore_system_lyxrc ||
2384                     save_compressed != system_lyxrc.save_compressed) {
2385                         os << "\\save_compressed " << convert<string>(save_compressed) << '\n';
2386                 }
2387                 if (tag != RC_LAST)
2388                         break;
2389         case RC_BACKUPDIR_PATH:
2390                 if (ignore_system_lyxrc ||
2391                     backupdir_path != system_lyxrc.backupdir_path) {
2392                         string const path = os::external_path(backupdir_path);
2393                         os << "\\backupdir_path \"" << path << "\"\n";
2394                 }
2395                 if (tag != RC_LAST)
2396                         break;
2397
2398                 os << "\n#\n"
2399                    << "# PLAIN TEXT EXPORT SECTION ##############################\n"
2400                    << "#\n\n";
2401
2402                 os << "\n#\n"
2403                    << "# SPELLCHECKER SECTION ##############################\n"
2404                    << "#\n\n";
2405
2406         case RC_ACCEPT_COMPOUND:
2407                 if (ignore_system_lyxrc ||
2408                     spellchecker_accept_compound != system_lyxrc.spellchecker_accept_compound) {
2409                         os << "\\accept_compound " << convert<string>(spellchecker_accept_compound)
2410                            << '\n';
2411                 }
2412                 if (tag != RC_LAST)
2413                         break;
2414         case RC_ALT_LANG:
2415                 if (ignore_system_lyxrc ||
2416                     spellchecker_alt_lang != system_lyxrc.spellchecker_alt_lang) {
2417                         os << "\\alternate_language \"" << spellchecker_alt_lang
2418                            << "\"\n";
2419                 }
2420                 if (tag != RC_LAST)
2421                         break;
2422         case RC_ESC_CHARS:
2423                 if (ignore_system_lyxrc ||
2424                     spellchecker_esc_chars != system_lyxrc.spellchecker_esc_chars) {
2425                         os << "\\escape_chars \"" << spellchecker_esc_chars << "\"\n";
2426                 }
2427                 if (tag != RC_LAST)
2428                         break;
2429         case RC_USE_SYSTEM_COLORS:
2430                 if (ignore_system_lyxrc ||
2431                     use_system_colors != system_lyxrc.use_system_colors) {
2432                         os << "\\use_system_colors "
2433                            << convert<string>(use_system_colors)
2434                            << '\n';
2435                 }
2436                 if (tag != RC_LAST)
2437                         break;
2438         case RC_USE_TOOLTIP:
2439                 if (ignore_system_lyxrc ||
2440                     use_tooltip != system_lyxrc.use_tooltip) {
2441                         os << "\\use_tooltip "
2442                            << convert<string>(use_tooltip)
2443                            << '\n';
2444                 }
2445                 if (tag != RC_LAST)
2446                         break;
2447         case RC_USE_PIXMAP_CACHE:
2448                 if (ignore_system_lyxrc ||
2449                     use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
2450                         os << "\\use_pixmap_cache "
2451                            << convert<string>(use_pixmap_cache)
2452                            << '\n';
2453                 }
2454                 if (tag != RC_LAST)
2455                         break;
2456
2457                 os << "\n#\n"
2458                    << "# LANGUAGE SUPPORT SECTION ##########################\n"
2459                    << "#\n\n";
2460                 if (tag != RC_LAST)
2461                         break;
2462
2463         case RC_DEFAULT_DECIMAL_POINT:
2464                 if (ignore_system_lyxrc ||
2465                     default_decimal_point != system_lyxrc.default_decimal_point) {
2466                         os << "\\default_decimal_point " << default_decimal_point << '\n';
2467                 }
2468                 if (tag != RC_LAST)
2469                         break;
2470
2471         case RC_SPELLCHECKER:
2472                 if (ignore_system_lyxrc ||
2473                     spellchecker != system_lyxrc.spellchecker) {
2474                         os << "\\spellchecker " << spellchecker << '\n';
2475                 }
2476                 if (tag != RC_LAST)
2477                         break;
2478
2479         case RC_SPELLCHECK_CONTINUOUSLY:
2480                 if (ignore_system_lyxrc ||
2481                     spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
2482                         os << "\\spellcheck_continuously " << convert<string>(spellcheck_continuously)
2483                            << '\n';
2484                 }
2485                 if (tag != RC_LAST)
2486                         break;
2487
2488         case RC_SPELLCHECK_NOTES:
2489                 if (ignore_system_lyxrc ||
2490                     spellcheck_notes != system_lyxrc.spellcheck_notes) {
2491                         os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
2492                            << '\n';
2493                 }
2494                 if (tag != RC_LAST)
2495                         break;
2496
2497         case RC_RTL_SUPPORT:
2498                 if (ignore_system_lyxrc ||
2499                     rtl_support != system_lyxrc.rtl_support) {
2500                         os << "\\rtl " << convert<string>(rtl_support) << '\n';
2501                 }
2502                 if (tag != RC_LAST)
2503                         break;
2504         case RC_VISUAL_CURSOR:
2505                 if (ignore_system_lyxrc ||
2506                         visual_cursor != system_lyxrc.visual_cursor) {
2507                         os << "\\visual_cursor " << convert<string>(visual_cursor) << '\n';
2508                 }
2509                 if (tag != RC_LAST)
2510                         break;
2511         case RC_LANGUAGE_CUSTOM_PACKAGE:
2512                 if (ignore_system_lyxrc ||
2513                     language_custom_package != system_lyxrc.language_custom_package) {
2514                         os << "\\language_custom_package \"" << language_custom_package
2515                            << "\"\n";
2516                 }
2517                 if (tag != RC_LAST)
2518                         break;
2519         case RC_LANGUAGE_GLOBAL_OPTIONS:
2520                 if (ignore_system_lyxrc ||
2521                     language_global_options
2522                     != system_lyxrc.language_global_options) {
2523                         os << "\\language_global_options \""
2524                            << convert<string>(language_global_options)
2525                            << "\"\n";
2526                 }
2527                 if (tag != RC_LAST)
2528                         break;
2529         case RC_LANGUAGE_PACKAGE_SELECTION:
2530                 if (ignore_system_lyxrc ||
2531                     language_package_selection != system_lyxrc.language_package_selection) {
2532                         os << "\\language_package_selection ";
2533                         switch (language_package_selection) {
2534                         case LP_AUTO: 
2535                                 os << "0\n";
2536                                 break;
2537                         case LP_BABEL:
2538                                 os << "1\n";
2539                                 break;
2540                         case LP_CUSTOM:
2541                                 os << "2\n";
2542                                 break;
2543                         case LP_NONE:
2544                                 os << "3\n";
2545                                 break;
2546                         }
2547                 }
2548                 if (tag != RC_LAST)
2549                         break;
2550         case RC_LANGUAGE_COMMAND_BEGIN:
2551                 if (ignore_system_lyxrc ||
2552                     language_command_begin
2553                     != system_lyxrc.language_command_begin) {
2554                         os << "\\language_command_begin \""
2555                            << language_command_begin
2556                            << "\"\n";
2557                 }
2558                 if (tag != RC_LAST)
2559                         break;
2560         case RC_LANGUAGE_COMMAND_END:
2561                 if (ignore_system_lyxrc ||
2562                     language_command_end
2563                     != system_lyxrc.language_command_end) {
2564                         os << "\\language_command_end \"" << language_command_end
2565                            << "\"\n";
2566                 }
2567                 if (tag != RC_LAST)
2568                         break;
2569         case RC_LANGUAGE_COMMAND_LOCAL:
2570                 if (ignore_system_lyxrc ||
2571                     language_command_local
2572                     != system_lyxrc.language_command_local) {
2573                         os << "\\language_command_local \""
2574                            << language_command_local
2575                            << "\"\n";
2576                 }
2577                 if (tag != RC_LAST)
2578                         break;
2579         case RC_LANGUAGE_AUTO_BEGIN:
2580                 if (ignore_system_lyxrc ||
2581                     language_auto_begin != system_lyxrc.language_auto_begin) {
2582                         os << "\\language_auto_begin "
2583                            << convert<string>(language_auto_begin) << '\n';
2584                 }
2585                 if (tag != RC_LAST)
2586                         break;
2587         case RC_LANGUAGE_AUTO_END:
2588                 if (ignore_system_lyxrc ||
2589                     language_auto_end != system_lyxrc.language_auto_end) {
2590                         os << "\\language_auto_end "
2591                            << convert<string>(language_auto_end) << '\n';
2592                 }
2593                 if (tag != RC_LAST)
2594                         break;
2595         case RC_MARK_FOREIGN_LANGUAGE:
2596                 if (ignore_system_lyxrc ||
2597                     mark_foreign_language
2598                     != system_lyxrc.mark_foreign_language) {
2599                         os << "\\mark_foreign_language " <<
2600                                 convert<string>(mark_foreign_language) << '\n';
2601                 }
2602                 if (tag != RC_LAST)
2603                         break;
2604
2605                 os << "\n#\n"
2606                    << "# 2nd MISC SUPPORT SECTION ##########################\n"
2607                    << "#\n\n";
2608
2609         case RC_AUTO_NUMBER:
2610                 if (ignore_system_lyxrc ||
2611                     auto_number != system_lyxrc.auto_number) {
2612                         os << "\\auto_number " << convert<string>(auto_number) << '\n';
2613                 }
2614                 if (tag != RC_LAST)
2615                         break;
2616         case RC_DEFAULT_LANGUAGE:
2617                 if (ignore_system_lyxrc ||
2618                     default_language != system_lyxrc.default_language) {
2619                         os << "\\default_language " << default_language << '\n';
2620                 }
2621                 if (tag != RC_LAST)
2622                         break;
2623         case RC_GUI_LANGUAGE:
2624                 if (ignore_system_lyxrc ||
2625                     gui_language != system_lyxrc.gui_language) {
2626                         os << "\\gui_language " << gui_language << '\n';
2627                 }
2628                 if (tag != RC_LAST)
2629                         break;
2630         case RC_EXPORT_OVERWRITE:
2631                 if (ignore_system_lyxrc ||
2632                     export_overwrite != system_lyxrc.export_overwrite) {
2633                         string status;
2634                         switch (export_overwrite) {
2635                         case NO_FILES:
2636                                 status = "ask";
2637                                 break;
2638                         case MAIN_FILE:
2639                                 status = "main";
2640                                 break;
2641                         case ALL_FILES:
2642                                 status = "all";
2643                                 break;
2644                         }
2645                         os << "\\export_overwrite " << status << '\n';
2646                 }
2647                 if (tag != RC_LAST)
2648                         break;
2649
2650         case RC_SCROLL_WHEEL_ZOOM:
2651                 if (ignore_system_lyxrc ||
2652                         scroll_wheel_zoom != system_lyxrc.scroll_wheel_zoom) {
2653                         string status;
2654                         switch (scroll_wheel_zoom) {
2655                         case SCROLL_WHEEL_ZOOM_OFF:
2656                                 status = "off";
2657                                 break;
2658                         case SCROLL_WHEEL_ZOOM_CTRL:
2659                                 status = "ctrl";
2660                                 break;
2661                         case SCROLL_WHEEL_ZOOM_SHIFT:
2662                                 status = "shift";
2663                                 break;
2664                         case SCROLL_WHEEL_ZOOM_ALT:
2665                                 status = "alt";
2666                                 break;
2667                         }
2668                         os << "\\scroll_wheel_zoom " << status << '\n';
2669                 }
2670                 if (tag != RC_LAST)
2671                         break;
2672
2673                 os << "\n#\n"
2674                    << "# FORMATS SECTION ##########################\n"
2675                    << "#\n\n";
2676
2677         case RC_FILEFORMAT:
2678                 // New/modified formats
2679                 for (Formats::const_iterator cit = formats.begin();
2680                      cit != formats.end(); ++cit) {
2681                         Format const * format =
2682                                 system_formats.getFormat(cit->name());
2683                         if (!format ||
2684                             format->extension() != cit->extension() ||
2685                             format->prettyname() != cit->prettyname() ||
2686                             format->shortcut() != cit->shortcut() ||
2687                             format->viewer() != cit->viewer() ||
2688                             format->editor() != cit->editor() ||
2689                             format->documentFormat() != cit->documentFormat() ||
2690                             format->vectorFormat() != cit->vectorFormat()) {
2691                                 os << "\\format \"" << cit->name() << "\" \""
2692                                    << cit->extension() << "\" \""
2693                                    << cit->prettyname() << "\" \""
2694                                    << cit->shortcut() << "\" \""
2695                                    << escapeCommand(cit->viewer()) << "\" \""
2696                                    << escapeCommand(cit->editor()) << "\" \"";
2697                                 vector<string> flags;
2698                                 if (cit->documentFormat())
2699                                         flags.push_back("document");
2700                                 if (cit->vectorFormat())
2701                                         flags.push_back("vector");
2702                                 os << getStringFromVector(flags);
2703                                 os << "\"\n";
2704                         }
2705                 }
2706
2707                 // Look for deleted formats
2708                 for (Formats::const_iterator cit = system_formats.begin();
2709                      cit != system_formats.end(); ++cit)
2710                         if (!formats.getFormat(cit->name()))
2711                                 os << "\\format \"" << cit->name()
2712                                    << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
2713                 if (tag != RC_LAST)
2714                         break;
2715         case RC_VIEWER_ALTERNATIVES: {
2716                 Alternatives::const_iterator it = viewer_alternatives.begin();
2717                 Alternatives::const_iterator const en = viewer_alternatives.end();
2718                 Alternatives::const_iterator const sysend = 
2719                                 system_lyxrc.viewer_alternatives.end();
2720                 for (; it != en; ++it) {
2721                         string const & fmt = it->first;
2722                         CommandSet const & cmd = it->second;
2723                         CommandSet::const_iterator sit = cmd.begin();
2724                         CommandSet::const_iterator const sen = cmd.end();
2725                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2726                                         system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
2727                                         system_lyxrc.viewer_alternatives.find(fmt);
2728                         for (; sit != sen; ++sit) {
2729                                 string const & cmd = *sit;
2730                                 if (ignore_system_lyxrc 
2731                                     || sysfmt == sysend               // format not found
2732                                          || sysfmt->second.count(cmd) == 0 // this command not found
2733                                    )
2734                                         os << "\\viewer_alternatives " << fmt << " " << cmd << "\n";
2735                         }
2736                 }
2737                 if (tag != RC_LAST)
2738                         break;
2739         }
2740         case RC_EDITOR_ALTERNATIVES: {
2741                 Alternatives::const_iterator it = editor_alternatives.begin();
2742                 Alternatives::const_iterator const en = editor_alternatives.end();
2743                 Alternatives::const_iterator const sysend = 
2744                                 system_lyxrc.editor_alternatives.end();
2745                 for (; it != en; ++it) {
2746                         string const & fmt = it->first;
2747                         CommandSet const & cmd = it->second;
2748                         CommandSet::const_iterator sit = cmd.begin();
2749                         CommandSet::const_iterator const sen = cmd.end();
2750                         Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
2751                                         system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
2752                                         system_lyxrc.editor_alternatives.find(fmt);
2753                         for (; sit != sen; ++sit) {
2754                                 string const & cmd = *sit;
2755                                 if (ignore_system_lyxrc 
2756                                     || sysfmt == sysend               // format not found
2757                                     || sysfmt->second.count(cmd) == 0 // this command not found
2758                                    )
2759                                         os << "\\editor_alternatives " << fmt << " " << cmd << "\n";
2760                         }
2761                 }
2762                 if (tag != RC_LAST)
2763                         break;
2764         }
2765         case RC_DEFAULT_VIEW_FORMAT:
2766                 if (ignore_system_lyxrc ||
2767                     default_view_format != system_lyxrc.default_view_format) {
2768                         os << "\\default_view_format " << default_view_format << '\n';
2769                 }
2770                 if (tag != RC_LAST)
2771                         break;
2772         case RC_VIEWER:
2773                 // Ignore it
2774                 if (tag != RC_LAST)
2775                         break;
2776
2777                 os << "\n#\n"
2778                    << "# CONVERTERS SECTION ##########################\n"
2779                    << "#\n\n";
2780
2781         case RC_CONVERTER:
2782                 // Look for new converters
2783                 for (Converters::const_iterator cit = theConverters().begin();
2784                      cit != theConverters().end(); ++cit) {
2785                         Converter const * converter =
2786                                 theSystemConverters().getConverter(cit->from,
2787                                                                cit->to);
2788                         if (!converter ||
2789                             converter->command != cit->command ||
2790                             converter->flags != cit->flags)
2791                                 os << "\\converter \"" << cit->from << "\" \""
2792                                    << cit->to << "\" \""
2793                                    << escapeCommand(cit->command) << "\" \""
2794                                    << cit->flags << "\"\n";
2795                 }
2796
2797                 // New/modifed converters
2798                 for (Converters::const_iterator cit = theSystemConverters().begin();
2799                      cit != theSystemConverters().end(); ++cit)
2800                         if (!theConverters().getConverter(cit->from, cit->to))
2801                                 os << "\\converter \"" << cit->from
2802                                    << "\" \"" << cit->to << "\" \"\" \"\"\n";
2803                 if (tag != RC_LAST)
2804                         break;
2805         
2806         case RC_COPIER:
2807                 if (tag == RC_LAST)
2808                         os << "\n#\n"
2809                            << "# COPIERS SECTION ##########################\n"
2810                            << "#\n\n";
2811
2812                 // Look for new movers
2813                 Movers::const_iterator const sysbegin = theSystemMovers().begin();
2814                 Movers::const_iterator const sysend = theSystemMovers().end();
2815                 Movers::const_iterator it = theMovers().begin();
2816                 Movers::const_iterator end = theMovers().end();
2817
2818                 for (; it != end; ++it) {
2819                         Movers::const_iterator const sysit =
2820                                 find_if(sysbegin, sysend, SameMover(*it));
2821                         if (sysit == sysend) {
2822                                 string const & fmt = it->first;
2823                                 string const & command =
2824                                         it->second.command();
2825
2826                                 os << "\\copier " << fmt
2827                                    << " \"" << escapeCommand(command) << "\"\n";
2828                         }
2829                 }
2830                 if (tag != RC_LAST)
2831                         break;
2832
2833                 // We don't actually delete SpecialisedMover(s) from the
2834                 // map, just clear their 'command', so there's no need
2835                 // to test for anything else.
2836         }
2837
2838         os.flush();
2839 }
2840
2841
2842 void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
2843 {
2844         // Why the switch you might ask. It is a trick to ensure that all
2845         // the elements in the LyXRCTags enum is handled. As you can see
2846         // there are no breaks at all. So it is just a huge fall-through.
2847         // The nice thing is that we will get a warning from the compiler
2848         // if we forget an element.
2849         LyXRC::LyXRCTags tag = LyXRC::RC_LAST;
2850         switch (tag) {
2851         case LyXRC::RC_ACCEPT_COMPOUND:
2852         case LyXRC::RC_ALT_LANG:
2853         case LyXRC::RC_PLAINTEXT_LINELEN:
2854         case LyXRC::RC_AUTOCORRECTION_MATH:
2855         case LyXRC::RC_AUTOREGIONDELETE:
2856         case LyXRC::RC_AUTORESET_OPTIONS:
2857         case LyXRC::RC_AUTOSAVE:
2858         case LyXRC::RC_AUTO_NUMBER:
2859         case LyXRC::RC_BACKUPDIR_PATH:
2860         case LyXRC::RC_BIBTEX_ALTERNATIVES:
2861         case LyXRC::RC_BIBTEX_COMMAND:
2862         case LyXRC::RC_BINDFILE:
2863         case LyXRC::RC_CHECKLASTFILES:
2864         case LyXRC::RC_COMPLETION_CURSOR_TEXT:
2865         case LyXRC::RC_COMPLETION_INLINE_DELAY:
2866         case LyXRC::RC_COMPLETION_INLINE_DOTS:
2867         case LyXRC::RC_COMPLETION_INLINE_MATH:
2868         case LyXRC::RC_COMPLETION_INLINE_TEXT:
2869         case LyXRC::RC_COMPLETION_POPUP_AFTER_COMPLETE:
2870         case LyXRC::RC_COMPLETION_POPUP_DELAY:
2871         case LyXRC::RC_COMPLETION_POPUP_MATH:
2872         case LyXRC::RC_COMPLETION_POPUP_TEXT:
2873         case LyXRC::RC_USELASTFILEPOS:
2874         case LyXRC::RC_LOADSESSION:
2875         case LyXRC::RC_CHKTEX_COMMAND:
2876         case LyXRC::RC_CONVERTER:
2877         case LyXRC::RC_CONVERTER_CACHE_MAXAGE:
2878         case LyXRC::RC_COPIER:
2879         case LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR:
2880         case LyXRC::RC_SCROLL_BELOW_DOCUMENT:
2881         case LyXRC::RC_DATE_INSERT_FORMAT:
2882         case LyXRC::RC_DEFAULT_LANGUAGE:
2883         case LyXRC::RC_GUI_LANGUAGE:
2884         case LyXRC::RC_DEFAULT_PAPERSIZE:
2885         case LyXRC::RC_DEFAULT_VIEW_FORMAT:
2886         case LyXRC::RC_DEFFILE:
2887         case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN:
2888         case LyXRC::RC_DISPLAY_GRAPHICS:
2889         case LyXRC::RC_DOCUMENTPATH:
2890                 if (lyxrc_orig.document_path != lyxrc_new.document_path) {
2891                         FileName path(lyxrc_new.document_path);
2892                         if (path.exists() && path.isDirectory())
2893                                 package().document_dir() = FileName(lyxrc.document_path);
2894                 }
2895         case LyXRC::RC_EDITOR_ALTERNATIVES:
2896         case LyXRC::RC_ESC_CHARS:
2897         case LyXRC::RC_EXAMPLEPATH:
2898         case LyXRC::RC_FONT_ENCODING:
2899         case LyXRC::RC_FORCE_PAINT_SINGLE_CHAR:
2900         case LyXRC::RC_FILEFORMAT:
2901         case LyXRC::RC_GROUP_LAYOUTS:
2902         case LyXRC::RC_HUNSPELLDIR_PATH:
2903         case LyXRC::RC_INDEX_ALTERNATIVES:
2904         case LyXRC::RC_INDEX_COMMAND:
2905         case LyXRC::RC_JBIBTEX_COMMAND:
2906         case LyXRC::RC_JINDEX_COMMAND:
2907         case LyXRC::RC_NOMENCL_COMMAND:
2908         case LyXRC::RC_INPUT:
2909         case LyXRC::RC_KBMAP:
2910         case LyXRC::RC_KBMAP_PRIMARY:
2911         case LyXRC::RC_KBMAP_SECONDARY:
2912         case LyXRC::RC_LANGUAGE_AUTO_BEGIN:
2913         case LyXRC::RC_LANGUAGE_AUTO_END:
2914         case LyXRC::RC_LANGUAGE_COMMAND_BEGIN:
2915         case LyXRC::RC_LANGUAGE_COMMAND_END:
2916         case LyXRC::RC_LANGUAGE_COMMAND_LOCAL:
2917         case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
2918         case LyXRC::RC_LANGUAGE_CUSTOM_PACKAGE:
2919         case LyXRC::RC_LANGUAGE_PACKAGE_SELECTION:
2920         case LyXRC::RC_LYXRCFORMAT:
2921         case LyXRC::RC_MAC_DONTSWAP_CTRL_META:
2922         case LyXRC::RC_MAC_LIKE_WORD_MOVEMENT:
2923         case LyXRC::RC_MACRO_EDIT_STYLE:
2924         case LyXRC::RC_MAKE_BACKUP:
2925         case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
2926         case LyXRC::RC_MOUSE_WHEEL_SPEED:
2927         case LyXRC::RC_NUMLASTFILES:
2928         case LyXRC::RC_PARAGRAPH_MARKERS:
2929         case LyXRC::RC_PATH_PREFIX:
2930                 if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
2931                         prependEnvPath("PATH", lyxrc.path_prefix);
2932                 }
2933         case LyXRC::RC_PREVIEW:
2934         case LyXRC::RC_PREVIEW_HASHED_LABELS:
2935         case LyXRC::RC_PREVIEW_SCALE_FACTOR:
2936         case LyXRC::RC_PRINTCOLLCOPIESFLAG:
2937         case LyXRC::RC_PRINTCOPIESFLAG:
2938         case LyXRC::RC_PRINTER:
2939         case LyXRC::RC_PRINTEVENPAGEFLAG:
2940         case LyXRC::RC_PRINTEXSTRAOPTIONS:
2941         case LyXRC::RC_PRINTFILEEXTENSION:
2942         case LyXRC::RC_PRINTLANDSCAPEFLAG:
2943         case LyXRC::RC_PRINTODDPAGEFLAG:
2944         case LyXRC::RC_PRINTPAGERANGEFLAG:
2945         case LyXRC::RC_PRINTPAPERDIMENSIONFLAG:
2946         case LyXRC::RC_PRINTPAPERFLAG:
2947         case LyXRC::RC_PRINTREVERSEFLAG:
2948         case LyXRC::RC_PRINTSPOOL_COMMAND:
2949         case LyXRC::RC_PRINTSPOOL_PRINTERPREFIX:
2950         case LyXRC::RC_PRINTTOFILE:
2951         case LyXRC::RC_PRINTTOPRINTER:
2952         case LyXRC::RC_PRINT_ADAPTOUTPUT:
2953         case LyXRC::RC_PRINT_COMMAND:
2954         case LyXRC::RC_RTL_SUPPORT:
2955         case LyXRC::RC_SAVE_COMPRESSED:
2956         case LyXRC::RC_SCREEN_DPI:
2957         case LyXRC::RC_SCREEN_FONT_ROMAN:
2958         case LyXRC::RC_SCREEN_FONT_ROMAN_FOUNDRY:
2959         case LyXRC::RC_SCREEN_FONT_SANS:
2960         case LyXRC::RC_SCREEN_FONT_SANS_FOUNDRY:
2961         case LyXRC::RC_SCREEN_FONT_SCALABLE:
2962         case LyXRC::RC_SCREEN_FONT_SIZES:
2963         case LyXRC::RC_SCREEN_FONT_TYPEWRITER:
2964         case LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
2965         case LyXRC::RC_GEOMETRY_SESSION:
2966         case LyXRC::RC_SCREEN_ZOOM:
2967         case LyXRC::RC_SERVERPIPE:
2968         case LyXRC::RC_SET_COLOR:
2969         case LyXRC::RC_SHOW_BANNER:
2970         case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
2971         case LyXRC::RC_SPELLCHECKER:
2972         case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
2973         case LyXRC::RC_SPELLCHECK_NOTES:
2974         case LyXRC::RC_SPLITINDEX_COMMAND:
2975         case LyXRC::RC_TEMPDIRPATH:
2976         case LyXRC::RC_TEMPLATEPATH:
2977         case LyXRC::RC_TEX_ALLOWS_SPACES:
2978         case LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS:
2979                 if (lyxrc_orig.windows_style_tex_paths != lyxrc_new.windows_style_tex_paths) {
2980                         os::windows_style_tex_paths(lyxrc_new.windows_style_tex_paths);
2981                 }
2982         case LyXRC::RC_THESAURUSDIRPATH:
2983         case LyXRC::RC_UIFILE:
2984         case LyXRC::RC_USER_EMAIL:
2985         case LyXRC::RC_USER_NAME:
2986         case LyXRC::RC_USE_CONVERTER_CACHE:
2987         case LyXRC::RC_USE_SYSTEM_COLORS:
2988         case LyXRC::RC_USE_TOOLTIP:
2989         case LyXRC::RC_USE_PIXMAP_CACHE:
2990         case LyXRC::RC_VIEWDVI_PAPEROPTION:
2991         case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
2992         case LyXRC::RC_SINGLE_INSTANCE:
2993         case LyXRC::RC_SORT_LAYOUTS:
2994         case LyXRC::RC_FULL_SCREEN_LIMIT:
2995         case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
2996         case LyXRC::RC_FULL_SCREEN_MENUBAR:
2997         case LyXRC::RC_FULL_SCREEN_TABBAR:
2998         case LyXRC::RC_FULL_SCREEN_TOOLBARS:
2999         case LyXRC::RC_FULL_SCREEN_WIDTH:
3000         case LyXRC::RC_VISUAL_CURSOR:
3001         case LyXRC::RC_VIEWER:
3002         case LyXRC::RC_VIEWER_ALTERNATIVES:
3003         case LyXRC::RC_FORWARD_SEARCH_DVI:
3004         case LyXRC::RC_FORWARD_SEARCH_PDF:
3005         case LyXRC::RC_EXPORT_OVERWRITE:
3006         case LyXRC::RC_DEFAULT_DECIMAL_POINT:
3007         case LyXRC::RC_SCROLL_WHEEL_ZOOM:
3008         case LyXRC::RC_LAST:
3009                 break;
3010         }
3011 }
3012
3013
3014 #if 0
3015 string const LyXRC::getDescription(LyXRCTags tag)
3016 {
3017         docstring str;
3018
3019         switch (tag) {
3020         case RC_ACCEPT_COMPOUND:
3021                 str = _("Consider run-together words, such as \"diskdrive\" for \"disk drive\", as legal words?");
3022                 break;
3023
3024         case RC_ALT_LANG:
3025                 str = _("Specify an alternate language. The default is to use the language of the document.");
3026                 break;
3027
3028         case RC_PLAINTEXT_LINELEN:
3029                 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.");
3030                 break;
3031
3032         case RC_AUTOREGIONDELETE:
3033                 str = _("De-select if you don't want the current selection to be replaced automatically by what you type.");
3034                 break;
3035
3036         case RC_AUTORESET_OPTIONS:
3037                 str = _("De-select if you don't want the class options to be reset to defaults after class change.");
3038                 break;
3039
3040         case RC_AUTOSAVE:
3041                 str = _("The time interval between auto-saves (in seconds). 0 means no auto-save.");
3042                 break;
3043
3044         case RC_AUTO_NUMBER:
3045                 break;
3046
3047         case RC_BACKUPDIR_PATH:
3048                 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.");
3049                 break;
3050
3051         case RC_BIBTEX_COMMAND:
3052                 str = _("Define the options of bibtex (cf. man bibtex) or select an alternative compiler (e.g. mlbibtex or bibulus).");
3053                 break;
3054
3055         case RC_JBIBTEX_COMMAND:
3056                 str = _("Define the options of the bibtex program for PLaTeX (Japanese LaTeX).");
3057                 break;
3058
3059         case RC_BINDFILE:
3060                 str = _("Keybindings file. Can either specify an absolute path, or LyX will look in its global and local bind/ directories.");
3061                 break;
3062
3063         case RC_CHECKLASTFILES:
3064                 str = _("Select to check whether the lastfiles still exist.");
3065                 break;
3066
3067         case RC_CHKTEX_COMMAND:
3068                 str = _("Define how to run chktex. E.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\" Refer to the ChkTeX documentation.");
3069                 break;
3070
3071         case RC_CONVERTER:
3072                 break;
3073
3074         case RC_COPIER:
3075                 break;
3076
3077         case RC_CURSOR_FOLLOWS_SCROLLBAR:
3078                 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.");
3079                 break;
3080
3081         case RC_SCROLL_BELOW_DOCUMENT:
3082                 str = _("LyX normally doesn't allow the user to scroll further than the bottom of the document. Set to true if you prefer to scroll the bottom of the document to the top of the screen");
3083                 break;
3084
3085         case RC_MAC_DONTSWAP_CTRL_META:
3086                 str = _("Make Apple key act as Meta and Control key as Ctrl.");
3087                 break;
3088
3089         case RC_MAC_LIKE_WORD_MOVEMENT:
3090                 str = _("Use the Mac OS X conventions for the word-level cursor movement");
3091                 break;
3092
3093         case RC_SHOW_MACRO_LABEL:
3094                 str = _("Show a small box around a Math Macro with the macro name when the cursor is inside.");
3095                 break;
3096
3097         case RC_DATE_INSERT_FORMAT:
3098                 //xgettext:no-c-format
3099                 str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
3100                 break;
3101
3102         case RC_DEFFILE:
3103                 str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories.");
3104                 break;
3105
3106         case RC_DEFAULT_VIEW_FORMAT:
3107                 str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE].");
3108                 break;
3109
3110         case RC_DEFAULT_LANGUAGE:
3111                 str = _("New documents will be assigned this language.");
3112                 break;
3113
3114         case RC_DEFAULT_PAPERSIZE:
3115                 str = _("Specify the default paper size.");
3116                 break;
3117
3118         case RC_DIALOGS_ICONIFY_WITH_MAIN:
3119                 str = _("Iconify the dialogs when the main window is iconified. (Affects only dialogs shown after the change has been made.)");
3120                 break;
3121
3122         case RC_DISPLAY_GRAPHICS:
3123                 str = _("Select how LyX will display any graphics.");
3124                 break;
3125
3126         case RC_DOCUMENTPATH:
3127                 str = _("The default path for your documents. An empty value selects the directory LyX was started from.");
3128                 break;
3129
3130         case RC_ESC_CHARS:
3131                 str = _("Specify additional chars that can be part of a word.");
3132                 break;
3133
3134         case RC_EXAMPLEPATH:
3135                 str = _("The path that LyX will set when offering to choose an example. An empty value selects the directory LyX was started from.");
3136                 break;
3137
3138         case RC_FONT_ENCODING:
3139                 str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
3140                 break;
3141
3142         case RC_FORCE_PAINT_SINGLE_CHAR:
3143                 str = _("Disable any kerning and ligatures for text drawing on screen.");
3144                 break;
3145
3146         case RC_FILEFORMAT:
3147                 break;
3148
3149         case RC_INDEX_COMMAND:
3150                 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\".");
3151                 break;
3152
3153         case RC_JINDEX_COMMAND:
3154                 str = _("Define the options of the index program for PLaTeX (Japanese LaTeX).");
3155                 break;
3156
3157         case RC_NOMENCL_COMMAND:
3158                 str = _("Define the options of makeindex (cf. man makeindex) to be used for nomenclatures. This might differ from the index processing options.");
3159                 break;
3160
3161         case RC_INPUT:
3162                 break;
3163
3164         case RC_KBMAP:
3165         case RC_KBMAP_PRIMARY:
3166         case RC_KBMAP_SECONDARY:
3167                 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.");
3168                 break;
3169
3170         case RC_LANGUAGE_AUTO_BEGIN:
3171                 str = _("Select if a language switching command is needed at the beginning of the document.");
3172                 break;
3173
3174         case RC_LANGUAGE_AUTO_END:
3175                 str = _("Select if a language switching command is needed at the end of the document.");
3176                 break;
3177
3178         case RC_LANGUAGE_COMMAND_BEGIN:
3179                 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.");
3180                 break;
3181
3182         case RC_LANGUAGE_COMMAND_END:
3183                 str = _("The LaTeX command for changing back to the language of the document.");
3184                 break;
3185
3186         case RC_LANGUAGE_COMMAND_LOCAL:
3187                 str = _("The LaTeX command for local changing of the language.");
3188                 break;
3189
3190         case RC_LANGUAGE_GLOBAL_OPTIONS:
3191                 str = _("De-select if you don't want the language(s) used as an argument to \\documentclass.");
3192                 break;
3193
3194         case RC_LANGUAGE_CUSTOM_PACKAGE:
3195                 str = _("The LaTeX command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
3196                 break;
3197
3198         case RC_LANGUAGE_PACKAGE_SELECTION:
3199                 str = _("De-select if you don't want babel to be used when the language of the document is the default language.");
3200                 break;
3201
3202         case RC_USELASTFILEPOS:
3203                 str = _("De-select if you do not want LyX to scroll to saved position.");
3204                 break;
3205
3206         case RC_LOADSESSION:
3207                 str = _("De-select to prevent loading files opened from the last LyX session.");
3208                 break;
3209
3210         case RC_MAKE_BACKUP:
3211                 str = _("De-select if you don't want LyX to create backup files.");
3212                 break;
3213
3214         case RC_MARK_FOREIGN_LANGUAGE:
3215                 str = _("Select to control the highlighting of words with a language foreign to that of the document.");
3216                 break;
3217
3218         case RC_MOUSE_WHEEL_SPEED:
3219                 str = bformat(_("The scrolling speed of the mouse wheel."),
3220                       maxlastfiles);
3221                 break;
3222
3223         case RC_COMPLETION_POPUP_DELAY:
3224                 str = _("The completion popup delay.");
3225                 break;
3226
3227         case RC_COMPLETION_POPUP_MATH:
3228                 str = _("Select to display the completion popup in math mode.");
3229                 break;
3230
3231         case RC_COMPLETION_POPUP_TEXT:
3232                 str = _("Select to display the completion popup in text mode.");
3233                 break;
3234
3235         case RC_COMPLETION_POPUP_AFTER_COMPLETE:
3236                 str = _("Show the completion popup without delay after non-unique completion attempt.");
3237                 break;
3238
3239         case RC_COMPLETION_POPUP_TEXT:
3240                 str = _("Show a small triangle on the cursor to indicate that a completion is available.");
3241                 break;
3242
3243         case RC_COMPLETION_POPUP_DELAY:
3244                 str = _("The inline completion delay.");
3245                 break;
3246
3247         case RC_COMPLETION_INLINE_MATH:
3248                 str = _("Select to display the inline completion in math mode.");
3249                 break;
3250
3251         case RC_COMPLETION_INLINE_TEXT:
3252                 str = _("Select to display the inline completion in text mode.");
3253                 break;
3254
3255         case RC_COMPLETION_INLINE_DOTS:
3256                 str = _("Use \"...\" to shorten long completions.");
3257                 break;
3258
3259         case RC_AUTOCORRECTION_MATH:
3260                 str = _("Allow TeXMacs shorthand, like => converting to \Rightarrow.");
3261                 break;
3262
3263         case RC_NUMLASTFILES:
3264                 str = bformat(_("Maximal number of lastfiles. Up to %1$d can appear in the file menu."),
3265                         maxlastfiles);
3266                 break;
3267
3268         case RC_PATH_PREFIX:
3269                 str = _("Specify those directories which should be "
3270                          "prepended to the PATH environment variable. "
3271                          "Use the OS native format.");
3272                 break;
3273
3274         case RC_PREVIEW:
3275                 str = _("Shows a typeset preview of things such as math");
3276                 break;
3277
3278         case RC_PREVIEW_HASHED_LABELS:
3279                 str = _("Previewed equations will have \"(#)\" labels rather than numbered ones");
3280                 break;
3281
3282         case RC_PREVIEW_SCALE_FACTOR:
3283                 str = _("Scale the preview size to suit.");
3284                 break;
3285
3286         case RC_PRINTCOLLCOPIESFLAG:
3287                 str = _("The option for specifying whether the copies should be collated.");
3288                 break;
3289
3290         case RC_PRINTCOPIESFLAG:
3291                 str = _("The option for specifying the number of copies to print.");
3292                 break;
3293
3294         case RC_PRINTER:
3295                 str = _("The default printer to print on. If none is specified, LyX will use the environment variable PRINTER.");
3296                 break;
3297
3298         case RC_PRINTEVENPAGEFLAG:
3299                 str = _("The option to print only even pages.");
3300                 break;
3301
3302         case RC_PRINTEXSTRAOPTIONS:
3303                 str = _("Extra options to pass to printing program after everything else, but before the filename of the DVI file to be printed.");
3304                 break;
3305
3306         case RC_PRINTFILEEXTENSION:
3307                 str = _("Extension of printer program output file. Usually \".ps\".");
3308                 break;
3309
3310         case RC_PRINTLANDSCAPEFLAG:
3311                 str = _("The option to print out in landscape.");
3312                 break;
3313
3314         case RC_PRINTODDPAGEFLAG:
3315                 str = _("The option to print only odd pages.");
3316                 break;
3317
3318         case RC_PRINTPAGERANGEFLAG:
3319                 str = _("The option for specifying a comma-separated list of pages to print.");
3320                 break;
3321
3322         case RC_PRINTPAPERDIMENSIONFLAG:
3323                                    str = _("Option to specify the dimensions of the print paper.");
3324                 break;
3325
3326         case RC_PRINTPAPERFLAG:
3327                 str = _("The option to specify paper type.");
3328                 break;
3329
3330         case RC_PRINTREVERSEFLAG:
3331                 str = _("The option to reverse the order of the pages printed.");
3332                 break;
3333
3334         case RC_PRINTSPOOL_COMMAND:
3335                 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.");
3336                 break;
3337
3338         case RC_PRINTSPOOL_PRINTERPREFIX:
3339                 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.");
3340                 break;
3341
3342         case RC_PRINTTOFILE:
3343                 str = _("Option to pass to the print program to print to a file.");
3344                 break;
3345
3346         case RC_PRINTTOPRINTER:
3347                 str = _("Option to pass to the print program to print on a specific printer.");
3348                 break;
3349
3350         case RC_PRINT_ADAPTOUTPUT:
3351                 str = _("Select for LyX to pass the name of the destination printer to your print command.");
3352                 break;
3353
3354         case RC_PRINT_COMMAND:
3355                 str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
3356                 break;
3357
3358         case RC_RTL_SUPPORT:
3359                 str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
3360                 break;
3361
3362         case RC_VISUAL_CURSOR:
3363                 str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
3364                 break;
3365
3366         case RC_SCREEN_DPI:
3367                 str = _("DPI (dots per inch) of your monitor is auto-detected by LyX. If that goes wrong, override the setting here.");
3368                 break;
3369
3370         case RC_SCREEN_FONT_ROMAN:
3371         case RC_SCREEN_FONT_SANS:
3372         case RC_SCREEN_FONT_TYPEWRITER:
3373                 str = _("The screen fonts used to display the text while editing.");
3374                 break;
3375
3376         case RC_SCREEN_FONT_ROMAN_FOUNDRY:
3377         case RC_SCREEN_FONT_SANS_FOUNDRY:
3378         case RC_SCREEN_FONT_TYPEWRITER_FOUNDRY:
3379                 break;
3380
3381         case RC_SCREEN_FONT_SCALABLE:
3382                 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.");
3383                 break;
3384
3385         case RC_SCREEN_FONT_SIZES:
3386                 str = _("The font sizes used for calculating the scaling of the screen fonts.");
3387                 break;
3388
3389         case RC_SCREEN_ZOOM:
3390                 //xgettext:no-c-format
3391                 str = _("The zoom percentage for screen fonts. A setting of 100% will make the fonts roughly the same size as on paper.");
3392                 break;
3393
3394         case RC_GEOMETRY_SESSION:
3395                 str = _("Allow session manager to save and restore windows geometry.");
3396                 break;
3397
3398         case RC_SERVERPIPE:
3399                 str = _("This starts the lyxserver. The pipes get an additional extension \".in\" and \".out\". Only for advanced users.");
3400                 break;
3401
3402         case RC_SET_COLOR:
3403                 break;
3404
3405         case RC_SHOW_BANNER:
3406                 str = _("De-select if you don't want the startup banner.");
3407                 break;
3408
3409         case RC_TEMPDIRPATH:
3410                 str = _("LyX will place its temporary directories in this path. They will be deleted when you quit LyX.");
3411                 break;
3412
3413         case RC_THESAURUSDIRPATH:
3414                 str = _("This is the place where the files of the thesaurus library reside.");
3415                 break;
3416
3417         case RC_TEMPLATEPATH:
3418                 str = _("The path that LyX will set when offering to choose a template. An empty value selects the directory LyX was started from.");
3419                 break;
3420
3421         case RC_TEX_ALLOWS_SPACES:
3422                 break;
3423
3424         case RC_TEX_EXPECTS_WINDOWS_PATHS:
3425                 break;
3426
3427         case RC_UIFILE:
3428                 str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
3429                 break;
3430
3431         case RC_USER_EMAIL:
3432                 break;
3433
3434         case RC_USER_NAME:
3435                 break;
3436
3437         case RC_USE_USE_SYSTEM_COLORS:
3438                 str = _("Enable use the system colors for some things like main window background and selection.");
3439                 break;
3440
3441         case RC_USE_TOOLTIP:
3442                 str = _("Enable the automatic appearance of tool tips in the work area.");
3443                 break;
3444
3445         case RC_USE_PIXMAP_CACHE:
3446                 str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
3447                 break;
3448
3449         case RC_VIEWDVI_PAPEROPTION:
3450                 _("Specify the paper command to DVI viewer (leave empty or use \"-paper\")");
3451                 break;
3452
3453         case RC_VIEWER:
3454                 break;
3455
3456         case RC_LAST:
3457                 break;
3458         }
3459
3460         return str;
3461 }
3462 #endif
3463
3464
3465 // The global instance
3466 LyXRC lyxrc;
3467
3468 // The global copy of the system lyxrc entries (everything except preferences)
3469 LyXRC system_lyxrc;
3470
3471
3472 } // namespace lyx