From f94b359d339cfcefb3725fe7c0e78211443815b4 Mon Sep 17 00:00:00 2001 From: forsyth Date: Fri, 2 Apr 2010 20:48:59 +0100 Subject: 20100402-2048 --- CHANGES | 2 ++ appl/cmd/limbo/types.b | 4 ++-- include/tk.h | 1 + include/version.h | 2 +- libtk/buton.c | 5 ++-- libtk/colrs.c | 3 +++ libtk/parse.c | 63 ++++++++++++++++++++++++++++++++++++++++---------- limbo/typecheck.c | 14 +---------- limbo/types.c | 4 ++-- 9 files changed, 66 insertions(+), 32 deletions(-) diff --git a/CHANGES b/CHANGES index a15d4451..447bd2e4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +20100402 + add new option OPTflags to libtk for later use 20100325 more swizzling of libtk for later use. revised radio and check buttons. 20100322 diff --git a/appl/cmd/limbo/types.b b/appl/cmd/limbo/types.b index 8be8f16d..467efa65 100644 --- a/appl/cmd/limbo/types.b +++ b/appl/cmd/limbo/types.b @@ -574,7 +574,7 @@ adtdefd(t: ref Type) # # assemble the data structure for an adt with a pick clause. # since the scoping rules for adt pick fields are strange, -# we have a cutomized check for overlapping defitions. +# we have a customized check for overlapping definitions. # pickdefd(t: ref Type, tg: ref Decl): ref Decl { @@ -3837,7 +3837,7 @@ mkextype(t: ref Type): ref Type } # -# convert an instantiated exception type to it's underlying type +# convert an instantiated exception type to its underlying type # mkextuptype(t: ref Type): ref Type { diff --git a/include/tk.h b/include/tk.h index 9f971994..b990f621 100644 --- a/include/tk.h +++ b/include/tk.h @@ -99,6 +99,7 @@ enum OPTignore, /* ignore this option */ OPTsticky, /* sticky (any comb. of chars n, s, e, w) */ OPTlist, /* list of text values */ + OPTflags, /* more than one OPTflag */ BoolX = 0, BoolT, diff --git a/include/version.h b/include/version.h index cbd8acf7..c6539f86 100644 --- a/include/version.h +++ b/include/version.h @@ -1 +1 @@ -#define VERSION "Fourth Edition (20100325)" +#define VERSION "Fourth Edition (20100402)" diff --git a/libtk/buton.c b/libtk/buton.c index 356b8985..325422b9 100644 --- a/libtk/buton.c +++ b/libtk/buton.c @@ -198,15 +198,16 @@ tkmkbutton(TkTop *t, int btype) tkl = TKobj(TkLabel, tk); tkl->ul = -1; tkl->justify = Tkleft; - if (btype == TKradiobutton) - tkl->variable = strdup(tkselbut); switch (btype) { case TKbutton: e = tkbindings(t, tk, bb, nelem(bb)); break; case TKcheckbutton: + e = tkbindings(t, tk, cb, nelem(cb)); + break; case TKradiobutton: + tkl->variable = strdup(tkselbut); e = tkbindings(t, tk, cb, nelem(cb)); break; } diff --git a/libtk/colrs.c b/libtk/colrs.c index d4fc73c4..b72b2801 100644 --- a/libtk/colrs.c +++ b/libtk/colrs.c @@ -73,6 +73,9 @@ static Coltab coltab[] = TkChighlightfgnd, RGB(0, 0, 0), TkSameshade, + TkCtransparent, + DTransparent, + TkSameshade, -1, }; diff --git a/libtk/parse.c b/libtk/parse.c index 32f9194a..57a1a651 100644 --- a/libtk/parse.c +++ b/libtk/parse.c @@ -47,6 +47,7 @@ static char* (*oparse[])(TkTop*, TkOption*, void*, char**, char*, char*) = /* OPTignore */ pignore, /* OPTsticky */ psticky, /* OPTlist */ plist, + /* OPTflags */ pstab, }; char* @@ -290,7 +291,7 @@ tkgencget(TkOptab *ft, char *arg, char **val, TkTop *t) TkStab *s; TkOption *o; int wh, con, i, n, flag, *v; - char *r, *buf, *fmt; + char *r, *buf, *fmt, *out; buf = mallocz(Tkmaxitem, 0); if(buf == nil) @@ -381,6 +382,23 @@ tkgencget(TkOptab *ft, char *arg, char **val, TkTop *t) } free(buf); return tkvalue(val, "%s", c); + case OPTflags: + con = OPTION(ft->ptr, int, o->offset); + out = mallocz(Tkmaxitem, 0); + if(out == nil) { + free(buf); + return TkNomem; + } + c = out; + for (s = o->aux; s->val != nil; s++) { + if (con & s->con) + c = seprint(c, out+Tkmaxitem, " %s", s->val); /* should this be quoted? */ + } + free(buf); + *c = 0; + r = tkvalue(val, "%s", out); + free(out); + return r; case OPTfont: e = OPTION(ft->ptr, TkEnv*, o->offset); free(buf); @@ -411,8 +429,10 @@ tkgencget(TkOptab *ft, char *arg, char **val, TkTop *t) free(buf); return nil; case OPTbmap: + //free(buf); return tkvalue(val, "%d", OPTION(ft->ptr, Image*, o->offset) != nil); case OPTimag: + //free(buf); return tkvalue(val, "%d", OPTION(ft->ptr, TkImg*, o->offset) != nil); } } @@ -518,41 +538,60 @@ psize(TkTop *t, TkOption *o, void *place, char **str, char *buf, char *ebuf) return nil; } +static TkStab* +lookstab(TkStab *s, char *word) +{ + for(; s->val != nil; s++) + if(strcmp(s->val, word) == 0) + return s; + return nil; +} + static char* pstab(TkTop *t, TkOption *o, void *place, char **str, char *buf, char *ebuf) { - char *p; - int mask; + char *p, *fields[8]; + int mask, val, nf; TkStab *s, *c; p = tkword(t, *str, buf, ebuf, nil); if(*buf == '\0') return TkOparg; - for(s = o->aux; s->val; s++) - if(strcmp(s->val, buf) == 0) - break; - if(s->val == nil) - return TkBadvl; - - *str = p; if(o->type == OPTstab) { + s = lookstab(o->aux, buf); + if(s == nil) + return TkBadvl; + *str = p; OPTION(place, int, o->offset) = s->con; return nil; } + nf = getfields(buf, fields, nelem(fields), 1, " \t,"); + if(nf < 1 || nf > 1 && o->type != OPTflags) + return TkBadvl; + mask = 0; for(c = o->aux; c->val; c++) mask |= c->con; + val = 0; + while(--nf >= 0) { + s = lookstab(o->aux, fields[nf]); + if(s == nil) + return TkBadvl; + val |= s->con; + } + *str = p; + OPTION(place, int, o->offset) &= ~mask; - OPTION(place, int, o->offset) |= s->con; + OPTION(place, int, o->offset) |= val; /* * a hack, but otherwise we have to dirty the focus order * every time any command is executed on a widget */ - if (!strcmp(o->o, "takefocus")) + if(strcmp(o->o, "takefocus") == 0) tkdirtyfocusorder(t); return nil; } diff --git a/limbo/typecheck.c b/limbo/typecheck.c index 08bfef16..8f1e2bb3 100644 --- a/limbo/typecheck.c +++ b/limbo/typecheck.c @@ -1812,18 +1812,6 @@ n->ty->decl->refs++; return ok; } break; -/* - if(mathchk(n, 0)){ - if(n->ty != tint){ - nerror(n, "exponentiation operands not int"); - ok.ok = ok.allok = 0; - return ok; - } - break; - } - ok.ok = ok.allok = 0; - return ok; -*/ case Olsh: case Orsh: if(shiftchk(n)) @@ -2590,7 +2578,7 @@ mkvarargs(Node *n, Node *args) } /* - * check that a print style format string matches it's arguments + * check that a print style format string matches its arguments */ void fmtcheck(Node *f, Node *fmtarg, Node *va) diff --git a/limbo/types.c b/limbo/types.c index 42b14289..6d231115 100644 --- a/limbo/types.c +++ b/limbo/types.c @@ -676,7 +676,7 @@ adtdefd(Type *t) /* * assemble the data structure for an adt with a pick clause. * since the scoping rules for adt pick fields are strange, - * we have a cutomized check for overlapping defitions. + * we have a customized check for overlapping definitions. */ Decl* pickdefd(Type *t, Decl *tg) @@ -4289,7 +4289,7 @@ mkextype(Type *t) } /* - * convert an instantiated exception type to it's underlying type + * convert an instantiated exception type to its underlying type */ Type* mkextuptype(Type *t) -- cgit v1.2.3