]> git.lyx.org Git - lyx.git/blobdiff - src/lyxrc.C
fix reading the author field.
[lyx.git] / src / lyxrc.C
index 9481951d056352962e53e1dff86491c599e7d143..e78189949d8146c3be6e39c1c73c6d8751126fa4 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "support/filetools.h"
 #include "support/lstrings.h"
-#include "support/translator.h"
 #include "support/tostr.h"
 #include "support/userinfo.h"
 
@@ -161,6 +160,7 @@ keyword_item lyxrcTags[] = {
        { "\\user_email", LyXRC::RC_USER_EMAIL },
        { "\\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 }
 };
@@ -264,16 +264,13 @@ void LyXRC::setDefaults() {
        cursor_follows_scrollbar = false;
        dialogs_iconify_with_main = false;
        label_init_length = 3;
-       preview = false;
+       preview = PREVIEW_OFF;
        preview_hashed_labels  = false;
        preview_scale_factor = 0.9;
 
        user_name = lyx::support::user_name();
 
        user_email = lyx::support::user_email();
-
-       if (user_email.empty())
-               user_email = _("email address unknown");
 }
 
 
@@ -786,9 +783,9 @@ int LyXRC::read(LyXLex & lexrc)
                                break;
                        }
 
-                       LColor::color const col = 
+                       LColor::color const col =
                                lcolor.getFromLyXName(lyx_name);
-                       if (col == LColor::none || 
+                       if (col == LColor::none ||
                            col == LColor::inherit ||
                            col == LColor::ignore)
                                break;
@@ -979,6 +976,7 @@ int LyXRC::read(LyXLex & lexrc)
                        }
                        break;
                }
+               // compatibility with versions older than 1.4.0 only
                case RC_VIEWER: {
                        string format, command;
                        if (lexrc.next()) {
@@ -1006,6 +1004,29 @@ int LyXRC::read(LyXLex & lexrc)
                        if (lexrc.next()) {
                                shortcut = lexrc.getString();
                        }
+                       string viewer, editor;
+                       // Hack to ensure compatibility with versions older
+                       // than 1.4.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 {
+                                       // We have got a known token.
+                                       // Therefore this is an old style
+                                       // format definition without
+                                       // viewer and editor.
+                                       lexrc.pushToken(viewer);
+                                       viewer.erase();
+                               }
+                       }
                        if (prettyname.empty()) {
                                if (converters.formatIsUsed(format)) {
                                        lyxerr << "Can't delete format "
@@ -1015,7 +1036,7 @@ int LyXRC::read(LyXLex & lexrc)
                                }
                        } else {
                                formats.add(format, extension, prettyname,
-                                           shortcut);
+                                           shortcut, viewer, editor);
                        }
                        break;
                }
@@ -1039,7 +1060,18 @@ int LyXRC::read(LyXLex & lexrc)
 
                case RC_PREVIEW:
                        if (lexrc.next()) {
-                               preview = lexrc.getBool();
+                               string const tmp = lexrc.getString();
+                               if (tmp == "true" || tmp == "on")
+                                       preview = PREVIEW_ON;
+                               else if (tmp == "no_math")
+                                       preview = PREVIEW_NO_MATH;
+                               else {
+                                       preview = PREVIEW_OFF;
+                                       if (tmp != "false" && tmp != "off")
+                                               lyxerr << "Unrecognized "
+                                                       "preview status \""
+                                                      << tmp << '\n' << endl;
+                               }
                        }
                        break;
 
@@ -1261,7 +1293,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
        case RC_PREVIEW:
                if (ignore_system_lyxrc ||
                    preview != system_lyxrc.preview) {
-                       os << "\\preview " << tostr(preview) << '\n';
+                       string status;
+                       switch (preview) {
+                       case PREVIEW_ON:
+                               status = "on";
+                               break;
+                       case PREVIEW_NO_MATH:
+                               status = "no_math";
+                               break;
+                       case PREVIEW_OFF:
+                               status = "off";
+                               break;
+                       }
+                       os << "\\preview " << status << '\n';
                }
 
        case RC_PREVIEW_HASHED_LABELS:
@@ -1801,7 +1845,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                   << "#\n\n";
 
        case RC_FORMAT:
-               // Look for deleted formats
+               // New/modifed formats
                for (Formats::const_iterator cit = formats.begin();
                     cit != formats.end(); ++cit) {
                        Format const * format =
@@ -1809,29 +1853,25 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
                        if (!format ||
                            format->extension() != cit->extension() ||
                            format->prettyname() != cit->prettyname() ||
-                           format->shortcut() != cit->shortcut())
+                           format->shortcut() != cit->shortcut() ||
+                           format->viewer() != cit->viewer() ||
+                           format->editor() != cit->editor())
                                os << "\\format \"" << cit->name() << "\" \""
                                   << cit->extension() << "\" \""
                                   << cit->prettyname() << "\" \""
-                                  << cit->shortcut() << "\"\n";
+                                  << cit->shortcut() << "\" \""
+                                  << cit->viewer() << "\" \""
+                                  << cit->editor() << "\"\n";
                }
 
-               // New/modifed formats
+               // Look for deleted formats
                for (Formats::const_iterator cit = system_formats.begin();
                     cit != system_formats.end(); ++cit)
                        if (!formats.getFormat(cit->name()))
                                os << "\\format \"" << cit->name()
-                                  << "\" \"\" \"\" \"\"\n";
+                                  << "\" \"\" \"\" \"\" \"\" \"\"\n";
        case RC_VIEWER:
-               for (Formats::const_iterator cit = formats.begin();
-                    cit != formats.end(); ++cit) {
-                       Format const * format =
-                               system_formats.getFormat(cit->name());
-                       if ((!format || format->viewer() != cit->viewer()) &&
-                           (format || !cit->viewer().empty()))
-                               os << "\\viewer \"" << cit->name() << "\" \""
-                                  << cit->viewer() << "\"\n";
-               }
+               // Ignore it
 
                os << "\n#\n"
                   << "# CONVERTERS SECTION ##########################\n"