vbl@dip.eecs.umich.edu (Vic Lortz) (02/24/90)
Hi. This little tool makes it easy to keep the default resource
comments in public widget header files up to date. I hope fellow
widget writers find it useful.
Vic Lortz
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: resources
# Wrapped by vbl@dip.eecs.umich.edu on Sun Feb 4 10:56:23 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f resources -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"resources\"
else
echo shar: Extracting \"resources\" \(2268 characters\)
sed "s/^X//" >resources <<'END_OF_resources'
X:
X# NAME: resources
X#
X# USAGE: resources widget_source.c
X#
X# AUDIENCE: Xt widget writers
X#
X# DESCRIPTION:
X#
X# This /bin/sh script extracts a summary of Xt widget
X# resource declarations from a widget source file. The output
X# is in the form of a C comment suitable for inclusion in the
X# widget's public ".h" file. Multiple resource declarations in
X# the same file are allowed. For example:
X#
X# static XtResource resources[] = {
X# #define offset(field) XtOffset(MapWidget, map.field)
X# { XtNcolorLabels, XtCColorLabels, XtRBoolean, sizeof(Boolean),
X# offset(color_labels), XtRString, (caddr_t) "False" },
X# { XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
X# XtOffset(MapWidget, simple.cursor), XtRString, "gumby" },
X# { XtNhighlightWidth, XtCHighlightWidth, XtRDimension, sizeof(Dimension),
X# offset(highlight_width), XtRImmediate, (caddr_t) 10 },
X# #undef offset
X# };
X#
X# The output given the above declaration is:
X#
X# /************************ Default Widget Resources *****************
X#
X# static XtResource resources[] = {
X# Name Class RepType Default Value
X# ---- ----- ------- -------------
X# XtNcolorLabels ColorLabels Boolean "False"
X# XtNcursor Cursor Cursor "gumby"
X# XtNhighlightWidth HighlightWidth Dimension 10
X# */
X#
X# AUTHOR: Vic Lortz (vbl@dip.eecs.umich.edu)
X# 2/2/90
X#
X
Xcase $# in
X 1) ;;
X *) echo "usage: $0 widget_source.c"; exit 1;;
Xesac
X
Xsed -n '/XtResource.*\[\]/,/} *;/p' $1 | sed -n '
X/XtResource.*\[\]/p
X/^[ ]*{/ {
X N
X /^$/d
X /^[^}][^}]*$/N
X s/[ \n{}]//g
X s/\([{,] *\)Xt[NRC]/\1/g
X s/[(]caddr_t[)]//
X s/[(]XtPointer[)]//
X s/XtOffset[ (a-zA-Z_0-9]*,//
X p
X }' | awk -f"," '
X BEGIN { printf "%s\n",\
X "/************************ Default Widget Resources *****************"
X }
X /XtResource.*\[\]/ {
X printf "\n%s\n",$0
X printf "%-20s %-18s %-16s %-18s\n",\
X "Name","Class","RepType","Default Value"
X printf "%-20s %-18s %-16s %-18s\n",\
X "----","-----","-------","-------------"
X }
X ! /XtResource.*\[\]/ { printf "%-20s %-18s %-16s %-18s\n",$1,$2,$3,$7 }
X END { print "*/" }'
X
END_OF_resources
if test 2268 -ne `wc -c <resources`; then
echo shar: \"resources\" unpacked with wrong size!
fi
chmod +x resources
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
##
## Disclaimer: My company hasn't the faintest what I do... I'm at
## graduate school now.