]> git.lyx.org Git - lyx.git/blobdiff - src/lyxrc.C
use anon namespace, somewhat better comp. handling of minipages, not quite there yet
[lyx.git] / src / lyxrc.C
index f4caddcd0b627abb4c836a7207553053b7cb29e7..0c0282ec235917a35ff7e6441e6b9a63cd3aa8ef 100644 (file)
@@ -40,10 +40,10 @@ using std::endl;
 using std::vector;
 
 extern LyXAction lyxaction;
-extern kb_keymap * toplevel_keymap;
+extern boost::scoped_ptr<kb_keymap> toplevel_keymap;
 
+namespace {
 
-static
 keyword_item lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
        { "\\alternate_language", LyXRC::RC_ALT_LANG },
@@ -68,10 +68,6 @@ keyword_item lyxrcTags[] = {
        { "\\document_path", LyXRC::RC_DOCUMENTPATH },
        { "\\escape_chars", LyXRC::RC_ESC_CHARS },
        { "\\exit_confirmation", LyXRC::RC_EXIT_CONFIRMATION },
-#if 0
-       { "\\fax_command", LyXRC::RC_FAX_COMMAND },
-       { "\\fax_program", LyXRC::RC_FAXPROGRAM },
-#endif
        { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
        { "\\format", LyXRC::RC_FORMAT },
        { "\\input", LyXRC::RC_INPUT },
@@ -83,7 +79,10 @@ keyword_item lyxrcTags[] = {
        { "\\language_auto_end", LyXRC::RC_LANGUAGE_AUTO_END },
        { "\\language_command_begin", LyXRC::RC_LANGUAGE_COMMAND_BEGIN },
        { "\\language_command_end", LyXRC::RC_LANGUAGE_COMMAND_END },
+       { "\\language_command_local", LyXRC::RC_LANGUAGE_COMMAND_LOCAL },
+       { "\\language_global_options", LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS },
        { "\\language_package", LyXRC::RC_LANGUAGE_PACKAGE },
+       { "\\language_use_babel", LyXRC::RC_LANGUAGE_USE_BABEL },
        { "\\lastfiles", LyXRC::RC_LASTFILES },
        { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
        { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
@@ -91,9 +90,6 @@ keyword_item lyxrcTags[] = {
        { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
        { "\\override_x_deadkeys", LyXRC::RC_OVERRIDE_X_DEADKEYS },
        { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
-#if 0
-       { "\\phone_book", LyXRC::RC_PHONEBOOK },
-#endif
        { "\\print_adapt_output", LyXRC::RC_PRINT_ADAPTOUTPUT },
        { "\\print_collcopies_flag", LyXRC::RC_PRINTCOLLCOPIESFLAG },
        { "\\print_command", LyXRC::RC_PRINT_COMMAND },
@@ -143,7 +139,9 @@ keyword_item lyxrcTags[] = {
 };
 
 /* Let the range depend of the size of lyxrcTags.  Alejandro 240596 */
-static const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
+const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
+
+} // namespace anon
 
 
 LyXRC::LyXRC() 
@@ -153,6 +151,8 @@ LyXRC::LyXRC()
 
 
 void LyXRC::setDefaults() {
+       bind_file = "cua";
+       hasBindFile = false;
        ui_file = "default";
        // Get printer from the environment. If fail, use default "",
        // assuming that everything is set up correctly.
@@ -202,7 +202,7 @@ void LyXRC::setDefaults() {
        menu_font_name = "-*-helvetica-bold-r";
        popup_font_name = "-*-helvetica-medium-r";
        font_norm = "iso8859-1";
-       font_norm_type = OTHER_ENCODING;
+       font_norm_type = ISO_8859_1;
        font_norm_menu = "";
        override_x_deadkeys = true;
        autosave = 300;
@@ -222,15 +222,17 @@ void LyXRC::setDefaults() {
        isp_use_pers_dict = false;
        isp_use_esc_chars = false;
        use_kbmap = false;
-       hasBindFile = false;
        rtl_support = false;
        auto_number = true;
        mark_foreign_language = true;
-       language_package = "\\usepackage{babel}";
        language_auto_begin = true;
        language_auto_end = true;
+       language_global_options = true;
+       language_use_babel = true;
+       language_package = "\\usepackage{babel}";
        language_command_begin = "\\selectlanguage{$$lang}";
        language_command_end = "\\selectlanguage{$$lang}";
+       language_command_local = "\\foreignlanguage{$$lang}{";
        default_language = "english";
        //
        new_ask_filename = false;
@@ -260,12 +262,14 @@ int LyXRC::ReadBindFile(string const & name)
        return result;
 }
 
+void LyXRC::readBindFileIfNeeded()
+{
+       if (!hasBindFile)
+               ReadBindFile(bind_file);
+}
 
 int LyXRC::read(string const & filename)
-{
-       // Default bindfile.
-       static string const bindFile("cua");
-       
+{      
        LyXLex lexrc(lyxrcTags, lyxrcCount);
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
@@ -306,13 +310,16 @@ int LyXRC::read(string const & filename)
                case RC_BINDFILE:                     // RVDK_PATCH_5
                        if (lexrc.next()) {
                                string tmp(lexrc.GetString());
-                               if (bind_file.empty()) {
-                                       // we only need the name of the first
-                                       // bind file since that (usually)
-                                       // includes several others.
+                               if (hasBindFile)
+                                       // We are already in the
+                                       // "actually read bind file"
+                                       // mode.
+                                       ReadBindFile(tmp);
+                               else
+                                       // We are still in the "just
+                                       // remember the name of the
+                                       // bind file" mode.
                                        bind_file = tmp;
-                               }
-                               ReadBindFile(tmp);
                        }
                        break;
                        
@@ -678,10 +685,8 @@ int LyXRC::read(string const & filename)
                        // we should not do an explicit binding before
                        // loading a bind file. So, in this case, load
                        // the default bind file.
-                       if (!hasBindFile) {
-                               bind_file = bindFile;
-                               ReadBindFile();
-                       }
+                       readBindFileIfNeeded();
+
                        // !!!chb, dynamic key binding...
                        int action, res = 0;
                        string seq, cmd;
@@ -734,25 +739,6 @@ int LyXRC::read(string const & filename)
                                cursor_follows_scrollbar = lexrc.GetBool();
                        break;
 
-#if 0
-               case RC_FAX_COMMAND:
-                       if (lexrc.next())
-                               fax_command = lexrc.GetString();
-                       break;
-               case RC_FAXPROGRAM:
-                       if (lexrc.next())
-                               fax_program = lexrc.GetString();
-                       break;
-               case RC_PHONEBOOK:
-                       if (lexrc.next()) {
-                               string s = lexrc.GetString();
-                               if (AbsolutePath(s))
-                                       phone_book = s;
-                               else
-                                       phone_book = user_lyxdir + s;
-                       }
-                       break;
-#endif
                case RC_ASCIIROFF_COMMAND:
                        if (lexrc.next())
                                ascii_roff_command = lexrc.GetString();
@@ -822,6 +808,14 @@ int LyXRC::read(string const & filename)
                        if (lexrc.next())
                                language_auto_end = lexrc.GetBool();
                        break;
+               case RC_LANGUAGE_GLOBAL_OPTIONS:
+                       if (lexrc.next())
+                               language_global_options = lexrc.GetBool();
+                       break;
+               case RC_LANGUAGE_USE_BABEL:
+                       if (lexrc.next())
+                               language_use_babel = lexrc.GetBool();
+                       break;
                case RC_LANGUAGE_COMMAND_BEGIN:
                        if (lexrc.next())
                                language_command_begin = lexrc.GetString();
@@ -830,6 +824,10 @@ int LyXRC::read(string const & filename)
                        if (lexrc.next())
                                language_command_end = lexrc.GetString();
                        break;
+               case RC_LANGUAGE_COMMAND_LOCAL:
+                       if (lexrc.next())
+                               language_command_local = lexrc.GetString();
+                       break;
                case RC_RTL_SUPPORT:
                        if (lexrc.next())
                                rtl_support = lexrc.GetBool();
@@ -912,6 +910,10 @@ int LyXRC::read(string const & filename)
                }
        }
 
+       /// Update converters data-structures
+       converters.Update(formats);
+       converters.BuildGraph();
+
        return 0;
 }
 
@@ -1357,24 +1359,6 @@ void LyXRC::output(ostream & os) const
                        os << "\\backupdir_path \"" << backupdir_path << "\"\n";
                }
 
-#if 0
-               os << "\n#\n"
-                  << "# FAX SECTION #######################################\n"
-                  << "#\n\n";
-               
-       case RC_FAX_COMMAND:
-               if (fax_command != system_lyxrc.fax_command) {
-                       os << "\\fax_command \"" << fax_command << "\"\n";
-               }
-       case RC_PHONEBOOK:
-               if (phone_book != system_lyxrc.phone_book) {
-                       os << "\\phone_book \"" << phone_book << "\"\n";
-               }
-       case RC_FAXPROGRAM:
-               if (fax_program != system_lyxrc.fax_program) {
-                       os << "\\fax_program \"" << fax_program << "\"\n";
-               }
-#endif
                os << "\n#\n"
                   << "# ASCII EXPORT SECTION ##############################\n"
                   << "#\n\n";
@@ -1449,6 +1433,19 @@ void LyXRC::output(ostream & os) const
                        os << "\\language_package \"" << language_package
                           << "\"\n";
                }
+       case RC_LANGUAGE_GLOBAL_OPTIONS:
+               if (language_global_options
+                   != system_lyxrc.language_global_options) {
+                       os << "\\language_global_options \""
+                          << tostr(language_global_options)
+                          << "\"\n";
+               }
+       case RC_LANGUAGE_USE_BABEL:
+               if (language_use_babel != system_lyxrc.language_use_babel) {
+                       os << "\\language_use_babel \""
+                          << tostr(language_use_babel)
+                          << "\"\n";
+               }
        case RC_LANGUAGE_COMMAND_BEGIN:
                if (language_command_begin
                    != system_lyxrc.language_command_begin) {
@@ -1462,6 +1459,13 @@ void LyXRC::output(ostream & os) const
                        os << "\\language_command_end \"" << language_command_end
                           << "\"\n";
                }
+       case RC_LANGUAGE_COMMAND_LOCAL:
+               if (language_command_local
+                   != system_lyxrc.language_command_local) {
+                       os << "\\language_command_local \""
+                          << language_command_local
+                          << "\"\n";
+               }
        case RC_LANGUAGE_AUTO_BEGIN:
                if (language_auto_begin != system_lyxrc.language_auto_begin) {
                        os << "\\language_auto_begin " 
@@ -1759,16 +1763,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = N_("Use this to set the correct mapping file for your keyboard. You'll need this if you for instance want to type German documents on an American keyboard.");
                break;
 
-#if 0
-       case RC_FAX_COMMAND:
-               break;
-               
-       case RC_PHONEBOOK:
-               break;
-               
-       case RC_FAXPROGRAM:
-               break;
-#endif 
        case RC_ASCIIROFF_COMMAND:
                str = N_("Use to define an external program to render tables in the ASCII output. E.g. \"groff -t -Tlatin1 $$FName\"  where $$FName is the input file. If \"none\" is specified, an internal routine is used.");
                break;
@@ -1861,6 +1855,14 @@ string const LyXRC::getDescription(LyXRCTags tag)
        case RC_LANGUAGE_PACKAGE:
                str = N_("The latex command for loading the language package. E.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
                break;
+
+       case RC_LANGUAGE_GLOBAL_OPTIONS:
+               str = N_("De-select if you don't want the language(s) used as an argument to \\documentclass.");
+               break;
+
+       case RC_LANGUAGE_USE_BABEL:
+               str = N_("De-select if you don't want babel to be used when the language of the document is the default language.");
+               break;
                
        case RC_LANGUAGE_AUTO_BEGIN:
                str = N_("Select if a language switching command is needed at the beginning of the document.");
@@ -1877,7 +1879,11 @@ string const LyXRC::getDescription(LyXRCTags tag)
        case RC_LANGUAGE_COMMAND_END:
                str = N_("The latex command for changing back to the language of the document.");
                break;
-               
+
+       case RC_LANGUAGE_COMMAND_LOCAL:
+               str = N_("The latex command for local changing of the language.");
+               break;
+
        case RC_DATE_INSERT_FORMAT:
                //xgettext:no-c-format
                str = N_("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");