summaryrefslogtreecommitdiff
path: root/zwgc
diff options
context:
space:
mode:
authorGravatar Karl Ramm <kcr@1ts.org>2009-04-20 04:29:58 +0000
committerGravatar Karl Ramm <kcr@1ts.org>2009-04-20 04:29:58 +0000
commit6b580d86ea2f7e9b60523f4ca7ce40d456612f41 (patch)
treedd6257e7ce621aabd81d8d898bbe68fcf8c8b7c3 /zwgc
parent5ffbe9b843b01cf769e40c357344a213b85959a3 (diff)
cleanup, and more death to macros.
Diffstat (limited to 'zwgc')
-rw-r--r--zwgc/X_gram.c176
-rw-r--r--zwgc/xshow.c181
2 files changed, 184 insertions, 173 deletions
diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c
index 390d061..e486835 100644
--- a/zwgc/X_gram.c
+++ b/zwgc/X_gram.c
@@ -318,19 +318,19 @@ x_gram_create(Display *dpy,
/*
* Adjust xpos, ypos based on the alignments xalign, yalign and the sizes:
*/
- if (xalign<0)
- xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xpos - xsize
- - 2*border_width;
+ if (xalign < 0)
+ xpos = WidthOfScreen(DefaultScreenOfDisplay(dpy))
+ - xpos - xsize - 2 * border_width;
else if (xalign == 0)
- xpos = ((WidthOfScreen(DefaultScreenOfDisplay(dpy)) - xsize
- - 2*border_width)>>1) + xpos;
+ xpos = ((WidthOfScreen(DefaultScreenOfDisplay(dpy))
+ - xsize - 2 * border_width) >> 1) + xpos;
if (yalign<0)
- ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ypos - ysize
- - 2*border_width;
+ ypos = HeightOfScreen(DefaultScreenOfDisplay(dpy))
+ - ypos - ysize - 2 * border_width;
else if (yalign == 0)
- ypos = ((HeightOfScreen(DefaultScreenOfDisplay(dpy)) - ysize
- - 2*border_width)>>1) + ypos;
+ ypos = ((HeightOfScreen(DefaultScreenOfDisplay(dpy))
+ - ysize - 2 * border_width) >> 1) + ypos;
/*
* Create the window:
@@ -348,7 +348,7 @@ x_gram_create(Display *dpy,
sizehints.width = xsize;
sizehints.height = ysize;
sizehints.win_gravity = x_calc_gravity(xalign, yalign);
- sizehints.flags = USPosition|USSize|PWinGravity;
+ sizehints.flags = USPosition | USSize | PWinGravity;
wmhints.input = False;
wmhints.initial_state = NormalState;
@@ -356,21 +356,20 @@ x_gram_create(Display *dpy,
wmhints.window_group = group_leader;
wmhints.flags = InputHint | StateHint | WindowGroupHint;
- x_set_icccm_hints(dpy,w,title_name,icon_name,&sizehints,&wmhints,
+ x_set_icccm_hints(dpy, w, title_name, icon_name, &sizehints, &wmhints,
group_leader);
} else {
wmhints.flags = InputHint | StateHint;
- x_set_icccm_hints(dpy,w,title_name,icon_name,&sizehints,&wmhints,0);
+ x_set_icccm_hints(dpy, w, title_name, icon_name, &sizehints, &wmhints, 0);
}
if (net_wm_window_type != None && net_wm_window_type_utility != None)
- XChangeProperty(dpy, w, net_wm_window_type, XA_ATOM, 32,
- PropModeReplace,
+ XChangeProperty(dpy, w, net_wm_window_type, XA_ATOM, 32, PropModeReplace,
(unsigned char *) &net_wm_window_type_utility, 1);
if (set_all_desktops && net_wm_desktop != None)
- XChangeProperty(dpy, w, net_wm_desktop, XA_CARDINAL, 32,
- PropModeReplace, (unsigned char *) &all_desktops, 1);
+ XChangeProperty(dpy, w, net_wm_desktop, XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &all_desktops, 1);
XSaveContext(dpy, w, desc_context, (caddr_t)gram);
@@ -385,16 +384,16 @@ x_gram_create(Display *dpy,
if (reverse_stack && bottom_gram) {
XWindowChanges winchanges;
- winchanges.sibling=bottom_gram->w;
- winchanges.stack_mode=Below;
+ winchanges.sibling = bottom_gram->w;
+ winchanges.stack_mode = Below;
/* Metacity may use border_width even if it's not specified in
* the value mask, so we must initialize it. See:
* http://bugzilla.gnome.org/show_bug.cgi?id=305257 */
- winchanges.border_width=border_width;
+ winchanges.border_width = border_width;
begin_xerror_trap (dpy);
XReconfigureWMWindow (dpy, w, DefaultScreen (dpy),
- CWSibling|CWStackMode, &winchanges);
+ CWSibling | CWStackMode, &winchanges);
end_xerror_trap (dpy);
if (xerror_happened) {
/* The event didn't go. Print an error message, and continue. */
@@ -417,11 +416,16 @@ x_gram_create(Display *dpy,
x_get_input(dpy);
}
+inline static void
+SetFG(Display *dpy, GC gc, unsigned long foreground) {
+ XGCValues gcvals;
+
+ gcvals.foreground = foreground;
+ XChangeGC(dpy, gc, GCForeground, &gcvals);
+}
+
void
-x_gram_draw(Display *dpy,
- Window w,
- x_gram *gram,
- Region region)
+x_gram_draw(Display *dpy, Window w, x_gram *gram, Region region)
{
int i;
GC gc;
@@ -430,87 +434,83 @@ x_gram_draw(Display *dpy,
XTextItem text;
int startblock, endblock, startpixel = 0, endpixel = 0;
-#define SetFG(fg) \
- gcvals.foreground=fg; \
- XChangeGC(dpy,gc,GCForeground,&gcvals)
-
gc = XCreateGC(dpy, w, 0, &gcvals);
- XSetRegion(dpy,gc,region);
+ XSetRegion(dpy, gc, region);
if ((markgram == gram) && (STARTBLOCK != -1) && (ENDBLOCK != -1)) {
if (xmarkSecond() == XMARK_END_BOUND) {
- startblock=STARTBLOCK;
- endblock=ENDBLOCK;
- startpixel=STARTPIXEL;
- endpixel=ENDPIXEL;
+ startblock = STARTBLOCK;
+ endblock = ENDBLOCK;
+ startpixel = STARTPIXEL;
+ endpixel = ENDPIXEL;
} else {
- startblock=ENDBLOCK;
- endblock=STARTBLOCK;
- startpixel=ENDPIXEL;
- endpixel=STARTPIXEL;
+ startblock = ENDBLOCK;
+ endblock = STARTBLOCK;
+ startpixel = ENDPIXEL;
+ endpixel = STARTPIXEL;
}
} else {
startblock = -1;
endblock = -1;
}
- for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
- if (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
- xb->y2-xb->y1) != RectangleOut) {
- if (i==startblock) {
- if (i==endblock) {
- SetFG(gram->bgcolor);
- XFillRectangle(dpy,w,gc,xb->x1,xb->y1,startpixel,
- (xb->y2-xb->y1));
- SetFG(xb->fgcolor);
- XFillRectangle(dpy,w,gc,xb->x1+startpixel,xb->y1,
- (endpixel-startpixel),(xb->y2-xb->y1));
- SetFG(gram->bgcolor);
- XFillRectangle(dpy,w,gc,xb->x1+endpixel,xb->y1,
- (xb->x2-xb->x1-endpixel),(xb->y2-xb->y1));
- } else {
- SetFG(gram->bgcolor);
- XFillRectangle(dpy,w,gc,xb->x1,xb->y1,startpixel,
- (xb->y2-xb->y1));
- SetFG(xb->fgcolor);
- XFillRectangle(dpy,w,gc,xb->x1+startpixel,xb->y1,
- (xb->x2-xb->x1-startpixel),(xb->y2-xb->y1));
- }
- } else if (i==endblock) {
- SetFG(xb->fgcolor);
- XFillRectangle(dpy,w,gc,xb->x1,xb->y1,endpixel,
- (xb->y2-xb->y1));
- SetFG(gram->bgcolor);
- XFillRectangle(dpy,w,gc,xb->x1+endpixel,xb->y1,
- (xb->x2-xb->x1-endpixel),(xb->y2-xb->y1));
- } else {
- if ((startblock < i) && (i < endblock)) {
- SetFG(xb->fgcolor);
- } else {
- SetFG(gram->bgcolor);
- }
- XFillRectangle(dpy,w,gc,xb->x1,xb->y1,(xb->x2-xb->x1),
- (xb->y2-xb->y1));
- }
+ for (i=0, xb = gram->blocks; i < gram->numblocks; i++, xb++) {
+ if (XRectInRegion(region, xb->x1, xb->y1, xb->x2 - xb->x1,
+ xb->y2 - xb->y1) != RectangleOut) {
+ if (i == startblock) {
+ if (i == endblock) {
+ SetFG(dpy, gc, gram->bgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1, xb->y1, startpixel,
+ xb->y2 - xb->y1);
+ SetFG(dpy, gc, xb->fgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1 + startpixel, xb->y1,
+ endpixel - startpixel, xb->y2 - xb->y1);
+ SetFG(dpy, gc, gram->bgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1 + endpixel, xb->y1,
+ xb->x2 - xb->x1 - endpixel, xb->y2 - xb->y1);
+ } else {
+ SetFG(dpy, gc, gram->bgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1, xb->y1, startpixel,
+ xb->y2 - xb->y1);
+ SetFG(dpy, gc, xb->fgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1 + startpixel, xb->y1,
+ xb->x2 - xb->x1 - startpixel,xb->y2 - xb->y1);
+ }
+ } else if (i == endblock) {
+ SetFG(dpy, gc, xb->fgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1, xb->y1, endpixel,
+ xb->y2 - xb->y1);
+ SetFG(dpy, gc, gram->bgcolor);
+ XFillRectangle(dpy, w, gc, xb->x1 + endpixel, xb->y1,
+ xb->x2 - xb->x1 - endpixel, xb->y2 - xb->y1);
+ } else {
+ if (startblock < i && i < endblock) {
+ SetFG(dpy, gc, xb->fgcolor);
+ } else {
+ SetFG(dpy, gc, gram->bgcolor);
+ }
+ XFillRectangle(dpy, w, gc, xb->x1, xb->y1, xb->x2 - xb->x1,
+ xb->y2 - xb->y1);
+ }
}
}
- gcvals.function=GXxor;
- XChangeGC(dpy,gc,GCFunction,&gcvals);
-
- for (i=0,xb=gram->blocks ; i<gram->numblocks ; i++,xb++) {
- if (XRectInRegion(region,xb->x1,xb->y1,xb->x2-xb->x1,
- xb->y2-xb->y1) != RectangleOut) {
- SetFG(gram->bgcolor^xb->fgcolor);
- text.chars=gram->text+xb->strindex;
- text.nchars=xb->strlen;
- text.delta=0;
- text.font=xb->fid;
- XDrawText(dpy,w,gc,xb->x,xb->y,&text,1);
+ gcvals.function = GXxor;
+ XChangeGC(dpy, gc, GCFunction, &gcvals);
+
+ for (i=0, xb = gram->blocks; i < gram->numblocks; i++, xb++) {
+ if (XRectInRegion(region, xb->x1, xb->y1, xb->x2 - xb->x1,
+ xb->y2 - xb->y1) != RectangleOut) {
+ SetFG(dpy, gc, gram->bgcolor ^ xb->fgcolor);
+ text.chars = gram->text + xb->strindex;
+ text.nchars = xb->strlen;
+ text.delta = 0;
+ text.font = xb->fid;
+ XDrawText(dpy, w, gc, xb->x, xb->y, &text, 1);
}
}
- XFreeGC(dpy,gc);
+ XFreeGC(dpy, gc);
}
void
diff --git a/zwgc/xshow.c b/zwgc/xshow.c
index 20bca23..720d4c8 100644
--- a/zwgc/xshow.c
+++ b/zwgc/xshow.c
@@ -156,22 +156,22 @@ fixup_and_draw(Display *dpy,
/* Find total lengths of left, center, and right parts. Also find the
length of the longest line and the total number of characters. */
- for (line=0; line<numlines; line++) {
+ for (line = 0; line < numlines; line++) {
lsize = csize = rsize = 0;
maxascent = maxdescent = 0;
/* add up sizes for each block, get max ascent and descent */
- for (i=0; i<lines[line].numblock; i++,block++) {
+ for (i = 0; i < lines[line].numblock; i++, block++) {
chars += auxblocks[block].len;
ssize = XTextWidth(auxblocks[block].font, auxblocks[block].str,
auxblocks[block].len);
auxblocks[block].width = ssize;
ascent = auxblocks[block].font->ascent;
descent = auxblocks[block].font->descent;
- if (ascent>maxascent)
+ if (ascent > maxascent)
maxascent = ascent;
- if (descent>maxdescent)
+ if (descent > maxdescent)
maxdescent = descent;
switch (auxblocks[block].align) {
case LEFTALIGN:
@@ -190,9 +190,9 @@ fixup_and_draw(Display *dpy,
/* save what we need to do size fixups */
- if (maxascent>lines[line].ascent)
+ if (maxascent > lines[line].ascent)
lines[line].ascent = maxascent;
- if (maxdescent>lines[line].descent)
+ if (maxdescent > lines[line].descent)
lines[line].descent = maxdescent;
lines[line].lsize = lsize;
lines[line].csize = csize;
@@ -200,7 +200,7 @@ fixup_and_draw(Display *dpy,
/* get width of line and see if it is bigger than the max width */
- switch ((lsize?1:0)+(csize?2:0)+(rsize?4:0)) {
+ switch ((lsize ? 1 : 0) + (csize ?2 : 0) + (rsize ? 4 : 0)) {
#ifdef DEBUG
default:
abort();
@@ -224,7 +224,7 @@ fixup_and_draw(Display *dpy,
/* XXX implicit assumption that a line must have at least one
block, so that there is indeed a reasonable font in
auxblocks[0].font */
- width = lsize*2+csize+XTextWidth(auxblocks[0].font," ",1);
+ width = lsize * 2 + csize + XTextWidth(auxblocks[0].font, " ", 1);
break;
case 4:
@@ -232,19 +232,19 @@ fixup_and_draw(Display *dpy,
break;
case 5:
- width = lsize+rsize+XTextWidth(auxblocks[0].font, " ", 1);
+ width = lsize + rsize + XTextWidth(auxblocks[0].font, " ", 1);
break;
case 6:
- width = csize+rsize*2+XTextWidth(auxblocks[0].font, " ", 1);
+ width = csize + rsize * 2 + XTextWidth(auxblocks[0].font, " ", 1);
break;
case 7:
- width = max(lsize,rsize)*2+csize+
- XTextWidth(auxblocks[0].font," ",1)*2;
+ width = max(lsize, rsize) * 2 + csize +
+ XTextWidth(auxblocks[0].font, " ", 1) * 2;
break;
}
- if (width>maxwidth)
+ if (width > maxwidth)
maxwidth = width;
}
@@ -254,16 +254,16 @@ fixup_and_draw(Display *dpy,
gram->text = (char *)malloc(chars);
block = 0;
- for (line=0; line<numlines; line++) {
+ for (line = 0; line < numlines; line++) {
lofs = internal_border_width;
- cofs = ((maxwidth-lines[line].csize)>>1) + internal_border_width;
- rofs = maxwidth-lines[line].rsize + internal_border_width;
+ cofs = ((maxwidth - lines[line].csize) >> 1) + internal_border_width;
+ rofs = maxwidth - lines[line].rsize + internal_border_width;
ystart = yofs;
yofs += lines[line].ascent;
- yend = yofs+lines[line].descent+1; /* +1 because lines look scrunched
- without it. */
+ yend = yofs + lines[line].descent + 1; /* +1 because lines look scrunched
+ without it. */
- for (i=0; i<lines[line].numblock; i++,block++) {
+ for (i = 0; i < lines[line].numblock; i++, block++) {
blocks[block].fid = auxblocks[block].font->fid;
switch (auxblocks[block].align) {
case LEFTALIGN:
@@ -292,7 +292,7 @@ fixup_and_draw(Display *dpy,
blocks[block].y2 = yend;
blocks[block].strindex = strindex;
blocks[block].strlen = auxblocks[block].len;
- strncpy(gram->text+strindex, auxblocks[block].str,
+ strncpy(gram->text + strindex, auxblocks[block].str,
auxblocks[block].len);
strindex += blocks[block].strlen;
}
@@ -301,41 +301,46 @@ fixup_and_draw(Display *dpy,
}
- if ((geometry = var_get_variable("X_geometry")),(geometry[0]=='\0'))
- if ((geometry = xres_get_geometry(style))==NULL)
- if ((geometry = var_get_variable("default_X_geometry")),
- (geometry[0]=='\0'))
- geometry = "+0+0";
+ geometry = var_get_variable("X_geometry");
+ if (geometry[0] == '\0')
+ geometry = xres_get_geometry(style);
+ if (geometry == NULL)
+ geometry = var_get_variable("default_X_geometry");
+ if (geometry[0] == '\0')
+ geometry = "+0+0";
+
sscanf(geometry, "%c%[0123456789c]%c%[0123456789c]", &xfrom, xpos,
- &yfrom, ypos);
+ &yfrom, ypos);
- if (xpos[0]=='c') {
+ if (xpos[0] == 'c') {
gram_xalign = 0;
gram_xpos = 0;
} else
gram_xpos = atoi(xpos);
- if (xfrom=='-')
+ if (xfrom == '-')
gram_xalign *= -1;
- if (ypos[0]=='c') {
+ if (ypos[0] == 'c') {
gram_yalign = 0;
gram_ypos = 0;
} else
gram_ypos = atoi(ypos);
- if (yfrom=='-')
+ if (yfrom == '-')
gram_yalign *= -1;
- if ((bgstr = var_get_variable("X_background")),(bgstr[0]=='\0'))
- if ((bgstr = xres_get_bgcolor(style))==NULL)
- if ((bgstr = var_get_variable("default_X_background")),
- (bgstr[0]=='\0'))
- gram->bgcolor = default_bgcolor;
- if (bgstr && bgstr[0])
- gram->bgcolor = x_string_to_color(bgstr,default_bgcolor);
+ bgstr = var_get_variable("X_background");
+ if (bgstr[0] == '\0')
+ bgstr = xres_get_bgcolor(style);
+ if (bgstr == NULL)
+ bgstr = var_get_variable("default_X_background");
+ if (bgstr[0]=='\0')
+ gram->bgcolor = default_bgcolor;
+ if (bgstr && bgstr[0])
+ gram->bgcolor = x_string_to_color(bgstr, default_bgcolor);
- gram_xsize = maxwidth+(internal_border_width<<1);
- gram_ysize = yofs+internal_border_width;
+ gram_xsize = maxwidth + (internal_border_width << 1);
+ gram_ysize = yofs + internal_border_width;
gram->numblocks = num;
gram->blocks = blocks;
#ifdef CMU_ZWGCPLUS
@@ -343,7 +348,7 @@ fixup_and_draw(Display *dpy,
#endif
x_gram_create(dpy, gram, gram_xalign, gram_yalign, gram_xpos,
- gram_ypos, gram_xsize, gram_ysize, beepcount);
+ gram_ypos, gram_xsize, gram_ysize, beepcount);
}
/* Silly almost-but-not-quite-useless helper function */
@@ -356,18 +361,27 @@ no_dots_downcase_var(char *str)
var2 = var;
while (*var++)
if (*var == '.')
- *var = '_';
+ *var = '_';
return(var2);
}
-#define MODE_TO_FONT(dpy,style,mode) \
- get_font((dpy),(style),(mode)->font?(mode)->font:(mode)->substyle, \
- (mode)->size, (mode)->bold+(mode)->italic*2)
+inline static XFontStruct *
+mode_to_font(Display *dpy, char *style, xmode *mode) {
+ return get_font(dpy,
+ style,
+ mode->font ? mode->font : mode->substyle,
+ mode->size,
+ mode->bold + mode->italic * 2);
+}
+
+inline static int
+envmatch(desctype *desc, char *str) {
+ int len = strlen(str);
+ return desc->len == len && strncasecmp(desc->str, str, len) == 0;
+}
+
void
-xshow(Display *dpy,
- desctype *desc,
- int numstr,
- int numnl)
+xshow(Display *dpy, desctype *desc, int numstr, int numnl)
{
XFontStruct *font;
xmode_stack modes = xmode_stack_create();
@@ -381,10 +395,10 @@ xshow(Display *dpy,
int free_style = 0;
int beepcount = 0;
- lines = (xlinedesc *)malloc(sizeof(xlinedesc)*(numnl+1));
+ lines = (xlinedesc *)malloc(sizeof(xlinedesc) * (numnl + 1));
- blocks = (xblock *)malloc(sizeof(xblock)*numstr);
- auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*numstr);
+ blocks = (xblock *)malloc(sizeof(xblock) * numstr);
+ auxblocks = (xauxblock *)malloc(sizeof(xauxblock) * numstr);
curmode.bold = 0;
curmode.italic = 0;
@@ -396,53 +410,50 @@ xshow(Display *dpy,
style = var_get_variable("style");
if (style[0] == '\0') {
- style = string_Concat(no_dots_downcase_var("class"),".");
- style = string_Concat2(style,no_dots_downcase_var("instance"));
- style = string_Concat2(style,".");
- style = string_Concat2(style,no_dots_downcase_var("sender"));
+ style = string_Concat(no_dots_downcase_var("class"), ".");
+ style = string_Concat2(style, no_dots_downcase_var("instance"));
+ style = string_Concat2(style, ".");
+ style = string_Concat2(style, no_dots_downcase_var("sender"));
string_Downcase(style);
free_style = 1;
}
- for (; desc->code!=DT_EOF; desc=desc->next) {
+ for (; desc->code != DT_EOF; desc = desc->next) {
switch (desc->code) {
case DT_ENV:
xmode_stack_push(modes, curmode);
curmode.substyle = string_Copy(curmode.substyle);
if (curmode.font)
curmode.font = string_Copy(curmode.font);
-
-#define envmatch(string,length) ((desc->len==(length)) && (strncasecmp(desc->str,(string),(length))==0))
-
- if (envmatch("roman",5)) {
+ if (envmatch(desc, "roman")) {
curmode.bold = 0;
curmode.italic = 0;
- } else if (envmatch("bold",4) || envmatch("b",1))
+ } else if (envmatch(desc, "bold") || envmatch(desc, "b"))
curmode.bold = 1;
- else if (envmatch("italic",6)||envmatch("i",1))
+ else if (envmatch(desc, "italic") || envmatch(desc, "i"))
curmode.italic = 1;
- else if (envmatch("large",5))
+ else if (envmatch(desc, "large"))
curmode.size = LARGE_SIZE;
- else if (envmatch("medium",6))
+ else if (envmatch(desc, "medium"))
curmode.size = MEDIUM_SIZE;
- else if (envmatch("small",5))
+ else if (envmatch(desc, "small"))
curmode.size = SMALL_SIZE;
- else if (envmatch("left",4)||envmatch("l",1))
+ else if (envmatch(desc, "left") || envmatch(desc, "l"))
curmode.align = LEFTALIGN;
- else if (envmatch("center",6)||envmatch("c",1))
+ else if (envmatch(desc, "center") || envmatch(desc, "c"))
curmode.align = CENTERALIGN;
- else if (envmatch("right",5)||envmatch("r",1))
+ else if (envmatch(desc, "right") || envmatch(desc, "r"))
curmode.align = RIGHTALIGN;
- else if (envmatch("beep",4))
+ else if (envmatch(desc, "beep"))
beepcount++;
- else if (envmatch("font",4)) {
+ else if (envmatch(desc, "font")) {
/* lookahead needed. desc->next->str should be the
font name, and desc->next->next->code should be
a DT_END*/
if ((desc->next) &&
(desc->next->next) &&
(desc->next->code == DT_STR) &&
- (desc->next->next->code==DT_END)) {
+ (desc->next->next->code == DT_END)) {
/* Since @font mutates the current environment, we have
to pop the environment that this case usually pushes */
@@ -451,20 +462,20 @@ xshow(Display *dpy,
xmode_stack_pop(modes);
/* mutating... */
- curmode.size=SPECIAL_SIZE; /* This is an @font() */
- curmode.font=string_CreateFromData(desc->next->str,
- desc->next->len);
+ curmode.size = SPECIAL_SIZE; /* This is an @font() */
+ curmode.font = string_CreateFromData(desc->next->str,
+ desc->next->len);
/* skip over the rest of the @font */
- desc=desc->next->next;
+ desc = desc->next->next;
}
- } else if (envmatch("color",5)) {
+ } else if (envmatch(desc, "color")) {
/* lookahead needed. desc->next->str should be the
font name, and desc->next->next->code should be
a DT_END*/
if ((desc->next) &&
(desc->next->next) &&
(desc->next->code == DT_STR) &&
- (desc->next->next->code==DT_END)) {
+ (desc->next->next->code == DT_END)) {
char *colorname;
/* Since @font mutates the current environment, we have
@@ -474,13 +485,13 @@ xshow(Display *dpy,
xmode_stack_pop(modes);
/* mutating... */
- colorname=string_CreateFromData(desc->next->str,
- desc->next->len);
- curmode.color = x_string_to_color(colorname,default_fgcolor);
+ colorname = string_CreateFromData(desc->next->str,
+ desc->next->len);
+ curmode.color = x_string_to_color(colorname, default_fgcolor);
free(colorname);
curmode.expcolor = 1;
/* skip over the rest of the @font */
- desc=desc->next->next;
+ desc = desc->next->next;
}
} else if (desc->len > 0) { /* avoid @{...} */
free(curmode.substyle);
@@ -494,14 +505,14 @@ xshow(Display *dpy,
case DT_STR:
auxblocks[nextblock].align = curmode.align;
- auxblocks[nextblock].font = MODE_TO_FONT(dpy,style,&curmode);
+ auxblocks[nextblock].font = mode_to_font(dpy, style, &curmode);
auxblocks[nextblock].str = desc->str;
auxblocks[nextblock].len = desc->len;
if (curmode.expcolor)
blocks[nextblock].fgcolor = curmode.color;
else
blocks[nextblock].fgcolor =
- x_string_to_color(mode_to_colorname(dpy,style,&curmode),
+ x_string_to_color(mode_to_colorname(dpy, style, &curmode),
default_fgcolor);
nextblock++;
break;
@@ -515,7 +526,7 @@ xshow(Display *dpy,
case DT_NL:
lines[line].startblock = linestart;
lines[line].numblock = nextblock-linestart;
- font = MODE_TO_FONT(dpy,style,&curmode);
+ font = mode_to_font(dpy, style, &curmode);
lines[line].ascent = font->ascent;
lines[line].descent = font->descent;
line++;
@@ -529,7 +540,7 @@ xshow(Display *dpy,
if (linestart != nextblock) {
lines[line].startblock = linestart;
lines[line].numblock = nextblock-linestart;
- font = MODE_TO_FONT(dpy,style,&curmode);
+ font = mode_to_font(dpy, style, &curmode);
lines[line].ascent = 0;
lines[line].descent = 0;
line++;