]> git.lyx.org Git - lyx.git/blobdiff - src/Color.cpp
Less expensive OP first as this might be called often.
[lyx.git] / src / Color.cpp
index c3d3f493d80b9d3234ba061e450afb40111721b0..3b9e68ebd1959d78537a838996f7d73d1f0aec69 100644 (file)
@@ -238,6 +238,7 @@ ColorSet::ColorSet()
        //char const * grey90 = "#e5e5e5";
        //  ColorCode, gui, latex, x11hexname, x11darkhexname, lyx
        // Warning: several of these entries are overridden in GuiApplication constructor
+       // lyx color names are collected for users in Customization manual (B.# Dynamic colors)
        static ColorEntry const items[] = {
        { Color_none, N_("none"), "none", black, black, "none" },
        { Color_black, N_("black"), "black", black, black, "black" },
@@ -270,7 +271,7 @@ ColorSet::ColorSet()
        { Color_textlabel3, N_("Text label 3"), "textlabel3", magenta, magenta, "textlabel3" },
        { Color_inlinecompletion, N_("inline completion"),
                "inlinecompletion", grey60, grey40, "inlinecompletion" },
-       { Color_nonunique_inlinecompletion, N_("non-unique inline completion"),
+       { Color_nonunique_inlinecompletion, N_("inline completion (non-unique)"),
                "nonuniqueinlinecompletion", grey80, grey60, "nonuniqueinlinecompletion" },
        { Color_preview, N_("previewed snippet"), "preview", black, Linen, "preview" },
        { Color_notelabel, N_("note label"), "note", yellow, "#FF6200", "note" },
@@ -300,7 +301,7 @@ ColorSet::ColorSet()
        { Color_buttonframe_broken, N_("button frame (broken reference)"), "commandframe", red, red, "commandframe_broken" },
        { Color_buttonhoverbg_broken, N_("button background (broken reference) under focus"), "buttonhoverbg", "#DB0B0B", "#DB0B0B", "buttonhoverbg_broken" },
        { Color_special, N_("special character"), "special", RoyalBlue, RoyalBlue, "special" },
-       { Color_math, N_("math"), "math", "#00008B", "#85F0FE", "math" },
+       { Color_math, N_("math text"), "math", "#00008B", "#85F0FE", "math" },
        { Color_mathbg, N_("math background"), "mathbg", Linen, black, "mathbg" },
        { Color_graphicsbg, N_("graphics background"), "graphicsbg", Linen, black, "graphicsbg" },
        { Color_mathmacrobg, N_("math macro background"), "mathmacrobg", Linen, black, "mathmacrobg" },
@@ -317,19 +318,21 @@ ColorSet::ColorSet()
        { Color_collapsible, N_("collapsible inset text"), "collapsible", DarkRed, DarkRed, "collapsible" },
        { Color_collapsibleframe, N_("collapsible inset frame"), "collapsibleframe", IndianRed, IndianRed, "collapsibleframe" },
        { Color_insetbg, N_("inset background"), "insetbg", grey80, grey80, "insetbg" },
+       { Color_insetlabel, N_("inset label"), "insetlabel", black, black, "insetlabel" },
        { Color_insetframe, N_("inset frame"), "insetframe", IndianRed, IndianRed, "insetframe" },
        { Color_error, N_("LaTeX error"), "error", red, DarkRed, "error" },
        { Color_eolmarker, N_("end-of-line marker"), "eolmarker", Brown, Brown, "eolmarker" },
        { Color_appendix, N_("appendix marker"), "appendix", Brown, Brown, "appendix" },
        { Color_changebar, N_("change bar"), "changebar", blue, "#86a4ff", "changebar" },
-       { Color_deletedtext, N_("deleted text (output)"), "deletedtext", "#ff0000", "#ff0000", "deletedtext" },
-       { Color_addedtext, N_("added text (output)"), "addedtext", "#0000ff", "#0000ff", "addedtext" },
-       { Color_addedtextauthor1, N_("added text (workarea, 1st author)"), "changedtextauthor1", "#0000ff", "#86a4ff", "changedtextauthor1" },
-       { Color_addedtextauthor2, N_("added text (workarea, 2nd author)"), "changedtextauthor2", "#ff00ff", "#ee86ee", "changedtextauthor2" },
-       { Color_addedtextauthor3, N_("added text (workarea, 3rd author)"), "changedtextauthor3", "#ff0000", "#ea8989", "changedtextauthor3" },
-       { Color_addedtextauthor4, N_("added text (workarea, 4th author)"), "changedtextauthor4", "#aa00ff", "#c371ec", "changedtextauthor4" },
-       { Color_addedtextauthor5, N_("added text (workarea, 5th author)"), "changedtextauthor5", "#55aa00", "#acd780", "changedtextauthor5" },
-       { Color_deletedtextmodifier, N_("deleted text modifier (workarea)"), "deletedtextmodifier", white, white, "deletedtextmodifier" },
+       { Color_deletedtext_output, N_("changes - deleted text (exported output)"), "deletedtext", "#ff0000", "#ff0000", "deletedtext" },
+       { Color_addedtext_output, N_("changes - added text (exported output)"), "addedtext", "#0000ff", "#0000ff", "addedtext" },
+       { Color_changedtext_workarea_author1, N_("changed text (workarea, 1st author)"), "changedtextauthor1", "#0000ff", "#86a4ff", "changedtextauthor1" },
+       { Color_changedtext_workarea_author2, N_("changed text (workarea, 2nd author)"), "changedtextauthor2", "#ff00ff", "#ee86ee", "changedtextauthor2" },
+       { Color_changedtext_workarea_author3, N_("changed text (workarea, 3rd author)"), "changedtextauthor3", "#ff0000", "#ea8989", "changedtextauthor3" },
+       { Color_changedtext_workarea_author4, N_("changed text (workarea, 4th author)"), "changedtextauthor4", "#aa00ff", "#c371ec", "changedtextauthor4" },
+       { Color_changedtext_workarea_author5, N_("changed text (workarea, 5th author)"), "changedtextauthor5", "#55aa00", "#acd780", "changedtextauthor5" },
+       { Color_changedtext_workarea_comparison, N_("changed text (workarea, document comparison)"), "changedtextcomparison", "#008080", "#719FB0", "changedtextcomparison" },
+       { Color_deletedtext_workarea_modifier, N_("changes - deleted text brightness (workarea)"), "deletedtextmodifier", white, white, "deletedtextmodifier" },
        { Color_added_space, N_("added space markers"), "added_space", Brown, Brown, "added_space" },
        { Color_tabularline, N_("table line"), "tabularline", black, Linen, "tabularline" },
        { Color_tabularonoffline, N_("table on/off line"), "tabularonoffline", "#b0c4de", "#23497b", "tabularonoffline" },
@@ -462,7 +465,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 +490,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() };