]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
Micro-optimization.
[lyx.git] / src / LyXRC.cpp
index f60abd49f0c126d9ed7bb6c1a9b06905cc8d4838..b320d9c316aefcf9b2d446ff84e5207c41fd100a 100644 (file)
@@ -174,6 +174,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
        { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
        { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
+       { "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES },
        { "\\spellchecker", LyXRC::RC_SPELLCHECKER },
        { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
        { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
@@ -277,9 +278,16 @@ void LyXRC::setDefaults()
        backupdir_path.erase();
        display_graphics = true;
        // Spellchecker settings:
+#if defined(USE_ASPELL)
        spellchecker = "aspell";
+#elif defined(USE_HUNSPELL)
+       spellchecker = "hunspell";
+#else
+       spellchecker = "aspell";
+#endif
        spellchecker_accept_compound = false;
        spellcheck_continuously = false;
+       spellcheck_notes = true;
        use_kbmap = false;
        rtl_support = true;
        visual_cursor = false;
@@ -909,6 +917,9 @@ int LyXRC::read(Lexer & lexrc)
                case RC_SPELLCHECK_CONTINUOUSLY:
                        lexrc >> spellcheck_continuously;
                        break;
+               case RC_SPELLCHECK_NOTES:
+                       lexrc >> spellcheck_notes;
+                       break;
                case RC_MAKE_BACKUP:
                        lexrc >> make_backup;
                        break;
@@ -1044,13 +1055,13 @@ int LyXRC::read(Lexer & lexrc)
                                format = lexrc.getString();
                        if (lexrc.eatLine())
                                command = lexrc.getString();
-                       viewer_alternatives.push_back(make_pair(format, command));
+                       viewer_alternatives[format].insert(command);
                        break;
                }
                case RC_EDITOR_ALTERNATIVES:  {
                        string format, command;
                        lexrc >> format >> command;
-                       editor_alternatives.push_back(make_pair(format, command));
+                       editor_alternatives[format].insert(command);
                        break;
                }
 
@@ -1393,8 +1404,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_BIBTEX_ALTERNATIVES: {
-               set<string>::const_iterator it = bibtex_alternatives.begin();
-               set<string>::const_iterator end = bibtex_alternatives.end();
+               CommandSet::const_iterator it = bibtex_alternatives.begin();
+               CommandSet::const_iterator end = bibtex_alternatives.end();
                for ( ; it != end; ++it) {
                        if (ignore_system_lyxrc
                            || !system_lyxrc.bibtex_alternatives.count(*it))
@@ -1419,8 +1430,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_INDEX_ALTERNATIVES: {
-               set<string>::const_iterator it = index_alternatives.begin();
-               set<string>::const_iterator end = index_alternatives.end();
+               CommandSet::const_iterator it = index_alternatives.begin();
+               CommandSet::const_iterator end = index_alternatives.end();
                for ( ; it != end; ++it) {
                        if (ignore_system_lyxrc
                            || !system_lyxrc.index_alternatives.count(*it))
@@ -2327,6 +2338,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
 
+       case RC_SPELLCHECK_NOTES:
+               if (ignore_system_lyxrc ||
+                   spellcheck_notes != system_lyxrc.spellcheck_notes) {
+                       os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
+                          << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
+
        case RC_RTL_SUPPORT:
                if (ignore_system_lyxrc ||
                    rtl_support != system_lyxrc.rtl_support) {
@@ -2492,31 +2512,51 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
        case RC_VIEWER_ALTERNATIVES: {
-               vector<pair<string, string> >::const_iterator it = viewer_alternatives.begin();
-               vector<pair<string, string> >::const_iterator const en = viewer_alternatives.end();
-               vector<pair<string, string> >::const_iterator const sysbeg = 
-                               system_lyxrc.viewer_alternatives.begin();
-               vector<pair<string, string> >::const_iterator const sysend = 
+               Alternatives::const_iterator it = viewer_alternatives.begin();
+               Alternatives::const_iterator const en = viewer_alternatives.end();
+               Alternatives::const_iterator const sysend = 
                                system_lyxrc.viewer_alternatives.end();
-               for ( ; it != en; ++it) {
-                       if (ignore_system_lyxrc || find(sysbeg, sysend, *it) == sysend)
-                               os << "\\viewer_alternatives "
-                                               << it->first << " " << it->second << "\n";
+               for (; it != en; ++it) {
+                       string const & fmt = it->first;
+                       CommandSet const & cmd = it->second;
+                       CommandSet::const_iterator sit = cmd.begin();
+                       CommandSet::const_iterator const sen = cmd.end();
+                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
+                                       system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
+                                       system_lyxrc.viewer_alternatives.find(fmt);
+                       for (; sit != sen; ++sit) {
+                               string const & cmd = *sit;
+                               if (ignore_system_lyxrc 
+                                   || sysfmt == sysend               // format not found
+                                        || sysfmt->second.count(cmd) == 0 // this command not found
+                                  )
+                                       os << "\\viewer_alternatives " << fmt << " " << cmd << "\n";
+                       }
                }
                if (tag != RC_LAST)
                        break;
        }
        case RC_EDITOR_ALTERNATIVES: {
-               vector<pair<string, string> >::const_iterator it = editor_alternatives.begin();
-               vector<pair<string, string> >::const_iterator const en = editor_alternatives.end();
-               vector<pair<string, string> >::const_iterator const sysbeg = 
-                               system_lyxrc.editor_alternatives.begin();
-               vector<pair<string, string> >::const_iterator const sysend = 
+               Alternatives::const_iterator it = editor_alternatives.begin();
+               Alternatives::const_iterator const en = editor_alternatives.end();
+               Alternatives::const_iterator const sysend = 
                                system_lyxrc.editor_alternatives.end();
-               for ( ; it != en; ++it) {
-                       if (ignore_system_lyxrc || find(sysbeg, sysend, *it) == sysend)
-                               os << "\\editor_alternatives "
-                                               << it->first << " " << it->second << "\n";
+               for (; it != en; ++it) {
+                       string const & fmt = it->first;
+                       CommandSet const & cmd = it->second;
+                       CommandSet::const_iterator sit = cmd.begin();
+                       CommandSet::const_iterator const sen = cmd.end();
+                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
+                                       system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
+                                       system_lyxrc.editor_alternatives.find(fmt);
+                       for (; sit != sen; ++sit) {
+                               string const & cmd = *sit;
+                               if (ignore_system_lyxrc 
+                                   || sysfmt == sysend               // format not found
+                                   || sysfmt->second.count(cmd) == 0 // this command not found
+                                  )
+                                       os << "\\editor_alternatives " << fmt << " " << cmd << "\n";
+                       }
                }
                if (tag != RC_LAST)
                        break;
@@ -2729,6 +2769,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_SPELL_COMMAND:
        case LyXRC::RC_SPELLCHECKER:
        case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
+       case LyXRC::RC_SPELLCHECK_NOTES:
        case LyXRC::RC_SPLITINDEX_COMMAND:
        case LyXRC::RC_TEMPDIRPATH:
        case LyXRC::RC_TEMPLATEPATH: