Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Enhance the hash_color() function so that it can provide foreground colors in addition to background colors. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | auto-fg-color |
| Files: | files | file ages | folders |
| SHA1: |
9cd79bf009db63cd852c4b05e9731679 |
| User & Date: | drh 2015-03-28 19:47:05.460 |
Context
|
2015-03-28
| ||
| 19:47 | Enhance the hash_color() function so that it can provide foreground colors in addition to background colors. ... (Closed-Leaf check-in: 9cd79bf009 user: drh tags: auto-fg-color) | |
|
2015-03-26
| ||
| 13:35 | Fix http_socket.c so that it builds on Solaris. ... (check-in: f93184125d user: drh tags: trunk) | |
Changes
Changes to src/branch.c.
| ︙ | ︙ | |||
469 470 471 472 473 474 475 |
}else{
@ <h2>Open Branches:</h2>
}
@ <ul>
cnt++;
}
if( colorTest ){
| | | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
}else{
@ <h2>Open Branches:</h2>
}
@ <ul>
cnt++;
}
if( colorTest ){
const char *zColor = hash_color(zBr, 0);
@ <li><span style="background-color: %s(zColor)">
@ %h(zBr) → %s(zColor)</span></li>
}else{
@ <li>%z(href("%R/timeline?r=%T&n=200",zBr))%h(zBr)</a></li>
}
}
if( cnt ){
|
| ︙ | ︙ |
Changes to src/finfo.c.
| ︙ | ︙ | |||
439 440 441 442 443 444 445 |
aParent[nParent] = db_column_int(&qparent, 0);
if( baseCheckin ) bag_insert(&ancestor, aParent[nParent]);
nParent++;
}
db_reset(&qparent);
if( zBr==0 ) zBr = "trunk";
if( uBg ){
| | | | 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
aParent[nParent] = db_column_int(&qparent, 0);
if( baseCheckin ) bag_insert(&ancestor, aParent[nParent]);
nParent++;
}
db_reset(&qparent);
if( zBr==0 ) zBr = "trunk";
if( uBg ){
zBgClr = hash_color(zUser, 0);
}else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
zBgClr = strcmp(zBr,"trunk")==0 ? "" : hash_color(zBr, 0);
}
gidx = graph_add_row(pGraph, frid>0 ? frid : fpid+1000000000,
nParent, aParent, zBr, zBgClr,
zUuid, 0);
if( strncmp(zDate, zPrevDate, 10) ){
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
@ <tr><td>
|
| ︙ | ︙ |
Changes to src/skins.c.
| ︙ | ︙ | |||
140 141 142 143 144 145 146 |
zOut = builtin_text(z);
fossil_free(z);
}
}
return zOut;
}
int skin_white_foreground(void){
| | > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
zOut = builtin_text(z);
fossil_free(z);
}
}
return zOut;
}
int skin_white_foreground(void){
static int rc = -1;
if( rc>=0 ) return rc;
if( pAltSkin ){
rc = pAltSkin->whiteForeground;
}else{
rc = db_get_boolean("white-foreground",0);
}
return rc;
}
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
94 95 96 97 98 99 100 | #define TIMELINE_UCOLOR 0x0080 /* Background color by user */ #define TIMELINE_FRENAMES 0x0100 /* Detail only file name changes */ #define TIMELINE_UNHIDE 0x0200 /* Unhide check-ins with "hidden" tag */ #define TIMELINE_SHOWRID 0x0400 /* Show RID values in addition to UUIDs */ #endif /* | | > | < < < < < < < < < < > | | > > > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
#define TIMELINE_UCOLOR 0x0080 /* Background color by user */
#define TIMELINE_FRENAMES 0x0100 /* Detail only file name changes */
#define TIMELINE_UNHIDE 0x0200 /* Unhide check-ins with "hidden" tag */
#define TIMELINE_SHOWRID 0x0400 /* Show RID values in addition to UUIDs */
#endif
/*
** Hash a string and use the hash to determine a background color or
** foreground color.
*/
char *hash_color(const char *z, int bFgnd){
int i; /* Loop counter */
unsigned int h = 0; /* Hash on the branch name */
int r, g, b; /* Values for red, green, and blue */
int h1, h2, h3, h4; /* Elements of the hash value */
int mx, mn; /* Components of HSV */
static char zColor[10]; /* The resulting color */
for(i=0; z[i]; i++ ){
h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i];
}
h1 = h % 6; h /= 6;
h3 = h % 30; h /= 30;
h4 = h % 40; h /= 40;
if( bFgnd^skin_white_foreground() ){
mx = 140 - h3;
mn = mx - h4 - 40;
}else{
mx = 216 - h3;
mn = mx - h4 - 16;
}
h2 = (h%(mx - mn)) + mn;
switch( h1 ){
case 0: r = mx; g = h2, b = mn; break;
case 1: r = h2; g = mx, b = mn; break;
case 2: r = mn; g = mx, b = h2; break;
case 3: r = mn; g = h2, b = mx; break;
case 4: r = h2; g = mn, b = mx; break;
|
| ︙ | ︙ | |||
146 147 148 149 150 151 152 |
**
** Print out the color names associated with each tag. Used for
** testing the hash_color() function.
*/
void test_hash_color(void){
int i;
for(i=2; i<g.argc; i++){
| | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
**
** Print out the color names associated with each tag. Used for
** testing the hash_color() function.
*/
void test_hash_color(void){
int i;
for(i=2; i<g.argc; i++){
fossil_print("%20s: %s\n", g.argv[i], hash_color(g.argv[i], 0));
}
}
/*
** WEBPAGE: hash-color-test
**
** Print out the color names associated with each tag. Used for
|
| ︙ | ︙ | |||
168 169 170 171 172 173 174 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("Hash Color Test");
for(i=cnt=0; i<10; i++){
sqlite3_snprintf(sizeof(zNm),zNm,"b%d",i);
zBr = P(zNm);
if( zBr && zBr[0] ){
| > | | | > > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
style_header("Hash Color Test");
for(i=cnt=0; i<10; i++){
sqlite3_snprintf(sizeof(zNm),zNm,"b%d",i);
zBr = P(zNm);
if( zBr && zBr[0] ){
@ <p>
@ <span style='border:1px solid;background-color:%s(hash_color(zBr,0));'>
@ %h(zBr) - %s(hash_color(zBr,0)) -
@ Omnes nos quasi oves erravimus unusquisque in viam
@ suam declinavit.</span>
cnt++;
@ <span style='color:%s(hash_color(zBr,1))'>
@ Corresponding foreground color: %s(hash_color(zBr,1))</span></p>
}
}
if( cnt ){
@ <hr>
}
@ <form method="post" action="%s(g.zTop)/hash-color-test">
@ <p>Enter candidate branch names below and see them displayed in their
|
| ︙ | ︙ | |||
351 352 353 354 355 356 357 |
}else if( rid==vid ){
@ <tr class="timelineCurrent">
}else {
@ <tr>
}
@ <td class="timelineTime">%s(zTime)</td>
@ <td class="timelineGraph">
| | | | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
}else if( rid==vid ){
@ <tr class="timelineCurrent">
}else {
@ <tr>
}
@ <td class="timelineTime">%s(zTime)</td>
@ <td class="timelineGraph">
if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser,0) : 0;
if( zType[0]=='c'
&& (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
){
db_reset(&qbranch);
db_bind_int(&qbranch, ":rid", rid);
if( db_step(&qbranch)==SQLITE_ROW ){
zBr = db_column_text(&qbranch, 0);
}else{
zBr = "trunk";
}
if( zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0 ){
if( zBr==0 || strcmp(zBr,"trunk")==0 ){
zBgClr = 0;
}else{
zBgClr = hash_color(zBr,0);
}
}
}
if( zType[0]=='c' && (pGraph || (tmFlags & TIMELINE_BRCOLOR)!=0) ){
int nParent = 0;
int aParent[GR_MAX_RAIL];
int gidx;
|
| ︙ | ︙ |