]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
Rename BufferView::updateScrollbar to show what does
[lyx.git] / src / LyXRC.cpp
index 59bdc70a58a6d87df9c0ee1e4cb2b350efd85d30..62673f4a69dd4207ad4a4b82b9c25f5a8dd2a70c 100644 (file)
 #include "Lexer.h"
 #include "LyX.h"
 #include "Mover.h"
-#include "Session.h"
 #include "SpellChecker.h"
 #include "version.h"
 
-#include "graphics/GraphicsTypes.h"
-
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/environment.h"
 #include "support/FileName.h"
 #include "support/filetools.h"
-#include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
 #include "support/TempFile.h"
-#include "support/userinfo.h"
 
 #ifdef USE_MACOSX_PACKAGING
 #include "support/AppleSupport.h"
@@ -65,7 +60,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 34; // yuriy: rename kmap files
+static unsigned int const LYXRC_FILEFORMAT = 36; // rkh: spellcheck_continuously default
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -115,6 +110,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
        { "\\escape_chars", LyXRC::RC_ESC_CHARS },
        { "\\example_path", LyXRC::RC_EXAMPLEPATH },
+       { "\\experimental:bookmarks_visibility", LyXRC::RC_BOOKMARKS_VISIBILITY },
        { "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
        { "\\format", LyXRC::RC_FILEFORMAT },
        { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
@@ -290,10 +286,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
        // format prior to 2.0 and introduction of format tag
        unsigned int rc_format = 0;
 
-#ifdef USE_MACOSX_PACKAGING
-       open_buffers_in_tabs = appleUserTabbingPreferenceAlways();
-#endif
-
        while (lexrc.isOK()) {
                // By using two switches we take advantage of the compiler
                // telling us if we have missed a LyXRCTags element in
@@ -662,6 +654,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        }
                        string const x11_name = lexrc.getString();
 
+                       string x11_darkname = x11_name;
+                       if (lexrc.next())
+                               x11_darkname = lexrc.getString();
+
                        ColorCode const col =
                                lcolor.getFromLyXName(lyx_name);
                        if (col == Color_none ||
@@ -669,9 +665,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                            col == Color_ignore)
                                break;
 
-                       if (!lcolor.setColor(col, x11_name))
+                       if (!lcolor.setColor(col, x11_name, x11_darkname))
                                LYXERR0("Bad lyxrc set_color for " << lyx_name);
-                       LYXERR(Debug::LYXRC, "Set " << lyx_name << "(" << col << ") to " << x11_name);
+                       LYXERR(Debug::LYXRC, "Set " << lyx_name << "(" << col << ") to "
+                              << x11_name << " and " << x11_darkname);
                        break;
                }
 
@@ -1063,6 +1060,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        break;
                case RC_OPEN_BUFFERS_IN_TABS:
                        lexrc >> open_buffers_in_tabs;
+#ifdef USE_MACOSX_PACKAGING
+                       if (appleUserTabbingPreferenceAlways())
+                               open_buffers_in_tabs = true;
+#endif
                        break;
                case RC_SINGLE_CLOSE_TAB_BUTTON:
                        lexrc >> single_close_tab_button;
@@ -1117,6 +1118,23 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        lexrc >> mouse_middlebutton_paste;
                        break;
 
+               case RC_BOOKMARKS_VISIBILITY:
+                       if (lexrc.next()) {
+                               string const tmp = lexrc.getString();
+                               if (tmp == "none")
+                                       bookmarks_visibility = BMK_NONE;
+                               else if (tmp == "margin")
+                                       bookmarks_visibility = BMK_MARGIN;
+                               else if (tmp == "inline")
+                                       bookmarks_visibility = BMK_INLINE;
+                               else {
+                                       bookmarks_visibility = BMK_NONE;
+                                       LYXERR0("Unrecognized bookmark visibility " << tmp <<'"');
+                               }
+                       }
+                       break;
+
+
                case RC_LAST:
                        break; // this is just a dummy
                }
@@ -1717,6 +1735,26 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
+       case RC_BOOKMARKS_VISIBILITY:
+               if (ignore_system_lyxrc ||
+                       bookmarks_visibility != system_lyxrc.bookmarks_visibility) {
+                       string status;
+                       switch (bookmarks_visibility) {
+                       case BMK_NONE:
+                               status = "none";
+                               break;
+                       case BMK_INLINE:
+                               status = "inline";
+                               break;
+                       case BMK_MARGIN:
+                               status = "margin";
+                               break;
+                       }
+                       os << "\\experimental:bookmarks_visibility " << status << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
+               // fall through
        case RC_MAC_DONTSWAP_CTRL_META:
                if (ignore_system_lyxrc ||
                    mac_dontswap_ctrl_meta
@@ -1992,12 +2030,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
        case RC_SET_COLOR:
                for (int i = 0; i < Color_ignore; ++i) {
                        ColorCode lc = static_cast<ColorCode>(i);
-                       string const col = lcolor.getX11HexName(lc);
+                       string const col = lcolor.getAllX11HexNames(lc).first;
+                       string const darkcol = lcolor.getAllX11HexNames(lc).second;
                        if (ignore_system_lyxrc
-                           || col != system_lcolor.getX11HexName(lc)) {
+                           || col != system_lcolor.getAllX11HexNames(lc).first
+                           || darkcol != system_lcolor.getAllX11HexNames(lc).second) {
                                os << "\\set_color \""
                                   << lcolor.getLyXName(lc) << "\" \""
-                                  << col << "\"\n";
+                                  << col << "\" \""
+                                  << darkcol << "\"\n";
                        }
                }
                if (tag != RC_LAST)
@@ -2726,8 +2767,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                        break;
                // fall through
        case RC_DEFAULT_VIEW_FORMAT:
-               if (ignore_system_lyxrc ||
-                   default_view_format != system_lyxrc.default_view_format) {
+               if ((ignore_system_lyxrc ||
+                       default_view_format != system_lyxrc.default_view_format)
+                       && !default_view_format.empty()) {
                        os << "\\default_view_format " << default_view_format << '\n';
                }
                if (tag != RC_LAST)
@@ -2829,6 +2871,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_BIBTEX_ALTERNATIVES:
        case LyXRC::RC_BIBTEX_COMMAND:
        case LyXRC::RC_BINDFILE:
+       case LyXRC::RC_BOOKMARKS_VISIBILITY:
        case LyXRC::RC_CITATION_SEARCH:
        case LyXRC::RC_CITATION_SEARCH_PATTERN:
        case LyXRC::RC_CITATION_SEARCH_VIEW:
@@ -2944,7 +2987,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
                || lyxrc_orig.roman_font_foundry != lyxrc_new.roman_font_foundry
                || lyxrc_orig.sans_font_foundry != lyxrc_new.sans_font_foundry
                || lyxrc_orig.use_scalable_fonts != lyxrc_new.use_scalable_fonts
-               || lyxrc_orig.font_sizes != lyxrc_new.font_sizes
+               || !std::equal(std::begin(lyxrc_orig.font_sizes), std::end(lyxrc_orig.font_sizes),
+                              std::begin(lyxrc_new.font_sizes))
                || lyxrc_orig.typewriter_font_foundry != lyxrc_new.typewriter_font_foundry
                || lyxrc_orig.defaultZoom != lyxrc_new.defaultZoom) {
                        dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));