v01i066: hype - a SunView object-oriented window builder, Part06/11
Charles Mcgrew
mcgrew at dartagnan.rutgers.edu
Fri Sep 15 12:48:12 AEST 1989
Submitted-by: apctrc!zmls04 at uunet.uu.net (Martin L. Smith)
Posting-number: Volume 1, Issue 66
Archive-name: hype/part06
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# archives
# src
# This archive created: Thu Sep 14 20:55:13 1989
export PATH; PATH=/bin:$PATH
if test ! -d 'archives'
then
echo shar: creating directory "'archives'"
mkdir 'archives'
fi
echo shar: entering directory "'archives'"
cd 'archives'
if test ! -d 'info'
then
echo shar: creating directory "'info'"
mkdir 'info'
fi
echo shar: entering directory "'info'"
cd 'info'
echo shar: extracting "'Makefile'" '(278 characters)'
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^ X//' << \SHAR_EOF > 'Makefile'
XCFLAGS = -g
X
X.SUFFIXES: .f .c .o .ln
X
X.c.ln:
X csh -c "lint -xu -i $<"
X
X
Xinfo.a: info_tl.o info_obj.o info_item.o info_util.o
X ar rcv info.a *.o
X ranlib info.a
X
Xlint : $(CMAINS:.c=.ln)
X csh -c "lint -ux -c $(CMAINS:.c=.ln) -lm" | tee lintfile | more
X
Xwc:
X wc *.c *.h Makefile
X
X
SHAR_EOF
if test 278 -ne "`wc -c < 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 278 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'info_item.c'" '(6848 characters)'
if test -f 'info_item.c'
then
echo shar: will not over-write existing file "'info_item.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'info_item.c'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include "../../src/util.h"
X#include "../../src/itemmod.h"
X#include "../../src/tlmod.h"
X
Xstatic Frame init_info();
Xstatic int confirm();
Xstatic void yes_no_ok();
Xstatic ITPtr gitem;
Xstatic int *gord;
Xstatic TLPtr gtl;
Xstatic Panel_item itemname;
Xstatic Panel_item itemtype;
Xstatic Panel_item itemord;
Xstatic Panel_item itemlabel;
Xstatic Panel_item itemdef;
Xstatic Panel_item itemchoices;
Xstatic Panel_item itemmin;
Xstatic Panel_item itemmax;
Xstatic Panel_item itemform;
Xstatic Panel_item itemdlen;
X
Xchar *answer;
X
Xstatic int gwritable;
X
Xvoid info_item(tl,item,ord,writable)
XITPtr item;
XTLPtr tl;
Xint *ord;
Xint writable;
X{
X Frame asker;
X gitem = item;
X gtl = tl;
X gord = ord;
X gwritable = writable;
X asker = init_info(item);
X
X
X /* make the user answer */
X window_loop(asker);
X
X /* destroy the confirmer */
X window_set(asker, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(asker);
X notify_post_destroy(asker,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X notify_dispatch();
X
X
X return;
X}
X
X
Xstatic Frame
Xinit_info(item)
XITPtr item;
X{
X Frame asker;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X
X
X asker = window_create(0, FRAME, FRAME_SHOW_LABEL, TRUE,
X FRAME_LABEL, "ITEM INFO BOX",
X 0);
X
X
X panel = window_create(asker, PANEL,
X PANEL_NOTIFY_LEVEL,PANEL_NON_PRINTABLE,
X 0);
X
X itemname = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Name :",
X PANEL_VALUE, item_get_name(item),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(2),
X 0);
X itemtype = panel_create_item(panel, PANEL_CHOICE,
X PANEL_LABEL_STRING, "Type:",
X PANEL_CHOICE_STRINGS,
X "Text",
X "Button",
X "Slider",
X "Toggle",
X "Text Subwindow", 0,
X PANEL_VALUE, item_get_type(item),
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(0),
X 0);
X itemlabel = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Label :",
X PANEL_VALUE, item_get_label(item),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(3),
X 0);
X itemdef = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Default:",
X PANEL_VALUE, cflatten(item_get_def(item)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(4),
X 0);
X
X itemchoices = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Choices:",
X PANEL_VALUE, cflatten(item_get_labels(item)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(5),
X 0);
X itemmin = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Min :",
X PANEL_VALUE, cflatten(item_get_min(item)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(6),
X 0);
X itemmax = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Max :",
X PANEL_VALUE, cflatten(item_get_max(item)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(7),
X 0);
X itemform = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Form :",
X PANEL_VALUE, cflatten(item_get_form(item)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(8),
X 0);
X itemord = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Number :",
X PANEL_VALUE, int_to_string(*gord),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(9),
X 0);
X itemdlen = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_LABEL_STRING, "Display Length:",
X PANEL_VALUE, cflatten(item_get_dlen(item)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(10),
X 0);
X pr = panel_button_image(panel, "CANCEL", 3, 0);
X width = 2 * pr->pr_width + 10;
X
X
X r = (Rect *) panel_get(itemname, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(25), PANEL_ITEM_Y, ATTR_ROW(11),
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(35), PANEL_ITEM_Y, ATTR_ROW(11),
X PANEL_LABEL_IMAGE, panel_button_image(panel, "OK", 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X
X window_fit(panel);
X window_fit(asker);
X
X /* center the asker frame on the screen */
X
X r = (Rect *) window_get(asker, WIN_SCREEN_RECT);
X
X width = (int) window_get(asker, WIN_WIDTH);
X height = (int) window_get(asker, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(asker, WIN_X, left, WIN_Y, top, 0);
X
X return asker;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X int n;
X n = (int) panel_get(item, PANEL_CLIENT_DATA);
X if (n == 0) {
X answer = NULL;
X } else {
X if (gwritable) {
X tl_set_itemord(gtl,gitem,atoi(panel_get(itemord,PANEL_VALUE,0)));
X item_set_name(gitem,panel_get(itemname,PANEL_VALUE,0));
X item_set_type(gitem,panel_get(itemtype,PANEL_VALUE,0));
X item_set_label(gitem,panel_get(itemlabel,PANEL_VALUE,0));
X item_set_def(gitem,
X cnew_constring(panel_get(itemdef,PANEL_VALUE,0)));
X item_set_labels(gitem,
X cnew_constring(panel_get(itemchoices,PANEL_VALUE,0)));
X item_set_numc(gitem,
X cget_numwords(item_get_labels(gitem)));
X item_set_min(gitem,
X cnew_constring(panel_get(itemmin,PANEL_VALUE,0)));
X item_set_max(gitem,
X cnew_constring(panel_get(itemmax,PANEL_VALUE,0)));
X item_set_form(gitem,
X cnew_constring(panel_get(itemform,PANEL_VALUE,0)));
X item_set_dlen(gitem,
X cnew_constring(panel_get(itemdlen,PANEL_VALUE,0)));
X }
X }
X window_return(n);
X}
X
SHAR_EOF
if test 6848 -ne "`wc -c < 'info_item.c'`"
then
echo shar: error transmitting "'info_item.c'" '(should have been 6848 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'info_obj.c'" '(5111 characters)'
if test -f 'info_obj.c'
then
echo shar: will not over-write existing file "'info_obj.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'info_obj.c'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include <stdio.h>
X#include "../../src/objmod.h"
X#include "../../src/tlmod.h"
X
Xstatic Frame init_info();
Xstatic int confirm();
Xstatic void yes_no_ok();
Xstatic OBPtr gobj;
Xstatic Panel_item objname;
Xstatic Panel_item objcolor;
Xstatic Panel_item objlabel;
X
Xchar *answer;
X
Xstatic int gwritable;
X
Xvoid info_box(obj,writable)
XOBPtr obj;
Xint writable;
X{
X Frame asker;
X gobj = obj;
X gwritable = writable;
X
X asker = init_info(obj);
X
X /* make the user answer */
X window_loop(asker);
X
X /* destroy the confirmer */
X window_set(asker, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(asker);
X notify_post_destroy(asker,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X notify_dispatch();
X
X return;
X}
X
X
Xstatic Frame
Xinit_info(obj)
XOBPtr obj;
X{
X Frame asker;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X Panel_item numkids,numtls,numtemps;
X char *numtempstring = "Number of templates = ";
X char *numkidsstring = "Number of children = ";
X char *numtlsstring = "Number of panes = ";
X
X asker = window_create(0, FRAME, FRAME_SHOW_LABEL, TRUE,
X FRAME_LABEL, "OBJECT INFO BOX",
X 0);
X
X sprintf(numkidsstring+22,"%d",object_get_numchild(obj));
X sprintf(numtempstring+22,"%d",object_get_numtls(obj));
X sprintf(numtlsstring+22,"%d",object_get_numtemps(obj));
X
X
X panel = window_create(asker, PANEL, 0);
X
X window_set(panel,WIN_CONSUME_PICK_EVENTS,WIN_NO_EVENTS,WIN_MOUSE_BUTTONS,0,0);
X window_set(panel,WIN_CONSUME_KBD_EVENTS,WIN_NO_EVENTS,WIN_ASCII_EVENTS,
X 0,0);
X objname = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Object Name :",
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE, object_get_name(obj),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(0),
X 0);
X objlabel = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Object Label :",
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE, cflatten(object_get_label(obj)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(1),
X 0);
X objcolor = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Color - r g b:",
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE, cflatten(object_get_color(obj)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(2),
X 0);
X numkids = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numkidsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(4),
X 0);
X numtls = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numtlsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(5),
X 0);
X numtemps = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numtempstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(6),
X 0);
X
X
X pr = panel_button_image(panel, "CANCEL", 3, 0);
X width = 2 * pr->pr_width + 10;
X
X
X r = (Rect *) panel_get(numtls, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(25), PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(35), PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_LABEL_IMAGE, panel_button_image(panel, "OK", 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X
X window_fit(panel);
X window_fit(asker);
X
X /* center the asker frame on the screen */
X
X r = (Rect *) window_get(asker, WIN_SCREEN_RECT);
X
X width = (int) window_get(asker, WIN_WIDTH);
X height = (int) window_get(asker, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(asker, WIN_X, left, WIN_Y, top, 0);
X
X return asker;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X int n;
X TLPtr tl;
X n = (int) panel_get(item, PANEL_CLIENT_DATA);
X if (n == 0) {
X answer = NULL;
X } else {
X if (gwritable) {
X object_set_name(gobj,panel_get(objname,PANEL_VALUE,0));
X answer = panel_get(item,PANEL_VALUE);
X object_set_color(gobj,
X cnew_constring(panel_get(objcolor,PANEL_VALUE,0)));
X object_set_label(gobj,
X cnew_constring(panel_get(objlabel,PANEL_VALUE,0)));
X }
X }
X window_return(n);
X}
Xstatic void
Xscript_proc(item,event)
XPanel_item item;
XEvent *event;
X{
X return;
X}
SHAR_EOF
if test 5111 -ne "`wc -c < 'info_obj.c'`"
then
echo shar: error transmitting "'info_obj.c'" '(should have been 5111 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'info_obj.orig'" '(5084 characters)'
if test -f 'info_obj.orig'
then
echo shar: will not over-write existing file "'info_obj.orig'"
else
sed 's/^ X//' << \SHAR_EOF > 'info_obj.orig'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include <stdio.h>
X#include "../../src/objmod.h"
X#include "../../src/tlmod.h"
X
Xstatic Frame init_info();
Xstatic int confirm();
Xstatic void yes_no_ok();
Xstatic OBPtr gobj;
Xstatic Panel_item objname;
Xstatic Panel_item objcolor;
Xstatic Panel_item objlabel;
X
Xchar *answer;
X
Xstatic int gwritable;
X
Xvoid info_box(obj,writable)
XOBPtr obj;
Xint writable;
X{
X Frame asker;
X gobj = obj;
X gwritable = writable;
X
X asker = init_info(obj);
X
X /* make the user answer */
X window_loop(asker);
X
X /* destroy the confirmer */
X window_set(asker, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(asker);
X notify_post_destroy(asker,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X notify_dispatch();
X
X return;
X}
X
X
Xstatic Frame
Xinit_info(obj)
XOBPtr obj;
X{
X Frame asker;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X Panel_item numkids,numtls,numtemps;
X char *numtempstring = "Number of templates = ";
X char *numkidsstring = "Number of children = ";
X char *numtlsstring = "Number of panes = ";
X
X asker = window_create(0, FRAME, FRAME_SHOW_LABEL, TRUE,
X FRAME_LABEL, "OBJECT INFO BOX",
X 0);
X
X sprintf(numkidsstring+22,"%d",object_get_numchild(obj));
X sprintf(numtempstring+22,"%d",object_get_numtls(obj));
X sprintf(numtlsstring+22,"%d",object_get_numtemps(obj));
X
X
X panel = window_create(asker, PANEL, 0);
X
X window_set(panel,WIN_CONSUME_PICK_EVENTS,WIN_NO_EVENTS,WIN_MOUSE_BUTTONS,0,0);
X window_set(panel,WIN_CONSUME_KBD_EVENTS,WIN_NO_EVENTS,WIN_ASCII_EVENTS,
X 0,0);
X objname = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Object Name :",
X PANEL_NOTIFY_LEVEL, PANEL_NONE,
X PANEL_VALUE, object_get_name(obj),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(0),
X 0);
X objcolor = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Color - r g b:",
X PANEL_NOTIFY_LEVEL, PANEL_NONE,
X PANEL_VALUE, cflatten(object_get_color(obj)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(2),
X 0);
X objlabel = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Object label :",
X PANEL_NOTIFY_LEVEL, PANEL_NONE,
X PANEL_VALUE, cflatten(object_get_label(obj)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(1),
X 0);
X numkids = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numkidsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(4),
X 0);
X numtls = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numtlsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(5),
X 0);
X numtemps = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numtempstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(6),
X 0);
X
X
X pr = panel_button_image(panel, "CANCEL", 3, 0);
X width = 2 * pr->pr_width + 10;
X
X
X r = (Rect *) panel_get(numtls, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(25), PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(35), PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_LABEL_IMAGE, panel_button_image(panel, "OK", 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X
X window_fit(panel);
X window_fit(asker);
X
X /* center the asker frame on the screen */
X
X r = (Rect *) window_get(asker, WIN_SCREEN_RECT);
X
X width = (int) window_get(asker, WIN_WIDTH);
X height = (int) window_get(asker, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(asker, WIN_X, left, WIN_Y, top, 0);
X
X return asker;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X int n;
X TLPtr tl;
X n = (int) panel_get(item, PANEL_CLIENT_DATA);
X if (n == 0) {
X answer = NULL;
X } else {
X if (gwritable) {
X object_set_name(gobj,panel_get(objname,PANEL_VALUE,0));
X answer = panel_get(item,PANEL_VALUE);
X object_set_color(gobj,
X cnew_constring(panel_get(objcolor,PANEL_VALUE,0)));
X object_set_label(gobj,
X cnew_constring(panel_get(objlabel,PANEL_VALUE,0)));
X }
X }
X window_return(n);
X}
Xstatic void
Xscript_proc(item,event)
XPanel_item item;
XEvent *event;
X{
X return;
X}
SHAR_EOF
if test 5084 -ne "`wc -c < 'info_obj.orig'`"
then
echo shar: error transmitting "'info_obj.orig'" '(should have been 5084 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'info_obj.tlf'" '(5111 characters)'
if test -f 'info_obj.tlf'
then
echo shar: will not over-write existing file "'info_obj.tlf'"
else
sed 's/^ X//' << \SHAR_EOF > 'info_obj.tlf'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include <stdio.h>
X#include "../../src/objmod.h"
X#include "../../src/tlmod.h"
X
Xstatic Frame init_info();
Xstatic int confirm();
Xstatic void yes_no_ok();
Xstatic OBPtr gobj;
Xstatic Panel_item objname;
Xstatic Panel_item objcolor;
Xstatic Panel_item objlabel;
X
Xchar *answer;
X
Xstatic int gwritable;
X
Xvoid info_box(obj,writable)
XOBPtr obj;
Xint writable;
X{
X Frame asker;
X gobj = obj;
X gwritable = writable;
X
X asker = init_info(obj);
X
X /* make the user answer */
X window_loop(asker);
X
X /* destroy the confirmer */
X window_set(asker, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(asker);
X notify_post_destroy(asker,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X notify_dispatch();
X
X return;
X}
X
X
Xstatic Frame
Xinit_info(obj)
XOBPtr obj;
X{
X Frame asker;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X Panel_item numkids,numtls,numtemps;
X char *numtempstring = "Number of templates = ";
X char *numkidsstring = "Number of children = ";
X char *numtlsstring = "Number of panes = ";
X
X asker = window_create(0, FRAME, FRAME_SHOW_LABEL, TRUE,
X FRAME_LABEL, "OBJECT INFO BOX",
X 0);
X
X sprintf(numkidsstring+22,"%d",object_get_numchild(obj));
X sprintf(numtempstring+22,"%d",object_get_numtls(obj));
X sprintf(numtlsstring+22,"%d",object_get_numtemps(obj));
X
X
X panel = window_create(asker, PANEL, 0);
X
X window_set(panel,WIN_CONSUME_PICK_EVENTS,WIN_NO_EVENTS,WIN_MOUSE_BUTTONS,0,0);
X window_set(panel,WIN_CONSUME_KBD_EVENTS,WIN_NO_EVENTS,WIN_ASCII_EVENTS,
X 0,0);
X objname = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Object Name :",
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE, object_get_name(obj),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(0),
X 0);
X objlabel = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Object Label :",
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE, cflatten(object_get_label(obj)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(1),
X 0);
X objcolor = panel_create_item(panel, PANEL_TEXT,
X PANEL_LABEL_STRING, "Color - r g b:",
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE, cflatten(object_get_color(obj)),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(2),
X 0);
X numkids = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numkidsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(4),
X 0);
X numtls = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numtlsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(5),
X 0);
X numtemps = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numtempstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(6),
X 0);
X
X
X pr = panel_button_image(panel, "CANCEL", 3, 0);
X width = 2 * pr->pr_width + 10;
X
X
X r = (Rect *) panel_get(numtls, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(25), PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(35), PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_LABEL_IMAGE, panel_button_image(panel, "OK", 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X
X window_fit(panel);
X window_fit(asker);
X
X /* center the asker frame on the screen */
X
X r = (Rect *) window_get(asker, WIN_SCREEN_RECT);
X
X width = (int) window_get(asker, WIN_WIDTH);
X height = (int) window_get(asker, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(asker, WIN_X, left, WIN_Y, top, 0);
X
X return asker;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X int n;
X TLPtr tl;
X n = (int) panel_get(item, PANEL_CLIENT_DATA);
X if (n == 0) {
X answer = NULL;
X } else {
X if (gwritable) {
X object_set_name(gobj,panel_get(objname,PANEL_VALUE,0));
X answer = panel_get(item,PANEL_VALUE);
X object_set_color(gobj,
X cnew_constring(panel_get(objcolor,PANEL_VALUE,0)));
X object_set_label(gobj,
X cnew_constring(panel_get(objlabel,PANEL_VALUE,0)));
X }
X }
X window_return(n);
X}
Xstatic void
Xscript_proc(item,event)
XPanel_item item;
XEvent *event;
X{
X return;
X}
SHAR_EOF
if test 5111 -ne "`wc -c < 'info_obj.tlf'`"
then
echo shar: error transmitting "'info_obj.tlf'" '(should have been 5111 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'info_tl.c'" '(4056 characters)'
if test -f 'info_tl.c'
then
echo shar: will not over-write existing file "'info_tl.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'info_tl.c'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include "../../src/util.h"
X#include "../../src/tlmod.h"
X#include "../../src/objmod.h"
X#include "../../src/pathname.h"
X
Xstatic Frame init_info();
Xstatic int confirm();
Xstatic void yes_no_ok();
Xstatic TLPtr gtl;
Xstatic Panel_item treename;
Xstatic Panel_item tlname;
X
X
Xstatic char *answer;
Xstatic int gwritable;
X
Xvoid info_tl(tl,writable)
XTLPtr tl;
Xint writable;
X{
X Frame asker;
X gtl = tl;
X gwritable = writable;
X asker = init_info(tl);
X
X /* make the user answer */
X window_loop(asker);
X
X /* destroy the confirmer */
X window_set(asker, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(asker);
X notify_post_destroy(asker,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X notify_dispatch();
X
X return;
X}
X
X
Xstatic Frame
Xinit_info(tl)
XTLPtr tl;
X{
X Frame asker;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X Panel_item numitems;
X Panel_item owner;
X Panel_item refcnts;
X void info_text_item();
X char *numitsstring = "Number of items = ";
X char *tlunder = "No underlay";
X char *ownerstring = "Owner Object = ";
X
X asker = window_create(0, FRAME, FRAME_SHOW_LABEL, TRUE,
X FRAME_LABEL, "TEMPLATE INFO BOX",
X 0);
X sprintf(numitsstring+19,"%d",tl_get_numitems(tl));
X sprintf(ownerstring+19,"%s",object_get_name(tl_get_owner(tl)));
X
X panel = window_create(asker, PANEL,
X 0);
X
X tlname = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NONE,
X PANEL_LABEL_STRING, "Template Name :",
X PANEL_VALUE, tl_get_name(tl),
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(0),
X 0);
X
X
X numitems = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, numitsstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(2),
X 0);
X owner = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, ownerstring,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(3),
X 0);
X
X pr = panel_button_image(panel, "CANCEL", 3, 0);
X width = 2 * pr->pr_width + 10;
X
X
X r = (Rect *) panel_get(tlname, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(25), PANEL_ITEM_Y, ATTR_ROW(5),
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, ATTR_COL(35), PANEL_ITEM_Y, ATTR_ROW(5),
X PANEL_LABEL_IMAGE, panel_button_image(panel, "OK", 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X
X window_fit(panel);
X window_fit(asker);
X
X /* center the asker frame on the screen */
X
X r = (Rect *) window_get(asker, WIN_SCREEN_RECT);
X
X width = (int) window_get(asker, WIN_WIDTH);
X height = (int) window_get(asker, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(asker, WIN_X, left, WIN_Y, top, 0);
X
X return asker;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X int n;
X TLPtr tl;
X OBPtr obj;
X char *x;
X n = (int) panel_get(item, PANEL_CLIENT_DATA);
X if (n == 0) {
X answer = NULL;
X } else {
X if (gwritable) {
X tl_set_name(panel_get(tlname,PANEL_VALUE),gtl);
X answer = panel_get(item,PANEL_VALUE);
X obj = tl_get_owner(gtl);
X }
X }
X window_return(n);
X}
Xstatic void
Xscript_proc(item,event)
XPanel_item item;
XEvent *event;
X{
X return;
X}
SHAR_EOF
if test 4056 -ne "`wc -c < 'info_tl.c'`"
then
echo shar: error transmitting "'info_tl.c'" '(should have been 4056 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'info_util.c'" '(0 character)'
if test -f 'info_util.c'
then
echo shar: will not over-write existing file "'info_util.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'info_util.c'
SHAR_EOF
if test 0 -ne "`wc -c < 'info_util.c'`"
then
echo shar: error transmitting "'info_util.c'" '(should have been 0 character)'
fi
fi # end of overwriting check
echo shar: done with directory "'info'"
cd ..
echo shar: done with directory "'archives'"
cd ..
if test ! -d 'src'
then
echo shar: creating directory "'src'"
mkdir 'src'
fi
echo shar: entering directory "'src'"
cd 'src'
echo shar: extracting "'Makefile'" '(2660 characters)'
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
sed 's/^ X//' << \SHAR_EOF > 'Makefile'
X# 10/10/88 tlf -- changed $(OBJFILES) to $(CSOURCES:.c=.o)
X
X# 8/22/89 mls -- set LOCALROOT to .. for shar file
X
XLOCALROOT = ..
XCFLAGS = -g
XCSOURCES = \
X attr.c amcomp.c clipboard.c color.c \
X confirm.c deque.c dialogue.c emalloc.c \
X edit_cont.c fileio.c global.c handler.c \
X hype.c iam.c info.c init.c \
X interface.c itemmod.c map.c objmod.c \
X pathname.c screen.c select.c sighandler.c \
X symbol.c textboard.c tlmod.c util.c \
X visual.c
X
XARCHIVES = ../archives/info/info.a \
X ../archives/mfile/mfile.a \
X ../archives/container/container.a \
X ../archives/hash/hash.a
X
XTARGET = $(LOCALROOT)/hype
X
Xhype : $(TARGET)
X
X$(TARGET): $(CSOURCES:.c=.o) scripter.o lex.o
X cc ${CFLAGS} -o $(TARGET) scripter.o lex.o $(CSOURCES:.c=.o) \
X $(ARCHIVES) \
X /usr/lib/debug/malloc.o -ll -lm \
X -lsuntool -lsunwindow -lpixrect
X size $(TARGET)
X
Xwc:
X wc *.c *.h *.y *.l makefile
X
Xlex.o : lex.l
X
Xscripter.o: scripter.y
X
Xamcomp.o: amcomp.c util.h scripter.h objmod.h iam.h sighandler.h
X
Xclipboard.o: clipboard.c util.h objmod.h tlmod.h itemmod.h
X
Xcolor.o: color.c
X
Xconfirm.o: confirm.c
X
Xdeque.o : deque.c util.h
X
Xdialogue.o: dialogue.c
X
Xemalloc.o: emalloc.c
X
Xedit_cont.o: edit_cont.c util.h sighandler.h
X
Xfileio.o: fileio.c util.h tlmod.h objmod.h itemmod.h attr.h info.h color.h \
Xinterface.h
X
Xglobal.o: global.c
X
Xhandler.o: handler.c util.h map.h itemmod.h tlmod.h objmod.h amcomp.h \
Xpathname.h
X
Xhype.o: hype.c
X
Xiam.o: iam.c util.h scripter.h itemmod.h tlmod.h objmod.h pathname.h\
Xvisual.h handler.h sighandler.h clipboard.h select.h
X
Xinfo.o: info.c util.h string.h itemmod.h tlmod.h objmod.h pathname.h
X
Xinit.o: init.c
Xinterface.o: interface.c util.h tlmod.h objmod.h itemmod.h visual.h \
Xamcomp.h fileio.h pathname.h info.h clipboard.h
X
Xitemmod.o: itemmod.c util.h map.h color.h tlmod.h attr.h
X
Xmap.o: map.c util.h
X
Xobjmod.o: objmod.c util.h string.h map.h itemmod.h tlmod.h info.h attr.h \
Xpathname.h color.h clipboard.h
X
Xpathname.o: pathname.c util.h itemmod.h tlmod.h objmod.h info.h
X
Xscreen.o: screen.c util.h interface.h dialogue.h tlmod.h attr.h objmod.h \
X itemmod.h info.h color.h
X
Xselect.o: select.c util.h tlmod.h objmod.h itemmod.h visual.h amcomp.h \
X fileio.h pathname.h info.h clipboard.h interface.h
X
Xsighandler.o: sighandler.c util.h
X
Xsymbol.o: symbol.c
X
Xtextboard.o: util.h
X
Xtlmod.o: tlmod.c util.h objmod.h itemmod.h map.h attr.h pathname.h
X
Xutil.o: util.h objmod.h
X
Xvisual.o: visual.c util.h itemmod.h tlmod.h objmod.h deque.h handler.h \
X pathname.h interface.h
X
X#safe:
X# rm -rf .safe
X# ar rv .safe Makefile *.h *.c *.y *.l
X# chmod ugo-w .safe
X
Xlink:
X rm -f $(TARGET)
X make $(TARGET)
SHAR_EOF
if test 2660 -ne "`wc -c < 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 2660 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'amcomp.c'" '(3526 characters)'
if test -f 'amcomp.c'
then
echo shar: will not over-write existing file "'amcomp.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'amcomp.c'
X
X#include <stdio.h>
X#include "util.h"
X#include "scripter.h"
X#include "../archives/container/container.h"
X#include "objmod.h"
X#include "iam.h"
X#include "sighandler.h"
X
XInst workspace[10000];
Xint curspace;
Xint globerror;
Xint lineno;
Xstatic int report;
X
XContainer mfin;
Xstatic gflag;
Xstatic recurlevel;
X
Xvoid init_amcomp()
X{
X init_symtable();
X init_builtins();
X}
Xint comp_report()
X{
X return report;
X}
XObjectCode compile(script,rep,startline)
XContainer script;
Xint rep;
Xint startline;
X{
X ObjectCode objectcode,current_program();
X void compinit();
X report = rep;
X mfin = script;
X crewind(script);
X compinit(startline);
X yyparse();
X if (globerror == 0) {
X objectcode = current_program();
X } else {
X if (rep) {
X vis_dialogue("Script not compiled due to error.");
X }
X objectcode = NULL;
X }
X return objectcode;
X}
Xvoid free_oc(oc)
XObjectCode oc;
X{
X free(oc);
X}
Xvoid setgloberror()
X{
X globerror = lineno;
X}
Xint getgloberror()
X{
X return globerror;
X}
XContainer execute_script(objcode,ref,param,otarget,self)
XObjectCode objcode;
XContainer param;
XOBPtr ref;
Xchar *otarget;
XContainer self;
X{
X Container ans;
X recurlevel++;
X if (recurlevel == 1) {
X gsigflag = INSCRIPT;
X setjmp(sigbuff[0]);
X svsignal(SIGINT,oninterrupt);
X if (gsigflag == TOPLEVEL) {
X recurlevel = 0;
X return cnew_con();
X }
X }
X ans = executescript(objcode,ref,param,otarget,self);
X recurlevel--;
X if (recurlevel == 0) {
X gsigflag = TOPLEVEL;
X }
X return ans;
X}
XContainer execute_source(script,ref,param,otarget,self)
XOBPtr ref;
XContainer script;
XContainer param;
Xchar *otarget;
XContainer self;
X{
X char x[128];
X ObjectCode objcode;
X objcode = compile(script,REPORT);
X if (globerror != 0) {
X sprintf(x,"script error near line %d\n",globerror);
X mywarning(x);
X return cnew_con();
X } else {
X return execute_script(objcode,ref,param,otarget,self);
X }
X/* FIX 8/16/88 unreachable code
X**
X** free_oc(objcode);
X*/
X}
X
XContainer execute_hypefile(name,ref,param,otarget,self)
XContainer param;
XOBPtr ref;
Xchar *otarget;
XContainer self;
Xchar *name;
X{
X FILE *fd;
X Container script;
X char c;
X char x[128];
X if (name == NULL) {
X return;
X }
X fd = fopen(name,"r");
X if (fd == NULL) {
X sprintf(x,"couldn't open script file %s\n",name);
X mywarning(x);
X return cnew_con();
X }
X script = cnew_con();
X c = getc(fd);
X while (c != EOF) {
X mfputc(script,c);
X c = getc(fd);
X }
X fclose(fd);
X mftrunc(script);
X return execute_source(script,ref,param,otarget,self);
X}
Xint load(inst)
XInst inst;
X{
X workspace[curspace] = inst;
X curspace++;
X return curspace - 1;
X}
Xint loadstring(str)
Xchar *str;
X{
X int i,n;
X n = strlen(str);
X workspace[curspace++] = (Inst) n;
X for (i = 0; i < n; i++) {
X (* (char *) (i + (char *) (workspace+curspace))) = str[i];
X }
X curspace += (n/4) + 1;
X return curspace - 1;
X}
Xint loadabsolute(pc,inst)
Xint pc;
XInst inst;
X{
X workspace[pc] = inst;
X return pc;
X}
Xint currentpc()
X{
X return curspace;
X}
XObjectCode current_program()
X{
X ObjectCode temp;
X int i;
X temp = (ObjectCode) malloc(sizeof(Inst) * curspace);
X for (i = 0; i < curspace; i++) {
X temp[i] = workspace[i];
X }
X return temp;
X}
Xvoid compinit(startline)
Xint startline;
X{
X curspace = 1;
X globerror = 0;
X lineno = 1 + startline;
X}
Xint get_lineno()
X{
X return lineno;
X}
Xvoid inc_lineno()
X{
X lineno++;
X}
Xvoid setnumlocals(n)
Xint n;
X{
X workspace[0] = (Inst) n;
X}
SHAR_EOF
if test 3526 -ne "`wc -c < 'amcomp.c'`"
then
echo shar: error transmitting "'amcomp.c'" '(should have been 3526 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'amcomp.h'" '(129 characters)'
if test -f 'amcomp.h'
then
echo shar: will not over-write existing file "'amcomp.h'"
else
sed 's/^ X//' << \SHAR_EOF > 'amcomp.h'
Xtypedef void *ObjectCode;
X
XObjectCode current_program();
Xvoid *execute_script();
Xvoid *execute_source();
XObjectCode compile();
X
X
SHAR_EOF
if test 129 -ne "`wc -c < 'amcomp.h'`"
then
echo shar: error transmitting "'amcomp.h'" '(should have been 129 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'attr.c'" '(2668 characters)'
if test -f 'attr.c'
then
echo shar: will not over-write existing file "'attr.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'attr.c'
X#include <sunwindow/rect.h>
X#include "util.h"
X#include "tlmod.h"
X#include "color.h"
X#include "../archives/container/container.h"
X
Xtypedef struct at {
X int lux;
X int luy;
X int width;
X int height;
X int type;
X int scroll;
X Container col;
X} Attr,*AttrPtr;
X
Xvoid attr_set_all(at,lux,luy,width,height,type,scroll,color)
XAttrPtr at;
Xint lux,luy,width,height,type,scroll;
XContainer color;
X{
X at->lux = lux;
X at->luy = luy;
X at->width = width;
X at->height = height;
X at->type = type;
X at->scroll = scroll;
X cdestroy(at->col);
X at->col = color;
X
X}
XAttrPtr make_attr()
X{
X AttrPtr temp;
X temp = (AttrPtr) malloc(sizeof(Attr) * 1);
X temp->lux = 0;
X temp->luy = 0;
X temp->width = 0;
X temp->height = 0;
X temp->type = 0;
X temp->col = cnew_con();
X return temp;
X}
XAttrPtr copy_attr(at)
XAttrPtr at;
X{
X AttrPtr temp;
X temp = make_attr();
X temp->lux = at->lux;
X temp->luy = at->luy;
X temp->width = at->width;
X temp->height = at->height;
X temp->type = at->type;
X temp->col = ccpy_con(at->col);
X temp->scroll = 0;
X return temp;
X}
Xvoid unmake_attr(at)
XAttrPtr at;
X{
X cdestroy(at->col);
X free(at);
X
X}
Xint attr_get_type(at)
XAttrPtr at;
X{
X return at->type;
X}
Xvoid attr_set_type(at,n)
XAttrPtr at;
Xint n;
X{
X at->type = n;
X}
Xvoid attr_set_scr(at,n)
XAttrPtr at;
Xint n;
X{
X at->scroll = n;
X}
Xvoid attr_set_col(at,clr)
XAttrPtr at;
XContainer clr;
X{
X at->col = clr;
X}
X
Xvoid attr_set_rect(at,r)
XAttrPtr at;
XRect *r;
X{
X at->lux = (int) r->r_left;
X at->luy = (int) r->r_top;
X at->width = (int) r->r_width;
X at->height = (int) r->r_height;
X}
XRect *attr_get_rect(at)
XAttrPtr at;
X{
X Rect *r;
X r = (Rect *) malloc(sizeof(Rect) * 1);
X r->r_left = (coord) at->lux;
X r->r_top = (coord) at->luy;
X r->r_width = (short) at->width;
X r->r_height = (short) at->height;
X return r;
X}
XContainer attr_get_col(at)
XAttrPtr at;
X{
X return at->col;
X}
Xint attr_get_lux(at)
XAttrPtr at;
X{
X return at->lux;
X}
Xint attr_get_scr(at)
XAttrPtr at;
X{
X return at->scroll;
X}
Xint attr_get_luy(at)
XAttrPtr at;
X{
X return at->luy;
X}
Xattr_set_lux(at,lux)
XAttrPtr at;
Xint lux;
X{
X at->lux = lux;
X}
Xattr_set_luy(at,luy)
XAttrPtr at;
Xint luy;
X{
X at->luy = luy;
X}
Xint attr_get_width(at)
XAttrPtr at;
X{
X return at->width;
X}
Xint attr_get_height(at)
XAttrPtr at;
X{
X return at->height;
X}
XAttrPtr read_attr(fd)
XFILE *fd;
X{
X AttrPtr at;
X at = make_attr();
X fscanf(fd,"%d %d %d %d %d %d\n",
X &at->lux,
X &at->luy,
X &at->width,
X &at->height,
X &at->scroll,
X &at->type);
X read_script(fd,at->col);
X return at;
X}
SHAR_EOF
if test 2668 -ne "`wc -c < 'attr.c'`"
then
echo shar: error transmitting "'attr.c'" '(should have been 2668 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'attr.h'" '(439 characters)'
if test -f 'attr.h'
then
echo shar: will not over-write existing file "'attr.h'"
else
sed 's/^ X//' << \SHAR_EOF > 'attr.h'
Xtypedef void *AttrPtr;
X
XAttrPtr make_attr();
X
Xvoid unmake_attr();
Xvoid *copy_attr();
Xint attr_get_type();
X
Xvoid attr_set_type();
X
Xvoid *attr_get_color();
Xvoid attr_set_color();
X
Xvoid attr_set_rect();
Xvoid *attr_get_rect();
X
Xint attr_get_lux();
Xint attr_get_luy();
Xint attr_get_width();
Xint attr_get_height();
XAttrPtr read_attr();
Xvoid *attr_get_col();
Xvoid *attr_get_rect();
SHAR_EOF
if test 439 -ne "`wc -c < 'attr.h'`"
then
echo shar: error transmitting "'attr.h'" '(should have been 439 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'cicon'" '(193 characters)'
if test -f 'cicon'
then
echo shar: will not over-write existing file "'cicon'"
else
sed 's/^ X//' << \SHAR_EOF > 'cicon'
X/* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
X */
X 0x0000,0x7FFF,0x6000,0x5000,0x4800,0x4400,0x4200,0x4100,
X 0x4080,0x4040,0x4020,0x4010,0x4008,0x4000,0x4000,0x4000
SHAR_EOF
if test 193 -ne "`wc -c < 'cicon'`"
then
echo shar: error transmitting "'cicon'" '(should have been 193 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'clipboard.c'" '(2210 characters)'
if test -f 'clipboard.c'
then
echo shar: will not over-write existing file "'clipboard.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'clipboard.c'
X#include "util.h"
X#include "objmod.h"
X#include "tlmod.h"
X#include "itemmod.h"
X
Xstatic int current_type;
Xstatic int current_only_reference;
Xstatic void *current_ptr;
X
Xget_clipboard_type()
X{
X return current_type;
X}
Xchar *get_clipboard_name()
X{
X switch (current_type) {
X case OBJECT_TYPE:
X return object_get_name(current_ptr);
X break;
X case TL_TYPE:
X return tl_get_name(current_ptr);
X break;
X case ITEM_TYPE:
X return item_get_name(current_ptr);
X break;
X }
X}
Xinit_clipboard()
X{
X current_ptr = NULL;
X current_only_reference = 0;
X current_type = NULL_TYPE;
X}
Xclipboard_report_dealloc(ptr)
Xvoid *ptr;
X{
X if (ptr == current_ptr) {
X init_clipboard();
X }
X}
Xstatic void deallocate_clip(ptr)
Xvoid *ptr;
X{
X switch (current_type) {
X case OBJECT_TYPE:
X unmake_object(ptr);
X break;
X case TL_TYPE:
X tl_unmake(ptr);
X break;
X case ITEM_TYPE:
X unmake_item(ptr);
X break;
X }
X}
Xput_object_clipboard(obj,flag)
XOBPtr obj;
Xint flag;
X{
X if (current_ptr != NULL) {
X if (current_only_reference) {
X deallocate_clip(current_ptr,OBJECT_TYPE);
X }
X }
X current_type = OBJECT_TYPE;
X current_only_reference = flag;
X current_ptr = (void *) obj;
X}
Xput_tl_clipboard(tl,flag)
XTLPtr tl;
Xint flag;
X{
X if (current_ptr != NULL) {
X if (current_only_reference) {
X deallocate_clip(current_ptr);
X }
X }
X current_type = TL_TYPE;
X current_only_reference = flag;
X current_ptr = (void *) tl;
X}
Xput_item_clipboard(it,flag)
XITPtr it;
Xint flag;
X{
X if (current_ptr != NULL) {
X if (current_only_reference) {
X deallocate_clip(current_ptr,ITEM_TYPE);
X }
X }
X current_type = ITEM_TYPE;
X current_only_reference = flag;
X current_ptr = (void *) it;
X}
X
X
XOBPtr get_object_clipboard()
X{
X if (current_type != OBJECT_TYPE) {
X mywarning("Entity on clipboard is not an Object!");
X return NULL;
X }
X return (OBPtr) current_ptr;
X}
XTLPtr get_tl_clipboard()
X{
X if (current_type != TL_TYPE) {
X mywarning("Entity on clipboard is not a Template!");
X return NULL;
X }
X return (TLPtr) current_ptr;
X}
XITPtr get_item_clipboard()
X{
X if (current_type != ITEM_TYPE) {
X mywarning("Entity on clipboard is not an Item!");
X return NULL;
X }
X return (ITPtr) current_ptr;
X}
X
SHAR_EOF
if test 2210 -ne "`wc -c < 'clipboard.c'`"
then
echo shar: error transmitting "'clipboard.c'" '(should have been 2210 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'clipboard.h'" '(118 characters)'
if test -f 'clipboard.h'
then
echo shar: will not over-write existing file "'clipboard.h'"
else
sed 's/^ X//' << \SHAR_EOF > 'clipboard.h'
Xvoid *get_object_clipboard();
Xvoid *get_tl_clipboard();
Xvoid *get_item_clipboard();
Xvoid *clipboard_report_dealloc();
SHAR_EOF
if test 118 -ne "`wc -c < 'clipboard.h'`"
then
echo shar: error transmitting "'clipboard.h'" '(should have been 118 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'color.c'" '(1870 characters)'
if test -f 'color.c'
then
echo shar: will not over-write existing file "'color.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'color.c'
X#include <suntool/sunview.h>
X#include "../archives/container/container.h"
X
X
Xtypedef struct sc {
X u_char r,g,b;
X } SINCOL,*Scolor;
X
XScolor color_get_random()
X{
X Scolor new;
X new = (Scolor) malloc(sizeof(SINCOL) * 1);
X new->r = rand() % 255;
X new->g = rand() % 255;
X new->b = rand() % 255;
X if (new->r < 100) {
X new->r += 150;
X }
X if (new->g < 100) {
X new->g += 150;
X }
X if (new->b < 100) {
X new->b += 150;
X }
X return new;
X}
XScolor make_white()
X{
X Scolor sc;
X sc = (Scolor) malloc(sizeof(SINCOL) * 1);
X sc->r = 255;
X sc->b = 255;
X sc->g = 255;
X return sc;
X}
XScolor make_color()
X{
X Scolor sc;
X sc = (Scolor) malloc(sizeof(SINCOL) * 1);
X return sc;
X}
XScolor unmake_color(sc)
XScolor sc;
X{
X free(sc);
X}
XScolor copy_color(sc)
XScolor sc;
X{
X Scolor temp;
X temp = make_color();
X temp->r = sc->r;
X temp->g = sc->g;
X temp->b = sc->b;
X}
Xint get_red(sc)
XScolor sc;
X{
X return sc->r;
X}
Xint get_blue(sc)
XScolor sc;
X{
X return sc->b;
X}
Xint get_green(sc)
XScolor sc;
X{
X return sc->g;
X}
Xvoid set_red(sc,r)
XScolor sc;
Xint r;
X{
X sc->r = r;
X}
Xvoid set_blue(sc,b)
XScolor sc;
Xint b;
X{
X sc->b = b;
X}
Xint set_green(sc,g)
XScolor sc;
Xint g;
X{
X sc->g = g;
X}
XScolor interp_color(cont)
XContainer cont;
X{
X char *x;
X Scolor temp;
X int r,g,b;
X temp = make_color();
X x = cflatten(cont);
X sscanf(x,"%d %d %d",&r,&g,&b);
X if ((r == 0) && (g == 0) && (b == 0)){
X temp->r = (u_char) 200;
X temp->g = (u_char) 30;
X temp->b = (u_char) 30;
X free(x);
X return temp;
X }
X if (r > 255) {
X r = 255;
X }
X if (g > 255) {
X g = 255;
X }
X if (b > 255) {
X b = 255;
X }
X if (r < 0) {
X r = 255;
X }
X if (g < 0) {
X g = 255;
X }
X if (b < 0) {
X b = 255;
X }
X temp->r = (u_char) r;
X temp->g = (u_char) g;
X temp->b = (u_char) b;
X free(x);
X return temp;
X}
SHAR_EOF
if test 1870 -ne "`wc -c < 'color.c'`"
then
echo shar: error transmitting "'color.c'" '(should have been 1870 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'color.h'" '(94 characters)'
if test -f 'color.h'
then
echo shar: will not over-write existing file "'color.h'"
else
sed 's/^ X//' << \SHAR_EOF > 'color.h'
Xtypedef void *Scolor;
X
XScolor color_get_random();
XScolor make_color();
XScolor interp_color();
SHAR_EOF
if test 94 -ne "`wc -c < 'color.h'`"
then
echo shar: error transmitting "'color.h'" '(should have been 94 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'confirm.c'" '(3354 characters)'
if test -f 'confirm.c'
then
echo shar: will not over-write existing file "'confirm.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'confirm.c'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X
Xstatic Frame init_confirmer();
Xstatic int confirm();
Xstatic void yes_no_ok();
X
X
Xint
Xconfirm_yes(message)
Xchar *message;
X{
X return confirm(message, "NO", "YES", FALSE);
X}
X
Xint
Xconfirm_ok(message)
Xchar *message;
X{
X return confirm(message, "", "", TRUE);
X}
Xint
Xconfirm_choose(message,first,second)
Xchar *message,*first,*second;
X{
X return confirm(message, first, second, FALSE);
X}
X
Xstatic int
Xconfirm(message, first, second, ok_only)
Xchar *message,*first,*second;
Xint ok_only;
X{
X Frame confirmer;
X int answer;
X int i;
X
X /* create the confirmer */
X confirmer = init_confirmer(message, first, second, ok_only);
X
X /* make the user answer */
X answer = (int) window_loop(confirmer);
X
X /* destroy the confirmer */
X window_set(confirmer, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(confirmer);
X notify_post_destroy(confirmer,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X for (i = 0; i < 1000; i++) {
X notify_dispatch();
X }
X return answer;
X}
X
X
Xstatic Frame
Xinit_confirmer(message, first, second, ok_only)
Xchar *message;
Xchar *first,*second;
Xint ok_only;
X{
X Frame confirmer;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X
X confirmer = window_create(0, FRAME, FRAME_SHOW_LABEL, FALSE, 0);
X
X panel = window_create(confirmer, PANEL, 0);
X
X message_item = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, message,
X 0);
X
X if (ok_only) {
X pr = panel_button_image(panel, "OK", 3, 0);
X width = pr->pr_width;
X } else {
X pr = panel_button_image(panel, first, 3, 0);
X width = 2 * pr->pr_width + 10;
X }
X
X r = (Rect *) panel_get(message_item, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X if (ok_only) {
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, left, PANEL_ITEM_Y, top,
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X } else {
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, left, PANEL_ITEM_Y, top,
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE, panel_button_image(panel, second, 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X }
X
X window_fit(panel);
X window_fit(confirmer);
X
X /* center the confirmer frame on the screen */
X
X r = (Rect *) window_get(confirmer, WIN_SCREEN_RECT);
X
X width = (int) window_get(confirmer, WIN_WIDTH);
X height = (int) window_get(confirmer, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(confirmer, WIN_X, left, WIN_Y, top, 0);
X
X return confirmer;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X window_return(panel_get(item, PANEL_CLIENT_DATA));
X}
SHAR_EOF
if test 3354 -ne "`wc -c < 'confirm.c'`"
then
echo shar: error transmitting "'confirm.c'" '(should have been 3354 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'container.c'" '(4285 characters)'
if test -f 'container.c'
then
echo shar: will not over-write existing file "'container.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'container.c'
X#include "../mfile/mfile.h"
X#include <stdio.h>
X
Xtypedef MFILE *Container;
X
XContainer cnew_con()
X{
X return mfopen();
X}
XContainer cnew_constring(str)
Xchar *str;
X{
X Container temp;
X void cins_cur_chars();
X void crewind();
X temp = cnew_con();
X cins_cur_chars(temp,str,strlen(str));
X crewind(temp);
X return temp;
X}
Xchar *cflatten(cont)
XContainer cont;
X{
X long n;
X char *temp;
X n = clength(cont);
X temp = (char *) malloc(sizeof(char) * n+1);
X crewind(cont);
X mfread(cont,temp,n);
X temp[n] = '\0';
X return temp;
X}
Xvoid cdestroy(cont)
XContainer cont;
X{
X mfclose(cont);
X}
Xvoid ctrunc(cont)
XContainer cont;
X{
X mftrunc(cont);
X}
Xvoid crewind(cont)
XContainer cont;
X{
X mfseek(cont,0,0);
X}
XContainer ccpy_con(old)
XContainer old;
X{
X long size;
X long curspot;
X Container new;
X char *buff,*cget_cur_chars();
X void cins_cur_chars();
X new = cnew_con();
X crewind(old);
X buff = cget_cur_chars(old,clength(old));
X cins_cur_chars(new,buff,clength(old));
X crewind(new);
X return new;
X}
Xlong clength(cont)
XContainer cont;
X{
X return mflength(cont);
X}
X
Xchar *cget_nth_line(cont,n)
XContainer cont;
Xint n;
X{
X char c;
X char *str;
X int m = 0;
X int i;
X mfseek(cont,0,0);
X
X while (n >= 0) {
X m = 0;
X c = mfgetc(cont);
X while ((c != EOF) && (c != '\n')) {
X c = mfgetc(cont);
X m++;
X }
X if (c == EOF) {
X break;
X }
X n--;
X }
X mfseek(cont,-(m+1),1);
X str = (char *) malloc(sizeof(char) * (m + 1));
X for (i = 0; i < m; i++) {
X str[i] = mfgetc(cont);
X }
X str[m] = '\0';
X return str;
X}
Xint cfind_nth_line(cont,n)
XContainer cont;
Xint n;
X{
X char c;
X char *str;
X int m = 0;
X int i;
X
X while (n >= 0) {
X m = 0;
X c = mfgetc(cont);
X while ((c != EOF) && (c != '\n')) {
X c = mfgetc(cont);
X m++;
X }
X if (c == EOF) {
X break;
X }
X n--;
X }
X mfseek(cont,-(m+1),1);
X return m;
X}
X
Xint cfind_nth_item(cont,n)
XContainer cont;
Xint n;
X{
X char c;
X char *str;
X int m = 0;
X int i;
X
X while (n >= 0) {
X m = 0;
X c = mfgetc(cont);
X while ((c != EOF) && (c != ',')) {
X c = mfgetc(cont);
X m++;
X }
X if (c == EOF) {
X break;
X }
X n--;
X }
X mfseek(cont,-(m+1),1);
X return m;
X}
X
X#define WHITE_SPACE(x) ((c == ' ') || (c == '\n') || (c == '\t'))
X
Xint cfind_nth_word(cont,n)
XContainer cont;
Xint n;
X{
X char c;
X char *str;
X int m = 0;
X int i;
X
X while (n >= 0) {
X m = 0;
X c = mfgetc(cont);
X while (WHITE_SPACE(c)) {
X c = mfgetc(cont);
X }
X while (!WHITE_SPACE(c)) {
X if (c == EOF) {
X if (n != 0) {
X return NULL;
X }
X mfseek(cont,-(m),1);
X return m;
X break;
X }
X
X c = mfgetc(cont);
X m++;
X }
X n--;
X }
X mfseek(cont,-(m+1),1);
X return m;
X}
X
Xchar *cget_nth_word(cont,n)
XContainer cont;
Xint n;
X{
X int length;
X char *temp;
X length = cfind_nth_word(cont,n);
X temp = (char *) malloc(sizeof(char) * (length + 1));
X mfread(cont,temp,length);
X temp[length] = '\0';
X return temp;
X}
Xchar *cget_nth_item(cont,n)
Xint n;
XContainer cont;
X{
X int length;
X char *temp;
X length = cfind_nth_item(cont,n);
X temp = (char *) malloc(sizeof(char) * (length + 1));
X mfread(cont,temp,length);
X return temp;
X}
Xchar *cget_cur_chars(cont,length)
XContainer cont;
Xint length;
X{
X char *temp;
X temp = (char *) malloc(sizeof(char) * (length + 1));
X mfread(cont,temp,length);
X return temp;
X}
Xint cget_numwords(cont)
XContainer cont;
X{
X int len;
X char c;
X int n;
X char *str;
X int m = 0;
X int i;
X c = 'a';
X mfseek(cont,0,0);
X n = 0;
X while (c != EOF) {
X m = 0;
X c = mfgetc(cont);
X while (WHITE_SPACE(c)) {
X c = mfgetc(cont);
X }
X while (!WHITE_SPACE(c)) {
X if (c == EOF)
X break;
X c = mfgetc(cont);
X m++;
X }
X n++;
X if (c == EOF) {
X return n;
X }
X }
X return n;
X}
Xint cget_numlines(cont)
XContainer cont;
X{
X char c,l;
X int n;
X char *str;
X mfseek(cont,0,0);
X n = 0;
X c = '!';
X while (c != EOF) {
X l = c;
X c = mfgetc(cont);
X if (c == '\n') {
X n++;
X }
X }
X if (l == '\n') {
X return n;
X }
X return n+1;
X}
X
Xvoid cdel_cur_chars(cont,n)
XContainer cont;
Xint n;
X{
X mfdelete(cont,n);
X}
X
Xvoid cins_cur_chars(cont,ptr,n)
XContainer cont;
Xchar *ptr;
Xint n;
X{
X mfinsert(cont,ptr,n);
X}
SHAR_EOF
if test 4285 -ne "`wc -c < 'container.c'`"
then
echo shar: error transmitting "'container.c'" '(should have been 4285 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'continue.hyp'" '(3230 characters)'
if test -f 'continue.hyp'
then
echo shar: will not over-write existing file "'continue.hyp'"
else
sed 's/^ X//' << \SHAR_EOF > 'continue.hyp'
XRecursionTest
X^
XRecursionTest^
X^
X#
X# send the message param() with param param() to all items.
X#
XinterceptSelfBroadcast:
X{
X stderr(" --- " $$ self() $$ ": caught interceptSelfBroadcast.");
X for(i = 0; i < numpanes(self()); i++) {
X pane = getnthpane(self(), i);
X stderr(" --- --- pane == " $$ pane );
X for(j = 0; j < numitems(pane); ++j) {
X item = getnthitem(pane, j);
X stderr(" --- --- --- item == " $$ item);
X send(param(), item, param());
X }
X }
X}.
X
X^
X1
XToys
X^
X^
X^
X
X^
X6
XCount
XCount:
X0
X0
X^
X
X^
X^
X1^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X10^
X205 60 0 0 0 0
X^
X^
XRecursionTest
XRecursion Test
X1
X0
X^
XmouseDown:
X{
X count = getitemval("!Toys#Count");
X stderr("Recursion to depth " $$ count $$ " starting." );
X send("recurseDeeply", self(), count);
X stderr("Done.");
X}.
X
XrecurseDeeply:
X{
X count = param();
X if(--count > 1)
X send("recurseDeeply", self(), count);
X}.
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X10 60 0 0 0 0
X^
X^
XC
XC
X1
X0
X^
XmouseUp:
X{
X open("..");
X close(".");
X}.
X
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X205 10 0 0 -1 0
X^
X^
XMessageTest
XMessage Test
X1
X0
X^
XmouseDown:
X{
X count = getitemval("!Toys#Count");
X stderr("Passing " $$ count $$ " messages." );
X for(i = 0; i < count; i++)
X send("testMessage", self(), "");
X stderr("Done.");
X}.
X
XtestMessage:
X{
X return "";
X}.
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X10 35 0 0 12 0
X^
X^
XScriptTest
XScript Test
X1
X0
X^
X#
X# master test script
X#
XmouseDown:
X{
X count = getitemval("!Toys#Count");
X send("performBroadcastTest", self(), count);
X if(send("performControlTest", self(), count) == "failure")
X stderr("Control test failed.");
X stderr("Done.");
X}.
X#
X# test 1: broadcast a message to ".", which spreads it downward,
X# and acknowledge receipt.
X#
XperformBroadcastTest:
X{
X count = param();
X stderr("===== Begin broadcast test =====" );
X broadcast("interceptSelfBroadcast", ".", "itemIntercept");
X stderr("===== End broadcast test =====" );
X}.
XitemIntercept:
X{
X stderr(" --- itemIntercept caught in " $$ self() );
X stderr(" --- test successful.");
X}.
X#
X# test 2: exercise control flow structures
X#
XperformControlTest:
X{
X n = 31;
X limit = 99;
X stderr("===== Flow of Control Test =====");
X#
X# single-level break
X#
X stderr(" --- single-level break test:");
X for(i = 0; i < limit; i++) {
X if(i == n)
X break;
X }
X if(i == n)
X stderr( " --- --- success");
X else {
X stderr( " --- --- FAILURE i == " $$ i);
X return "failure";
X }
X#
X# multi-level break
X#
X stderr(" --- multi-level break test:");
X for(i = 0; i < 5; i++) {
X for(j = 0; j < limit; j++)
X if(j == n)
X break;
X if(j != n) {
X stderr(" --- --- FAILURE j == " $$ j);
X return "failure";
X }
X }
X if(i == 5)
X stderr( " --- --- success");
X else {
X stderr( " --- --- FAILURE i == " $$ i);
X return "failure";
X }
X#
X# single-level continue
X#
X stderr(" --- single-level continue test:");
X for(i = 0; i < limit; i++) {
X if(i == n)
X continue;
X if(i == n) {
X stderr( " --- --- FAILURE in continue.");
X return "failure";
X }
X }
X stderr( " --- --- success");
X}.
X
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X10 10 0 0 28 0
X^
X^
XSaveState
XSave State
X1
X0
X^
XmouseDown:
X{
X savestate();
X}.
X
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X^
X205 35 0 0 -2147483648 0
X^
X^
X772 243 349 126 0 1
X^
X^
X1
X!Toys
X0 0 349 126 0 0
X^
X^
X0
X743 65 359 149 0 0
X^
X99 126 132^
X^
X1^
X/RecursionTest!Toys#Count
X+
SHAR_EOF
if test 3230 -ne "`wc -c < 'continue.hyp'`"
then
echo shar: error transmitting "'continue.hyp'" '(should have been 3230 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'deque.c'" '(1929 characters)'
if test -f 'deque.c'
then
echo shar: will not over-write existing file "'deque.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'deque.c'
X#include <stdio.h>
X#include "util.h"
X#include <sys/param.h>
X
X#define KNOWN_USED_BY_SUNVIEW 19
X#define MAX_NUM_FILES (NOFILE-KNOWN_USED_BY_SUNVIEW)
X
Xstatic int fds_inuse = 0;
X
X
Xtypedef struct qnode {
X struct qnode *next;
X struct qnode *prev;
X void *ptr_data;
X int client_data;
X int tl_not_obj;
X} QND,*QNDPtr;
X
Xstatic QNDPtr front = NULL;
Xstatic QNDPtr rear = NULL;
X
Xstatic QNDPtr make_qnode()
X{
X QNDPtr temp;
X temp = (QNDPtr) malloc(sizeof(QND) * 1);
X return temp;
X}
X
Xstatic void unmake_qnode(q)
XQNDPtr q;
X{
X free(q);
X}
X
Xadd_frontq(ptr,numfiles,tl_not_obj)
Xvoid *ptr;
Xint numfiles;
Xint tl_not_obj;
X{
X QNDPtr temp;
X void *rptr;
X temp = make_qnode();
X del_q(ptr);
X temp->ptr_data = ptr;
X temp->client_data = numfiles;
X fds_inuse += numfiles;
X temp->next = front;
X if (front == NULL) {
X front = temp;
X rear = temp;
X } else {
X front->prev = temp;
X }
X temp->prev = NULL;
X temp->tl_not_obj = tl_not_obj;
X front = temp;
X if (rear == NULL)
X rear = front;
X while (fds_inuse > MAX_NUM_FILES) {
X if (rear == NULL) {
X mywarning("Too many file descriptors in use!!!\n");
X break;
X }
X rptr = rear->ptr_data;
X if (rear->tl_not_obj) {
X close_tl(rptr);
X } else {
X close_obj(rptr);
X }
X del_q(rptr);
X }
X}
Xlast_window()
X{
X if (front == NULL) {
X return 1;
X } else {
X if (front->next == NULL) {
X return 1;
X }
X }
X return 0;
X}
Xdel_q(ptr)
Xvoid *ptr;
X{
X QNDPtr temp;
X temp = front;
X while (temp != NULL) {
X if (temp->ptr_data == ptr) {
X fds_inuse -= (int) temp->client_data;
X if (temp->next != NULL) {
X temp->next->prev = temp->prev;
X }
X if (temp->prev != NULL) {
X temp->prev->next = temp->next;
X }
X if (temp == front) {
X front = temp->next;
X }
X if (temp == rear) {
X rear = temp->prev;
X }
X unmake_qnode(temp);
X break;
X } else {
X temp = temp->next;
X }
X }
X}
SHAR_EOF
if test 1929 -ne "`wc -c < 'deque.c'`"
then
echo shar: error transmitting "'deque.c'" '(should have been 1929 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'deque.h'" '(23 characters)'
if test -f 'deque.h'
then
echo shar: will not over-write existing file "'deque.h'"
else
sed 's/^ X//' << \SHAR_EOF > 'deque.h'
Xadd_frontq();
Xdel_q();
SHAR_EOF
if test 23 -ne "`wc -c < 'deque.h'`"
then
echo shar: error transmitting "'deque.h'" '(should have been 23 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'dialogue.c'" '(3047 characters)'
if test -f 'dialogue.c'
then
echo shar: will not over-write existing file "'dialogue.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'dialogue.c'
X/*********************************************************/
X#ifndef lint
Xstatic char sccsid[] = "@(#)confirm.c 1.1 87/01/08 Copyr 1986 Sun Micro";
X#endif
X/*********************************************************/
X
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include <stdio.h>
X/*
X** FIX 8/16/88 including util.h
X*/
X#include "util.h"
X
Xstatic Frame init_asker();
Xstatic int confirm();
Xstatic void yes_no_ok();
Xstatic Panel_item ans_item;
X
Xstatic char *answer;
X
Xchar *scr_ask(message)
Xchar *message;
X{
X Frame asker;
X FILE *fd;
X int i;
X
X /* create the confirmer */
X asker = init_asker(message);
X
X /* make the user answer */
X window_loop(asker);
X
X /* destroy the confirmer */
X window_set(asker, FRAME_NO_CONFIRM, TRUE, 0);
X window_destroy(asker);
X notify_post_destroy(asker,DESTROY_CLEANUP,NOTIFY_IMMEDIATE);
X for (i = 0; i < 1; i++) {
X notify_dispatch();
X }
X
X return answer;
X}
X
X
Xstatic Frame
Xinit_asker(message)
Xchar *message;
X{
X Frame asker;
X Panel panel;
X Panel_item message_item;
X int left, top, width, height;
X Rect *r;
X struct pixrect *pr;
X
X asker = window_create(0, FRAME, 0);
X window_set(asker,FRAME_SHOW_LABEL, FALSE,0);
X
X panel = window_create(asker, PANEL, 0);
X message_item = panel_create_item(panel, PANEL_MESSAGE,
X PANEL_LABEL_STRING, mystrcpy(message),
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(1),
X 0);
X ans_item = panel_create_item(panel, PANEL_TEXT,
X PANEL_NOTIFY_LEVEL, PANEL_NON_PRINTABLE,
X PANEL_VALUE_DISPLAY_LENGTH, 40,
X PANEL_ITEM_X, ATTR_COL(5),
X PANEL_ITEM_Y, ATTR_ROW(2),
X 0);
X pr = panel_button_image(panel, "CANCEL", 3, 0);
X width = 2 * pr->pr_width + 10;
X
X
X r = (Rect *) panel_get(ans_item, PANEL_ITEM_RECT);
X
X /* center the yes/no or ok buttons under the message */
X left = (r->r_width - width) / 2;
X if (left < 0)
X left = 0;
X top = rect_bottom(r) + 5;
X
X
X
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_ITEM_X, left, PANEL_ITEM_Y, top,
X PANEL_LABEL_IMAGE, pr,
X PANEL_CLIENT_DATA, 0,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X panel_create_item(panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE, panel_button_image(panel, "OK", 3, 0),
X PANEL_CLIENT_DATA, 1,
X PANEL_NOTIFY_PROC, yes_no_ok,
X 0);
X
X
X window_fit(panel);
X window_fit(asker);
X
X /* center the asker frame on the screen */
X
X r = (Rect *) window_get(asker, WIN_SCREEN_RECT);
X
X width = (int) window_get(asker, WIN_WIDTH);
X height = (int) window_get(asker, WIN_HEIGHT);
X
X left = (r->r_width - width) / 2;
X top = (r->r_height - height) / 2;
X
X if (left < 0)
X left = 0;
X if (top < 0)
X top = 0;
X
X window_set(asker, WIN_X, left, WIN_Y, top, 0);
X
X return asker;
X}
X
X
X/* yes/no/ok notify proc */
Xstatic void
Xyes_no_ok(item, event)
XPanel_item item;
XEvent *event;
X{
X int n;
X n = (int) panel_get(item, PANEL_CLIENT_DATA);
X if (n == 0) {
X answer = NULL;
X } else {
X answer = mystrcpy(panel_get(ans_item,PANEL_VALUE));
X }
X window_return(n);
X}
SHAR_EOF
if test 3047 -ne "`wc -c < 'dialogue.c'`"
then
echo shar: error transmitting "'dialogue.c'" '(should have been 3047 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'dialogue.h'" '(17 characters)'
if test -f 'dialogue.h'
then
echo shar: will not over-write existing file "'dialogue.h'"
else
sed 's/^ X//' << \SHAR_EOF > 'dialogue.h'
Xchar *scr_ask();
SHAR_EOF
if test 17 -ne "`wc -c < 'dialogue.h'`"
then
echo shar: error transmitting "'dialogue.h'" '(should have been 17 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'edit_cont.c'" '(1365 characters)'
if test -f 'edit_cont.c'
then
echo shar: will not over-write existing file "'edit_cont.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'edit_cont.c'
X#include <stdio.h>
X#include <signal.h>
X#include "../archives/container/container.h"
X#include "util.h"
X#include "../archives/mfile/mfile.h"
X#include "sighandler.h"
X
X/*
X** FIX 8/16/88 declaration for get_editor()
X*/
Xextern char *get_editor();
Xextern int editor_open;
Xextern int editor_done;
Xextern int editor_id;
X
Xvoid edit_cont(src,label)
XContainer src;
Xchar *label;
X{
X FILE *fd;
X char c;
X char *x;
X int i,j;
X char *argv[7];
X char tempfile[L_tmpnam + 1];
X
X tmpnam(tempfile);
X fd = fopen(tempfile,"w");
X if (fd == NULL) {
X fprintf(stderr,"open file failed\n");
X return;
X }
X x = cflatten(src);
X fprintf(fd,"%s",x);
X fclose(fd);
X if ((i = fork()) == 0) {
X close_all();
X argv[0] = "shelltool";
X argv[1] = "-Wl";
X argv[2] = label;
X argv[3] = "-c";
X argv[4] = get_editor();
X argv[5] = tempfile;
X argv[6] = NULL;
X execv("/usr/bin/shelltool",argv);
X exit(0);
X } else {
X wait_on_pid(i);
X }
X fd = fopen(tempfile,"r");
X if (fd == NULL) {
X fprintf(stderr,"open file failed\n");
X return;
X }
X crewind(src);
X c = getc(fd);
X while (c != EOF) {
X mfputc(src,c);
X c = getc(fd);
X }
X fclose(fd);
X unlink(tempfile);
X mftrunc(src);
X free(x);
X return;
X}
X
Xstatic int wait_on_pid(pid)
Xint pid;
X{
X editor_open = 1;
X editor_id = pid;
X editor_done = 0;
X while (!editor_done) {
X sleep(1);
X }
X}
X
SHAR_EOF
if test 1365 -ne "`wc -c < 'edit_cont.c'`"
then
echo shar: error transmitting "'edit_cont.c'" '(should have been 1365 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'emalloc.c'" '(213 characters)'
if test -f 'emalloc.c'
then
echo shar: will not over-write existing file "'emalloc.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'emalloc.c'
X#include <stdio.h>
X
Xvoid *emalloc(x)
Xint x;
X{
X void *p;
X if ((p = (void *) malloc(x)) != 0) {
X return p;
X }
X fprintf(stderr,"Malloc failed.\n");
X exit(4);
X}
Xvoid *efree(x)
Xvoid *x;
X{
X free(x);
X}
SHAR_EOF
if test 213 -ne "`wc -c < 'emalloc.c'`"
then
echo shar: error transmitting "'emalloc.c'" '(should have been 213 characters)'
fi
fi # end of overwriting check
echo shar: done with directory "'src'"
cd ..
# End of shell archive
exit 0
More information about the Comp.sources.sun
mailing list