]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
Revert UI fix for two digit numbers. It actually does not work.
[lyx.git] / src / LyXRC.cpp
index a274c5f03f94a658bf170f92111e53db615fd460..fa50d4a51d8aa2832ac8781bc93b5c85e6b947dd 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"
+#endif
 
 #include <fstream>
 #include <iostream>
@@ -61,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 = 32; // spitz: add \ct_markup_copied
+static unsigned int const LYXRC_FILEFORMAT = 37; // chillenb: screen_width and screen_limit
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -78,6 +77,9 @@ LexerKeyword lyxrcTags[] = {
        { "\\bind_file", LyXRC::RC_BINDFILE },
        { "\\check_lastfiles", LyXRC::RC_CHECKLASTFILES },
        { "\\chktex_command", LyXRC::RC_CHKTEX_COMMAND },
+       { "\\citation_search", LyXRC::RC_CITATION_SEARCH },
+       { "\\citation_search_pattern", LyXRC::RC_CITATION_SEARCH_PATTERN },
+       { "\\citation_search_view", LyXRC::RC_CITATION_SEARCH_VIEW },
        { "\\close_buffer_with_last_view", LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW },
        { "\\completion_cursor_text", LyXRC::RC_COMPLETION_CURSOR_TEXT },
        { "\\completion_inline_delay", LyXRC::RC_COMPLETION_INLINE_DELAY },
@@ -105,20 +107,20 @@ LexerKeyword lyxrcTags[] = {
        { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
        { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS },
        { "\\document_path", LyXRC::RC_DOCUMENTPATH },
+       { "\\draw_strategy", LyXRC::RC_DRAW_STRATEGY },
        { "\\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 },
        { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
-       { "\\fullscreen_limit", LyXRC::RC_FULL_SCREEN_LIMIT },
        { "\\fullscreen_menubar", LyXRC::RC_FULL_SCREEN_MENUBAR },
        { "\\fullscreen_scrollbar", LyXRC::RC_FULL_SCREEN_SCROLLBAR },
        { "\\fullscreen_statusbar", LyXRC::RC_FULL_SCREEN_STATUSBAR },
        { "\\fullscreen_tabbar", LyXRC::RC_FULL_SCREEN_TABBAR },
        { "\\fullscreen_toolbars", LyXRC::RC_FULL_SCREEN_TOOLBARS },
-       { "\\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 },
@@ -173,6 +175,8 @@ LexerKeyword lyxrcTags[] = {
        { "\\screen_font_sizes", LyXRC::RC_SCREEN_FONT_SIZES },
        { "\\screen_font_typewriter", LyXRC::RC_SCREEN_FONT_TYPEWRITER },
        { "\\screen_font_typewriter_foundry", LyXRC::RC_SCREEN_FONT_TYPEWRITER_FOUNDRY },
+       { "\\screen_limit", LyXRC::RC_SCREEN_LIMIT },
+       { "\\screen_width", LyXRC::RC_SCREEN_WIDTH },
        { "\\screen_zoom", LyXRC::RC_SCREEN_ZOOM },
        { "\\scroll_below_document", LyXRC::RC_SCROLL_BELOW_DOCUMENT },
        { "\\scroll_wheel_zoom", LyXRC::RC_SCROLL_WHEEL_ZOOM },
@@ -643,13 +647,17 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                                lexrc.printError("Missing color tag.");
                                break;
                        }
-                       string lyx_name = lexrc.getString();
+                       string const lyx_name = lexrc.getString();
 
                        if (!lexrc.next()) {
                                lexrc.printError("Missing color name for color: `$$Token'");
                                break;
                        }
-                       string x11_name = lexrc.getString();
+                       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);
@@ -658,8 +666,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 << " and " << x11_darkname);
                        break;
                }
 
@@ -678,6 +688,20 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        }
                        break;
 
+               case RC_CITATION_SEARCH:
+                       lexrc >> citation_search;
+                       break;
+
+               case RC_CITATION_SEARCH_PATTERN:
+                       if (lexrc.next())
+                               citation_search_pattern = lexrc.getString();
+                       break;
+
+               case RC_CITATION_SEARCH_VIEW:
+                       if (lexrc.next())
+                               citation_search_view = lexrc.getString();
+                       break;
+
                case RC_CT_ADDITIONS_UNDERLINED:
                        lexrc >> ct_additions_underlined;
                        break;
@@ -1014,8 +1038,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_GROUP_LAYOUTS:
                        lexrc >> group_layouts;
                        break;
-               case RC_FULL_SCREEN_LIMIT:
-                       lexrc >> full_screen_limit;
+               case RC_SCREEN_LIMIT:
+                       lexrc >> screen_limit;
                        break;
                case RC_FULL_SCREEN_TOOLBARS:
                        lexrc >> full_screen_toolbars;
@@ -1032,11 +1056,15 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_FULL_SCREEN_MENUBAR:
                        lexrc >> full_screen_menubar;
                        break;
-               case RC_FULL_SCREEN_WIDTH:
-                       lexrc >> full_screen_width;
+               case RC_SCREEN_WIDTH:
+                       lexrc >> screen_width;
                        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;
@@ -1091,6 +1119,36 @@ 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_DRAW_STRATEGY:
+                       if (lexrc.next()) {
+                               string const tmp = lexrc.getString();
+                               if (tmp == "partial")
+                                       draw_strategy = DS_PARTIAL;
+                               else if (tmp == "backingstore")
+                                       draw_strategy = DS_BACKINGSTORE;
+                               else {
+                                       draw_strategy = DS_PARTIAL;
+                                       LYXERR0("Unrecognized draw strategy " << tmp <<'"');
+                               }
+                       }
+                       break;
+
                case RC_LAST:
                        break; // this is just a dummy
                }
@@ -1601,6 +1659,36 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
+       case RC_CITATION_SEARCH:
+               if (ignore_system_lyxrc ||
+                   citation_search != system_lyxrc.citation_search) {
+                       os << "# Set to true to use script to search"
+                          << " local disk for citation targets.\n"
+                          << "\\citation_search "
+                          << convert<string>(citation_search)
+                          << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
+               // fall through
+       case RC_CITATION_SEARCH_VIEW:
+               if (ignore_system_lyxrc ||
+                   citation_search_view != system_lyxrc.citation_search_view) {
+                       os << "\\citation_search_view \""
+                          << citation_search_view << "\"\n";
+               }
+               if (tag != RC_LAST)
+                       break;
+               // fall through
+       case RC_CITATION_SEARCH_PATTERN:
+               if (ignore_system_lyxrc ||
+                   citation_search_pattern != system_lyxrc.citation_search_pattern) {
+                       os << "\\citation_search_pattern \""
+                          << citation_search_pattern << "\"\n";
+               }
+               if (tag != RC_LAST)
+                       break;
+               // fall through
        case RC_CT_ADDITIONS_UNDERLINED:
                if (ignore_system_lyxrc ||
                    ct_additions_underlined
@@ -1661,6 +1749,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
@@ -1812,11 +1920,11 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
-       case RC_FULL_SCREEN_LIMIT:
+       case RC_SCREEN_LIMIT:
                if (ignore_system_lyxrc ||
-                   full_screen_limit != system_lyxrc.full_screen_limit) {
-                       os << "\\fullscreen_limit "
-                          << convert<string>(full_screen_limit)
+                   screen_limit != system_lyxrc.screen_limit) {
+                       os << "\\screen_limit "
+                          << convert<string>(screen_limit)
                           << '\n';
                }
                if (tag != RC_LAST)
@@ -1872,11 +1980,11 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
                // fall through
-       case RC_FULL_SCREEN_WIDTH:
+       case RC_SCREEN_WIDTH:
                if (ignore_system_lyxrc ||
-                   full_screen_width != system_lyxrc.full_screen_width) {
-                       os << "\\fullscreen_width "
-                          << convert<string>(full_screen_width)
+                   screen_width != system_lyxrc.screen_width) {
+                       os << "\\screen_width "
+                          << screen_width.asString()
                           << '\n';
                }
                if (tag != RC_LAST)
@@ -1927,21 +2035,42 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+               // fall through
+       case RC_DRAW_STRATEGY:
+               if (ignore_system_lyxrc ||
+                       draw_strategy != system_lyxrc.draw_strategy) {
+                       string status;
+                       switch (draw_strategy) {
+                       case DS_PARTIAL:
+                               status = "partial";
+                               break;
+                       case DS_BACKINGSTORE:
+                               status = "backingstore";
+                               break;
+                       }
+                       os << "\\draw_strategy " << status << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
+               // fall through
 
        os << "\n#\n"
-                       << "# COLOR SECTION ###################################\n"
-                       << "#\n\n";
+               << "# COLOR SECTION ###################################\n"
+               << "#\n\n";
 
        // fall through
        case RC_SET_COLOR:
                for (int i = 0; i < Color_ignore; ++i) {
                        ColorCode lc = static_cast<ColorCode>(i);
-                       string const col = lcolor.getX11Name(lc);
+                       string const col = lcolor.getAllX11HexNames(lc).first;
+                       string const darkcol = lcolor.getAllX11HexNames(lc).second;
                        if (ignore_system_lyxrc
-                           || col != system_lcolor.getX11Name(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)
@@ -2670,8 +2799,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)
@@ -2773,6 +2903,10 @@ 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:
        case LyXRC::RC_CHECKLASTFILES:
        case LyXRC::RC_COMPLETION_CURSOR_TEXT:
        case LyXRC::RC_COMPLETION_INLINE_DELAY:
@@ -2808,6 +2942,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
                                package().document_dir() = FileName(lyxrc.document_path);
                }
                // fall through
+       case LyXRC::RC_DRAW_STRATEGY:
        case LyXRC::RC_EDITOR_ALTERNATIVES:
        case LyXRC::RC_ESC_CHARS:
        case LyXRC::RC_EXAMPLEPATH:
@@ -2885,7 +3020,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));
@@ -2928,13 +3064,13 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_SINGLE_CLOSE_TAB_BUTTON:
        case LyXRC::RC_SINGLE_INSTANCE:
        case LyXRC::RC_SORT_LAYOUTS:
-       case LyXRC::RC_FULL_SCREEN_LIMIT:
+       case LyXRC::RC_SCREEN_LIMIT:
        case LyXRC::RC_FULL_SCREEN_SCROLLBAR:
        case LyXRC::RC_FULL_SCREEN_MENUBAR:
        case LyXRC::RC_FULL_SCREEN_STATUSBAR:
        case LyXRC::RC_FULL_SCREEN_TABBAR:
        case LyXRC::RC_FULL_SCREEN_TOOLBARS:
-       case LyXRC::RC_FULL_SCREEN_WIDTH:
+       case LyXRC::RC_SCREEN_WIDTH:
        case LyXRC::RC_VISUAL_CURSOR:
        case LyXRC::RC_CLOSE_BUFFER_WITH_LAST_VIEW:
        case LyXRC::RC_VIEWER: