]> git.lyx.org Git - lyx.git/blobdiff - src/Color.cpp
Rename BufferView::updateScrollbar to show what does
[lyx.git] / src / Color.cpp
index c3d3f493d80b9d3234ba061e450afb40111721b0..cf297e909b5a3629d39ca8de0d3beb2c8c5a72b4 100644 (file)
@@ -462,7 +462,7 @@ bool ColorSet::setLaTeXName(string const & lyxname, string const & latexname)
 {
        string const lcname = ascii_lowercase(lyxname);
        if (lyxcolors.find(lcname) == lyxcolors.end()) {
-               LYXERR(Debug::GUI, "ColorSet::setColor: Unknown color \""
+               LYXERR(Debug::GUI, "ColorSet::setLaTeXName: Unknown color \""
                       << lyxname << '"');
                addColor(static_cast<ColorCode>(infotab.size()), lcname);
        }
@@ -487,6 +487,35 @@ bool ColorSet::setLaTeXName(string const & lyxname, string const & latexname)
 }
 
 
+bool ColorSet::setGUIName(string const & lyxname, string const & guiname)
+{
+       string const lcname = ascii_lowercase(lyxname);
+       if (lyxcolors.find(lcname) == lyxcolors.end()) {
+               LYXERR(Debug::GUI, "ColorSet::setGUIName: Unknown color \""
+                      << lyxname << '"');
+               return false;
+       }
+
+       ColorCode col = lyxcolors[lcname];
+       InfoTab::iterator it = infotab.find(col);
+       if (it == infotab.end()) {
+               LYXERR0("Color " << col << " not found in database.");
+               return false;
+       }
+
+       // "inherit" is returned for colors not in the database
+       // (and anyway should not be redefined)
+       if (col == Color_none || col == Color_inherit || col == Color_ignore) {
+               LYXERR0("Color " << getLyXName(col) << " may not be redefined.");
+               return false;
+       }
+
+       if (!guiname.empty())
+               it->second.guiname = guiname;
+       return true;
+}
+
+
 void ColorSet::addColor(ColorCode c, string const & lyxname)
 {
        ColorEntry ce = { c, "", "", "", "", lyxname.c_str() };