]> git.lyx.org Git - lyx.git/blobdiff - src/LyXRC.cpp
#7379 avoid the wrap spell check question when buffer is empty
[lyx.git] / src / LyXRC.cpp
index 487255f5fba67f1f4aa1783eb728e4b464cb3bed..86a62919199e5068a0194b7a5ffaeec54299fa3a 100644 (file)
@@ -85,6 +85,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\converter_cache_maxage", LyXRC::RC_CONVERTER_CACHE_MAXAGE },
        { "\\copier", LyXRC::RC_COPIER },
        { "\\cursor_follows_scrollbar", LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR },
+       { "\\cursor_width", LyXRC::RC_CURSOR_WIDTH },
        { "\\date_insert_format", LyXRC::RC_DATE_INSERT_FORMAT },
        { "\\def_file", LyXRC::RC_DEFFILE },
        { "\\default_decimal_point", LyXRC::RC_DEFAULT_DECIMAL_POINT },
@@ -99,6 +100,7 @@ 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 },
@@ -359,6 +361,7 @@ void LyXRC::setDefaults()
        completion_inline_dots = -1;
        completion_inline_delay = 0.2;
        default_decimal_point = ".";
+       cursor_width = 1;
 }
 
 
@@ -377,13 +380,13 @@ void oldFontFormat(string & family, string & foundry)
 } // namespace anon
 
 
-bool LyXRC::read(FileName const & filename)
+bool LyXRC::read(FileName const & filename, bool check_format)
 {
        Lexer lexrc(lyxrcTags);
        lexrc.setFile(filename);
        LYXERR(Debug::LYXRC, "Reading '" << filename << "'...");
-       ReturnValues retval = read(lexrc);
-       if (retval != FormatMismatch)
+       ReturnValues retval = read(lexrc, check_format);
+       if (!check_format || retval != FormatMismatch)
                return retval == ReadOK;
 
        LYXERR(Debug::FILES, "Converting LyXRC file to " << LYXRC_FILEFORMAT);
@@ -397,7 +400,7 @@ bool LyXRC::read(FileName const & filename)
        Lexer lexrc2(lyxrcTags);
        lexrc2.setFile(tempfile);
        LYXERR(Debug::LYXRC, "Reading '" << tempfile << "'...");
-       retval = read(lexrc2);
+       retval = read(lexrc2, check_format);
        tempfile.removeFile();
        return retval == ReadOK;
 }
@@ -410,11 +413,11 @@ bool LyXRC::read(istream & is)
        Lexer lexrc(lyxrcTags);
        lexrc.setStream(is);
        LYXERR(Debug::LYXRC, "Reading istream...");
-       return read(lexrc) == ReadOK;
+       return read(lexrc, false) == ReadOK;
 }
 
 
-LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
+LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
 {
        if (lyxerr.debugging(Debug::PARSER))
                lexrc.printTable(lyxerr);
@@ -422,6 +425,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
        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;
 
@@ -453,9 +459,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
                                FileName const tmp =
                                        libFileSearch(string(),
                                                      lexrc.getString());
-                               if (read(tmp)) {
-                                       lexrc.printError("Error reading "
-                                                        "included file: " + tmp.absFileName());
+                               if (read(tmp, check_format)) {
+                                       lexrc.printError(
+                                           "Error reading included file: " + tmp.absFileName());
                                }
                        }
                        break;
@@ -523,6 +529,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
                        lexrc >> fontenc;
                        break;
 
+               case RC_FORCE_PAINT_SINGLE_CHAR:
+                       lexrc >> force_paint_single_char;
+                       break;
+
                case RC_PRINTER:
                        lexrc >> printer;
                        break;
@@ -895,6 +905,10 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
                        lexrc >> cursor_follows_scrollbar;
                        break;
 
+               case RC_CURSOR_WIDTH:
+                       lexrc >> cursor_width;
+                       break;
+
                case RC_SCROLL_BELOW_DOCUMENT:
                        lexrc >> scroll_below_document;
                        break;
@@ -1090,6 +1104,8 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
                                        flgs |= Format::document;
                                else if (flag == "vector")
                                        flgs |= Format::vector;
+                               else if (flag == "menu=export")
+                                       flgs |= Format::export_menu;
                                else
                                        LYXERR0("Ignoring unknown flag `"
                                               << flag << "' for format `"
@@ -1125,7 +1141,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
                case RC_DEFAULT_VIEW_FORMAT:
                        lexrc >> default_view_format;
                        break;
-                       
+
                case RC_DEFAULT_LANGUAGE:
                        lexrc >> default_language;
                        break;
@@ -1216,11 +1232,11 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
                                run_mode = single_instance ? USE_REMOTE : NEW_INSTANCE;
                        break;
                case RC_FORWARD_SEARCH_DVI:
-                       if (lexrc.next(true)) 
+                       if (lexrc.next(true))
                                forward_search_dvi = lexrc.getString();
                        break;
                case RC_FORWARD_SEARCH_PDF:
-                       if (lexrc.next(true)) 
+                       if (lexrc.next(true))
                                forward_search_pdf = lexrc.getString();
                        break;
                case RC_EXPORT_OVERWRITE:
@@ -1262,7 +1278,7 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc)
 
                // This is triggered the first time through the loop unless
                // we hit a format tag.
-               if (format != LYXRC_FILEFORMAT)
+               if (check_format && format != LYXRC_FILEFORMAT)
                        return FormatMismatch;
        }
 
