]> git.lyx.org Git - features.git/blobdiff - src/BufferParams.cpp
Typos
[features.git] / src / BufferParams.cpp
index 93a539833bfe93088061cd218baa31d2e4d1054a..ec4cc0d60aed42f5ca4c94d4ea8d8bc3f1c2042c 100644 (file)
@@ -341,6 +341,7 @@ public:
 
        AuthorList authorlist;
        BranchList branchlist;
+       IgnoreList spellignore;
        Bullet temp_bullets[4];
        Bullet user_defined_bullets[4];
        IndicesList indiceslist;
@@ -462,7 +463,9 @@ BufferParams::BufferParams()
        isfontcolor = false;
        // light gray is the default font color for greyed-out notes
        notefontcolor = lyx::rgbFromHexName("#cccccc");
+       isnotefontcolor = false;
        boxbgcolor = lyx::rgbFromHexName("#ff0000");
+       isboxbgcolor = false;
        compressed = lyxrc.save_compressed;
        for (int iter = 0; iter < 4; ++iter) {
                user_defined_bullet(iter) = ITEMIZE_DEFAULTS[iter];
@@ -475,6 +478,7 @@ BufferParams::BufferParams()
        html_math_img_scale = 1.0;
        html_css_as_file = false;
        docbook_table_output = HTMLTable;
+       docbook_mathml_prefix = MPrefix;
        display_pixel_ratio = 1.0;
 
        shell_escape = false;
@@ -598,6 +602,38 @@ IndicesList const & BufferParams::indiceslist() const
 }
 
 
+typedef std::vector<WordLangTuple> IgnoreList;
+
+
+IgnoreList & BufferParams::spellignore()
+{
+       return pimpl_->spellignore;
+}
+
+
+IgnoreList const & BufferParams::spellignore() const
+{
+       return pimpl_->spellignore;
+}
+
+
+bool BufferParams::spellignored(WordLangTuple const & wl) const
+{
+       bool has_item = false;
+       vector<WordLangTuple> il = spellignore();
+       vector<WordLangTuple>::const_iterator it = il.begin();
+       for (; it != il.end(); ++it) {
+               if (it->lang()->code() != wl.lang()->code())
+                       continue;
+               if (it->word() == wl.word()) {
+                       has_item = true;
+                       break;
+               }
+       }
+       return has_item;
+}
+
+
 Bullet & BufferParams::temp_bullet(lyx::size_type const index)
 {
        LASSERT(index < 4, return pimpl_->temp_bullets[0]);
@@ -702,9 +738,10 @@ BufferParams::MathNumber BufferParams::getMathNumber() const
 
 
 string BufferParams::readToken(Lexer & lex, string const & token,
-       FileName const & filepath)
+       FileName const & filename)
 {
        string result;
+       FileName const & filepath = filename.onlyPath();
 
        if (token == "\\textclass") {
                lex.next();
@@ -990,19 +1027,13 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                        }
                        if (tok == "\\color") {
                                lex.eatLine();
-                               string color = lex.getString();
-                               if (branch_ptr) {
-                                       branch_ptr->setColor(color);
-                                       if (branch_ptr->color() == "none")
-                                               color = lcolor.getX11HexName(Color_background);
-                               }
-                               // Update also the Color table:
-                               if (color == "none")
-                                       color = lcolor.getX11HexName(Color_background);
-                               else if (color.size() != 7 || color[0] != '#')
-                                       color = lcolor.getFromLyXName(color);
-                               // FIXME UNICODE
-                               lcolor.setColor(to_utf8(branch), color);
+                               vector<string> const colors = getVectorFromString(lex.getString(), " ");
+                               string const lmcolor = colors.front();
+                               string dmcolor;
+                               if (colors.size() > 1)
+                                       dmcolor = colors.back();
+                               if (branch_ptr)
+                                       branch_ptr->setColors(lmcolor, dmcolor);
                        }
                }
        } else if (token == "\\index") {
@@ -1032,9 +1063,17 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                        color = lcolor.getX11HexName(Color_background);
                                // FIXME UNICODE
                                if (!shortcut.empty())
-                                       lcolor.setColor(to_utf8(shortcut), color);
+                                       lcolor.setColor(to_utf8(shortcut)+ "@" + filename.absFileName(), color);
                        }
                }
