diff options
Diffstat (limited to 'vendor/x11iraf/obmsh')
-rw-r--r-- | vendor/x11iraf/obmsh/.gdb_history | 58 | ||||
-rw-r--r-- | vendor/x11iraf/obmsh/Imakefile | 47 | ||||
-rw-r--r-- | vendor/x11iraf/obmsh/Imakefile.orig | 23 | ||||
-rw-r--r-- | vendor/x11iraf/obmsh/README | 11 | ||||
-rw-r--r-- | vendor/x11iraf/obmsh/obmsh.c | 127 | ||||
-rw-r--r-- | vendor/x11iraf/obmsh/obmsh.man | 71 | ||||
-rw-r--r-- | vendor/x11iraf/obmsh/obmsh.ps | 552 | ||||
-rwxr-xr-x | vendor/x11iraf/obmsh/puzzle | 330 | ||||
-rwxr-xr-x | vendor/x11iraf/obmsh/zz | 334 |
9 files changed, 1553 insertions, 0 deletions
diff --git a/vendor/x11iraf/obmsh/.gdb_history b/vendor/x11iraf/obmsh/.gdb_history new file mode 100644 index 00000000..1dbd3323 --- /dev/null +++ b/vendor/x11iraf/obmsh/.gdb_history @@ -0,0 +1,58 @@ +run puzzle +where +quit +run puzzle +list +p argc +p argv +quit +run puzzle +quit +run +dump +? +help +b main +run +p argc +p *argc +quit +run +where +list +p argc +b main +run +p argc +p argv +p *argv +quit +run +where +p argc +quit +run +quit +help trace +help tracepoints +help +help stack +help status +run puzzle +info +info frame +where +up +where +bt +s +where +quit +run +quit +run +quit +run +quit +run puzzle +quit diff --git a/vendor/x11iraf/obmsh/Imakefile b/vendor/x11iraf/obmsh/Imakefile new file mode 100644 index 00000000..8a67758a --- /dev/null +++ b/vendor/x11iraf/obmsh/Imakefile @@ -0,0 +1,47 @@ +# Imakefile for the OBM shell. + +X11IRAFDIR = ../ +#include <../X11IRAF.tmpl> + + CDEBUGFLAGS = -g + +/* Hack to build on NOAO HP systems where the Xmu and Xaw libs had to be added + * specially to the system they don't come with the default X11 development + * system. This also avoids the binary requiring the shared lib version on + * systems which may not have it. + */ +#if defined(HPArchitecture) && OSMajorVersion >= 10 + XMULIB = /usr/lib/X11R6/libXmu.a + XAWLIB = /usr/lib/X11R6/libXaw.a +#endif + + + LOCAL_LDFLAGS = $(X11IRAF_LDFLAGS) + EXTRA_INCLUDES = $(X11IRAF_INCLUDES) + OBMLIBS = LibObm LibXpm + MATHLIB = -lm + XAWLIB = LibXaw3d + + SRCS = obmsh.c + OBJS = obmsh.o + + +AllTarget(obmsh) + +NormalProgramTarget(obmsh,$(OBJS),,${OBMLIBS} XawClientLibs,$(MATHLIB)) + +#if InstallBinaries +install:: obmsh + -@if [ -d X11irafBinDir ]; then set +x; \ + else (set -x; $(MKDIRHIER) X11irafBinDir); fi + $(CP) obmsh X11irafBinDir +#endif + +#if InstallManuals +install:: + MakeDir(X11irafManDir) + $(CP) obmsh.man X11irafManDir/obmsh.1 +#endif + +DependTarget() + diff --git a/vendor/x11iraf/obmsh/Imakefile.orig b/vendor/x11iraf/obmsh/Imakefile.orig new file mode 100644 index 00000000..1462c251 --- /dev/null +++ b/vendor/x11iraf/obmsh/Imakefile.orig @@ -0,0 +1,23 @@ +# Imakefile for the OBM shell. + + CDEBUGFLAGS = -g + XAWLIB = -lXaw3d # set to Xaw3d for 3d look + BINDIR = /usr/local/bin + + LOCAL_LDFLAGS = -L../lib + EXTRA_INCLUDES = -I../include + OBMLIBS = -lobm -lXpm + MATHLIB = -lm + DEPOBM = ../lib/libobm.a + + SRCS = obmsh.c + OBJS = obmsh.o + +AllTarget(obmsh) + +NormalProgramTarget(obmsh,$(OBJS),${DEPOBM},${OBMLIBS} XawClientLibs,$(MATHLIB)) + +${DEPOBM}: + +InstallProgramWithFlags(obmsh, $(BINDIR), $(INSTUIDFLAGS)) +DependTarget() diff --git a/vendor/x11iraf/obmsh/README b/vendor/x11iraf/obmsh/README new file mode 100644 index 00000000..bd578d1d --- /dev/null +++ b/vendor/x11iraf/obmsh/README @@ -0,0 +1,11 @@ +OBMSH -- Unix shell for the IRAF Widget Server / Object Manager (OBM). + +Obmsh may be used to execute a GUI file by name, or may be given as the +shell executable (e.g. #!/usr/local/bin/obmsh) within a unix shell script +to write GUI script commands. + + Imakefile Build file + obmsh.c Source (doesn't take much!) + puzzle Sample OBMSH shell script (contributed by MJF) + +To build: xmkmf, make, make install. diff --git a/vendor/x11iraf/obmsh/obmsh.c b/vendor/x11iraf/obmsh/obmsh.c new file mode 100644 index 00000000..918aabf4 --- /dev/null +++ b/vendor/x11iraf/obmsh/obmsh.c @@ -0,0 +1,127 @@ +#include <stdio.h> +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> +#include <Obm.h> + +/* + * OBMSH -- GUI shell using the OBM (Object Manager) library. The GUI script + * to be executed may be read from either the standard input or a file. + */ + +/* Compatibility hacks. */ +#ifdef AUX +void *memmove(a,b,n) void *a; const void *b; size_t n; { bcopy(b,a,n); } +#else +#if defined(sun) && !defined(SYSV) +void *memmove(a,b,n) void *a, *b; int n; { bcopy(b,a,n); } +#endif +#endif + +/* Data. */ +XtAppContext app_context; +static char server[] = "server"; + +static void deactivate(); +static void output(); + + +/* MAIN -- OBMSH main program. + */ +main (argc, argv) +int argc; +char *argv[]; +{ + Widget toplevel; + XtPointer obm; + char **sv_argv; + int sv_argc; + char *fname; + + /* Get local copy of argc and argv. */ + if ((sv_argc = argc) > 0) { + sv_argv = (char **) XtMalloc (argc * sizeof(char *)); + memmove (sv_argv, argv, argc * sizeof(char *)); + } else + sv_argv = argv; + + /* Initialize applications context. */ + toplevel = XtAppInitialize (&app_context, "OBMsh", + (XrmOptionDescList) NULL, 0, &sv_argc, sv_argv, + (String *) NULL, (ArgList) NULL, 0); + + /* Free saved arglist. */ + free ((char *)sv_argv); + if (!toplevel) + exit (1); + + /* Initialize the object manager. */ + if (!(obm = (XtPointer) ObmOpen (app_context, argc, argv))) + exit (2); + ObmAddCallback (obm, OBMCB_deactivate|OBMCB_preserve, deactivate, obm); + ObmAddCallback (obm, OBMCB_clientOutput|OBMCB_preserve, output, obm); + + /* Open and execute the GUI file if there was one, otherwise read + * the GUI from the standard input. + */ + if (argc == 2) { + if (access (fname=argv[1],0) != 0) { + fprintf (stderr, "cannot open %s\n", fname); + exit (3); + } + if (ObmDeliverMsgFromFile (obm, server, fname) != 0) { + fprintf (stderr, "error executing GUI %s\n", fname); + exit (4); + } + } else { + register int ch; + register char *op; + char *message = (char *) XtMalloc (1024000); + + for (op=message; (ch = getc(stdin)) != EOF; ) + *op++ = ch; + *op++ = '\0'; + + ObmDeliverMsg (obm, server, message); + free (message); + } + + /* Activate the GUI. */ + ObmActivate (obm); + + /* EXECUTE */ + XtAppMainLoop (app_context); +} + + +/* DEACTIVATE -- The deactivate callback is called when deactivate is executed + * in the GUI. + */ +static void +deactivate (obm, toplevel) +XtPointer obm; +Widget toplevel; +{ + ObmClose (obm); + exit (0); +} + + +/* OUTPUT -- The output callback is called when the GUI sends data or requests + * to the "client" object, which is this routine in the case of obmsh. + */ +static void +output (obm, tcl, objname, key, string) +XtPointer obm; +XtPointer tcl; /* not used */ +char *objname; /* not used */ +int key; +char *string; +{ + if (key == 'q' || key == 'Q') { + ObmClose (obm); + exit (0); + } else { + printf ("key=%c(%03o) command = `%s'\n", key, key, string); + fflush (stdout); + } +} diff --git a/vendor/x11iraf/obmsh/obmsh.man b/vendor/x11iraf/obmsh/obmsh.man new file mode 100644 index 00000000..06d7a923 --- /dev/null +++ b/vendor/x11iraf/obmsh/obmsh.man @@ -0,0 +1,71 @@ +.\" @(#)obmsh.1 1.1 28-Aug-97 MJF +.TH OBMSH 1 "28 Aug 1997" "X11IRAF Project" +.SH NAME +obmsh \- Object Manager GUI script interpreter +.SH SYNOPSIS +\fBobmsh\fP [\fIfile\fP] +.SH DESCRIPTION +.LP +\fBObmsh\fP is a GUI command interpreter for the IRAF Widget Server / +Object Manager (OBM) that +executes commands read from the standard input or from a file. As with +other shell interpreters such as \fIcsh\fR if the program is a file +beginning with \fB#!\fR, the remainder of the first line specifies an +interpreter for the program, usually the path to the obmsh executable. +There are no arguments. + +OBM programs are Tcl scripts consisting of application widgets to be created, +resource values for those widgets, callback procedures, and OBM-specific +functions needed to create and activate the GUI. In applications such as +\fIXimtool\fR the GUI interacts with an underlying client program by passing +messages to the client, server (the object manager itself) or various +parameters or widgets in the script. Obmsh scripts have no client but +will execute a default callback that outputs the client message to the +standard output, the script will continue to run until a 'q' keystroke is +detected in a client message. + +Obmsh script support all features of the Tcl language but also provide a +builtin GUI capability. For applications which do not require a client +to perform more complex operations, the obmsh provides a fully featured +GUI scripting language. For more information on the IRAF Widget Server / +OBM contact iraf@noao.edu or see Tody, D. 1995, in ADASS IV Proceedings, +ASP Conf. Ser, Vol 77, p. 89. + +.SH EXAMPLE +.LP +The following GUI script program demonstrates a simple "hello world" +application: +.nf + + #!/usr/local/bin/obmsh + + reset-server + appInitialize hello Hello { + ! Application defaults for the hello world program. + Hello*objects:\\ + toplevel Form helloForm\\ + helloForm Label helloLabel\\ + helloForm Command quitButton + + *background: bisque + *helloLabel.label: Hello, world! + *quitButton.fromHoriz: helloLabel + *quitButton.label: Quit + } + + createObjects + proc quit args { send client gkey q; deactivate unmap } + send quitButton addCallback quit + activate + +.fi +If the file has execute permissions set the \fB#!\fR will invoke the obmsh +to execute the file, otherwise it may be running using either +.nf + + % obmsh hello.gui or % obmsh < hello.gui +.fi +.SH SEE ALSO +xgterm(1), ximtool(1) +.SH COPYRIGHT +Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. diff --git a/vendor/x11iraf/obmsh/obmsh.ps b/vendor/x11iraf/obmsh/obmsh.ps new file mode 100644 index 00000000..3a7a3d86 --- /dev/null +++ b/vendor/x11iraf/obmsh/obmsh.ps @@ -0,0 +1,552 @@ +%!PS-Adobe-1.0 +%%Creator: devps (Pipeline Associates, Inc.) +%%CreationDate: Thu Sep 11 15:23:56 1997 +%%Pages: (atend) +%%DocumentFonts: (atend) + +/X{exch}def +/r{rmoveto}def +/m{moveto}def +/l{lineto}def +/rl{rlineto}def +/lc{yc X xc X l st}def +/mc{yc X xc X m}def +/el{gs /a X def a div 1 X scale cp np a xc 2 div 0 360 arc st gr}def +/ar{cp 7 2 roll np xc 5 1 roll atan 3 1 roll atan X arc st}def +/sp{yc X xc X 6 2 roll yc X xc X 6 2 roll yc X xc X 6 2 roll ct}def +/st{stroke}def +/gs{gsave}def +/gr{grestore}def +/cp{currentpoint}def +/np{newpath}def +/ct{curveto}def +/m0{0 0 moveto}def +/BP{/devps-save save def m0}def +/EP{ +clear devps-save restore +showpage}def +/res 10.000000 def +/V{res neg div 792 add +currentpoint pop X +m}def +/H{res div +currentpoint X pop +moveto}def +/h{res div 0 r}def +/v{res neg div 0 X r}def +/xc{res div}def +/yc{res neg div 792 add}def +/S{X H show}def +/psize 10 def +/height 1 def +/slant 0 def +/FF{findfont X dup 12 div setlinewidth /psize X def + [psize 0 psize height mul slant sin slant cos div mul psize height mul 0 0] + makefont setfont}def +/shade{gs + /dy X def + /dx X def + np m + setgray + 0 dy rl + dx 0 rl + 0 dy neg rl + dx neg 0 rl + closepath + fill +gr}def +1 setlinecap +/R{/Times-Roman FF}def +/B{/Times-Bold FF}def +/I{/Times-Italic FF}def +/Y{/Symbol FF}def +%%EndProlog +%%Page: 1 1 +BP +/slant 0 def +/height 1.000000 def +10 R +10 R +480 V +900(OBMSH)S +1272(\()S +1321(1)S +1387(\))S +2787(USER COMMANDS )S +5060(OBMSH)S +5432(\()S +5481(1)S +5547(\))S +960 V +9 B +900(NAME)S +1080 V +10 R +1260(obmsh)S +1557(\261)S +1637(Object)S +1933(Manager)S +2317(GUI)S +2524(script)S +2776(interpreter)S +1248 V +9 B +900(SYNOPSIS)S +1368 V +10 B +1260(obmsh)S +10 R +1574([)S +10 I +1607(\256le)S +10 R +1729(])S +1536 V +9 B +900(DESCRIPTION)S +1656 V +10 B +1260(Obmsh)S +10 R +1611(is)S +1717(a)S +1800(GUI)S +2016(command)S +2449(interpreter)S +2903(for)S +3058(the)S +3219(IRAF)S +3486(Widget)S +3819(Server)S +4118(/)S +4185(Object)S +4491(Manager)S +4885(\(OBM\))S +5219(that)S +5409(exe-)S +1776 V +1260(cutes)S +1499(commands)S +1966(read)S +2171(from)S +2399(the)S +2555(standard)S +2927(input)S +3167(or)S +3284(from)S +3512(a)S +3590(\256le.)S +3807(As)S +3952(with)S +4164(other)S +4403(shell)S +4626(interpreters)S +5114(such)S +5331(as)S +10 I +5447(csh)S +1896 V +10 R +1260(if)S +1360(the)S +1521(program)S +1898(is)S +2004(a)S +2087(\256le)S +2254(beginning)S +2693(with)S +10 B +2910(#!)S +10 R +2993(,)S +3057(the)S +3218(remainder)S +3661(of)S +3783(the)S +3944(\256rst)S +4139(line)S +4329(speci\256es)S +4713(an)S +4847(interpreter)S +5302(for)S +5458(the)S +2016 V +1260(program,)S +1653(usually)S +1972(the)S +2124(path)S +2326(to)S +2434(the)S +2586(obmsh)S +2883(executable.)S +3394(There)S +3656(are)S +3807(no)S +3937(arguments.)S +2256 V +1260(OBM)S +1524(programs)S +1937(are)S +2095(Tcl)S +2265(scripts)S +2563(consisting)S +3006(of)S +3126(application)S +3607(widgets)S +3955(to)S +4070(be)S +4201(created,)S +4550(resource)S +4924(values)S +5216(for)S +5369(those)S +2376 V +1260(widgets,)S +1644(callback)S +2024(procedures,)S +2534(and)S +2726(OBM-speci\256c)S +3340(functions)S +3760(needed)S +4090(to)S +4216(create)S +4501(and)S +4692(activate)S +5049(the)S +5218(GUI.)S +5497(In)S +2496 V +1260(applications)S +1776(such)S +1992(as)S +10 I +2108(Ximtool)S +10 R +2458(the)S +2613(GUI)S +2823(interacts)S +3194(with)S +3405(an)S +3532(underlying)S +3998(client)S +4253(program)S +4624(by)S +4757(passing)S +5091(messages)S +5502(to)S +2616 V +1260(the)S +1414(client,)S +1693(server)S +1967(\(the)S +2153(object)S +2428(manager)S +2802(itself\))S +3066(or)S +3180(various)S +3505(parameters)S +3973(or)S +4087(widgets)S +4429(in)S +4538(the)S +4691(script.)S +4999(Obmsh)S +5319(scripts)S +2736 V +1260(have)S +1484(no)S +1620(client)S +1878(but)S +2042(will)S +2234(execute)S +2574(a)S +2655(default)S +2969(callback)S +3338(that)S +3525(outputs)S +3857(the)S +4016(client)S +4275(message)S +4650(to)S +4765(the)S +4924(standard)S +5299(output,)S +2856 V +1260(the)S +1412(script)S +1664(will)S +1850(continue)S +2224(to)S +2332(run)S +2495(until)S +2709(a)S +2783('q')S +2929(keystroke)S +3347(is)S +3444(detected)S +3806(in)S +3914(a)S +3988(client)S +4240(message.)S +3096 V +1260(Obmsh)S +1594(script)S +1861(support)S +2206(all)S +2351(features)S +2711(of)S +2840(the)S +3008(Tcl)S +3187(language)S +3593(but)S +3767(also)S +3974(provide)S +4325(a)S +4415(builtin)S +4723(GUI)S +4946(capability.)S +5441(For)S +3216 V +1260(applications)S +1787(which)S +2075(do)S +2219(not)S +2391(require)S +2717(a)S +2805(client)S +3070(to)S +3191(perform)S +3555(more)S +3803(complex)S +4190(operations,)S +4674(the)S +4839(obmsh)S +5149(provides)S +5536(a)S +3336 V +1260(fully)S +1482(featured)S +1841(GUI)S +2051(scripting)S +2434(language.)S +2882(For)S +3054(more)S +3292(information)S +3797(on)S +3930(the)S +4085(IRAF)S +4346(Widget)S +4674(Server)S +4968(/)S +5030(OBM)S +5292(contact)S +3456 V +1260(iraf@noao.edu)S +1883(or)S +1996(see)S +2153(Tody,)S +2419(D.)S +2546(1995,)S +2801(in)S +2909(ADASS)S +3267(IV)S +3402(Proceedings,)S +3945(ASP)S +4159(Conf.)S +4414(Ser,)S +4602(Vol)S +4782(77,)S +4937(p.)S +5042(89.)S +3744 V +9 B +900(EXAMPLE)S +3864 V +10 R +1260(The)S +1445(following)S +1864(GUI)S +2071(script)S +2323(program)S +2691(demonstrates)S +3248(a)S +3322(simple)S +3619("hello)S +3890(world")S +4194(application:)S +4104 V +1380(#!/usr/local/bin/obmsh)S +4344 V +1380(reset-server)S +4464 V +1380(appInitialize)S +1909(hello)S +2139(Hello)S +2391({)S +4584 V +1500(!)S +1563(Application)S +2065(defaults)S +2411(for)S +2557(the)S +2709(hello)S +2939(world)S +3202(program.)S +4704 V +1500(Hello)S +10 Y +1722(*)S +10 R +1772(objects:\\)S +4824 V +1740(toplevel)S +2700(Form)S +3157(helloForm\\)S +4944 V +1740(helloForm)S +2700(Label)S +3137(helloLabel\\)S +5064 V +1740(helloForm)S +2700(Command)S +3267(quitButton)S +5304 V +10 Y +1500(*)S +10 R +1550(background:)S +2559(bisque)S +5424 V +10 Y +1500(*)S +10 R +1550(helloLabel.label:)S +2554(Hello,)S +2831(world!)S +5544 V +10 Y +1500(*)S +10 R +1550(quitButton.fromHoriz:)S +2663(helloLabel)S +5664 V +10 Y +1500(*)S +10 R +1550(quitButton.label:)S +2556(Quit)S +5784 V +1380(})S +6024 V +1380(createObjects)S +6144 V +1380(proc)S +1587(quit)S +1773(args)S +1969({)S +2047(send)S +2260(client)S +2512(gkey)S +2736(q;)S +2844(deactivate)S +3278(unmap)S +3580(})S +6264 V +1380(send)S +1593(quitButton)S +2052(addCallback)S +2581(quit)S +6384 V +1380(activate)S +6624 V +1260(If)S +1361(the)S +1519(\256le)S +1683(has)S +1852(execute)S +2192(permissions)S +2706(set)S +2853(the)S +10 B +3011(#!)S +10 R +3130(will)S +3322(invoke)S +3630(the)S +3788(obmsh)S +4091(to)S +4205(execute)S +4545(the)S +4703(\256le,)S +4892(otherwise)S +5316(it)S +5408(may)S +6744 V +1260(be)S +1384(running)S +1725(using)S +1972(either)S +6984 V +1620(%)S +1733(obmsh)S +2030(hello.gui)S +2700(or)S +3090(%)S +3203(obmsh)S +3500(<)S +3586(hello.gui)S +7680 V +900(X11IRAF Project)S +2703(Last change: 28 Aug 1997)S +5530(1)S +7920 V +EP +%%Page: 2 2 +BP +/slant 0 def +/height 1.000000 def +10 R +10 R +480 V +900(OBMSH)S +1272(\()S +1321(1)S +1387(\))S +2787(USER COMMANDS )S +5060(OBMSH)S +5432(\()S +5481(1)S +5547(\))S +960 V +9 B +900(SEE)S +1112(ALSO)S +1080 V +10 R +1260(xgterm\(1\),)S +1714(ximtool\(1\))S +1248 V +9 B +900(COPYRIGHT)S +1368 V +10 R +1260(Copyright\(c\))S +1806(1986)S +2036(Association)S +2538(of)S +2651(Universities)S +3164(for)S +3310(Research)S +3705(in)S +3813(Astronomy)S +4293(Inc.)S +7680 V +900(X11IRAF Project)S +2703(Last change: 28 Aug 1997)S +5530(2)S +7920 V +EP +%%Trailer +%%DocumentFonts: Times-Roman Times-Bold Times-Italic Symbol +%%Pages: 2 +
\ No newline at end of file diff --git a/vendor/x11iraf/obmsh/puzzle b/vendor/x11iraf/obmsh/puzzle new file mode 100755 index 00000000..e43d04f4 --- /dev/null +++ b/vendor/x11iraf/obmsh/puzzle @@ -0,0 +1,330 @@ +#!/usr/local/bin/obmsh + +# PUZZLE.GUI -- A simple number re-ordering puzzle, kinda like the one my +# Dad would make me play on long car trips to shut me up.... +# +# History: 4/23/94 - written (MJF) +# 4/25/94 - Added timer and move counter labels + +reset-server +appInitialize puzzle Puzzle { + Puzzle*objects:\ + toplevel Paned puzzle\ + puzzle Form tForm\ + tForm Label timerLabel\ + tForm Toggle pauseButton\ + tForm Label movesLabel\ +\ + puzzle Form pForm\ + pForm Command pos11\ + pForm Command pos12\ + pForm Command pos13\ + pForm Command pos14\ + pForm Command pos15\ + pForm Command pos21\ + pForm Command pos22\ + pForm Command pos23\ + pForm Command pos24\ + pForm Command pos25\ + pForm Command pos31\ + pForm Command pos32\ + pForm Command pos33\ + pForm Command pos34\ + pForm Command pos35\ + pForm Command pos41\ + pForm Command pos42\ + pForm Command pos43\ + pForm Command pos44\ + pForm Command pos45\ + pForm Command pos51\ + pForm Command pos52\ + pForm Command pos53\ + pForm Command pos54\ + pForm Command pos55\ +\ + puzzle Form pCmd\ + pCmd Command newButton\ + pCmd Command quitButton + + *tForm*background: bisque3 + *tForm*showGrip: false + *tForm*resizeable: false + *tForm*Label.background: black + *tForm*Label.foreground: red + *tForm*Label.shadowWidth: 0 + *tForm*Label.borderWidth: 0 + *tForm*Command.background: grey80 + *tForm*Toggle.background: grey80 + *pForm*background: bisque3 + *pForm*showGrip: false + *pForm*resizeable: false + *pForm*Command.background: grey80 + *pCmd*background: bisque3 + *pCmd*Command.background: grey80 + *pCmd*resizeable: false + + *timerLabel.label: 0000 + *timerLabel.height: 30 + *timerLabel*font: *times-bold-r*24* + *pauseButton.label: Pause + *pauseButton.height: 30 + *pauseButton.fromHoriz: timerLabel + *pauseButton.horizDistance: 10 + *pauseButton*font: *times-bold-r*18* + *movesLabel.label: 0000 + *movesLabel.height: 30 + *movesLabel*font: *times-bold-r*24* + *movesLabel.fromHoriz: pauseButton + *movesLabel.horizDistance: 10 + + *pForm*width: 50 + *pForm*height: 50 + *pForm*horizDistance: 0 + *pForm*vertDistance: 0 + *pForm*Label.background: bisque3 + *pForm*Label.shadowWidth: 0 + *pForm*Label.borderWidth: 0 + *pForm*font: *times-bold-r*24* + + *pos12.fromHoriz: pos11 + *pos13.fromHoriz: pos12 + *pos14.fromHoriz: pos13 + *pos15.fromHoriz: pos14 + + *pos11.vertDistance: 2 + *pos12.vertDistance: 2 + *pos13.vertDistance: 2 + *pos14.vertDistance: 2 + *pos15.vertDistance: 2 + + *pos21.fromVert: pos11 + *pos21.horizDistance: 1 + *pos22.fromVert: pos12 + *pos22.fromHoriz: pos21 + *pos23.fromVert: pos13 + *pos23.fromHoriz: pos22 + *pos24.fromVert: pos14 + *pos24.fromHoriz: pos23 + *pos25.fromVert: pos15 + *pos25.fromHoriz: pos24 + + *pos31.fromVert: pos21 + *pos31.horizDistance: 1 + *pos32.fromHoriz: pos31 + *pos32.fromVert: pos22 + *pos33.fromVert: pos23 + *pos33.fromHoriz: pos32 + *pos34.fromVert: pos24 + *pos34.fromHoriz: pos33 + *pos35.fromVert: pos25 + *pos35.fromHoriz: pos34 + + *pos41.fromVert: pos31 + *pos41.horizDistance: 1 + *pos42.fromHoriz: pos41 + *pos42.fromVert: pos32 + *pos43.fromVert: pos33 + *pos43.fromHoriz: pos42 + *pos44.fromVert: pos34 + *pos44.fromHoriz: pos43 + *pos45.fromVert: pos35 + *pos45.fromHoriz: pos44 + + *pos51.fromVert: pos41 + *pos51.horizDistance: 1 + *pos52.fromHoriz: pos51 + *pos52.fromVert: pos42 + *pos53.fromVert: pos43 + *pos53.fromHoriz: pos52 + *pos54.fromVert: pos44 + *pos54.fromHoriz: pos53 + *pos55.fromVert: pos45 + *pos55.fromHoriz: pos54 + + *pCmd*Command.height: 30 + *pCmd*Command.width: 50 + *pCmd*Command.vertDistance: 12 + *pCmd*Command*font: *times-bold-r*18* + *newButton.label: New Game + *quitButton.fromHoriz: newButton + *quitButton.vertDistance: 5 + *quitButton.label: Quit +} + + +# Crank 'er up... +createObjects +activate + +# Should be a better way to randomize the start. +set space [ expr ( [pid] % 23 ) ] +set random "17 8 13 19 22 21 12 18 15 9 23 5 3 20 6 4 1 7 24 10 14 16 2 11" + +# Quit the game. +proc Quit args { + global timerId + + if {[send pauseButton get state] == 0} { + deleteTimedCallback $timerId + } + send client gkey q + deactivate unmap +} ; send quitButton addCallback Quit + + +# Initialize the game board. +proc Init args { + global space random + + set k $space + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + + for { set i 1 } { $i<=5 } { incr i } { + for { set j 1 } { $j<=5 } { incr j } { + set val [lindex $random $k] + if {[expr [expr $i == $ispace] && [expr $j == $jspace]]} { + send pForm unmanage pos$i$j + } else { + send pos$i$j "set label $val" + set k [ expr ($k == 23) ? 0 : [expr $k+1] ] + } + } + } +} ; Init + + +# Define the game buttons and positions. +set buttons { pos11 pos12 pos13 pos14 pos15 + pos21 pos22 pos23 pos24 pos25 + pos31 pos32 pos33 pos34 pos35 + pos41 pos42 pos43 pos44 pos45 + pos51 pos52 pos53 pos54 pos55 +} + +set indx 0 +for { set i 1 } { $i<=5 } { incr i } { + for { set j 1 } { $j<=5 } { incr j } { + set bpos(pos$i$j) "$i $j $indx" + incr indx + } +} + +# Take action when hitting a button. +proc Move { widget args } { + global space buttons bpos + + # If we've paused the game then don't move anything. + if {[send pauseButton get state] == 1} { + return + } + + # Get the position of the empty space. + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + + # Get the position of the current widget. + set i [ lindex $bpos($widget) 0] + set j [ lindex $bpos($widget) 1] + + # Now see if the current widget is next to the empty space, but not on + # a corner. + set xdiff [expr abs ([expr $ispace-$i])] + set ydiff [expr abs ([expr $jspace-$j])] + if { ! [expr [expr $xdiff == 1] && [expr $ydiff == 1]]} { + if {[expr [expr $xdiff < 2] && [expr $ydiff < 2]]} { + + # Manage the empty space. + manage_space $space + + # Set space label to current label. + set lab [send $widget get label] + send [lindex $buttons $space] "set label $lab" + + # Unmanage current space. + unmanage_space [lindex $bpos($widget) 2] + set space [lindex $bpos($widget) 2] + + # Update the number of times we've made a move. + update_nmoves + } + } + +} ; foreach item $buttons { send $item addCallback Move } + + +# Start a new game. +proc New_Game args { + global space time nmoves timerId + + # If we've paused the game then don't do anything. + if {[send pauseButton get state] == 1} { + return + } + manage_space $space + new_space + Init + set nmoves -1 ; update_nmoves + set time 0 + deleteTimedCallback $timerId + send timerLabel set label 0000 + set timerId [postTimedCallback timer 1000] +} ; send newButton addCallback New_Game + + +# Get a new empty space. +proc new_space args { + global space random + set space [lindex $random [ expr ($space >= 23) ? 0 : $space ] ] + if {$space == 24} { set space 5 } +} + + +# Show a puzzle piece. +proc manage_space { space args } { + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + send pForm manage pos$ispace$jspace +} + + +# Remove a puzzle piece. +proc unmanage_space { space args } { + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + send pForm unmanage pos$ispace$jspace +} + + +# Install a timer so we can keep score of our best times. +set timerId 0 +set time 0 +proc timer args { + global timerId time + + send timerLabel set label [ format "%04d" $time ] + incr time + set timerId [postTimedCallback timer 1000] +}; set timerId [postTimedCallback timer 1000] + + +# Count the number of times we move a piece. +set nmoves 0 +proc update_nmoves args { + global nmoves + + incr nmoves + send movesLabel set label [ format "%04d" $nmoves ] +} + + +# Define a 'pause' command in case the boss walks in... +proc pause_toggle args { + global timerId + + if {[send pauseButton get state] == 0} { + set timerId [postTimedCallback timer 1000] + } else { + deleteTimedCallback $timerId + } +} ; send pauseButton addCallback pause_toggle diff --git a/vendor/x11iraf/obmsh/zz b/vendor/x11iraf/obmsh/zz new file mode 100755 index 00000000..9419c0c5 --- /dev/null +++ b/vendor/x11iraf/obmsh/zz @@ -0,0 +1,334 @@ +#!/usr/local/bin/obmsh + +# PUZZLE.GUI -- A simple number re-ordering puzzle, kinda like the one my +# Dad would make me play on long car trips to shut me up.... +# +# History: 4/23/94 - written (MJF) +# 4/25/94 - Added timer and move counter labels + +reset-server +appInitialize puzzle Puzzle { + Puzzle*objects:\ + toplevel Paned puzzle\ + puzzle Form tForm\ + tForm Label timerLabel\ + tForm Toggle pauseButton\ + tForm Label movesLabel\ +\ + puzzle Form pForm\ + pForm Command pos11\ + pForm Command pos12\ + pForm Command pos13\ + pForm Command pos14\ + pForm Command pos15\ + pForm Command pos21\ + pForm Command pos22\ + pForm Command pos23\ + pForm Command pos24\ + pForm Command pos25\ + pForm Command pos31\ + pForm Command pos32\ + pForm Command pos33\ + pForm Command pos34\ + pForm Command pos35\ + pForm Command pos41\ + pForm Command pos42\ + pForm Command pos43\ + pForm Command pos44\ + pForm Command pos45\ + pForm Command pos51\ + pForm Command pos52\ + pForm Command pos53\ + pForm Command pos54\ + pForm Command pos55\ +\ + puzzle Form pCmd\ + pCmd Command newButton\ + pCmd Command quitButton + + *tForm*background: bisque3 + *tForm*showGrip: false + *tForm*resizeable: false + *tForm*Label.background: black + *tForm*Label.foreground: red + *tForm*Label.shadowWidth: 0 + *tForm*Label.borderWidth: 0 + *tForm*Command.background: grey80 + *tForm*Toggle.background: grey80 + *pForm*background: bisque3 + *pForm*showGrip: false + *pForm*resizeable: false + *pForm*Command.background: grey80 + *pCmd*background: bisque3 + *pCmd*Command.background: grey80 + *pCmd*resizeable: false + + *timerLabel.label: 0000 + *timerLabel.height: 30 + *timerLabel*font: *times-bold-r*24* + *pauseButton.label: Pause + *pauseButton.height: 30 + *pauseButton.fromHoriz: timerLabel + *pauseButton.horizDistance: 10 + *pauseButton*font: *times-bold-r*18* + *movesLabel.label: 0000 + *movesLabel.height: 30 + *movesLabel*font: *times-bold-r*24* + *movesLabel.fromHoriz: pauseButton + *movesLabel.horizDistance: 10 + + *pForm*width: 50 + *pForm*height: 50 + *pForm*horizDistance: 0 + *pForm*vertDistance: 0 + *pForm*Label.background: bisque3 + *pForm*Label.shadowWidth: 0 + *pForm*Label.borderWidth: 0 + *pForm*font: *times-bold-r*24* + + *pos12.fromHoriz: pos11 + *pos13.fromHoriz: pos12 + *pos14.fromHoriz: pos13 + *pos15.fromHoriz: pos14 + + *pos11.vertDistance: 2 + *pos12.vertDistance: 2 + *pos13.vertDistance: 2 + *pos14.vertDistance: 2 + *pos15.vertDistance: 2 + + *pos21.fromVert: pos11 + *pos21.horizDistance: 1 + *pos22.fromVert: pos12 + *pos22.fromHoriz: pos21 + *pos23.fromVert: pos13 + *pos23.fromHoriz: pos22 + *pos24.fromVert: pos14 + *pos24.fromHoriz: pos23 + *pos25.fromVert: pos15 + *pos25.fromHoriz: pos24 + + *pos31.fromVert: pos21 + *pos31.horizDistance: 1 + *pos32.fromHoriz: pos31 + *pos32.fromVert: pos22 + *pos33.fromVert: pos23 + *pos33.fromHoriz: pos32 + *pos34.fromVert: pos24 + *pos34.fromHoriz: pos33 + *pos35.fromVert: pos25 + *pos35.fromHoriz: pos34 + + *pos41.fromVert: pos31 + *pos41.horizDistance: 1 + *pos42.fromHoriz: pos41 + *pos42.fromVert: pos32 + *pos43.fromVert: pos33 + *pos43.fromHoriz: pos42 + *pos44.fromVert: pos34 + *pos44.fromHoriz: pos43 + *pos45.fromVert: pos35 + *pos45.fromHoriz: pos44 + + *pos51.fromVert: pos41 + *pos51.horizDistance: 1 + *pos52.fromHoriz: pos51 + *pos52.fromVert: pos42 + *pos53.fromVert: pos43 + *pos53.fromHoriz: pos52 + *pos54.fromVert: pos44 + *pos54.fromHoriz: pos53 + *pos55.fromVert: pos45 + *pos55.fromHoriz: pos54 + + *pCmd*Command.height: 30 + *pCmd*Command.width: 50 + *pCmd*Command.vertDistance: 12 + *pCmd*Command*font: *times-bold-r*18* + *newButton.label: New Game + *quitButton.fromHoriz: newButton + *quitButton.vertDistance: 5 + *quitButton.label: Quit +} + + +# Crank 'er up... +createObjects +activate + +# Should be a better way to randomize the start. +set space [ expr ( [pid] % 23 ) ] +set random "17 8 13 19 22 21 12 18 15 9 23 5 3 20 6 4 1 7 24 10 14 16 2 11" + +print [format "test %05d" 123456] + +# Quit the game. +proc Quit args { + global timerId + + if {[send pauseButton get state] == 0} { + deleteTimedCallback $timerId + } + send client gkey q + deactivate unmap +} ; send quitButton addCallback Quit + + +# Initialize the game board. +proc Init args { + global space random + + set k $space + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + + for { set i 1 } { $i<=5 } { incr i } { + for { set j 1 } { $j<=5 } { incr j } { + set val [lindex $random $k] + if {[expr [expr $i == $ispace] && [expr $j == $jspace]]} { + send pForm unmanage pos$i$j + } else { + send pos$i$j "set label $val" + set k [ expr ($k == 23) ? 0 : [expr $k+1] ] + } + } + } +} ; Init + + +# Define the game buttons and positions. +set buttons { pos11 pos12 pos13 pos14 pos15 + pos21 pos22 pos23 pos24 pos25 + pos31 pos32 pos33 pos34 pos35 + pos41 pos42 pos43 pos44 pos45 + pos51 pos52 pos53 pos54 pos55 +} + +set indx 0 +for { set i 1 } { $i<=5 } { incr i } { + for { set j 1 } { $j<=5 } { incr j } { + set bpos(pos$i$j) "$i $j $indx" + incr indx + } +} + +# Take action when hitting a button. +proc Move { widget args } { + global space buttons bpos + + # If we've paused the game then don't move anything. + if {[send pauseButton get state] == 1} { + return + } + + # Get the position of the empty space. + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + + # Get the position of the current widget. + set i [ lindex $bpos($widget) 0] + set j [ lindex $bpos($widget) 1] + + # Now see if the current widget is next to the empty space, but not on + # a corner. + set xdiff [expr abs ([expr $ispace-$i])] + set ydiff [expr abs ([expr $jspace-$j])] + if { ! [expr [expr $xdiff == 1] && [expr $ydiff == 1]]} { + if {[expr [expr $xdiff < 2] && [expr $ydiff < 2]]} { + + # Manage the empty space. + manage_space $space + + # Set space label to current label. + set lab [send $widget get label] + send [lindex $buttons $space] "set label $lab" + + # Unmanage current space. + unmanage_space [lindex $bpos($widget) 2] + set space [lindex $bpos($widget) 2] + + # Update the number of times we've made a move. + update_nmoves + } + } + +} ; foreach item $buttons { send $item addCallback Move } + + +# Start a new game. +proc New_Game args { + global space time nmoves timerId + + # If we've paused the game then don't do anything. + if {[send pauseButton get state] == 1} { + return + } + manage_space $space + new_space + Init + set nmoves -1 ; update_nmoves + set time 0 + deleteTimedCallback $timerId + send timerLabel set label 0000 + set timerId [postTimedCallback timer 1000] +} ; send newButton addCallback New_Game + + +# Get a new empty space. +proc new_space args { + global space random + set space [lindex $random [ expr ($space >= 23) ? 0 : $space ] ] + if {$space == 24} { set space 5 } +} + + +# Show a puzzle piece. +proc manage_space { space args } { + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + send pForm manage pos$ispace$jspace +} + + +# Remove a puzzle piece. +proc unmanage_space { space args } { + set ispace [ expr ($space / 5 + 1) ] + set jspace [ expr ($space % 5 + 1) ] + send pForm unmanage pos$ispace$jspace +} + + +# Install a timer so we can keep score of our best times. +set timerId 0 +set time 0 +proc timer args { + global timerId time + + send timerLabel set label [ format "%04d" $time ] + incr time + set timerId [postTimedCallback timer 1000] +}; set timerId [postTimedCallback timer 1000] + + +# Count the number of times we move a piece. +set nmoves 0 +proc update_nmoves args { + global nmoves + + incr nmoves + send movesLabel set label [ format "%04d" $nmoves ] +} + + +# Define a 'pause' command in case the boss walks in... +proc pause_toggle args { + global timerId + + if {[send pauseButton get state] == 0} { + set timerId [postTimedCallback timer 1000] + } else { + deleteTimedCallback $timerId + } +} ; send pauseButton addCallback pause_toggle + + |