From 21ad79473eb7f8ef6010494c0c4e4f9f6518abdb Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 27 Jun 1989 10:10:01 +0000 Subject: [PATCH] Change resource handling to use property names similar to those used by GNU Emacs. --- v7/src/microcode/x11base.c | 125 +++++++++++++++++++++++------------- v7/src/microcode/x11graph.c | 5 +- 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/v7/src/microcode/x11base.c b/v7/src/microcode/x11base.c index 64ee913f3..dc05ebdf2 100644 --- a/v7/src/microcode/x11base.c +++ b/v7/src/microcode/x11base.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.2 1989/06/23 04:34:49 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11base.c,v 1.3 1989/06/27 10:09:48 cph Exp $ Copyright (c) 1989 Massachusetts Institute of Technology @@ -187,17 +187,38 @@ x_decode_color (display, color_map, color_name, default_color) return (cdef . pixel); return (default_color); } + +char * +x_get_default (display, resource_name, property_name, class_name, sdefault) + Display * display; + char * resource_name; + char * property_name; + char * class_name; + char * sdefault; +{ + char * result; + + result = (XGetDefault (display, resource_name, property_name)); + if (result != ((char *) 0)) + return (result); + result = (XGetDefault (display, resource_name, class_name)); + if (result != ((char *) 0)) + return (result); + return (sdefault); +} unsigned long -x_default_color (display, resource_name, property_name, default_color) +x_default_color (display, resource_name, property_name, class_name, + default_color) Display * display; char * resource_name; char * property_name; + char * class_name; unsigned long default_color; { - char * color_name; - - color_name = (XGetDefault (display, resource_name, property_name)); + char * color_name = + (x_get_default + (display, resource_name, property_name, class_name, ((char *) 0))); if (color_name == ((char *) 0)) return (default_color); return @@ -207,6 +228,26 @@ x_default_color (display, resource_name, property_name, default_color) color_name, default_color)); } + +void +x_set_mouse_colors (display, mouse_cursor, mouse_pixel, background_pixel) + Display * display; + Cursor mouse_cursor; + unsigned long mouse_pixel; + unsigned long background_pixel; +{ + Colormap color_map = (DefaultColormap (display, (DefaultScreen (display)))); + XColor mouse_color; + XColor background_color; + + (mouse_color . pixel) = mouse_pixel; + XQueryColor (display, color_map, (& mouse_color)); + (background_color . pixel) = background_pixel; + XQueryColor (display, color_map, (& background_color)); + XRecolorCursor + (display, mouse_cursor, (& mouse_color), (& background_color)); + return; +} void x_default_attributes (display, resource_name, attributes) @@ -216,62 +257,54 @@ x_default_attributes (display, resource_name, attributes) { int screen_number = (DefaultScreen (display)); + (attributes -> font) = + (XLoadQueryFont + (display, + (x_get_default + (display, resource_name, "font", "Font", "9x15")))); + if ((attributes -> font) == ((XFontStruct *) 0)) + error_external_return (); { - char * font_name; - - font_name = (XGetDefault (display, resource_name, "Font")); - if (font_name == ((char *) 0)) - font_name = "9x15"; - (attributes -> font) = (XLoadQueryFont (display, font_name)); - if ((attributes -> font) == ((XFontStruct *) 0)) - error_external_return (); + char * s = + (x_get_default + (display, resource_name, "borderWidth", "BorderWidth", ((char *) 0))); + (attributes -> border_width) = ((s == ((char *) 0)) ? 2 : (atoi (s))); } { - char * s; - - s = (XGetDefault (display, resource_name, "BorderWidth")); - (attributes -> border_width) = ((s == ((char *) 0)) ? 2 : (atoi (s))); - s = (XGetDefault (display, resource_name, "InternalBorder")); + char * s = + (x_get_default + (display, resource_name, + "internalBorder", "BorderWidth", ((char *) 0))); (attributes -> internal_border_width) = - ((s == ((char *) 0)) ? 4 : (atoi (s))); + ((s == ((char *) 0)) ? (attributes -> border_width) : (atoi (s))); } { unsigned long white_pixel = (WhitePixel (display, screen_number)); unsigned long black_pixel = (BlackPixel (display, screen_number)); + unsigned long foreground_pixel; (attributes -> background_pixel) = - (x_default_color (display, resource_name, "Background", white_pixel)); - (attributes -> foreground_pixel) = - (x_default_color (display, resource_name, "Foreground", black_pixel)); + (x_default_color + (display, resource_name, "background", "Background", white_pixel)); + foreground_pixel = + (x_default_color + (display, resource_name, "foreground", "Foreground", black_pixel)); + (attributes -> foreground_pixel) = foreground_pixel; (attributes -> border_pixel) = - (x_default_color (display, resource_name, "BorderColor", black_pixel)); + (x_default_color + (display, resource_name, + "borderColor", "BorderColor", foreground_pixel)); (attributes -> cursor_pixel) = - (x_default_color (display, resource_name, "CursorColor", black_pixel)); + (x_default_color + (display, resource_name, + "cursorColor", "Foreground", foreground_pixel)); (attributes -> mouse_pixel) = - (x_default_color (display, resource_name, "pointerColor", black_pixel)); + (x_default_color + (display, resource_name, + "pointerColor", "Foreground", foreground_pixel)); } return; } - -void -x_set_mouse_colors (display, mouse_cursor, mouse_pixel, background_pixel) - Display * display; - Cursor mouse_cursor; - unsigned long mouse_pixel; - unsigned long background_pixel; -{ - Colormap color_map = (DefaultColormap (display, (DefaultScreen (display)))); - XColor mouse_color; - XColor background_color; - - (mouse_color . pixel) = mouse_pixel; - XQueryColor (display, color_map, (& mouse_color)); - (background_color . pixel) = background_pixel; - XQueryColor (display, color_map, (& background_color)); - XRecolorCursor - (display, mouse_cursor, (& mouse_color), (& background_color)); - return; -} #define MAKE_GC(gc, fore, back) \ { \ @@ -646,7 +679,7 @@ DEFINE_PRIMITIVE ("X-WINDOW-FLUSH", Prim_x_window_flush, 1, 1, 0) PRIMITIVE_RETURN (UNSPECIFIC); } -DEFINE_PRIMITIVE ("X-WINDOW-GET-DEFAULT", Prim_x_get_default, 3, 3, 0) +DEFINE_PRIMITIVE ("X-WINDOW-GET-DEFAULT", Prim_x_window_get_default, 3, 3, 0) { char * result; PRIMITIVE_HEADER (3); diff --git a/v7/src/microcode/x11graph.c b/v7/src/microcode/x11graph.c index d05d30fa7..01fe69ed1 100644 --- a/v7/src/microcode/x11graph.c +++ b/v7/src/microcode/x11graph.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.2 1989/06/21 11:44:39 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/x11graph.c,v 1.3 1989/06/27 10:10:01 cph Rel $ Copyright (c) 1989 Massachusetts Institute of Technology @@ -404,7 +404,8 @@ If third argument SUPPRESS-MAP? is true, do not map the window immediately.") geometry = (((ARG_REF (2)) == SHARP_F) - ? (XGetDefault (display, RESOURCE_NAME, "Geometry")) + ? (x_get_default + (display, RESOURCE_NAME, "geometry", "Geometry", ((char *) 0))) : (STRING_ARG (2))); result = (XGeometry (display, screen_number, geometry, -- 2.25.1