summaryrefslogtreecommitdiff
path: root/zwgc/xshow.c
diff options
context:
space:
mode:
authorGravatar Kenneth G Raeburn <raeburn@mit.edu>1990-11-09 09:33:06 +0000
committerGravatar Kenneth G Raeburn <raeburn@mit.edu>1990-11-09 09:33:06 +0000
commit8b8eaf9068cc13551a3deda098a71db32ae9322e (patch)
treec7789e6e712355bcf5d5e7db264099117f75e554 /zwgc/xshow.c
parentdc232aee987d66dae928ac323b59b0b3dda95efc (diff)
Combined xres_get_{geometry,bgcolor} into one function, with data
structures controlling the behavior. Wrote macros with old function names to call new function.
Diffstat (limited to 'zwgc/xshow.c')
-rw-r--r--zwgc/xshow.c73
1 files changed, 28 insertions, 45 deletions
diff --git a/zwgc/xshow.c b/zwgc/xshow.c
index 4415f55..f4171d7 100644
--- a/zwgc/xshow.c
+++ b/zwgc/xshow.c
@@ -33,8 +33,6 @@ static char rcsid_xshow_c[] = "$Id$";
#define max(a,b) ((a)>(b)?(a):(b))
XContext desc_context;
-static pointer_dictionary geometry_dict = NULL;
-static pointer_dictionary bgcolor_dict = NULL;
static pointer_dictionary colorname_dict = NULL;
extern int internal_border_width;
@@ -84,68 +82,53 @@ char *mode_to_colorname(dpy,style,mode)
}
}
-static char *xres_get_geometry(style)
- char *style;
-{
- char *desc;
- pointer_dictionary_binding *binding;
- int exists;
- char *spec;
+struct res_dict_type {
+ pointer_dictionary dict;
+ char * resname_suffix;
+ char * resclass;
+};
- desc=string_Concat("style.",style);
- desc=string_Concat2(desc,".geometry");
+static struct res_dict_type geometry_resources = {
+ NULL, ".geometry", "StyleKey.Style1.Style2.Style3.GeometryKey",
+};
- if (!geometry_dict)
- geometry_dict = pointer_dictionary_Create(37);
- binding = pointer_dictionary_Define(geometry_dict,desc,&exists);
+static struct res_dict_type bgcolor_resources = {
+ NULL, ".background", "StyleKey.Style1.Style2.Style3.BackgroundKey",
+};
- if (exists) {
- free(desc);
- return((string) binding->value);
- } else {
-#define GEOM_CLASS "StyleKey.Style1.Style2.Style3.GeometryKey"
- spec=get_string_resource(desc,GEOM_CLASS);
-#undef GEOM_CLASS
- free(desc);
- if (spec==NULL)
- pointer_dictionary_Delete(geometry_dict,binding);
- else
- binding->value=(pointer) spec;
- return(spec); /* If resource returns NULL, return NULL also */
- }
-}
-
-static char *xres_get_bgcolor(style)
- char *style;
+static char *xres_get_resource (restype, style)
+ struct res_dict_type *restype;
+ char *style;
{
char *desc;
pointer_dictionary_binding *binding;
int exists;
- char *color;
+ char *value;
- desc=string_Concat("style.",style);
- desc=string_Concat2(desc,".background");
+ desc=string_Concat("style.", style);
+ desc=string_Concat2(desc, restype->resname_suffix);
- if (!bgcolor_dict)
- bgcolor_dict = pointer_dictionary_Create(37);
- binding = pointer_dictionary_Define(bgcolor_dict,desc,&exists);
+ if (!restype->dict)
+ restype->dict = pointer_dictionary_Create(37);
+ binding = pointer_dictionary_Define(restype->dict, desc, &exists);
if (exists) {
free(desc);
return((string) binding->value);
} else {
-#define BG_CLASS "StyleKey.Style1.Style2.Style3.BackgroundKey"
- color=get_string_resource(desc,BG_CLASS);
-#undef BG_CLASS
+ value=get_string_resource(desc, restype->resclass);
free(desc);
- if (color==NULL)
- pointer_dictionary_Delete(bgcolor_dict,binding);
+ if (value==NULL)
+ pointer_dictionary_Delete(restype->dict, binding);
else
- binding->value=(pointer) color;
- return(color); /* If resource returns NULL, return NULL also */
+ binding->value=(pointer) value;
+ return value; /* If resource returns NULL, return NULL also */
}
}
+#define xres_get_geometry(style) xres_get_resource(&geometry_resources,style)
+#define xres_get_bgcolor(style) xres_get_resource(&bgcolor_resources,style)
+
void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
beepcount)
Display *dpy;