+       } else if (token == "\\spellchecker_ignore") {
+               lex.eatLine();
+               docstring wl = lex.getDocString();
+               docstring language;
+               docstring word = split(wl, language, ' ');
+               Language const * lang = languages.getLanguage(to_ascii(language));
+               if (lang)
+                       spellignore().push_back(WordLangTuple(word, lang));
        } else if (token == "\\author") {
                lex.eatLine();
                istringstream ss(lex.getString());
@@ -1058,11 +1097,17 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                string color = lex.getString();
                notefontcolor = lyx::rgbFromHexName(color);
                lcolor.setColor("notefontcolor", color);
+               lcolor.setLaTeXName("notefontcolor", "note_fontcolor");
+               lcolor.setGUIName("notefontcolor", N_("greyedout inset text"));
+               // set a local name for the painter
+               lcolor.setColor("notefontcolor@" + filename.absFileName(), color);
+               isnotefontcolor = true;
        } else if (token == "\\boxbgcolor") {
                lex.eatLine();
                string color = lex.getString();
                boxbgcolor = lyx::rgbFromHexName(color);
-               lcolor.setColor("boxbgcolor", color);
+               lcolor.setColor("boxbgcolor@" + filename.absFileName(), color);
+               isboxbgcolor = true;
        } else if (token == "\\paperwidth") {
                lex >> paperwidth;
        } else if (token == "\\paperheight") {
@@ -1147,6 +1192,10 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                int temp;
                lex >> temp;
                docbook_table_output = static_cast<TableOutput>(temp);
+       } else if (token == "\\docbook_mathml_prefix") {
+               int temp;
+               lex >> temp;
+               docbook_mathml_prefix = static_cast<MathMLNameSpacePrefix>(temp);
        } else if (token == "\\output_sync") {
                lex >> output_sync;
        } else if (token == "\\output_sync_macro") {
@@ -1383,16 +1432,16 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
        if (isfontcolor)
                os << "\\fontcolor " << lyx::X11hexname(fontcolor) << '\n';
-       if (notefontcolor != lyx::rgbFromHexName("#cccccc"))
+       if (isnotefontcolor)
                os << "\\notefontcolor " << lyx::X11hexname(notefontcolor) << '\n';
-       if (boxbgcolor != lyx::rgbFromHexName("#ff0000"))
+       if (isboxbgcolor)
                os << "\\boxbgcolor " << lyx::X11hexname(boxbgcolor) << '\n';
 
        for (auto const & br : branchlist()) {
                os << "\\branch " << to_utf8(br.branch())
                   << "\n\\selected " << br.isSelected()
                   << "\n\\filename_suffix " << br.hasFileNameSuffix()
-                  << "\n\\color " << br.color()
+                  << "\n\\color " << br.lightModeColor() << " " << br.darkModeColor()
                   << "\n\\end_branch"
                   << "\n";
        }
@@ -1405,6 +1454,12 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                   << "\n";
        }
 
+       for (auto const & si : spellignore()) {
+               os << "\\spellchecker_ignore " << si.lang()->lang()
+                  << " " << to_utf8(si.word())
+                  << "\n";
+       }
+
        if (!paperwidth.empty())
                os << "\\paperwidth "
                   << VSpace(paperwidth).asLyXCommand() << '\n';
@@ -1505,6 +1560,7 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
           << "\\html_be_strict " << convert<string>(html_be_strict) << '\n';
 
        os << "\\docbook_table_output " << docbook_table_output << '\n';
+       os << "\\docbook_mathml_prefix " << docbook_mathml_prefix << '\n';
 
        if (html_math_img_scale != 1.0)
                os << "\\html_math_img_scale " << convert<string>(html_math_img_scale) << '\n';