Fossil SCM

Add the color-hash-seed setting.

drh 2021-01-28 20:21 UTC trunk
Commit 8996fe0d6fef22ae876cfc08bf382e269f94d7f7f8df237b2dc9cdda13f7f2b8
1 file changed +8 -1
+8 -1
--- src/timeline.c
+++ src/timeline.c
@@ -125,29 +125,36 @@
125125
/*
126126
** Hash a string and use the hash to determine a background color.
127127
**
128128
** This value returned is in static space and is overwritten with
129129
** each subsequent call.
130
+**
131
+** SETTING: color-hash-seed width=16 default=0
132
+**
133
+** This is a seed value used for the hash that determines automatically
134
+** selected colors for branches and users.
130135
*/
131136
char *hash_color(const char *z){
132137
int i; /* Loop counter */
133138
unsigned int h = 0; /* Hash on the branch name */
134139
int r, g, b; /* Values for red, green, and blue */
135140
int h1, h2, h3, h4; /* Elements of the hash value */
136141
int mx, mn; /* Components of HSV */
137142
static char zColor[10]; /* The resulting color */
138
- static int ix[2] = {0,0}; /* Color chooser parameters */
143
+ static int ix[3] = {0,0,0}; /* Color chooser parameters */
139144
140145
if( ix[0]==0 ){
141146
if( skin_detail_boolean("white-foreground") ){
142147
ix[0] = 0x50;
143148
ix[1] = 0x20;
144149
}else{
145150
ix[0] = 0xf8;
146151
ix[1] = 0x20;
147152
}
153
+ ix[2] = db_get_int("color-hash-seed",0);
148154
}
155
+ h = ix[2];
149156
for(i=0; z[i]; i++ ){
150157
h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i];
151158
}
152159
h1 = h % 6; h /= 6;
153160
h3 = h % 10; h /= 10;
154161
--- src/timeline.c
+++ src/timeline.c
@@ -125,29 +125,36 @@
125 /*
126 ** Hash a string and use the hash to determine a background color.
127 **
128 ** This value returned is in static space and is overwritten with
129 ** each subsequent call.
 
 
 
 
 
130 */
131 char *hash_color(const char *z){
132 int i; /* Loop counter */
133 unsigned int h = 0; /* Hash on the branch name */
134 int r, g, b; /* Values for red, green, and blue */
135 int h1, h2, h3, h4; /* Elements of the hash value */
136 int mx, mn; /* Components of HSV */
137 static char zColor[10]; /* The resulting color */
138 static int ix[2] = {0,0}; /* Color chooser parameters */
139
140 if( ix[0]==0 ){
141 if( skin_detail_boolean("white-foreground") ){
142 ix[0] = 0x50;
143 ix[1] = 0x20;
144 }else{
145 ix[0] = 0xf8;
146 ix[1] = 0x20;
147 }
 
148 }
 
149 for(i=0; z[i]; i++ ){
150 h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i];
151 }
152 h1 = h % 6; h /= 6;
153 h3 = h % 10; h /= 10;
154
--- src/timeline.c
+++ src/timeline.c
@@ -125,29 +125,36 @@
125 /*
126 ** Hash a string and use the hash to determine a background color.
127 **
128 ** This value returned is in static space and is overwritten with
129 ** each subsequent call.
130 **
131 ** SETTING: color-hash-seed width=16 default=0
132 **
133 ** This is a seed value used for the hash that determines automatically
134 ** selected colors for branches and users.
135 */
136 char *hash_color(const char *z){
137 int i; /* Loop counter */
138 unsigned int h = 0; /* Hash on the branch name */
139 int r, g, b; /* Values for red, green, and blue */
140 int h1, h2, h3, h4; /* Elements of the hash value */
141 int mx, mn; /* Components of HSV */
142 static char zColor[10]; /* The resulting color */
143 static int ix[3] = {0,0,0}; /* Color chooser parameters */
144
145 if( ix[0]==0 ){
146 if( skin_detail_boolean("white-foreground") ){
147 ix[0] = 0x50;
148 ix[1] = 0x20;
149 }else{
150 ix[0] = 0xf8;
151 ix[1] = 0x20;
152 }
153 ix[2] = db_get_int("color-hash-seed",0);
154 }
155 h = ix[2];
156 for(i=0; z[i]; i++ ){
157 h = (h<<11) ^ (h<<1) ^ (h>>3) ^ z[i];
158 }
159 h1 = h % 6; h /= 6;
160 h3 = h % 10; h /= 10;
161

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button