Created
          March 3, 2017 16:34 
        
      - 
      
- 
        Save mariusae/bfb2588e54746e012845adbc062b0113 to your computer and use it in GitHub Desktop. 
    acme theme
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | diff --git a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c | |
| index 2f4fe3a..fa74df9 100644 | |
| --- a/src/cmd/acme/acme.c | |
| +++ b/src/cmd/acme/acme.c | |
| @@ -42,11 +42,14 @@ char *fontnames[2] = | |
| "/lib/font/bit/lucm/unicode.9.font" | |
| }; | |
| +long *theme = nil; | |
| + | |
| Command *command; | |
| void shutdownthread(void*); | |
| void acmeerrorinit(void); | |
| void readfile(Column*, char*); | |
| +long *parsetheme(char*); | |
| static int shutdown(void*, char*); | |
| void | |
| @@ -113,6 +116,12 @@ threadmain(int argc, char *argv[]) | |
| case 'r': | |
| swapscrollbuttons = TRUE; | |
| break; | |
| + case 't': | |
| + /* Forgive me. */ | |
| + theme = parsetheme(ARGF()); | |
| + if(theme == nil) | |
| + goto Usage; | |
| + break; | |
| case 'W': | |
| winsize = ARGF(); | |
| if(winsize == nil) | |
| @@ -280,6 +289,55 @@ threadmain(int argc, char *argv[]) | |
| threadexitsall(nil); | |
| } | |
| +long* | |
| +parsetheme(char *spec) | |
| +{ | |
| + long *theme = malloc(sizeof(long)*NTHEME); | |
| + int which; | |
| + char *p = spec; | |
| + int i; | |
| + | |
| + for(i=0; i<NTHEME; i++) | |
| + theme[i] = -1; | |
| + | |
| + while(*spec){ | |
| + while(*spec==',') spec++; | |
| + for(p=spec;*p != ':'; p++); | |
| + *p++=0; | |
| + | |
| + if(strcmp(spec, "textback") == 0) which = Textback; | |
| + else if(strcmp(spec, "texthigh") == 0) which = Texthigh; | |
| + else if(strcmp(spec, "textbord") == 0) which = Textbord; | |
| + else if(strcmp(spec, "texttext") == 0) which = Texttext; | |
| + else if(strcmp(spec, "texthtext") == 0) which = Texthtext; | |
| + else if(strcmp(spec, "tagback") == 0) which = Tagback; | |
| + else if(strcmp(spec, "taghigh") == 0) which = Taghigh; | |
| + else if(strcmp(spec, "tagbord") == 0) which = Tagbord; | |
| + else if(strcmp(spec, "tagtext") == 0) which = Tagtext; | |
| + else if(strcmp(spec, "taghtext") == 0) which = Taghtext; | |
| + else if(strcmp(spec, "butmod") == 0) which = Butmod; | |
| + else if(strcmp(spec, "butcol") == 0) which = Butcol; | |
| + else if(strcmp(spec, "but2col") == 0) which = But2col; | |
| + else if(strcmp(spec, "but3col") == 0) which = But3col; | |
| + else{ | |
| + fprint(2, "unrecognized key %s\n", spec); | |
| + return nil; | |
| + } | |
| + | |
| + theme[which] = strtol(p, &spec, 16); | |
| + } | |
| + | |
| + for(i=0; i<NTHEME; i++) | |
| + if(theme[i] < 0){ | |
| + fprint(2, "missing key %d\n", i); | |
| + return nil; | |
| + } | |
| + | |
| + | |
| + return theme; | |
| +} | |
| + | |
| + | |
| void | |
| readfile(Column *c, char *s) | |
| { | |
| @@ -967,8 +1025,28 @@ iconinit(void) | |
| { | |
| Rectangle r; | |
| Image *tmp; | |
| + int i; | |
| + | |
| + if(theme){ | |
| + textcols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Textback]); | |
| + textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Texthigh]); | |
| + textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Textbord]); | |
| + textcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Texttext]); | |
| + textcols[HTEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Texthtext]); | |
| + | |
| + tagcols[BACK] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Tagback]); | |
| + tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Taghigh]); | |
| + tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Tagbord]); | |
| + tagcols[TEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Tagtext]); | |
| + tagcols[HTEXT] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Taghtext]); | |
| + | |
| +/* | |
| + for(i=0;i<nelem(boxcursor.clr);i++) | |
| + if(boxcursor.clr[i] == 0x00) | |
| + boxcursor.clr[i] = Tagtext; | |
| +*/ | |
| - if(tagcols[BACK] == nil) { | |
| + } else if(tagcols[BACK] == nil) { | |
| /* Blue */ | |
| tagcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite); | |
| tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen); | |
| @@ -1005,15 +1083,23 @@ iconinit(void) | |
| r.max.x -= ButtonBorder; | |
| border(modbutton, r, ButtonBorder, tagcols[BORD], ZP); | |
| r = insetrect(r, ButtonBorder); | |
| - tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedblue); | |
| + if(theme) | |
| + tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, theme[Butmod]); | |
| + else | |
| + tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedblue); | |
| draw(modbutton, r, tmp, nil, ZP); | |
| freeimage(tmp); | |
| r = button->r; | |
| - colbutton = allocimage(display, r, screen->chan, 0, DPurpleblue); | |
| - | |
| - but2col = allocimage(display, r, screen->chan, 1, 0xAA0000FF); | |
| - but3col = allocimage(display, r, screen->chan, 1, 0x006600FF); | |
| + if (theme){ | |
| + colbutton = allocimage(display, r, screen->chan, 0, theme[Butcol]); | |
| + but2col = allocimage(display, r, screen->chan, 1, theme[But2col]); | |
| + but3col = allocimage(display, r, screen->chan, 1, theme[But3col]); | |
| + }else{ | |
| + colbutton = allocimage(display, r, screen->chan, 0, DPurpleblue); | |
| + but2col = allocimage(display, r, screen->chan, 1, 0xAA0000FF); | |
| + but3col = allocimage(display, r, screen->chan, 1, 0x006600FF); | |
| + } | |
| } | |
| /* | |
| diff --git a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h | |
| index df1a642..6d7326f 100644 | |
| --- a/src/cmd/acme/dat.h | |
| +++ b/src/cmd/acme/dat.h | |
| @@ -554,6 +554,28 @@ int globalautoindent; | |
| int dodollarsigns; | |
| char* mtpt; | |
| +enum | |
| +{ | |
| + Textback, | |
| + Texthigh, | |
| + Textbord, | |
| + Texttext, | |
| + Texthtext, | |
| + | |
| + Tagback, | |
| + Taghigh, | |
| + Tagbord, | |
| + Tagtext, | |
| + Taghtext, | |
| + | |
| + Butmod, | |
| + Butcol, | |
| + But2col, | |
| + But3col, | |
| + | |
| + NTHEME | |
| +}; | |
| + | |
| enum | |
| { | |
| Kscrolloneup = KF|0x20, | |
| @@ -577,3 +599,4 @@ Channel *cwarn; /* chan(void*)[1] (really chan(unit)[1]) */ | |
| QLock editoutlk; | |
| #define STACK 65536 | |
| + | |
| diff --git a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c | |
| index 6fe423a..6d6a113 100644 | |
| --- a/src/cmd/acme/exec.c | |
| +++ b/src/cmd/acme/exec.c | |
| @@ -13,6 +13,7 @@ | |
| #include "dat.h" | |
| #include "fns.h" | |
| + | |
| Buffer snarfbuf; | |
| /* | |
| diff --git a/src/cmd/acme/text.c b/src/cmd/acme/text.c | |
| index be93e6d..4f6fdb4 100644 | |
| --- a/src/cmd/acme/text.c | |
| +++ b/src/cmd/acme/text.c | |
| @@ -16,6 +16,8 @@ Image *tagcols[NCOL]; | |
| Image *textcols[NCOL]; | |
| static Rune Ldot[] = { '.', 0 }; | |
| +extern long *theme; | |
| + | |
| enum{ | |
| TABDIR = 3 /* width of tabs in directory windows */ | |
| }; | |
| @@ -44,6 +46,10 @@ textredraw(Text *t, Rectangle r, Font *f, Image *b, int odx) | |
| Rectangle rr; | |
| frinit(&t->fr, r, f, b, t->fr.cols); | |
| + if(theme){ | |
| + freeimage(t->fr.tick); | |
| + t->fr.tick = allocimage(f->display, Rect(0, 0, t->fr.tickscale*2, t->fr.font->height), t->fr.b->chan, 0, theme[Tagtext]); | |
| + } | |
| rr = t->fr.r; | |
| rr.min.x -= Scrollwid+Scrollgap; /* back fill to scroll bar */ | |
| if(!t->fr.noredraw) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
launch with
-t .., e.g.,: