diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-09-28 10:42:31 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-09-28 10:42:31 (GMT) |
commit | ccdd8d3ab00162ae1628413134fbda50e17212e9 (patch) | |
tree | ac49bac7b0a5b38a5c7103eb9cfe0c6a7caf8afc /generic | |
parent | 52f37b7b2bdb8369bd206d66ad5b4c499daebf7c (diff) | |
parent | 35c5d43f01e2ff6e8cc9f7585adceb7bcbbbbcf9 (diff) | |
download | tk-ccdd8d3ab00162ae1628413134fbda50e17212e9.zip tk-ccdd8d3ab00162ae1628413134fbda50e17212e9.tar.gz tk-ccdd8d3ab00162ae1628413134fbda50e17212e9.tar.bz2 |
Add 8 colors to the supported color list (aqua, crimson, fuchsia, indigo, lime, olive, silver and teal), part of TIP #403
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkColor.c | 51 | ||||
-rw-r--r-- | generic/tkInt.h | 2 |
2 files changed, 47 insertions, 6 deletions
diff --git a/generic/tkColor.c b/generic/tkColor.c index 1111c51..76d0baa 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -416,8 +416,8 @@ Tk_GCForColor( if (tkColPtr->gc == None) { gcValues.foreground = tkColPtr->color.pixel; - tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), - drawable, GCForeground, &gcValues); + tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), drawable, + GCForeground, &gcValues); } return tkColPtr->gc; } @@ -800,8 +800,35 @@ TkDebugColor( } #ifndef __WIN32__ + /* This function is not necessary for Win32, * since XParseColor already does the right thing */ + +#undef XParseColor + +CONST char *CONST tkWebColors[20] = { + /* 'a' */ "qua\0#0000ffffffff", + /* 'b' */ NULL, + /* 'c' */ "rimson\0#dcdc14143c3c", + /* 'd' */ NULL, + /* 'e' */ NULL, + /* 'f' */ "uchsia\0#ffff0000ffff", + /* 'g' */ NULL, + /* 'h' */ NULL, + /* 'i' */ "ndigo\0#4b4b00008282", + /* 'j' */ NULL, + /* 'k' */ NULL, + /* 'l' */ "ime\0#0000ffff0000", + /* 'm' */ NULL, + /* 'n' */ NULL, + /* 'o' */ "live\0#808080800000", + /* 'p' */ NULL, + /* 'q' */ NULL, + /* 'r' */ NULL, + /* 's' */ "ilver\0#c0c0c0c0c0c0", + /* 't' */ "eal\0#000080808080" +}; + Status TkParseColor( Display *display, /* The display */ @@ -854,12 +881,24 @@ TkParseColor( } else { name -= 13; } - } else { - if (strlen(name) > 99) { - /* Don't bother to parse this. [Bug 2809525]*/ - return 0; + goto done; + } else if (((*name - 'A') & 0xdf) < sizeof(tkWebColors)/sizeof(tkWebColors[0])) { + const char *p = tkWebColors[((*name - 'A') & 0x1f)]; + if (p) { + const char *q = name; + while (!((*p - *(++q)) & 0xdf)) { + if (!*p++) { + name = p; + goto done; + } + } } } + if (strlen(name) > 99) { + /* Don't bother to parse this. [Bug 2809525]*/ + return 0; + } +done: return XParseColor(display, map, name, color); } #endif /* __WIN32__ */ diff --git a/generic/tkInt.h b/generic/tkInt.h index c30eceb..9a36e1e 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -971,6 +971,8 @@ MODULE_SCOPE TkMainInfo *tkMainWindowList; MODULE_SCOPE Tk_ImageType tkPhotoImageType; MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable; +MODULE_SCOPE CONST char *const tkWebColors[20]; + #include "tkIntDecls.h" #ifdef BUILD_tk |