]> git.lyx.org Git - lyx.git/blobdiff - src/lyxrc.C
minimal effort implementation of:
[lyx.git] / src / lyxrc.C
index d1276ba94cb1eb95687333c089ddf0f8ddbff4e6..fd741ab8ff8cfb8f82ee92b43a2c184f8f9eef5d 100644 (file)
@@ -48,6 +48,7 @@ using lyx::support::expandPath;
 using lyx::support::getEnv;
 using lyx::support::libFileSearch;
 using lyx::support::token;
+using lyx::support::tokenPos;
 
 using std::cout;
 using std::endl;
@@ -80,7 +81,6 @@ keyword_item lyxrcTags[] = {
        { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
        { "\\custom_export_command", LyXRC::RC_CUSTOM_EXPORT_COMMAND },
        { "\\custom_export_format", LyXRC::RC_CUSTOM_EXPORT_FORMAT },
-       { "\\cygwin_path_fix_needed", LyXRC::RC_CYGWIN_PATH_FIX },
        { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
        { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE },
        { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE },
@@ -162,6 +162,7 @@ keyword_item lyxrcTags[] = {
        { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
        { "\\template_path", LyXRC::RC_TEMPLATEPATH },
        { "\\tex_allows_spaces", LyXRC::RC_TEX_ALLOWS_SPACES },
+       { "\\tex_expects_windows_paths", LyXRC::RC_TEX_EXPECTS_WINDOWS_PATHS },
        { "\\ui_file", LyXRC::RC_UIFILE },
        { "\\use_alt_language", LyXRC::RC_USE_ALT_LANG },
        { "\\use_escape_chars", LyXRC::RC_USE_ESC_CHARS },
@@ -177,8 +178,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},
-       { "\\wheel_jump", LyXRC::RC_WHEEL_JUMP }
+       { "\\viewer" ,LyXRC::RC_VIEWER}
 };
 
 const int lyxrcCount = sizeof(lyxrcTags) / sizeof(keyword_item);
@@ -226,7 +226,6 @@ void LyXRC::setDefaults() {
        geometry_width = 0;
        geometry_height = 0;
        geometry_xysaved = true;
-       wheel_jump = 5;
        // Default LaTeX font size:
        font_sizes[LyXFont::SIZE_TINY] = "5.0";
        font_sizes[LyXFont::SIZE_SCRIPT] = "7.0";
@@ -254,7 +253,7 @@ void LyXRC::setDefaults() {
        num_lastfiles = maxlastfiles;
        check_lastfiles = true;
        use_lastfilepos = true;
-       load_session = true;
+       load_session = false;
        make_backup = true;
        backupdir_path.erase();
        display_graphics = lyx::graphics::ColorDisplay;
@@ -279,7 +278,7 @@ void LyXRC::setDefaults() {
        language_command_local = "\\foreignlanguage{$$lang}{";
        default_language = "english";
        show_banner = true;
-       cygwin_path_fix = false;
+       windows_style_tex_paths = false;
        tex_allows_spaces = false;
        date_insert_format = "%A, %e %B %Y";
        cursor_follows_scrollbar = false;
@@ -397,9 +396,9 @@ int LyXRC::read(LyXLex & lexrc)
                        }
                        break;
 
-               case RC_CYGWIN_PATH_FIX:
+               case RC_TEX_EXPECTS_WINDOWS_PATHS:
                        if (lexrc.next()) {
-                               cygwin_path_fix = lexrc.getBool();
+                               windows_style_tex_paths = lexrc.getBool();
                        }
                        break;
 
@@ -656,12 +655,6 @@ int LyXRC::read(LyXLex & lexrc)
                        }
                        break;
 
-               case RC_WHEEL_JUMP:
-                       if (lexrc.next()) {
-                               wheel_jump = lexrc.getInteger();
-                       }
-                       break;
-
                case RC_SCREEN_FONT_SIZES:
                        if (lexrc.next()) {
                                font_sizes[LyXFont::SIZE_TINY] =
@@ -1051,8 +1044,7 @@ int LyXRC::read(LyXLex & lexrc)
                        if (lexrc.next()) {
                                flags = lexrc.getString();
                        }
-                       if (command.empty()
-                           || token(command, ' ', 0) == "none") {
+                       if (command.empty()) {
                                converters.erase(from, to);
                        } else {
                                converters.add(from, to, command, flags);
@@ -1067,8 +1059,6 @@ int LyXRC::read(LyXLex & lexrc)
                        }
                        if (lexrc.next()) {
                                command = lexrc.getString();
-                               if (token(command, ' ', 0) == "none")
-                                       command.erase();
                        }
                        formats.setViewer(format, command);
                        break;
@@ -1088,28 +1078,35 @@ int LyXRC::read(LyXLex & lexrc)
                                shortcut = lexrc.getString();
                        }
                        string viewer, editor;
+                       if (lexrc.next())
+                               viewer = lexrc.getString();
+                       if (lexrc.next())
+                               editor = lexrc.getString();
+                       // The only supported flag for now is "document".
+                       // More flags could be added in the future.
+                       // Therefore we use tokenPos below to read the flag.
+                       string flags;
                        // Hack to ensure compatibility with versions older
-                       // than 1.4.0
+                       // than 1.5.0
                        int le = lexrc.lex();
                        if (le != LyXLex::LEX_FEOF && le != LyXLex::LEX_UNDEF) {
-                               viewer = lexrc.getString();
-                               if (le == LyXLex::LEX_DATA) {
-                                       if (token(viewer, ' ', 0) == "none")
-                                               viewer.erase();
-                                       if (lexrc.next()) {
-                                               editor = lexrc.getString();
-                                               if (token(editor, ' ', 0) == "none")
-                                                       editor.erase();
-                                       }
-                               } else {
+                               flags = lexrc.getString();
+                               if (le != LyXLex::LEX_DATA) {
                                        // We have got a known token.
                                        // Therefore this is an old style
                                        // format definition without
-                                       // viewer and editor.
-                                       lexrc.pushToken(viewer);
-                                       viewer.erase();
+                                       // flags.
+                                       lexrc.pushToken(flags);
+                                       flags.erase();
                                }
                        }
+                       bool const document =
+                               (tokenPos(flags, ',', "document") >= 0);
+                       if (!flags.empty() && flags != "document")
+                               lyxerr << "Ignoring flags other than "
+                                         "`document' in `" << flags
+                                      << "' for format `" << format << "'."
+                                      << endl;
                        if (prettyname.empty()) {
                                if (converters.formatIsUsed(format)) {
                                        lyxerr << "Can't delete format "
@@ -1119,7 +1116,7 @@ int LyXRC::read(LyXLex & lexrc)
                                }
                        } else {
                                formats.add(format, extension, prettyname,
-                                           shortcut, viewer, editor);
+                                           shortcut, viewer, editor, document);
                        }
                        break;
                }
@@ -1369,11 +1366,11 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                    index_command != system_lyxrc.index_command) {
                        os << "\\index_command \"" << index_command << "\"\n";
                }
-       case RC_CYGWIN_PATH_FIX:
+       case RC_TEX_EXPECTS_WINDOWS_PATHS:
                if (ignore_system_lyxrc ||
-                   cygwin_path_fix != system_lyxrc.cygwin_path_fix) {
-                       os << "\\cygwin_path_fix_needed "
-                          << convert<string>(cygwin_path_fix) << '\n';
+                   windows_style_tex_paths != system_lyxrc.windows_style_tex_paths) {
+                       os << "\\tex_expects_windows_paths "
+                          << convert<string>(windows_style_tex_paths) << '\n';
                }
        case RC_TEX_ALLOWS_SPACES:
                if (tex_allows_spaces != system_lyxrc.tex_allows_spaces) {
@@ -1511,11 +1508,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                        os << "\\screen_geometry_xysaved " << convert<string>(geometry_xysaved)
                           << '\n';
                }
-       case RC_WHEEL_JUMP:
-               if (ignore_system_lyxrc ||
-                   wheel_jump != system_lyxrc.wheel_jump) {
-                       os << "\\wheel_jump " << wheel_jump << '\n';
-               }
        case RC_CURSOR_FOLLOWS_SCROLLBAR:
                if (ignore_system_lyxrc ||
                    cursor_follows_scrollbar
@@ -1795,7 +1787,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
        case RC_USELASTFILEPOS:
                if (ignore_system_lyxrc ||
                    use_lastfilepos != system_lyxrc.use_lastfilepos) {
-                       os << "\\use_session " << convert<string>(use_lastfilepos)
+                       os << "\\use_lastfilepos " << convert<string>(use_lastfilepos)
                           << '\n';
                }
        case RC_LOADSESSION:
@@ -2013,7 +2005,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                   << "#\n\n";
 
        case RC_FORMAT:
-               // New/modifed formats
+               // New/modified formats
                for (Formats::const_iterator cit = formats.begin();
                     cit != formats.end(); ++cit) {
                        Format const * format =
@@ -2023,13 +2015,18 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                            format->prettyname() != cit->prettyname() ||
                            format->shortcut() != cit->shortcut() ||
                            format->viewer() != cit->viewer() ||
-                           format->editor() != cit->editor())
+                           format->editor() != cit->editor() ||
+                           format->documentFormat() != cit->documentFormat()) {
                                os << "\\format \"" << cit->name() << "\" \""
                                   << cit->extension() << "\" \""
                                   << cit->prettyname() << "\" \""
                                   << cit->shortcut() << "\" \""
                                   << cit->viewer() << "\" \""
-                                  << cit->editor() << "\"\n";
+                                  << cit->editor() << "\" \"";
+                               if (cit->documentFormat())
+                                       os << "document";
+                               os << "\"\n";
+                       }
                }
 
                // Look for deleted formats
@@ -2037,7 +2034,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                     cit != system_formats.end(); ++cit)
                        if (!formats.getFormat(cit->name()))
                                os << "\\format \"" << cit->name()
-                                  << "\" \"\" \"\" \"\" \"\" \"\"\n";
+                                  << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n";
        case RC_VIEWER:
                // Ignore it
 
@@ -2135,7 +2132,7 @@ string const LyXRC::getDescription(LyXRCTags tag)
                break;
 
        case RC_ASCIIROFF_COMMAND:
-               str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"none\" is specified, an internal routine is used.");
+               str = _("Use to define an external program to render tables in plain text output. E.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file. If \"\" is specified, an internal routine is used.");
                break;
 
        case RC_ASCII_LINELEN:
@@ -2193,9 +2190,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
        case RC_CUSTOM_EXPORT_FORMAT:
                break;
 
-       case RC_CYGWIN_PATH_FIX:
-               break;
-
        case RC_DATE_INSERT_FORMAT:
                //xgettext:no-c-format
                str = _("This accepts the normal strftime formats; see man strftime for full details. E.g.\"%A, %e. %B %Y\".");
@@ -2480,6 +2474,9 @@ string const LyXRC::getDescription(LyXRCTags tag)
        case RC_TEX_ALLOWS_SPACES:
                break;
 
+       case RC_TEX_EXPECTS_WINDOWS_PATHS:
+               break;
+
        case RC_UIFILE:
                str = _("The UI (user interface) file. Can either specify an absolute path, or LyX will look in its global and local ui/ directories.");
                break;
@@ -2507,10 +2504,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
        case RC_VIEWER:
                break;
 
-       case RC_WHEEL_JUMP:
-               str = _("The number of lines that are scrolled by mice with wheels or five button mice.");
-               break;
-
        case RC_LAST:
                break;
        }