]> git.lyx.org Git - lyx.git/blobdiff - src/Color.cpp
Rename BufferView::updateScrollbar to show what does
[lyx.git] / src / Color.cpp
index c627e5b6549d29802386a8210ef210c2e280487a..cf297e909b5a3629d39ca8de0d3beb2c8c5a72b4 100644 (file)
@@ -458,6 +458,64 @@ bool ColorSet::setColor(string const & lyxname, string const & x11hexname,
 }
 
 
+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::setLaTeXName: Unknown color \""
+                      << lyxname << '"');
+               addColor(static_cast<ColorCode>(infotab.size()), lcname);
+       }
+
+       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 (!latexname.empty())
+               it->second.latexname = latexname;
+       return true;
+}
+
+
+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() };