ref: bd118be0e1b3df0cbd9cb3137db32852aec1ffde
parent: 10fe2e4f3fbe370a9b42624ee979999305a0d19d
author: phil9 <telephil9@gmail.com>
date: Sun Dec 5 05:43:02 EST 2021
fix default colors I mistakenly committed my own color scheme. Revert to standard colors and simplify the colors definition which will help people willing to change the colorscheme.
--- a/vdiff.c
+++ b/vdiff.c
@@ -7,6 +7,7 @@
#include <bio.h>
typedef struct Line Line;
+typedef struct Col Col;
struct Line {
int t;
@@ -15,6 +16,11 @@
int l;
};
+struct Col {
+ Image *bg;
+ Image *fg;
+};
+
enum
{
Lfile = 0,
@@ -39,10 +45,8 @@
Rectangle scrposr;
Rectangle listr;
Rectangle textr;
-Image *cols[Ncols];
-Image *bg;
-Image *fg;
-Image *scrollbg;
+Col cols[Ncols];
+Col scrlcol;
int scrollsize;
int lineh;
int nlines;
@@ -57,27 +61,25 @@
void
drawline(Rectangle r, Line *l)
{
- Image *bg;
Point p;
Rune rn;
char *s;
int off;
- bg = cols[l->t];
- draw(screen, r, bg, nil, ZP);
+ draw(screen, r, cols[l->t].bg, nil, ZP);
p = Pt(r.min.x + Hpadding, r.min.y + (Dy(r)-font->height)/2);
off = Δpan / stringwidth(font, " ");
for(s = l->s; *s; off--){
if(*s == '\t'){
- p = string(screen, p, fg, ZP, font, " ");
+ p = string(screen, p, cols[l->t].fg, ZP, font, " ");
s++;
}else if((p.x+Hpadding+stringwidth(font, " ")+stringwidth(font, ellipsis)>=textr.max.x)){
- string(screen, p, fg, ZP, font, ellipsis);
+ string(screen, p, cols[l->t].fg, ZP, font, ellipsis);
break;
}else{
s += chartorune(&rn, s);
if(off <= 0)
- p = runestringn(screen, p, fg, ZP, font, &rn, 1);
+ p = runestringn(screen, p, cols[l->t].fg, ZP, font, &rn, 1);
}
}
}
@@ -88,8 +90,8 @@
Rectangle lr;
int i, h, y;
- draw(screen, sr, bg, nil, ZP);
- draw(screen, scrollr, scrollbg, nil, ZP);
+ draw(screen, sr, cols[Lnone].bg, nil, ZP);
+ draw(screen, scrollr, scrlcol.bg, nil, ZP);
if(lcount>0){
h = ((double)nlines/lcount)*Dy(scrollr);
y = ((double)offset/lcount)*Dy(scrollr);
@@ -96,7 +98,7 @@
scrposr = Rect(scrollr.min.x, scrollr.min.y+y, scrollr.max.x-1, scrollr.min.y+y+h);
}else
scrposr = Rect(scrollr.min.x, scrollr.min.y, scrollr.max.x-1, scrollr.max.y);
- draw(screen, scrposr, bg, nil, ZP);
+ draw(screen, scrposr, scrlcol.fg, nil, ZP);
for(i=0; i<nlines && offset+i<lcount; i++){
lr = Rect(textr.min.x, textr.min.y+i*lineh, textr.max.x, textr.min.y+(i+1)*lineh);
drawline(lr, lines[offset+i]);
@@ -165,19 +167,21 @@
}
void
-initcols(void)
+initcol(Col *c, ulong fg, ulong bg)
{
- Rectangle cr;
+ c->fg = allocimage(display, Rect(0,0,1,1), screen->chan, 1, fg);
+ c->bg = allocimage(display, Rect(0,0,1,1), screen->chan, 1, bg);
+}
- cr = Rect(0, 0, 1, 1);
- bg = allocimage(display, cr, screen->chan, 1, 0x282828ff);
- fg = allocimage(display, cr, screen->chan, 1, 0xebdbb2ff);
- cols[Lfile] = allocimage(display, cr, screen->chan, 1, 0xa89984ff);
- cols[Lsep] = allocimage(display, cr, screen->chan, 1, 0x458588ff);
- cols[Ladd] = allocimage(display, cr, screen->chan, 1, 0x98971aff);
- cols[Ldel] = allocimage(display, cr, screen->chan, 1, 0xcc241dff);
- cols[Lnone] = bg;
- scrollbg = allocimage(display, cr, screen->chan, 1, 0x504945ff);
+void
+initcols(void)
+{
+ initcol(&scrlcol, DWhite, 0x999999FF);
+ initcol(&cols[Lfile], DBlack, 0xEFEFEFFF);
+ initcol(&cols[Lsep], DBlack, 0xEAFFFFFF);
+ initcol(&cols[Ladd], DBlack, 0xE6FFEDFF);
+ initcol(&cols[Ldel], DBlack, 0xFFEEF0FF);
+ initcol(&cols[Lnone], DBlack, DWhite);
}
int