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