@@ -1313,7 +1329,7 @@ namespace {
 
        // Escape \ and " so that LyXLex can read the string later
        string escapeCommand(string const & str) {
-               return subst(subst(str , "\\", "\\\\"), 
+               return subst(subst(str , "\\", "\\\\"),
                             "\"", "\\\"");
        }
 
@@ -1323,7 +1339,7 @@ namespace {
 void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) const
 {
        LyXRCTags tag = RC_LAST;
-       
+
        if (!name.empty()) {
                for (int i = 0; i != lyxrcCount; ++i)
                        if ("\\" + name == lyxrcTags[i].tag)
@@ -1744,6 +1760,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                }
                if (tag != RC_LAST)
                        break;
+       case RC_CURSOR_WIDTH:
+               if (ignore_system_lyxrc ||
+                       cursor_width
+                       != system_lyxrc.cursor_width) {
+                       os << "\\cursor_width "
+                       << cursor_width << '\n';
+               }
+               if (tag != RC_LAST)
+                       break;
        case RC_SCROLL_BELOW_DOCUMENT:
                if (ignore_system_lyxrc ||
                    scroll_below_document
@@ -2178,6 +2203,14 @@ 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";
@@ -2513,7 +2546,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                    language_package_selection != system_lyxrc.language_package_selection) {
                        os << "\\language_package_selection ";
                        switch (language_package_selection) {
-                       case LP_AUTO: 
+                       case LP_AUTO:
                                os << "0\n";
                                break;
                        case LP_BABEL:
@@ -2669,7 +2702,8 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                            format->viewer() != cit->viewer() ||
                            format->editor() != cit->editor() ||
                            format->documentFormat() != cit->documentFormat() ||
-                           format->vectorFormat() != cit->vectorFormat()) {
+                           format->vectorFormat() != cit->vectorFormat() ||
+                           format->inExportMenu() != cit->inExportMenu()) {
                                os << "\\format \"" << cit->name() << "\" \""
                                   << cit->extension() << "\" \""
                                   << cit->prettyname() << "\" \""
@@ -2681,6 +2715,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                                        flags.push_back("document");
                                if (cit->vectorFormat())
                                        flags.push_back("vector");
+                               if (cit->inExportMenu())
+                                       flags.push_back("menu=export");
+
                                os << getStringFromVector(flags);
                                os << "\"\n";
                        }
@@ -2697,19 +2734,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
        case RC_VIEWER_ALTERNATIVES: {
                Alternatives::const_iterator it = viewer_alternatives.begin();
                Alternatives::const_iterator const en = viewer_alternatives.end();
-               Alternatives::const_iterator const sysend = 
+               Alternatives::const_iterator const sysend =
                                system_lyxrc.viewer_alternatives.end();
                for (; it != en; ++it) {
                        string const & fmt = it->first;
                        CommandSet const & cmd = it->second;
                        CommandSet::const_iterator sit = cmd.begin();
                        CommandSet::const_iterator const sen = cmd.end();
-                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
+                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ?
                                        system_lyxrc.viewer_alternatives.begin() : // we won't use it in this case
                                        system_lyxrc.viewer_alternatives.find(fmt);
                        for (; sit != sen; ++sit) {
                                string const & cmd = *sit;
-                               if (ignore_system_lyxrc 
+                               if (ignore_system_lyxrc
                                    || sysfmt == sysend               // format not found
                                         || sysfmt->second.count(cmd) == 0 // this command not found
                                   )
@@ -2722,19 +2759,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
        case RC_EDITOR_ALTERNATIVES: {
                Alternatives::const_iterator it = editor_alternatives.begin();
                Alternatives::const_iterator const en = editor_alternatives.end();
-               Alternatives::const_iterator const sysend = 
+               Alternatives::const_iterator const sysend =
                                system_lyxrc.editor_alternatives.end();
                for (; it != en; ++it) {
                        string const & fmt = it->first;
                        CommandSet const & cmd = it->second;
                        CommandSet::const_iterator sit = cmd.begin();
                        CommandSet::const_iterator const sen = cmd.end();
-                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ? 
+                       Alternatives::const_iterator const sysfmt = ignore_system_lyxrc ?
                                        system_lyxrc.editor_alternatives.begin() : // we won't use it in this case
                                        system_lyxrc.editor_alternatives.find(fmt);
                        for (; sit != sen; ++sit) {
                                string const & cmd = *sit;
-                               if (ignore_system_lyxrc 
+                               if (ignore_system_lyxrc
                                    || sysfmt == sysend               // format not found
                                    || sysfmt->second.count(cmd) == 0 // this command not found
                                   )
@@ -2784,7 +2821,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                                   << "\" \"" << cit->to << "\" \"\" \"\"\n";
                if (tag != RC_LAST)
                        break;
-       
+
        case RC_COPIER:
                if (tag == RC_LAST)
                        os << "\n#\n"
@@ -2878,6 +2915,7 @@ 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:
@@ -2986,6 +3024,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_EXPORT_OVERWRITE:
        case LyXRC::RC_DEFAULT_DECIMAL_POINT:
        case LyXRC::RC_SCROLL_WHEEL_ZOOM:
+       case LyXRC::RC_CURSOR_WIDTH:
        case LyXRC::RC_LAST:
                break;
        }
@@ -3059,6 +3098,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("LyX normally doesn't update the cursor position if you move the scrollbar. Set to true if you'd prefer to always have the cursor on screen.");
                break;
 
+       case RC_CURSOR_WIDTH:
+               str = _("Configure the width of the text cursor. Automatic zoom-controlled cursor width used when set to 0.");
+               break;
+
        case RC_SCROLL_BELOW_DOCUMENT:
                str = _("LyX normally doesn't allow the user to scroll further than the bottom of the document. Set to true if you prefer to scroll the bottom of the document to the top of the screen");
                break;
@@ -3120,6 +3163,10 @@ 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;