]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
Fix crash noticed by Bennett:
[lyx.git] / src / LyXRC.cpp
index b2654eecb3993be550a753bf1a9ef49d3a3b582c..b9dde4187b386e4c01a1769c4c8eb308f778972c 100644 (file)
@@ -87,6 +87,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
        { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
        { "\\document_path", LyXRC::RC_DOCUMENTPATH },
+       { "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
        { "\\escape_chars", LyXRC::RC_ESC_CHARS },
        { "\\example_path", LyXRC::RC_EXAMPLEPATH },
        { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
@@ -99,6 +100,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\fullscreen_width", LyXRC::RC_FULL_SCREEN_WIDTH },
        { "\\group_layouts", LyXRC::RC_GROUP_LAYOUTS },
        { "\\gui_language", LyXRC::RC_GUI_LANGUAGE },
+       { "\\hunspelldir_path", LyXRC::RC_HUNSPELLDIR_PATH },
        { "\\index_alternatives", LyXRC::RC_INDEX_ALTERNATIVES },
        { "\\index_command", LyXRC::RC_INDEX_COMMAND },
        { "\\input", LyXRC::RC_INPUT },
@@ -125,6 +127,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
        { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
        { "\\open_buffers_in_tabs", LyXRC::RC_OPEN_BUFFERS_IN_TABS },
+       { "\\paragraph_markers", LyXRC::RC_PARAGRAPH_MARKERS },
        { "\\path_prefix", LyXRC::RC_PATH_PREFIX },
        { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
        { "\\plaintext_linelen", LyXRC::RC_PLAINTEXT_LINELEN },
@@ -168,6 +171,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
        { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
        { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
+       { "\\spellchecker", LyXRC::RC_SPELLCHECKER },
        { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
        { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
        { "\\template_path", LyXRC::RC_TEMPLATEPATH },
@@ -192,6 +196,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
        // compatibility with versions older than 1.4.0 only
        { "\\viewer", LyXRC::RC_VIEWER},
+       { "\\viewer_alternatives", LyXRC::RC_VIEWER_ALTERNATIVES },
        { "\\visual_cursor" ,LyXRC::RC_VISUAL_CURSOR}
 };
 
@@ -238,7 +243,7 @@ void LyXRC::setDefaults()
        index_command = "makeindex -c -q";
        nomencl_command = "makeindex -s nomencl.ist";
        dpi = 75;
-       // Because a screen typically is wider than a piece of paper:
+       // Because a screen is typically wider than a piece of paper:
        zoom = 150;
        allow_geometry_session = true;
        // Default LaTeX font size:
@@ -269,8 +274,8 @@ void LyXRC::setDefaults()
        backupdir_path.erase();
        display_graphics = true;
        // Spellchecker settings:
+       spellchecker = "aspell";
        spellchecker_accept_compound = false;
-       spellchecker_use_esc_chars = false;
        spellcheck_continuously = false;
        use_kbmap = false;
        rtl_support = true;
@@ -294,13 +299,14 @@ void LyXRC::setDefaults()
        date_insert_format = "%x";
        cursor_follows_scrollbar = false;
        scroll_below_document = false;
+       paragraph_markers = false;
        mac_like_word_movement = false;
        macro_edit_style = MACRO_EDIT_INLINE_BOX;
        dialogs_iconify_with_main = false;
        label_init_length = 3;
        preview = PREVIEW_OFF;
        preview_hashed_labels  = false;
-       preview_scale_factor = "0.9";
+       preview_scale_factor = 1.0;
        use_converter_cache = true;
        use_tooltip = true;
        use_pixmap_cache = false;
@@ -451,10 +457,8 @@ int LyXRC::read(Lexer & lexrc)
                case RC_KBMAP_PRIMARY:
                        if (lexrc.next()) {
                                string const kmap(os::internal_path(lexrc.getString()));
-                               if (kmap.empty()) {
-                                       // nothing
-                               } else if (!libFileSearch("kbd", kmap,
-                                                         "kmap").empty()) {
+                               if (!libFileSearch("kbd", kmap, "kmap").empty()
+                                         || kmap.empty()) {
                                        primary_kbmap = kmap;
                                } else {
                                        lexrc.printError("LyX: Keymap `$$Token' not found");
@@ -465,10 +469,8 @@ int LyXRC::read(Lexer & lexrc)
                case RC_KBMAP_SECONDARY:
                        if (lexrc.next()) {
                                string const kmap(os::internal_path(lexrc.getString()));
-                               if (kmap.empty()) {
-                                       // nothing
-                               } else if (!libFileSearch("kbd", kmap,
-                                                         "kmap").empty()) {
+                               if (!libFileSearch("kbd", kmap, "kmap").empty()
+                                         || kmap.empty()) {
                                        secondary_kbmap = kmap;
                                } else {
                                        lexrc.printError("LyX: Keymap `$$Token' not found");
@@ -709,6 +711,13 @@ int LyXRC::read(Lexer & lexrc)
                        }
                        break;
 
+               case RC_HUNSPELLDIR_PATH:
+                       if (lexrc.next()) {
+                               hunspelldir_path = os::internal_path(lexrc.getString());
+                               hunspelldir_path = expandPath(hunspelldir_path);
+                       }
+                       break;
+
                case RC_USELASTFILEPOS:
                        lexrc >> use_lastfilepos;
                        break;
@@ -849,6 +858,10 @@ int LyXRC::read(Lexer & lexrc)
                        lexrc >> scroll_below_document;
                        break;
 
+               case RC_PARAGRAPH_MARKERS:
+                       lexrc >> paragraph_markers;
+                       break;
+
                case RC_MAC_LIKE_WORD_MOVEMENT:
                        lexrc >> mac_like_word_movement;
                        break;
@@ -880,8 +893,8 @@ int LyXRC::read(Lexer & lexrc)
                case RC_USE_PIXMAP_CACHE:
                        lexrc >> use_pixmap_cache;
                        break;
-               case RC_USE_ESC_CHARS:
-                       lexrc >> spellchecker_use_esc_chars;
+               case RC_SPELLCHECKER:
+                       lexrc >> spellchecker;
                        break;
                case RC_ALT_LANG:
                        lexrc >> spellchecker_alt_lang;
@@ -1021,6 +1034,22 @@ int LyXRC::read(Lexer & lexrc)
                        }
                        break;
                }
+               case RC_VIEWER_ALTERNATIVES:  {
+                       string format, command;
+                       if (lexrc.next())
+                               format = lexrc.getString();
+                       if (lexrc.eatLine())
+                               command = lexrc.getString();
+                       viewer_alternatives.push_back(make_pair(format, command));
+                       break;
+               }
+               case RC_EDITOR_ALTERNATIVES:  {
+                       string format, command;
+                       lexrc >> format >> command;
+                       editor_alternatives.push_back(make_pair(format, command));
+                       break;
+               }
+
                case RC_DEFAULT_VIEW_FORMAT:
                        lexrc >> default_view_format;
                        break;
@@ -1118,6 +1147,7 @@ int LyXRC::read(Lexer & lexrc)
                case RC_PERS_DICT:
                case RC_PLAINTEXT_ROFF_COMMAND: 
                case RC_USE_ALT_LANG:
+               case RC_USE_ESC_CHARS:
                case RC_USE_INP_ENC:
                case RC_USE_PERS_DICT:
                case RC_USE_SPELL_LIB:
@@ -1603,6 +1633,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_PARAGRAPH_MARKERS:
+               if (ignore_system_lyxrc ||
+                       paragraph_markers
+                   != system_lyxrc.paragraph_markers) {
+                       os << "\\paragraph_markers "
+                          << convert<string>(paragraph_markers) << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_MAC_LIKE_WORD_MOVEMENT:
                if (ignore_system_lyxrc ||
                    mac_like_word_movement
@@ -2139,6 +2178,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_HUNSPELLDIR_PATH:
+               if (ignore_system_lyxrc ||
+                   hunspelldir_path != system_lyxrc.hunspelldir_path) {
+                       string const path = os::external_path(hunspelldir_path);
+                       os << "\\hunspelldir_path \"" << path << "\"\n";
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_USETEMPDIR:
                if (tag != RC_LAST)
                        break;
@@ -2203,11 +2250,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_USE_ESC_CHARS:
-               if (ignore_system_lyxrc ||
-                   spellchecker_use_esc_chars != system_lyxrc.spellchecker_use_esc_chars) {
-                       os << "\\use_escape_chars " << convert<string>(spellchecker_use_esc_chars)
-                          << '\n';
-               }
                if (tag != RC_LAST)
                        break;
        case RC_ESC_CHARS:
@@ -2254,6 +2296,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
 
+       case RC_SPELLCHECKER:
+               if (ignore_system_lyxrc ||
+                   spellchecker != system_lyxrc.spellchecker) {
+                       os << "\\spellchecker " << spellchecker << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
+
        case RC_SPELLCHECK_CONTINUOUSLY:
                if (ignore_system_lyxrc ||
                    spellcheck_continuously != system_lyxrc.spellcheck_continuously) {
@@ -2427,6 +2477,26 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                                   << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
                if (tag != RC_LAST)
                        break;
+       case RC_VIEWER_ALTERNATIVES:
+               if (ignore_system_lyxrc ||
+                   viewer_alternatives != system_lyxrc.viewer_alternatives) {
+                       for (vector<pair<string, string> >::const_iterator it = viewer_alternatives.begin();
+                            it != viewer_alternatives.end(); ++it)
+                       os << "\\viewer_alternatives "
+                          << it->first << " " << it->second << "\n";
+               }
+               if (tag != RC_LAST)
+                       break;
+       case RC_EDITOR_ALTERNATIVES:
+               if (ignore_system_lyxrc ||
+                   editor_alternatives != system_lyxrc.editor_alternatives) {
+                       for (vector<pair<string, string> >::const_iterator it = editor_alternatives.begin();
+                            it != editor_alternatives.end(); ++it)
+                       os << "\\editor_alternatives "
+                          << it->first << " " << it->second << "\n";
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_DEFAULT_VIEW_FORMAT:
                if (ignore_system_lyxrc ||
                    default_view_format != system_lyxrc.default_view_format) {