]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
cosmetics
[lyx.git] / src / LyXRC.cpp
index 099de7575cc7cf701a69a941dce31d0025ee681d..c856d756ac4e06af05f69a97f66dd543172efbd2 100644 (file)
 #include "LyXRC.h"
 
 #include "debug.h"
+#include "Color.h"
 #include "Converter.h"
 #include "Format.h"
 #include "gettext.h"
 #include "Session.h"
-#include "Color.h"
 #include "Lexer.h"
-#include "Font.h"
+#include "FontEnums.h"
 #include "Mover.h"
 
 #include "graphics/GraphicsTypes.h"
@@ -84,6 +84,7 @@ keyword_item lyxrcTags[] = {
        { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
        { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
        { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
+       { "\\def_file", LyXRC::RC_DEFFILE },
        { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
        { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
        { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN },
@@ -152,6 +153,7 @@ keyword_item lyxrcTags[] = {
        { "\\serverpipe", LyXRC::RC_SERVERPIPE },
        { "\\set_color", LyXRC::RC_SET_COLOR },
        { "\\show_banner", LyXRC::RC_SHOW_BANNER },
+       { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
        { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
        { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
        { "\\template_path", LyXRC::RC_TEMPLATEPATH },
@@ -164,6 +166,7 @@ keyword_item lyxrcTags[] = {
        { "\\use_input_encoding", LyXRC::RC_USE_INP_ENC },
        { "\\use_lastfilepos", LyXRC::RC_USELASTFILEPOS },
        { "\\use_personal_dictionary", LyXRC::RC_USE_PERS_DICT },
+       { "\\use_pixmap_cache", LyXRC::RC_USE_PIXMAP_CACHE },
        // compatibility with versions older than 1.4.0 only
        { "\\use_pspell", LyXRC::RC_USE_SPELL_LIB },
        { "\\use_spell_lib", LyXRC::RC_USE_SPELL_LIB },
@@ -173,7 +176,7 @@ keyword_item lyxrcTags[] = {
        { "\\user_name", LyXRC::RC_USER_NAME },
        { "\\view_dvi_paper_option", LyXRC::RC_VIEWDVI_PAPEROPTION },
        // compatibility with versions older than 1.4.0 only
-       { "\\viewer" ,LyXRC::RC_VIEWER}
+       { "\\viewer"LyXRC::RC_VIEWER}
 };
 
 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
@@ -189,6 +192,7 @@ LyXRC::LyXRC()
 
 void LyXRC::setDefaults() {
        bind_file = "cua";
+       def_file = "default";
        ui_file = "default";
        // Get printer from the environment. If fail, use default "",
        // assuming that everything is set up correctly.
@@ -222,16 +226,16 @@ void LyXRC::setDefaults() {
        geometry_height = 0;
        geometry_xysaved = true;
        // Default LaTeX font size:
-       font_sizes[Font::SIZE_TINY] = "5.0";
-       font_sizes[Font::SIZE_SCRIPT] = "7.0";
-       font_sizes[Font::SIZE_FOOTNOTE] = "8.0";
-       font_sizes[Font::SIZE_SMALL] = "9.0";
-       font_sizes[Font::SIZE_NORMAL] = "10.0";
-       font_sizes[Font::SIZE_LARGE] = "12.0";
-       font_sizes[Font::SIZE_LARGER] = "14.4";
-       font_sizes[Font::SIZE_LARGEST] = "17.26";
-       font_sizes[Font::SIZE_HUGE] = "20.74";
-       font_sizes[Font::SIZE_HUGER] = "24.88";
+       font_sizes[FONT_SIZE_TINY] = "5.0";
+       font_sizes[FONT_SIZE_SCRIPT] = "7.0";
+       font_sizes[FONT_SIZE_FOOTNOTE] = "8.0";
+       font_sizes[FONT_SIZE_SMALL] = "9.0";
+       font_sizes[FONT_SIZE_NORMAL] = "10.0";
+       font_sizes[FONT_SIZE_LARGE] = "12.0";
+       font_sizes[FONT_SIZE_LARGER] = "14.4";
+       font_sizes[FONT_SIZE_LARGEST] = "17.26";
+       font_sizes[FONT_SIZE_HUGE] = "20.74";
+       font_sizes[FONT_SIZE_HUGER] = "24.88";
        use_scalable_fonts = true;
        roman_font_name = "";
        sans_font_name = "";
@@ -266,6 +270,7 @@ void LyXRC::setDefaults() {
        language_package = "\\usepackage{babel}";
        language_command_begin = "\\selectlanguage{$$lang}";
        language_command_local = "\\foreignlanguage{$$lang}{";
+       sort_layouts = false;
        default_language = "english";
        show_banner = true;
        windows_style_tex_paths = false;
@@ -278,6 +283,7 @@ void LyXRC::setDefaults() {
        preview_hashed_labels  = false;
        preview_scale_factor = "0.9";
        use_converter_cache = true;
+       use_pixmap_cache = false;
        converter_cache_maxage = 6 * 30 * 24 * 3600; // 6 months
 
        user_name = to_utf8(support::user_name());
@@ -370,6 +376,12 @@ int LyXRC::read(Lexer & lexrc)
                        }
                        break;
 
+               case RC_DEFFILE:
+                       if (lexrc.next()) {
+                               def_file = os::internal_path(lexrc.getString());
+                       }
+                       break;
+
                case RC_UIFILE:
                        if (lexrc.next()) {
                                ui_file = os::internal_path(lexrc.getString());
@@ -649,43 +661,43 @@ int LyXRC::read(Lexer & lexrc)
 
                case RC_SCREEN_FONT_SIZES:
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_TINY] =
+                               font_sizes[FONT_SIZE_TINY] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_SCRIPT] =
+                               font_sizes[FONT_SIZE_SCRIPT] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_FOOTNOTE] =
+                               font_sizes[FONT_SIZE_FOOTNOTE] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_SMALL] =
+                               font_sizes[FONT_SIZE_SMALL] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_NORMAL] =
+                               font_sizes[FONT_SIZE_NORMAL] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_LARGE] =
+                               font_sizes[FONT_SIZE_LARGE] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_LARGER] =
+                               font_sizes[FONT_SIZE_LARGER] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_LARGEST] =
+                               font_sizes[FONT_SIZE_LARGEST] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_HUGE] =
+                               font_sizes[FONT_SIZE_HUGE] =
                                        lexrc.getString();
                        }
                        if (lexrc.next()) {
-                               font_sizes[Font::SIZE_HUGER] =
+                               font_sizes[FONT_SIZE_HUGER] =
                                        lexrc.getString();
                        }
                        break;
@@ -812,11 +824,11 @@ int LyXRC::read(Lexer & lexrc)
                                break;
                        }
 
-                       Color::color const col =
+                       ColorCode const col =
                                lcolor.getFromLyXName(lyx_name);
-                       if (col == Color::none ||
-                           col == Color::inherit ||
-                           col == Color::ignore)
+                       if (col == Color_none ||
+                           col == Color_inherit ||
+                           col == Color_ignore)
                                break;
 
                        if (!lcolor.setColor(col, x11_name)) {
@@ -893,6 +905,11 @@ int LyXRC::read(Lexer & lexrc)
                                isp_use_pers_dict = lexrc.getBool();
                        }
                        break;
+               case RC_USE_PIXMAP_CACHE:
+                       if (lexrc.next()) {
+                               use_pixmap_cache = lexrc.getBool();
+                       }
+                       break;
                case RC_USE_ESC_CHARS:
                        if (lexrc.next()) {
                                isp_use_esc_chars = lexrc.getBool();
@@ -1163,6 +1180,11 @@ int LyXRC::read(Lexer & lexrc)
                                        convert<unsigned int>(lexrc.getString());
                        break;
 
+               case RC_SORT_LAYOUTS:
+                       if (lexrc.next())
+                               sort_layouts = lexrc.getBool();
+                       break;
+
                case RC_LAST: break; // this is just a dummy
                }
        }
@@ -1215,7 +1237,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
        LyXRCTags tag = RC_LAST;
        
        if (!name.empty()) {
-               for (size_t i = 0; i < lyxrcCount; ++i)
+               for (int i = 0; i != lyxrcCount; ++i)
                        if ("\\" + name == lyxrcTags[i].tag)
                                tag = static_cast<LyXRCTags>(lyxrcTags[i].code);
        }
@@ -1226,7 +1248,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                   << "###          LyX, The Document Processor\n"
                   << "###\n"
                   << "###          Copyright 1995 Matthias Ettrich\n"
-                  << "###          Copyright 1995-2001 The LyX Team.\n"
+                  << "###          Copyright 1995-2007 The LyX Team.\n"
                   << "###\n"
                   << "### ========================================================\n"
                   << "\n"
@@ -1252,6 +1274,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
 
+       case RC_DEFFILE:
+               if (ignore_system_lyxrc ||
+                   def_file != system_lyxrc.def_file) {
+                       string const path = os::external_path(def_file);
+                       os << "\\def_file \"" << path << "\"\n";
+               }
+               if (tag != RC_LAST)
+                       break;
+
                //
                // Misc Section
                //
@@ -1310,12 +1341,20 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                        os << "# Display graphics within LyX\n"
                           << "# monochrome|grayscale|color|none\n"
                           << "\\display_graphics "
-                          << graphics::displayTranslator().find(display_graphics)
+                          << graphics::displayTranslator().find(
+                                graphics::DisplayType(display_graphics))
                           << '\n';
                }
                if (tag != RC_LAST)
                        break;
-
+       case RC_SORT_LAYOUTS:
+               if (ignore_system_lyxrc ||
+                   sort_layouts != system_lyxrc.sort_layouts) {
+                       os << "# Sort layouts alphabetically.\n"
+                          << "\\sort_layouts " << convert<string>(sort_layouts) << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_VIEWDVI_PAPEROPTION:
                if (ignore_system_lyxrc ||
                    view_dvi_paper_option
@@ -1636,39 +1675,39 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                        break;
        case RC_SCREEN_FONT_SIZES:
                if (ignore_system_lyxrc ||
-                   font_sizes[Font::SIZE_TINY]
-                   != system_lyxrc.font_sizes[Font::SIZE_TINY] ||
-                   font_sizes[Font::SIZE_SCRIPT]
-                   != system_lyxrc.font_sizes[Font::SIZE_SCRIPT] ||
-                   font_sizes[Font::SIZE_FOOTNOTE]
-                   != system_lyxrc.font_sizes[Font::SIZE_FOOTNOTE] ||
-                   font_sizes[Font::SIZE_SMALL]
-                   != system_lyxrc.font_sizes[Font::SIZE_SMALL] ||
-                   font_sizes[Font::SIZE_NORMAL]
-                   != system_lyxrc.font_sizes[Font::SIZE_NORMAL] ||
-                   font_sizes[Font::SIZE_LARGE]
-                   != system_lyxrc.font_sizes[Font::SIZE_LARGE] ||
-                   font_sizes[Font::SIZE_LARGER]
-                   != system_lyxrc.font_sizes[Font::SIZE_LARGER] ||
-                   font_sizes[Font::SIZE_LARGEST]
-                   != system_lyxrc.font_sizes[Font::SIZE_LARGEST] ||
-                   font_sizes[Font::SIZE_HUGE]
-                   != system_lyxrc.font_sizes[Font::SIZE_HUGE] ||
-                   font_sizes[Font::SIZE_HUGER]
-                   != system_lyxrc.font_sizes[Font::SIZE_HUGER]) {
+                   font_sizes[FONT_SIZE_TINY]
+                   != system_lyxrc.font_sizes[FONT_SIZE_TINY] ||
+                   font_sizes[FONT_SIZE_SCRIPT]
+                   != system_lyxrc.font_sizes[FONT_SIZE_SCRIPT] ||
+                   font_sizes[FONT_SIZE_FOOTNOTE]
+                   != system_lyxrc.font_sizes[FONT_SIZE_FOOTNOTE] ||
+                   font_sizes[FONT_SIZE_SMALL]
+                   != system_lyxrc.font_sizes[FONT_SIZE_SMALL] ||
+                   font_sizes[FONT_SIZE_NORMAL]
+                   != system_lyxrc.font_sizes[FONT_SIZE_NORMAL] ||
+                   font_sizes[FONT_SIZE_LARGE]
+                   != system_lyxrc.font_sizes[FONT_SIZE_LARGE] ||
+                   font_sizes[FONT_SIZE_LARGER]
+                   != system_lyxrc.font_sizes[FONT_SIZE_LARGER] ||
+                   font_sizes[FONT_SIZE_LARGEST]
+                   != system_lyxrc.font_sizes[FONT_SIZE_LARGEST] ||
+                   font_sizes[FONT_SIZE_HUGE]
+                   != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
+                   font_sizes[FONT_SIZE_HUGER]
+                   != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
                        os.setf(ios::fixed);
                        os.precision(2);
                        os << "\\screen_font_sizes"
-                          << ' ' << font_sizes[Font::SIZE_TINY]
-                          << ' ' << font_sizes[Font::SIZE_SCRIPT]
-                          << ' ' << font_sizes[Font::SIZE_FOOTNOTE]
-                          << ' ' << font_sizes[Font::SIZE_SMALL]
-                          << ' ' << font_sizes[Font::SIZE_NORMAL]
-                          << ' ' << font_sizes[Font::SIZE_LARGE]
-                          << ' ' << font_sizes[Font::SIZE_LARGER]
-                          << ' ' << font_sizes[Font::SIZE_LARGEST]
-                          << ' ' << font_sizes[Font::SIZE_HUGE]
-                          << ' ' << font_sizes[Font::SIZE_HUGER]
+                          << ' ' << font_sizes[FONT_SIZE_TINY]
+                          << ' ' << font_sizes[FONT_SIZE_SCRIPT]
+                          << ' ' << font_sizes[FONT_SIZE_FOOTNOTE]
+                          << ' ' << font_sizes[FONT_SIZE_SMALL]
+                          << ' ' << font_sizes[FONT_SIZE_NORMAL]
+                          << ' ' << font_sizes[FONT_SIZE_LARGE]
+                          << ' ' << font_sizes[FONT_SIZE_LARGER]
+                          << ' ' << font_sizes[FONT_SIZE_LARGEST]
+                          << ' ' << font_sizes[FONT_SIZE_HUGE]
+                          << ' ' << font_sizes[FONT_SIZE_HUGER]
                           << '\n';
                }
                if (tag != RC_LAST)
@@ -1679,8 +1718,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                   << "#\n\n";
 
        case RC_SET_COLOR:
-               for (int i = 0; i < Color::ignore; ++i) {
-                       Color::color lc = static_cast<Color::color>(i);
+               for (int i = 0; i < Color_ignore; ++i) {
+                       ColorCode lc = static_cast<ColorCode>(i);
 
                        string const col(lcolor.getX11Name(lc));
                        if (ignore_system_lyxrc ||
@@ -2046,6 +2085,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_USE_PIXMAP_CACHE:
+               if (ignore_system_lyxrc ||
+                   use_pixmap_cache != system_lyxrc.use_pixmap_cache) {
+                       os << "\\use_pixmap_cache "
+                          << convert<string>(use_pixmap_cache)
+                          << '\n';
+               }
        case RC_PERS_DICT:
                if (isp_pers_dict != system_lyxrc.isp_pers_dict) {
                        string const path = os::external_path(isp_pers_dict);
@@ -2367,6 +2413,11 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
                break;
 
+       case RC_DEFFILE:
+               //FIXME: fix description.
+               str = _("Command definition file.");
+               break;
+
        case RC_DEFAULT_LANGUAGE:
                str = _("New documents will be assigned this language.");
                break;
@@ -2651,6 +2702,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("Specify whether to pass the -T input encoding option to ispell. Enable this if you cannot check the spelling of words containing accented letters. This may not work with all dictionaries.");
                break;
 
+       case RC_USE_PIXMAP_CACHE:
+               str = _("Enable the pixmap cache that might improve performance on Mac and Windows.");
+               break;
+
        case RC_USE_SPELL_LIB:
                break;