]> git.lyx.org Git - lyx.git/blobdiff - src/LColor.C
citation patch from Angus
[lyx.git] / src / LColor.C
index 9fec78cbcaaccc399945072cb607ffced2b0b5b2..8ba1e503d757a136bda1e8faec9bb3d817144019 100644 (file)
@@ -22,6 +22,7 @@
 #include "gettext.h"
 #include "support/lstrings.h"
 
+using std::endl;
 
 void LColor::fill(LColor::color col, string const & gui,
                  string const & latex, string const & x11,
@@ -66,6 +67,7 @@ LColor::LColor()
        { notebg, N_("note background"), "notebg", "yellow", "notebg" },
        { noteframe, N_("note frame"), "noteframe", "black", "noteframe" },
        { depthbar, N_("depth bar"), "depthbar", "IndianRed", "depthbar" },
+       { language, N_("language"), "language", "Blue", "language" },
        { command, N_("command-inset"), "command", "black", "command" },
        { commandbg, N_("command-inset background"), "commandbg", "grey80", "commandbg" },
        { commandframe, N_("inset frame"), "commandframe", "black", "commandframe" },
@@ -170,10 +172,27 @@ void LColor::setColor(LColor::color col, string const & x11name)
 }
 
 
+bool LColor::setColor(string const & lyxname, string const & x11name)
+{
+       color col = getFromLyXName (lyxname);
+
+       // "inherit" is returned for colors not in the database
+       // (and anyway should not be redefined)
+       if (col == inherit || col == ignore) {
+               lyxerr << "Color " << lyxname << " is undefined or may not be"
+                       " redefined" << endl;
+               return false;
+       }
+       setColor (col, x11name);
+       return true;
+}
+
+
 LColor::color LColor::getFromGUIName(string const & guiname) const
 {
        InfoTab::const_iterator ici = infotab.begin();
-       for (; ici != infotab.end(); ++ici) {
+       InfoTab::const_iterator end = infotab.end();
+       for (; ici != end; ++ici) {
                if (!compare_no_case((*ici).second.guiname, guiname))
                        return (*ici).first;
        }
@@ -185,7 +204,8 @@ LColor::color LColor::getFromLyXName(string const & lyxname) const
 {
        
        InfoTab::const_iterator ici = infotab.begin();
-       for (; ici != infotab.end(); ++ici) {
+       InfoTab::const_iterator end = infotab.end();
+       for (; ici != end; ++ici) {
                if (!compare_no_case((*ici).second.lyxname, lyxname))
                        return (*ici).first;
        }