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