]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
Properly fix #6369
[lyx.git] / src / LyXRC.cpp
index 07ffef1f11e3cbcf1f21e02a2ea335ce29ec4108..57d9c504c8d248bc56305ebbc8741964715b2e79 100644 (file)
@@ -40,6 +40,7 @@
 #include "support/lstrings.h"
 #include "support/os.h"
 #include "support/Package.h"
+#include "support/TempFile.h"
 #include "support/userinfo.h"
 
 #include <fstream>
@@ -55,7 +56,9 @@ namespace os = support::os;
 
 namespace {
 
-static unsigned int const LYXRC_FILEFORMAT = 14; // spitz: default_otf_view_format
+// 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 = 17; // lasgouttes: remove \\rtl
 
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
@@ -103,7 +106,6 @@ LexerKeyword lyxrcTags[] = {
        { "\\example_path", LyXRC::RC_EXAMPLEPATH },
        { "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
        { "\\font_encoding", LyXRC::RC_FONT_ENCODING },
-       { "\\force_paint_single_char", LyXRC::RC_FORCE_PAINT_SINGLE_CHAR },
        { "\\format", LyXRC::RC_FILEFORMAT },
        { "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
        { "\\forward_search_pdf", LyXRC::RC_FORWARD_SEARCH_PDF },
@@ -140,6 +142,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
        { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
        { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
+       { "\\mouse_middlebutton_paste", LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE },
        { "\\mouse_wheel_speed", LyXRC::RC_MOUSE_WHEEL_SPEED },
        { "\\nomencl_command", LyXRC::RC_NOMENCL_COMMAND },
        { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
@@ -168,7 +171,6 @@ LexerKeyword lyxrcTags[] = {
        { "\\print_to_file", LyXRC::RC_PRINTTOFILE },
        { "\\print_to_printer", LyXRC::RC_PRINTTOPRINTER },
        { "\\printer", LyXRC::RC_PRINTER },
-       { "\\rtl", LyXRC::RC_RTL_SUPPORT },
        { "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
        { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
        { "\\screen_font_roman", LyXRC::RC_SCREEN_FONT_ROMAN },
@@ -311,7 +313,6 @@ void LyXRC::setDefaults()
        completion_minlength = 6;
        spellcheck_notes = true;
        use_kbmap = false;
-       rtl_support = true;
        visual_cursor = false;
        auto_number = true;
        mark_foreign_language = true;
@@ -377,6 +378,7 @@ void LyXRC::setDefaults()
        default_length_unit = Length::CM;
        cursor_width = 1;
        close_buffer_with_last_view = "yes";
+       mouse_middlebutton_paste = true;
 }
 
 
@@ -405,7 +407,8 @@ bool LyXRC::read(FileName const & filename, bool check_format)
                return retval == ReadOK;
 
        LYXERR(Debug::FILES, "Converting LyXRC file to " << LYXRC_FILEFORMAT);
-       FileName const tempfile = FileName::tempName("convert_lyxrc");
+       TempFile tmp("convert_lyxrc");
+       FileName const tempfile = tmp.name();
        bool const success = prefs2prefs(filename, tempfile, false);
        if (!success) {
                LYXERR0 ("Unable to convert " << filename.absFileName() <<
@@ -420,7 +423,6 @@ bool LyXRC::read(FileName const & filename, bool check_format)
                LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
                retval = read(lexrc2, check_format);
        }
-       tempfile.removeFile();
        return retval == ReadOK;
 }
 
@@ -444,9 +446,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
        if (!lexrc.isOK())
                return ReadError;
 
-       // default for current rowpainter capabilities
-       force_paint_single_char = true;
-
        // format prior to 2.0 and introduction of format tag
        unsigned int format = 0;
 
@@ -552,10 +551,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        lexrc >> fontenc;
                        break;
 
-               case RC_FORCE_PAINT_SINGLE_CHAR:
-                       lexrc >> force_paint_single_char;
-                       break;
-
                case RC_PRINTER:
                        lexrc >> printer;
                        break;
@@ -1047,9 +1042,6 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_LANGUAGE_COMMAND_LOCAL:
                        lexrc >> language_command_local;
                        break;
-               case RC_RTL_SUPPORT:
-                       lexrc >> rtl_support;
-                       break;
                case RC_VISUAL_CURSOR:
                        lexrc >> visual_cursor;
                        break;
@@ -1302,6 +1294,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                        }
                        break;
 
+               case RC_MOUSE_MIDDLEBUTTON_PASTE:
+                       lexrc >> mouse_middlebutton_paste;
+                       break;
+
                case RC_LAST:
                        break; // this is just a dummy
                }
@@ -1905,6 +1901,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                    != system_lyxrc.font_sizes[FONT_SIZE_HUGE] ||
                    font_sizes[FONT_SIZE_HUGER]
                    != system_lyxrc.font_sizes[FONT_SIZE_HUGER]) {
+                       streamsize old_prec = os.precision();
                        os.setf(ios::fixed);
                        os.precision(2);
                        os << "\\screen_font_sizes"
@@ -1919,6 +1916,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                           << ' ' << font_sizes[FONT_SIZE_HUGE]
                           << ' ' << font_sizes[FONT_SIZE_HUGER]
                           << '\n';
+                       os.precision(old_prec);
+                       os.unsetf(ios::fixed);
                }
                if (tag != RC_LAST)
                        break;
@@ -2218,14 +2217,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
 
-       case RC_FORCE_PAINT_SINGLE_CHAR:
-               if (ignore_system_lyxrc ||
-                   force_paint_single_char != system_lyxrc.force_paint_single_char) {
-                       os << "\\force_paint_single_char \"" << force_paint_single_char << "\"\n";
-               }
-               if (tag != RC_LAST)
-                       break;
-
                os << "\n#\n"
                   << "# FILE SECTION ######################################\n"
                   << "#\n\n";
@@ -2261,6 +2252,14 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_MOUSE_MIDDLEBUTTON_PASTE:
+               if (ignore_system_lyxrc ||
+                   mouse_middlebutton_paste != system_lyxrc.mouse_middlebutton_paste) {
+                       os << "\\mouse_middlebutton_paste "
+                          << convert<string>(mouse_middlebutton_paste) << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_COMPLETION_INLINE_DELAY:
                if (ignore_system_lyxrc ||
                    completion_inline_delay != system_lyxrc.completion_inline_delay) {
@@ -2348,7 +2347,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
-                       
+
                case RC_NUMLASTFILES:
                if (ignore_system_lyxrc ||
                    num_lastfiles != system_lyxrc.num_lastfiles) {
@@ -2550,13 +2549,6 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (tag != RC_LAST)
                        break;
 
-       case RC_RTL_SUPPORT:
-               if (ignore_system_lyxrc ||
-                   rtl_support != system_lyxrc.rtl_support) {
-                       os << "\\rtl " << convert<string>(rtl_support) << '\n';
-               }
-               if (tag != RC_LAST)
-                       break;
        case RC_VISUAL_CURSOR:
                if (ignore_system_lyxrc ||
                        visual_cursor != system_lyxrc.visual_cursor) {
@@ -2827,8 +2819,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                        break;
        }
        case RC_DEFAULT_OTF_VIEW_FORMAT:
-               if (ignore_system_lyxrc ||
-                   default_otf_view_format != system_lyxrc.default_otf_view_format) {
+        if ((ignore_system_lyxrc ||
+            default_otf_view_format != system_lyxrc.default_otf_view_format)
+            && !default_otf_view_format.empty()) {
                        os << "\\default_otf_view_format " << default_otf_view_format << '\n';
                }
                if (tag != RC_LAST)
@@ -2854,23 +2847,23 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                for (Converters::const_iterator cit = theConverters().begin();
                     cit != theConverters().end(); ++cit) {
                        Converter const * converter =
-                               theSystemConverters().getConverter(cit->from,
-                                                              cit->to);
+                               theSystemConverters().getConverter(cit->from(),
+                                                                  cit->to());
                        if (!converter ||
-                           converter->command != cit->command ||
-                           converter->flags != cit->flags)
-                               os << "\\converter \"" << cit->from << "\" \""
-                                  << cit->to << "\" \""
-                                  << escapeCommand(cit->command) << "\" \""
-                                  << cit->flags << "\"\n";
+                           converter->command() != cit->command() ||
+                           converter->flags() != cit->flags())
+                               os << "\\converter \"" << cit->from() << "\" \""
+                                  << cit->to() << "\" \""
+                                  << escapeCommand(cit->command()) << "\" \""
+                                  << cit->flags() << "\"\n";
                }
 
                // New/modifed converters
                for (Converters::const_iterator cit = theSystemConverters().begin();
                     cit != theSystemConverters().end(); ++cit)
-                       if (!theConverters().getConverter(cit->from, cit->to))
-                               os << "\\converter \"" << cit->from
-                                  << "\" \"" << cit->to << "\" \"\" \"\"\n";
+                       if (!theConverters().getConverter(cit->from(), cit->to()))
+                               os << "\\converter \"" << cit->from()
+                                  << "\" \"" << cit->to() << "\" \"\" \"\"\n";
                if (tag != RC_LAST)
                        break;
 
@@ -2970,7 +2963,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_ESC_CHARS:
        case LyXRC::RC_EXAMPLEPATH:
        case LyXRC::RC_FONT_ENCODING:
-       case LyXRC::RC_FORCE_PAINT_SINGLE_CHAR:
        case LyXRC::RC_FILEFORMAT:
        case LyXRC::RC_GROUP_LAYOUTS:
        case LyXRC::RC_HUNSPELLDIR_PATH:
@@ -2999,11 +2991,14 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_MAKE_BACKUP:
        case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
        case LyXRC::RC_MOUSE_WHEEL_SPEED:
+       case LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE:
        case LyXRC::RC_NUMLASTFILES:
        case LyXRC::RC_PARAGRAPH_MARKERS:
        case LyXRC::RC_PATH_PREFIX:
                if (lyxrc_orig.path_prefix != lyxrc_new.path_prefix) {
                        prependEnvPath("PATH", lyxrc_new.path_prefix);
+                       // Resets python path
+                       support::os::python(true);
                }
        case LyXRC::RC_PREVIEW:
        case LyXRC::RC_PREVIEW_HASHED_LABELS:
@@ -3026,7 +3021,6 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_PRINTTOPRINTER:
        case LyXRC::RC_PRINT_ADAPTOUTPUT:
        case LyXRC::RC_PRINT_COMMAND:
-       case LyXRC::RC_RTL_SUPPORT:
        case LyXRC::RC_SAVE_COMPRESSED:
        case LyXRC::RC_SCREEN_DPI:
        case LyXRC::RC_SCREEN_FONT_ROMAN:
@@ -3222,10 +3216,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("The font encoding used for the LaTeX2e fontenc package. T1 is highly recommended for non-English languages.");
                break;
 
-       case RC_FORCE_PAINT_SINGLE_CHAR:
-               str = _("Disable any kerning and ligatures for text drawing on screen.");
-               break;
-
        case RC_FILEFORMAT:
                break;
 
@@ -3340,7 +3330,7 @@ string const LyXRC::getDescription(LyXRCTags tag)
                break;
 
        case RC_AUTOCORRECTION_MATH:
-               str = _("Allow TeXMacs shorthand, like => converting to \Rightarrow.");
+               str = _("Allow TeXMacs shorthand, like => converting to \\Rightarrow.");
                break;
 
        case RC_NUMLASTFILES:
@@ -3438,10 +3428,6 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("Your favorite print program, e.g. \"dvips\", \"dvilj4\".");
                break;
 
-       case RC_RTL_SUPPORT:
-               str = _("Select to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
-               break;
-
        case RC_VISUAL_CURSOR:
                str = _("Select to have visual bidi cursor movement, unselect for logical movement.");
                break;