$nbsp | "
webs_start_break=""
webs_sep="| | "
webs_break="
"
# variable
group_tab () { # $1=url $2=name $3=selected or "", optional $4=width
echo "$2 | "
}
webs_tab () { # $1=url $2=name $3=selected or "", optional $4=width
echo "$2 | "
}
###################################################################### INITS
weblist_template () {
cat <<\EOF
---+ List of all Webs
For the Plugins.KoalaSkin
Format: space-separated items
1 _3 spaces_ * webgroupname hue [options][comments]
hue can bit 2 hex digits, or the 6 hex digits for the RGB value
options can be:
* EMPTY the group is not to be used per se, only its sub-webs
1 _6 spaces_ * webname [comments]
comments can be continued on the following lines.
If no webname, starts a new row of tabs (useful for webs too numerous
to fit on a line)
1 other colors are set in the TWiki syntax:
_6 spaces_ * Set *VARIABLE* = _value_
variables being:
* KSCOLORBG the color of the page background
* KSCOLORUNSEL color of tabs of unselected web groups
* KSCOLORSEL color of the text of the selected tab
* KSICON upper-left wiki icon IMG tag, with dims
* KSHELP url of the help page (for the help icon)
* KSNOICONS set to true to disable icons for buttons on the upper
right: Home/Edit/Attach/Sitemap/Help
* KSLMARGIN left margin (default 150)
* KSTABWIDTH minimum width of web tabs (default 80)
* KSNOEXPAND if not equal to "false", do not expand template
includes to save space but consume CPU.
---
* Set KSCOLORBG = #FFFEE4
* Set KSCOLORUNSEL = #e0e0c0
* Set KSCOLORSEL = #ffff80
* Set KSICON =
EOF
}
generate_distrib () {
tar cf - \
bin/searchmulti \
bin/savemulti \
bin/koalaskin-generate \
templates/sitemap.koala.tmpl \
templates/style.koala.tmpl \
templates/twiki.koala.tmpl \
templates/view.koala.tmpl \
templates/edit.koala.tmpl \
templates/preview.koala.tmpl \
templates/attach.koala.tmpl \
templates/changeform.koala.tmpl \
templates/moveattachment.koala.tmpl \
templates/oopsmore.koala.tmpl \
templates/renamebase.koala.tmpl \
templates/rdiff.koala.tmpl \
templates/search.koala.tmpl \
templates/searchbookview.koala.tmpl \
templates/searchformat.koala.tmpl \
templates/searchmeta.koala.tmpl \
templates/searchrenameview.koala.tmpl \
templates/changes.koala.tmpl \
templates/ks_leftbar.koala.tmpl \
pub/Plugins/KoalaSkin/home.gif \
pub/Plugins/KoalaSkin/edit.gif \
pub/Plugins/KoalaSkin/attach.gif \
pub/Plugins/KoalaSkin/help.gif \
pub/Plugins/KoalaSkin/print.gif \
pub/Plugins/KoalaSkin/sitemap.gif \
pub/Plugins/KoalaSkin/TWikiKoalaSkin.txt \
| gzip -9 > /tmp/TWikiKoalaSkin.tgz
cp pub/Plugins/KoalaSkin/TWikiKoalaSkin.txt /tmp
echo "generated /tmp/TWikiKoalaSkin.tgz and /tmp/TWikiKoalaSkin.txt"
}
###################################################################### COLORS
rgb2hsv=/tmp/rgb2hsvhex
hsv2rgb=/tmp/hsv2rgbhex
rgb2hsv () {
$rgb2hsv "$@"
}
hsv2rgb () {
$hsv2rgb "$@"
}
colorname2rgb () {
grep -i "^[ ]*[0-9][0-9]*[ ][ ]*[0-9][0-9]*[ ][ ]*[0-9][0-9]*[ ][ ]*$1\$" /usr/X11R6/lib/X11/rgb.txt | ( read R G B rest;
echo "${hex[$R]}${hex[$G]}${hex[$B]}"
if [ -z "$B" ]; then echo "Error: colorname not found: $1" >&2; exit 1; fi
if $verbose; then echo "$1: ($R,$G,$B): ${hex[$R]}${hex[$G]}${hex[$B]}" 1>&2; fi
)
}
tolower () {
echo "$1" | tr '[A-Z]' '[a-z]'
}
hex=(00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF)
generate_rgb2hsvhex () {
if [ -x $rgb2hsv ]; then :
else
rm -rf $rgb2hsv ${rgb2hsv}.c
cat > ${rgb2hsv}.c << \EOF
/* code stolen from GTK */
#include
#define MIN(a,b) (ab?a:b)
#define NO_HUE -1
/* Input: r, g, b as hex-webstring
Outputs: h, s, v as hex-webstring
*/
gtk_color_selection_rgb_to_hsv (double r, double g, double b,
double *h, double *s, double *v)
{
double max, min, delta;
max = r;
if (g > max)
max = g;
if (b > max)
max = b;
min = r;
if (g < min)
min = g;
if (b < min)
min = b;
*v = max;
if (max != 0.0)
*s = (max - min) / max;
else
*s = 0.0;
if (*s == 0.0)
*h = -1.0;
else
{
delta = max - min;
if (r == max)
*h = (g - b) / delta;
else if (g == max)
*h = 2.0 + (b - r) / delta;
else if (b == max)
*h = 4.0 + (r - g) / delta;
*h = *h * 60.0;
if (*h < 0.0)
*h = *h + 360;
}
}
int main (int argc, char **argv)
{
int ri, gi, bi, hi, si, vi;
double r, g, b, h, s, v;
if (argc == 2) {
sscanf(argv[1], "%2x%2x%2x", &ri, &gi, &bi);
r = ri; r /= 255;
g = gi; g /= 255;
b = bi; b /= 255;
gtk_color_selection_rgb_to_hsv(r, g, b, &h, &s, &v);
hi = (h/360)*255;
si = s*255;
vi = v*255;
printf("%02x%02x%02x\n", hi,si, vi);
return 0;
} else
return 1;
}
EOF
$CC -O -o $rgb2hsv ${rgb2hsv}.c
if [ "$OSTYPE" = cygwin ]; then chmod a+x $rgb2hsv; fi
rm -f ${rgb2hsv}.c
fi
if [ "`/tmp/rgb2hsvhex 123456`" != 94c956 ]; then
error "/tmp/rgb2hsvhex incorrectly compiled!"
fi
}
generate_hsv2rgbhex () {
if [ -x $hsv2rgb ]; then :
else
rm -rf $hsv2rgb ${hsv2rgb}.c
cat > ${hsv2rgb}.c << \EOF
/* code stolen from GTK */
#include
#define MIN(a,b) (ab?a:b)
#define NO_HUE -1
/* Input: r, g, b as hex-webstring
Outputs: h, s, v as hex-webstring
*/
void
gtk_color_selection_hsv_to_rgb (double h, double s, double v,
double *r, double *g, double *b) {
int i;
double f, w, q, t;
if (s == 0.0)
s = 0.000001;
if (h == -1.0) {
*r = v; *g = v; *b = v;
} else {
if (h == 360.0) h = 0.0;
h = h / 60.0;
i = (int) h;
f = h - i;
w = v * (1.0 - s);
q = v * (1.0 - (s * f));
t = v * (1.0 - (s * (1.0 - f)));
switch (i) {
case 0: *r = v; *g = t; *b = w; break;
case 1: *r = q; *g = v; *b = w; break;
case 2: *r = w; *g = v; *b = t; break;
case 3: *r = w; *g = q; *b = v; break;
case 4: *r = t; *g = w; *b = v; break;
case 5: *r = v; *g = w; *b = q; break;
}
}
}
int main (int argc, char **argv)
{
int ri, gi, bi, hi, si, vi;
double r, g, b, h, s, v;
if (argc == 2) {
sscanf(argv[1], "%2x%2x%2x", &hi, &si, &vi);
h = hi * 360; h /= 255;
s = si; s /= 255;
v = vi; v /= 255;
gtk_color_selection_hsv_to_rgb(h, s, v, &r, &g, &b);
ri = r*255;
gi = g*255;
bi = b*255;
printf("%02x%02x%02x\n", ri, gi, bi);
return 0;
} else
return 1;
}
EOF
$CC -O -o $hsv2rgb ${hsv2rgb}.c
if [ "$OSTYPE" = cygwin ]; then chmod a+x $hsv2rgb; fi
rm -f ${hsv2rgb}.c
fi
if [ "`/tmp/hsv2rgbhex 123456`" != 564b44 ]; then
error "/tmp/hsv2rgbhex incorrectly compiled!"
fi
}
###################################################################### MAIN
if [ -n "$do_weblist_template" ]; then weblist_template
elif [ -n "$do_generate_distrib" ]; then generate_distrib
else sed -e 's/ /=/g' -e 's/
//g' $weblist | main
fi
rm -f $ktemp
exit 0
### EMACS MODES
### Local Variables: ***
### mode:ksh ***
### End: ***
|