home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-11-20 | 57.3 KB | 2,149 lines |
- Path: sparky!uunet!stanford.edu!morrow.stanford.edu!sep!steve
- From: steve@sep.Stanford.EDU (Steve Cole)
- Newsgroups: alt.sources
- Subject: xtpanel 2.0 - interactive program builder - part 05/10
- Followup-To: alt.sources.d
- Date: 21 Nov 1992 00:32:14 GMT
- Organization: Stanford Exploration Project
- Lines: 2136
- Distribution: world
- Message-ID: <1ek02eINN194@morrow.stanford.edu>
- NNTP-Posting-Host: taal.stanford.edu
-
-
- Submitted-by: steve@sep.Stanford.EDU
- Archive-name: xtpanel/part05
-
- #!/bin/sh
- # This is part 05 of a multipart archive
- # ============= xtpanel/main.c ==============
- if test ! -d 'xtpanel'; then
- echo 'x - creating directory xtpanel'
- mkdir 'xtpanel'
- fi
- if test -f 'xtpanel/main.c' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/main.c (File already exists)'
- else
- echo 'x - extracting xtpanel/main.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/main.c' &&
- /*
- X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
- X * University. Official permission to use this software is included in
- X * the documentation. It authorizes you to use this file for any
- X * non-commercial purpose, provided that this copyright notice is not
- X * removed and that any modifications made to this file are commented
- X * and dated in the style of the example below.
- X */
- X
- /*
- X *
- X * source file: ./xtpanel/main.c
- X *
- X * Steve Cole, Dave Nichols (SEP), August 28 1992
- X * Inserted this sample edit history entry.
- X * Please log any further modifications made to this file:
- X * Steve Cole, Dave Nichols (SEP), November 20 1992 - version 2.00
- X * 1) added new objects: toggle, scrollbar, graph.
- X * 2) added new actions: ASSIGN, SET.
- X * 3) objects can have multiple actions.
- X * 4) backquoted strings in actions get executed at action time.
- X */
- X
- #include "patchlevel.h"
- X
- #include <stdio.h>
- #include <X11/Intrinsic.h>
- #include <X11/StringDefs.h>
- X
- #include <X11/Xaw/Box.h>
- #include <X11/Xaw/Cardinals.h>
- #include <X11/Xaw/Paned.h>
- #include <X11/Xmu/Converters.h>
- X
- #ifdef _POSIX_SOURCE
- #include <unistd.h>
- #else
- extern int isatty();
- #endif
- X
- #include "tree.h"
- #include "builders.h"
- X
- String fallback_resources[] = {
- X "*input: True",
- X "*Paned*resizable: True",
- X "*Dialog*command*label: ok",
- X "*command*label: ok",
- X "*Dialog*resizable: True",
- X "*Viewport*allowVert: True",
- X "*Box*allowResize: True",
- X "*Box*resizable: True",
- X /* give menus room for dots */
- X "*SimpleMenu*HorizontalMargins: 30",
- X "*Scrollbar*orientation: horizontal",
- X "*text*resizable: True",
- X "*Text*resizable: True",
- X "*text*scrollVertical: whenNeeded",
- X NULL,
- };
- X
- extern void return_key_callback(),dialog_update_callback();
- extern void text_update_callback(),graph_update_callback();
- X
- static XtActionsRec window_actions[] = {
- X {"return_key", return_key_callback},
- X {"update_dialog", dialog_update_callback},
- X {"update_text", text_update_callback},
- X {"update_graph", graph_update_callback},
- };
- X
- enum boxType{ NOBORDER, VBOX, HBOX, VPANE, HPANE };
- X
- int quitflag=0;
- X
- Widget toplevel;
- char* progname;
- X
- extern void quit_xtpanel(),parse_args();
- static void process_tree();
- X
- int main(argc,argv)
- X
- X int argc;
- X char **argv;
- {
- X XtAppContext app_con;
- X entry *root;
- X
- X toplevel = XtAppInitialize(&app_con, "XTpanel", NULL, ZERO,
- X &argc, argv, fallback_resources,
- X NULL, ZERO);
- X
- X XtAddCallback( toplevel, XtNdestroyCallback, quit_xtpanel, NULL);
- X
- X XtAppAddActions(app_con, window_actions, XtNumber(window_actions));
- X
- X /* make the root entry to the tree, it is called "root" */
- X root= new_entry( "root", 4);
- X
- X /* now go and parse what is left of the command line */
- X progname = strdupl( *argv );
- X argv++; argc--;
- X
- X parse_args( argc, argv, root );
- X
- X /* parse stdin if it pointing at something */
- X if( !isatty( fileno(stdin) ) ) parse_file( stdin, root );
- X
- X /* print tree for debugging */
- X /* print_entry( stderr,root,0 );*/
- X
- X /*now go and do something with the tree we have created */
- X process_tree( root,toplevel,NOBORDER );
- X
- X XtRealizeWidget(toplevel);
- X
- X /* do the action for all objects with action type string */
- X /* so that strings are set to something when they are needed */
- X all_actions();
- X
- X /* make panel just big enough to encompass all items */
- X /* pass control to notifier */
- X XtAppMainLoop(app_con);
- X
- X return 0;
- }
- X
- X
- /*
- X This routine take the fully parsed object tree and makes the
- X appropriate widgets from each object.
- X
- X The widgets are then added to the paned widget.
- X */
- X
- /* this routine may be called recursively (if the user defined sub boxes ) */
- X
- static void process_tree( root,parent,btype )
- X entry *root;
- X Widget parent;
- X enum boxType btype;
- {
- X entry* curr;
- X Widget box;
- X char *name;
- X Arg args[10];
- X int narg;
- X
- X switch (btype) {
- X case NOBORDER:
- X default:
- X /* a vertical box with no border */
- X /* used only for boxes made by xtpanel, which have no name */
- X narg=0;
- X box = XtCreateManagedWidget("noborder",boxWidgetClass,parent,
- X args,narg);
- X break;
- X case VBOX:
- X /* begin a new vertical (tall and thin) box */
- X name = get_value(root,"name","vbox");
- X narg=0;
- X common_tags(root,args,&narg,SET_ALL);
- X XtSetArg(args[narg], XtNorientation, XtorientVertical ); narg++;
- X box = XtCreateManagedWidget(name,boxWidgetClass,parent,args,narg);
- X break;
- X case HBOX:
- X /* begin a new horizontal box */
- X name = get_value(root,"name","hbox");
- X narg=0;
- X common_tags(root,args,&narg,SET_ALL);
- X XtSetArg(args[narg], XtNorientation, XtorientHorizontal ); narg++;
- X box = XtCreateManagedWidget(name,boxWidgetClass,parent,args,narg);
- X break;
- X case VPANE:
- X /* begin a new vertically paned widget */
- X name = get_value(root,"name","paned");
- X narg=0;
- X common_tags(root,args,&narg,SET_ALL);
- X XtSetArg(args[narg], XtNorientation, XtorientVertical ); narg++;
- X box = XtCreateManagedWidget(name,panedWidgetClass,parent,args,narg);
- X break;
- X case HPANE:
- X /* begin a new horizontally paned widget */
- X name = get_value(root,"name","paned");
- X narg=0;
- X common_tags(root,args,&narg,SET_ALL);
- X XtSetArg(args[narg], XtNorientation, XtorientHorizontal ); narg++;
- X box = XtCreateManagedWidget("paned",panedWidgetClass,parent,args,narg);
- X break;
- X }
- X
- X /* loop over first level of tree */
- X for( curr=root->child; curr != (entry*)0; curr=curr->next ){
- X
- X /* here is the big switch on item type */
- X
- X if( !strcmp( curr->tag, "box" ) || !strcmp( curr->tag, "vbox")){
- X /* recursively call process_tree, rooted at this entry */
- X process_tree( curr, box, VBOX);
- X
- X }else if( !strcmp( curr->tag, "hbox" ) ){
- X /* recursively call process_tree, rooted at this entry */
- X process_tree( curr, box, HBOX);
- X
- X }else if( !strcmp( curr->tag, "pane" ) || !strcmp( curr->tag,"vpane")){
- X process_tree( curr, box, VPANE);
- X
- X }else if( !strcmp( curr->tag, "hpane" ) ){
- X process_tree( curr, box, HPANE);
- X
- X }else if( !strcmp( curr->tag, "message" ) ){
- X build_message(curr,box);
- X
- X }else if( !strcmp( curr->tag, "button" ) ||
- X !strcmp( curr->tag, "toggle" )){
- X build_button(curr,box,curr->tag);
- X
- X }else if( !strcmp( curr->tag, "choice" ) ){
- X build_choice(curr,box);
- X
- X }else if( !strcmp( curr->tag, "slider" ) ||
- X !strcmp( curr->tag, "scrollbar" )){
- X build_slider(curr,box,curr->tag);
- X
- X }else if( !strcmp( curr->tag, "graph" ) ){
- X build_graph(curr,box);
- X
- X }else if( !strcmp( curr->tag, "menubutton" ) ){
- X build_menubutton(curr,box);
- X
- X }else if( !strcmp( curr->tag, "list" ) ){
- X build_list(curr,box);
- X
- X }else if( !strcmp( curr->tag, "dialog" ) ){
- X build_dialog(curr,box);
- X
- X }else if( !strcmp( curr->tag, "text" ) ){
- X build_text(curr,box);
- X
- X }else if( !strcmp( curr->tag, "var" ) ){
- X build_variable(curr,box);
- X
- X /* ignore tags specified for top level box */
- X }else if( !strcmp( curr->tag, "name" ) ||
- X !strcmp( curr->tag, "foreground" ) ||
- X !strcmp( curr->tag, "background" ) ||
- X !strcmp( curr->tag, "borderColor" ) ||
- X !strcmp( curr->tag, "height" ) ||
- X !strcmp( curr->tag, "width" ) ||
- X !strcmp( curr->tag, "orientation" ) ||
- X !strcmp( curr->tag, "bitmap" ) ||
- X !strcmp( curr->tag, "editType" ) ||
- X !strcmp( curr->tag, "font" )) {
- X
- X }else{
- X fprintf( stderr,"Unrecognised object type %s \n", curr->tag );
- X exit(-1);
- X }
- X
- X }
- X
- }
- X
- /*
- X * Function name: quit_xtpanel
- X * Description: quits by destroying toplevel widget.
- X * Arguments: none
- X * Returns: none
- X */
- void quit_xtpanel()
- {
- X extern Widget toplevel;
- X
- X XtDestroyWidget((Widget)toplevel);
- X exit(0);
- }
- X
- SHAR_EOF
- chmod 0664 xtpanel/main.c ||
- echo 'restore of xtpanel/main.c failed'
- Wc_c="`wc -c < 'xtpanel/main.c'`"
- test 7865 -eq "$Wc_c" ||
- echo 'xtpanel/main.c: original size 7865, current size' "$Wc_c"
- fi
- # ============= xtpanel/parse.c ==============
- if test -f 'xtpanel/parse.c' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/parse.c (File already exists)'
- else
- echo 'x - extracting xtpanel/parse.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/parse.c' &&
- /*
- X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
- X * University. Official permission to use this software is included in
- X * the documentation. It authorizes you to use this file for any
- X * non-commercial purpose, provided that this copyright notice is not
- X * removed and that any modifications made to this file are commented
- X * and dated in the style of the example below.
- X */
- X
- /*
- X *
- X * source file: ./xtpanel/parse.c
- X *
- X * Steve Cole, Dave Nichols (SEP), August 28 1992
- X * Inserted this sample edit history entry.
- X * Please log any further modifications made to this file:
- X * Steve Cole, Dave Nichols (SEP), November 20 1992 - version 2.00
- X * 1) added new objects: toggle, scrollbar, graph.
- X * 2) added new actions: ASSIGN, SET.
- X * 3) objects can have multiple actions.
- X * 4) backquoted strings in actions get executed at action time.
- X */
- X
- #include <sys/types.h>
- #include <sys/stat.h>
- X
- #include "tree.h"
- #include <stdio.h>
- #include <string.h>
- #include "string_buf.h"
- X
- #ifndef CPP_COM
- #define CPP_COM "/lib/cpp -P"
- #endif
- X
- #ifdef _POSIX_SOURCE
- X
- #include <limits.h>
- #ifdef MAX_PATH
- #define MAXPATHLEN PATH_MAX
- #else
- #define MAXPATHLEN _POSIX_PATH_MAX
- #endif
- X
- #include <unistd.h>
- X
- #else /* not posix */
- X
- #include <sys/param.h>
- X
- #ifndef MAXPATHLEN
- #define MAXPATHLEN 1024
- #endif
- extern char* getenv();
- X
- #endif /* not posix */
- X
- extern char* progname;
- X
- static void cpp_arg_scan();
- static void parse_file_named();
- void parse_file();
- static void usage();
- static void parse_item();
- static void parse_slider();
- static void parse_message();
- static void parse_dialog();
- static void parse_text();
- static void parse_variable();
- static void parse_button();
- static void parse_menubutton();
- static void parse_choice();
- static void parse_list();
- static void parse_scrollbar();
- static void parse_graph();
- X
- X
- /* parse the command line */
- void parse_args( argc, argv, root )
- int argc;
- char** argv;
- entry *root;
- {
- X entry *ent, *subent;
- X int use_cpp;
- X char *cpp_args;
- X
- /* no arguments and stdin is a terminal - do self-doc */
- if (argc == 0 && isatty(fileno(stdin))) {
- X usage();
- X exit(0);
- }
- X
- /* first argument -tty - take input from stdin if it is a tty */
- if (argc > 0) {
- X if (!strcmp( *argv, "-tty" ) ){
- X if( isatty( fileno(stdin))) {
- X (void) parse_file(stdin,root);
- X }
- X argv++; argc--;
- X }
- }
- X
- /* first argument -help - run the help script */
- if (argc > 0) {
- X if (!strcmp( *argv, "-help" ) ){
- X system("xtpanel -file help/help");
- X argv++; argc--;
- X if (argc == 0) exit(0);
- X }
- }
- X
- /* scan over the argument list looking for the -cpp flag and any
- X * C-preprocessor arguments, -I... and -D....
- X */
- cpp_arg_scan( &argc, &argv, &use_cpp, &cpp_args );
- X
- X
- /* process the rest of the command line */
- while(argc>0){
- X
- X ent = (entry*)0;
- X
- X if( !strcmp( *argv, "-quit" ) ){
- X ent = new_entry("button",6);
- X subent = new_entry( "name", 4 );
- X subent->value = strdupl("QUIT");
- X add_child( ent, subent );
- X subent = new_entry( "action", 6 );
- X subent->value = strdupl("QUIT");
- X add_child( ent, subent );
- X argv++; argc--;
- X
- X }else if( !strcmp( *argv, "-file" ) ){
- X argv++; argc--;
- X if( argc >0 ){
- X char* filename;
- X filename = *argv; argv++; argc--;
- X parse_file_named( filename, root, use_cpp, cpp_args );
- X }else{
- X fprintf(stderr,"expecting filename after \"-file\"\n");
- X usage(); exit(-1);
- X }
- X
- X }else if( !strcmp( *argv, "-button" ) ){
- X ent = new_entry("button", 6 ); argv++; argc--;
- X parse_button( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-slider" ) ){
- X ent = new_entry("slider", 6 ); argv++; argc--;
- X parse_slider( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-menubutton" ) ){
- X ent = new_entry("menubutton", 10 ); argv++; argc--;
- X parse_menubutton( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-text" ) ){
- X ent = new_entry("text", 4 ); argv++; argc--;
- X parse_text( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-dialog" ) ){
- X ent = new_entry("dialog", 6 ); argv++; argc--;
- X parse_dialog( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-choice" ) ){
- X ent = new_entry("choice", 6 ); argv++; argc--;
- X parse_choice( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-list" ) ){
- X ent = new_entry("list", 4 ); argv++; argc--;
- X parse_list( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-message" ) ){
- X ent = new_entry("message", 7 ); argv++; argc--;
- X parse_message( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-var" ) ){
- X ent = new_entry("var", 3 ); argv++; argc--;
- X parse_variable( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-toggle" ) ){
- X ent = new_entry("toggle", 6 ); argv++; argc--;
- X parse_button( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-scrollbar" ) ){
- X ent = new_entry("scrollbar", 9 ); argv++; argc--;
- X parse_scrollbar( &argc, &argv, ent );
- X
- X }else if( !strcmp( *argv, "-graph" ) ){
- X ent = new_entry("graph", 5 ); argv++; argc--;
- X parse_graph( &argc, &argv, ent );
- X
- X }else{
- X fprintf( stderr," unrecognised argument %s \n",*argv);
- X usage();
- X exit(-1);
- X }
- X
- X if( ent != (entry*)0 ) {
- X add_child( root, ent );
- X }
- X
- }
- }
- X
- X
- /* scan over the argument list looking for the -cpp flag and any
- X * C-preprocessor arguments, -I... and -D....
- X * remove all relevant arguments from the argument list
- X */
- X
- static void cpp_arg_scan( pargc, pargv, use_cpp, cpp_args )
- int *pargc;
- char*** pargv;
- int *use_cpp;
- char** cpp_args;
- {
- X
- int *keep_args,i;
- int num_keep=0;
- char** locargv= *pargv;
- int argc= *pargc;
- X
- *cpp_args = malloc(1024);
- strcpy( *cpp_args, "");
- X
- X keep_args = (int*)malloc( argc * sizeof(int) );
- X
- X *use_cpp = 0;
- X
- X for( i=0; i<argc; i++ ){
- X if( !strcmp( *locargv, "-cpp" ) ){
- X *use_cpp = 1;
- X }else if( !strncmp( *locargv, "-I", 2 )){
- X strcat( *cpp_args, *locargv );
- X strcat( *cpp_args, " " );
- X }else if( !strncmp( *locargv, "-D", 2 )){
- X strcat( *cpp_args, *locargv );
- X strcat( *cpp_args, " " );
- X }else{
- X keep_args[num_keep] = i;
- X num_keep++;
- X }
- X locargv++;
- X }
- X
- X /* now compress the argument list */
- X for( i=0 ; i<num_keep; i++ ){
- X (*pargv)[i] = (*pargv)[keep_args[i]];
- X }
- X *pargc = num_keep;
- X
- }
- X
- static char *find_file();
- X
- static void parse_file_named( filename , root, use_cpp, cpp_args )
- char *filename;
- entry *root;
- int use_cpp;
- char *cpp_args;
- {
- char* name;
- FILE* file;
- char cpp_command[1024];
- X
- X if( (name = find_file( filename )) == NULL ){
- X fprintf(stderr,"unable to find file %s\n",filename); exit(-1);
- X }else{
- X if( use_cpp ){
- X sprintf(cpp_command," %s <%s %s ",CPP_COM,name,cpp_args);
- X file = popen( cpp_command, "r" );
- X }else{
- X file = fopen( name, "r" );
- X }
- X
- X if( file == (FILE*)0 ){
- X fprintf(stderr,"unable to open file %s\n",name); exit(-1);
- X }else{
- X parse_file( file, root );
- X }
- X
- X if( use_cpp ){
- X pclose( file );
- X }else{
- X fclose( file );
- X }
- X }
- X
- }
- X
- /* parse a file */
- #define PARSE_LEN 5000
- char parse_buf[PARSE_LEN]; /* PARSE_LEN is the size of chunks to read */
- X
- void parse_file( file , root )
- FILE* file;
- entry* root;
- {
- X int num;
- X string_buf * buffer;
- X char *charry;
- X
- X buffer = buf_start();
- X
- X while( (num = fread( parse_buf, 1, PARSE_LEN, file )) > 0 ){
- X buf_cat( buffer, parse_buf, num );
- X };
- X if( num <0 ){
- X fprintf(stderr," error reading input \n");
- X exit(-1);
- X }
- X
- X /* trim off trailing whitespace */
- X buf_trim( buffer, " \t\n" );
- X
- X charry = buf_fetch( buffer );
- X
- X if( strlen(charry) >0 ) xtpanel_scan( charry, root );
- X
- X free(charry);
- X
- }
- X
- X
- /* make an entry for a given tag, the value will be the next argument */
- static entry* parse_next( pargc, pargv , tag )
- int *pargc;
- char*** pargv;
- char* tag;
- {
- X entry* newent;
- X
- X if( *pargc == 0 || **pargv[0] == '-' ){
- X /* no more arguments for this object */
- X newent = (entry*)0;
- X }else{
- X /* else get the next argument an make an entry */
- X newent = new_entry( tag, strlen(tag) );
- X newent->value = strdupl( **pargv );
- X (*pargc)--; (*pargv)++;
- X }
- X return newent;
- }
- X
- /* parse a button, it has a label, action, name, value */
- static void parse_button( pargc, pargv, ent )
- int *pargc;
- char*** pargv;
- entry *ent;
- {
- X
- entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- }
- X
- /* parse a variable, it has a name and a value */
- static void parse_variable( pargc, pargv, ent )
- int *pargc;
- char*** pargv;
- entry *ent;
- {
- X
- entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- }
- X
- /* parse a text item: value, action, name, width, height, editType */
- static void parse_text( pargc, pargv, ent )
- int *pargc;
- char*** pargv;
- entry *ent;
- {
- entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "width" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "height" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "editType" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- }
- X
- /* parse a dialog item: label, action, name, value */
- static void parse_dialog( pargc, pargv, ent )
- int *pargc;
- char*** pargv;
- entry *ent;
- {
- entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent);
- X
- }
- X
- /* parse a mesage item: value, name */
- static void parse_message( pargc, pargv, ent )
- int *pargc;
- char*** pargv;
- entry *ent;
- {
- entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- }
- X
- /* parse a slider item, it just has lots of arguments*/
- static void parse_slider( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "min" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "max" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "format" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "width" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "height" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- }
- X
- /* parse a scrollbar item, like slider but no label */
- static void parse_scrollbar( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "min" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "max" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "format" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "width" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "height" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- }
- X
- /* parse a graph item, it is even worse than a slider */
- static void parse_graph( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "nsamp" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "min" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "max" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "format" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "width" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "height" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- }
- X
- /* generic item, used in choice, list, and menubutton */
- static void parse_item( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 )
- X { fprintf( stderr," expecting label for item \n"); exit(-1); }
- X add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 )
- X { fprintf( stderr," expecting value for item \n");exit(-1); }
- X add_child( ent, newent );
- X
- }
- X
- static void parse_menubutton( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( *pargc >0 ){
- X int numitem;
- X numitem = atoi( **pargv ); (*pargc)--; (*pargv)++;
- X while( numitem >0 ){
- X entry* newitem;
- X newitem = new_entry("item", 4);
- X parse_item( pargc, pargv, newitem );
- X add_child( ent, newitem );
- X numitem--;
- X }
- X }else{
- X (*pargv)--;
- X fprintf( stderr, " unexpected end of arguments after %s\n",
- X (**pargv) );
- X fprintf( stderr, " expecting number of items in menu \n");
- X usage();
- X exit(-1);
- X }
- }
- X
- X
- static void parse_choice( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( *pargc >0 ){
- X int numitem;
- X numitem = atoi( **pargv ); (*pargc)--; (*pargv)++;
- X while( numitem >0 ){
- X entry* newitem;
- X newitem = new_entry("item", 4);
- X parse_item( pargc, pargv, newitem );
- X add_child( ent, newitem );
- X numitem--;
- X }
- X }else{
- X (*pargv)--;
- X fprintf( stderr, " unexpected end of arguments after %s\n",
- X (**pargv) );
- X fprintf( stderr, " expecting number of items in choice \n");
- X usage();
- X exit(-1);
- X }
- }
- X
- X
- static void parse_list( pargc, pargv, ent )
- X int *pargc;
- X char*** pargv;
- X entry *ent;
- {
- X entry *newent;
- X
- X if( (newent=parse_next( pargc, pargv, "label" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "action" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "name" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( (newent=parse_next( pargc, pargv, "value" )) == (entry*) 0 ) return;
- X else add_child( ent, newent );
- X
- X if( *pargc >0 ){
- X int numitem;
- X numitem = atoi( **pargv ); (*pargc)--; (*pargv)++;
- X while( numitem >0 ){
- X entry* newitem;
- X newitem = new_entry("item", 4);
- X parse_item( pargc, pargv, newitem );
- X add_child( ent, newitem );
- X numitem--;
- X }
- X }else{
- X (*pargv)--;
- X fprintf( stderr, " unexpected end of arguments after %s\n",
- X (**pargv) );
- X fprintf( stderr, " expecting number of items in list \n");
- X usage();
- X exit(-1);
- X }
- }
- X
- X
- static void usage()
- {
- X fprintf( stderr,"USAGE\n-----\n%s [ < config_file ] \n",progname);
- X fprintf( stderr,"\t[ -file \t config_file2 ] \n");
- X fprintf( stderr,"\t[ -help ] \n");
- X fprintf( stderr,"\t[ -quit ] \n");
- X fprintf( stderr,"\t[ -message \t value name ] \n");
- X fprintf( stderr,"\t[ -text \t value action name width height");
- X fprintf( stderr," editType ]\n");
- X fprintf( stderr,"\t[ -button \t label action name value ] \n");
- X fprintf( stderr,"\t[ -toggle \t label action name value ] \n");
- X fprintf( stderr,"\t[ -dialog \t label action name value ]\n");
- X fprintf( stderr,"\t[ -slider \t label action name value min max");
- X fprintf( stderr," format width height ]\n");
- X fprintf( stderr,"\t[ -scrollbar \t action name value min max");
- X fprintf( stderr," format width height ]\n");
- X fprintf( stderr,"\t[ -choice \t label action name value numchoice");
- X fprintf( stderr," label value ... ]\n");
- X fprintf( stderr,"\t[ -list \t label action name value numchoice");
- X fprintf( stderr," label value ... ]\n");
- X fprintf( stderr,"\t[ -menubutton \t label action name value numchoice");
- X fprintf( stderr," label value ... ]\n");
- X fprintf( stderr,"\t[ -graph \t nsamp label action name value min max");
- X fprintf( stderr," format width height ]\n");
- X fprintf( stderr,"\t[ -var \t\t name value ]\n");
- X fprintf( stderr,"\n\n\n");
- }
- X
- X
- static char *get_file_path();
- static char *find_file( name )
- X char *name;
- {
- X static char file_name[ MAXPATHLEN ];
- X struct stat s;
- X int path_index;
- X char *path;
- X
- X /* name begins with / */
- X if( name[0] == '/' )
- X return name;
- X
- X /* search path */
- X path_index = 0;
- X while( ( path = get_file_path( path_index ) ) != NULL )
- X {
- X strcpy( file_name, path );
- X strcat( file_name, "/" );
- X strcat( file_name, name );
- X if( stat( file_name, &s ) != -1 ) return file_name;
- X path_index++;
- X }
- X
- X return name;
- }
- X
- #ifndef SYS_XTPANELDIR
- #define SYS_XTPANELDIR "/usr/local/lib/xtpanel"
- #endif
- X
- static char* get_file_path( index )
- X int index;
- {
- X static char path[ MAXPATHLEN ];
- X char *file_path = NULL;
- X char *p;
- X char *q;
- X
- X /* build the path */
- X if( ( file_path = getenv( "XTPANEL_PATH" ) ) != NULL ){
- X strcpy( path, file_path );
- X strcat( path, ":" );
- X }else{
- X strcpy( path, "./:" );
- X }
- X strcat( path, getenv("HOME") );
- X strcat( path, "/.xtpanel:" );
- X strcat( path, SYS_XTPANELDIR );
- X
- X p = path;
- X
- X while( index-- >= 0 )
- X {
- X q = p;
- X p = strchr( p, ':' );
- X if( p == NULL )
- X break;
- X else
- X p++;
- X }
- X
- X if( index >= 0 )
- X return NULL;
- X
- X if( p != NULL ) p--;
- X if( p != NULL && *p == ':' ) *p = '\0';
- X
- X return q;
- X
- }
- X
- X
- /* parse an itemlist into separate items */
- void parse_itemlist( root )
- X entry *root;
- {
- X entry *curr;
- X entry *itement, *leaf;
- X char* itemlist;
- X char* separator;
- X char* item;
- X
- X
- X /* for all itemlist entries in "root" , convert them into items */
- X for (curr = get_next(root,"itemlist",(entry*) 0); curr != ((entry*) 0);
- X curr = get_next(root,"itemlist",curr) ){
- X
- X itemlist = get_value( curr, "list", "" );
- X separator = get_value( curr, "separator", " " );
- X
- X for( item=strtok(itemlist,separator);
- X item != (char*)0 ;
- X item =strtok( (char*)0, separator ) ){
- X
- X /* make a new item entry */
- X itement = new_entry( "item", 4 );
- X add_child( root, itement );
- X
- X /* make a new label entry */
- X leaf = new_entry( "label", 5 );
- X leaf->value = strdupl( item );
- X add_child( itement, leaf );
- X
- X }
- X }
- X
- }
- SHAR_EOF
- chmod 0664 xtpanel/parse.c ||
- echo 'restore of xtpanel/parse.c failed'
- Wc_c="`wc -c < 'xtpanel/parse.c'`"
- test 22092 -eq "$Wc_c" ||
- echo 'xtpanel/parse.c: original size 22092, current size' "$Wc_c"
- fi
- # ============= xtpanel/tree.c ==============
- if test -f 'xtpanel/tree.c' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/tree.c (File already exists)'
- else
- echo 'x - extracting xtpanel/tree.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/tree.c' &&
- /*
- X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
- X * University. Official permission to use this software is included in
- X * the documentation. It authorizes you to use this file for any
- X * non-commercial purpose, provided that this copyright notice is not
- X * removed and that any modifications made to this file are commented
- X * and dated in the style of the example below.
- X */
- X
- /*
- X *
- X * source file: ./xtpanel/tree.c
- X *
- X * Steve Cole, Dave Nichols (SEP), August 28 1992
- X * Inserted this sample edit history entry.
- X * Please log any further modifications made to this file:
- X * Steve Cole, Dave Nichols (SEP), November 20 1992 - version 2.00
- X * 1) added new objects: toggle, scrollbar, graph.
- X * 2) added new actions: ASSIGN, SET.
- X * 3) objects can have multiple actions.
- X * 4) backquoted strings in actions get executed at action time.
- X */
- X
- #include <stdio.h>
- X
- #include "tree.h"
- X
- /*
- X
- X This is an entry stucture as defined in tree.h.
- X
- X Each item in a tree is an entry.
- X
- X struct _ent {
- X char* tag;
- X char* value;
- X struct _ent* child;
- X struct _ent* next;
- X } ;
- X
- X */
- X
- /* a tree contains either nodes or leaves.
- X * each entry must have a tag ( its name )
- X *
- X * nodes have a child but no value.
- X *
- X * leaves have a value but no children.
- X *
- X * either may have a sibling (next)
- X */
- X
- /* create a new empty entry, the tag is not null terminated */
- entry* new_entry( tag, len )
- X char*tag;
- X int len;
- {
- X entry* a;
- X a = (entry*) malloc( sizeof( entry ) );
- X
- X a->tag = malloc( len+1 );
- X strncpy( a->tag, tag, len );
- X a->tag[len] = '\0';
- X
- X a->value = (char*)0;
- X a->child= (entry*)0;
- X a->next= (entry*)0;
- X return a;
- }
- X
- /* add a sibling to an entry, if this entry already has one it
- X * will go and find the last sibling without a "next" field. */
- void add_sibling( orig, sib )
- X entry* orig, *sib;
- {
- X entry *curr;
- X curr=orig;
- X
- X while( curr->next != (entry*)0 ){ curr = curr->next; }
- X
- X curr->next = sib;
- }
- X
- /* add a child to an entry. It will be the sibling of any existing child */
- void add_child( parent, child )
- X entry *parent,*child;
- {
- X if( parent->child == (entry*)0 ){
- X parent->child = child;
- X }else{
- X add_sibling( parent->child, child );
- X }
- }
- X
- X
- /* retrieve an entry given the tag, if prev is non zero the entry will
- X be the next matching entry after prev */
- entry* get_next( root, tag, prev )
- X entry* root;
- X char* tag;
- X entry* prev;
- {
- X entry *ent;
- X
- X /* start with the first child */
- X ent = root->child;
- X
- X /* first find the previous entry */
- X if( prev != (entry*)0 ){
- X while( ent != (entry*)0 && ent != prev ) ent = ent->next;
- X /* found prev, start at the next one */
- X if( ent != (entry*)0 ) ent = ent->next;
- X }
- X
- X while( ent != (entry*)0 ){
- X if( !strcmp( ent->tag, tag ) ) break;
- X ent = ent->next;
- X }
- X
- X return ent;
- }
- X
- /* retrieve a copy of the value string given a tag.
- X if the tag is not found the default string will be copied */
- char* get_value( root, tag, defstring )
- X entry* root;
- X char* tag;
- X char * defstring;
- {
- X char *retval;
- X entry * ent;
- X
- X retval = (char*)0;
- X
- X ent = get_next( root, tag, 0 );
- X
- X if( ent != (entry*)0 && ent->value != (char*)0 ) {
- X retval = strdupl( ent->value );
- X }else{
- X retval = strdupl( defstring );
- X }
- X
- X return retval;
- }
- X
- /* See if a given tag exists */
- int is_specified( root, tag )
- X entry* root;
- X char* tag;
- {
- X int retval;
- X entry * ent;
- X
- X retval = 0;
- X
- X ent = get_next( root, tag, 0 );
- X
- X if( ent != (entry*)0 && ent->value != (char*)0 ) {
- X retval = 1;
- X }else{
- X retval = 0;
- X }
- X
- X return retval;
- }
- X
- /* print the tree rooted at this entry, useful for debugging */
- void print_entry( file, ent, num_tab )
- X FILE* file;
- X entry *ent;
- X int num_tab;
- {
- X char tabs[20];
- X int i;
- X entry *ch;
- X
- X for ( i=0; i<num_tab; i++ ) tabs[i] = '\t';
- X tabs[num_tab]='\0';
- X
- X fprintf(file,"%s tag=%s\n",tabs,ent->tag);
- X if( ent->value != 0 ) fprintf(file,"%s value=%s\n",tabs,ent->value);
- X
- X ch = ent->child;
- X while( ch != 0 ) {
- X print_entry( file, ch, num_tab+1 );
- X ch = ch->next;
- X }
- X
- X fprintf(file,"\n");
- X
- }
- SHAR_EOF
- chmod 0664 xtpanel/tree.c ||
- echo 'restore of xtpanel/tree.c failed'
- Wc_c="`wc -c < 'xtpanel/tree.c'`"
- test 4270 -eq "$Wc_c" ||
- echo 'xtpanel/tree.c: original size 4270, current size' "$Wc_c"
- fi
- # ============= xtpanel/tree.h ==============
- if test -f 'xtpanel/tree.h' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/tree.h (File already exists)'
- else
- echo 'x - extracting xtpanel/tree.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/tree.h' &&
- #ifndef TREE_H
- #define TREE_H
- X
- #if defined __STDC__ || defined __stdc__
- #include <stdlib.h>
- #else
- #if defined AIXV3 || defined sun || defined ultrix
- #include <stdlib.h>
- #else
- extern char* malloc();
- extern double atof();
- #endif
- #endif
- X
- #include <string.h>
- X
- #define ALPHNUM \
- X "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
- X
- struct _ent {
- X char* tag;
- X char* value;
- X struct _ent* child;
- X struct _ent* next;
- } ;
- X
- typedef struct _ent entry;
- X
- #ifndef _NO_PROTO
- #include <stdio.h>
- extern entry* new_entry( char*, int);
- extern void add_child( entry*, entry* );
- extern void add_sibling( entry*, entry* );
- char* get_value( entry*, char*, char*);
- char* get_name( entry*, char* );
- entry* get_next(entry*, char*, entry* );
- extern void print_entry( FILE*, entry*, int );
- extern int is_specified( entry*, char* );
- X
- #else
- extern entry* new_entry();
- extern void add_child();
- extern void add_sibling();
- char* get_value();
- char* get_name();
- entry* get_next();
- extern void print_entry();
- extern int is_specified();
- #endif
- X
- static char* strdupl(a)
- char*a; { char*b; b=malloc( strlen(a)+1); strcpy( b, a ); return b; }
- X
- #endif
- SHAR_EOF
- chmod 0664 xtpanel/tree.h ||
- echo 'restore of xtpanel/tree.h failed'
- Wc_c="`wc -c < 'xtpanel/tree.h'`"
- test 1134 -eq "$Wc_c" ||
- echo 'xtpanel/tree.h: original size 1134, current size' "$Wc_c"
- fi
- # ============= xtpanel/XTpanel.ad.sed ==============
- if test -f 'xtpanel/XTpanel.ad.sed' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/XTpanel.ad.sed (File already exists)'
- else
- echo 'x - extracting xtpanel/XTpanel.ad.sed (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/XTpanel.ad.sed' &&
- *input: True
- *Paned*resizable: True
- *Dialog*Command*label: ok
- *Command*label: ok
- *Dialog*resizable: True
- *Dialog*value.translations: #override <Key>Return: return_key()
- *Viewport*allowVert: True
- *Box*allowResize: True
- *Box*resizable: True
- *SimpleMenu*HorizontalMargins: 30
- *sliderbox*Scrollbar*orientation: horizontal
- *sliderbox*Scrollbar*length: 100
- *sliderbox*Scrollbar*thickness: 25
- *text*resizable: True
- *Text*resizable: True
- *text*scrollVertical: whenNeeded
- *text*scrollHorizonal: whenNeeded
- X
- ! A widget with name=noborder doesn't have a border
- *noborder.borderWidth: 0
- X
- ! A box with name=squeezebox squeezes everything inside it
- *squeezebox*vSpace: 0
- *squeezebox*hSpace: 0
- *squeezebox*Box*borderWidth: 0
- *squeezebox*Box*vSpace: 0
- *squeezebox*Box*hSpace: 0
- *squeezebox*Command*borderWidth: 0
- *squeezebox*Command*label:
- *squeezebox*Command*width: 10
- *squeezebox*Command*height: 10
- *squeezebox.Scrollbar.orientation: vertical
- *squeezebox*Toggle*borderWidth: 0
- *squeezebox*Toggle*label:
- *squeezebox*Toggle*width: 10
- *squeezebox*Toggle*height: 10
- *squeezebox*togglebox*Label:
- *squeezebox*togglebox*orientation: horizontal
- *squeezebox*sliderbox.orientation: horizontal
- *squeezebox*sliderbox.Scrollbar.orientation: horizontal
- *squeezebox*Toggle.translations:#augment\n\
- X Meta<EnterNotify>:toggle() notify()
- *squeezebox*Scrollbar*borderWidth: 0
- *squeezebox*Scrollbar.translations:#override\n\
- X Meta<EnterNotify>: StartScroll(Continuous) MoveThumb() NotifyThumb()\n\
- X Meta<LeaveNotify>: NotifyScroll(Proportional) EndScroll()\n\
- X Meta<Motion>: MoveThumb() NotifyThumb()
- X
- ! A box with name=graphbox contains a graph object
- *graphbox.orientation: vertical
- *graphbox.borderWidth: 0
- *graphbox*vSpace: 0
- *graphbox*hSpace: 0
- *graphbox*Box*vSpace: 0
- *graphbox*Box*hSpace: 0
- *graphbox*Scrollbar*borderWidth: 0
- *graphbox*Scrollbar.translations:#override\n\
- X Meta<EnterNotify>: StartScroll(Continuous) MoveThumb() NotifyThumb()\n\
- X Meta<LeaveNotify>: NotifyScroll(Proportional) EndScroll()\n\
- X Meta<Motion>: MoveThumb() NotifyThumb()
- X
- *stevebitmap.bitmap: SYS_XTPANELDIR/help/steve.xbm
- *davebitmap.bitmap: SYS_XTPANELDIR/help/dave.xbm
- SHAR_EOF
- chmod 0664 xtpanel/XTpanel.ad.sed ||
- echo 'restore of xtpanel/XTpanel.ad.sed failed'
- Wc_c="`wc -c < 'xtpanel/XTpanel.ad.sed'`"
- test 2377 -eq "$Wc_c" ||
- echo 'xtpanel/XTpanel.ad.sed: original size 2377, current size' "$Wc_c"
- fi
- # ============= xtpanel/README ==============
- if test -f 'xtpanel/README' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/README (File already exists)'
- else
- echo 'x - extracting xtpanel/README (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/README' &&
- xtpanel - build an interactive program, from the command line
- X or using a simple scripting language
- X
- xtpanel provides a quick and easy way of producing a panel
- containing interactive objects such as buttons, sliders, and text
- fields, either from the command line or from an xtpanel script file.
- Each panel object maintains a string representation of its value. When
- the object is modified it updates its value and it can also perform an
- action such as printing its value or calling a system command. Objects
- can make use of the values of other objects in constructing their
- actions, and they can set the values of other objects as the result of
- an action. The result is an interactive X windows program, without the
- need for conventional programming.
- X
- This program is not intended as a replacement for a full featured
- interface programming toolkit like Tk or Dirt or as a replacement for a
- simple menu builder like xmenu, it falls somewhere in the gap between the two.
- It is intended as an easy to use tool that can be used to add an
- interactive wrapper to all those old programs and shells that you have
- lying around.
- X
- X
- Three utilities are provided with xtpanel. All three utilities are
- written as xtpanel scripts.
- X
- The first is a script generator. This is a collection af xtpanel scripts
- that can be used to build, examine and test xtpanel script files.
- It is invoked using the command "xtpanel-generator". The second utility is a
- collection of example scripts and a master script that can be use to
- view and run the examples. It is invoked using the command
- "xtpanel-examples". A particularly powerful demo is the "lister"
- script example, which is a tool for maneuvering through a Unix
- filesystem and viewing files at any level. The third is a set of
- xtpanel scripts that present information about xtpanel, mostly taken
- from this manual page, in an interactive, menu-driven form. This
- is invoked by doing "xtpanel -help".
- X
- This program uses the X toolkit and the MIT Athena widget
- set.
- X
- COPYRIGHT
- Although xtpanel is not in the public domain, its copyright is not
- very restrictive. Here is the official xtpanel copyright notice:
- .PP
- Copyright 1992 the Board of Trustees of the Leland Stanford Junior
- University. All Rights Reserved. Permission is hereby given
- to use, copy, modify, and distribute this software provided
- that (1) copyright and proprietary notices are retained in
- each copy, (2) any files which are modified are identified as such,
- and (3) you do not copy or distribute the software for payment or
- for commercial use without prior written consent from Stanford.
- STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
- concerning this software or its use.
- X
- X
- AUTHORS
- Steve Cole (steve@sep.stanford.edu)
- Dave Nichols (dave@sep.stanford.edu)
- Stanford Exploration Project, Department of Geophysics
- Stanford University, Stanford, CA 94305-2215
- SHAR_EOF
- chmod 0664 xtpanel/README ||
- echo 'restore of xtpanel/README failed'
- Wc_c="`wc -c < 'xtpanel/README'`"
- test 2871 -eq "$Wc_c" ||
- echo 'xtpanel/README: original size 2871, current size' "$Wc_c"
- fi
- # ============= xtpanel/xtpanel_scan.l ==============
- if test -f 'xtpanel/xtpanel_scan.l' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/xtpanel_scan.l (File already exists)'
- else
- echo 'x - extracting xtpanel/xtpanel_scan.l (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/xtpanel_scan.l' &&
- %C
- NONSEPAR [^ \t\n\{\}]
- WHITE [ \t\n]
- ALPHA [A-Za-z]
- ALPHANUM [A-Za-z0-9_-]
- TAG {ALPHA}{ALPHANUM}*=
- TAGBRACE {ALPHA}{ALPHANUM}*=\{
- SQ \'([^']*\'\')*[^']*[']
- DQ \"([^"]*\"\")*[^"]*["]
- BQ \`[^`]*[`]
- LEFT \{
- RIGHT \}
- X
- X
- %{
- X
- /*
- X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
- X * University. Official permission to use this software is included in
- X * the documentation. It authorizes you to use this file for any
- X * non-commercial purpose, provided that this copyright notice is not
- X * removed and that any modifications made to this file are commented
- X * and dated in the style of the example below.
- X */
- X
- /*
- X *
- X * source file: ./xtpanel/xtpanel-scan.l
- X *
- X * Steve Cole, Dave Nichols (SEP), August 31 1992
- X * Inserted this sample edit history entry.
- X * Please log any further modifications made to this file:
- X * Steve Cole, Dave Nichols (SEP), November 20 1992 - version 2.00
- X * 1) added new objects: toggle, scrollbar, graph.
- X * 2) added new actions: ASSIGN, SET.
- X * 3) objects can have multiple actions.
- X * 4) backquoted strings in actions get executed at action time.
- X */
- X
- /* lexical scanning for xtpanel */
- X
- #include <ctype.h>
- #include <stdio.h>
- #include <string.h>
- X
- #if defined _POSIX_SOURCE
- #include <unistd.h>
- #endif
- X
- #include "tree.h"
- #include "eval_command.h"
- X
- #ifndef MIN
- #define MIN(A,B) (A<B?A:B)
- #endif
- X
- #define MAX_NEST 20
- static int stack_ptr = -1;
- static char *input_buf;
- static char *input_buf_start;
- static char *input_buf_end;
- X
- static entry *entry_stack[MAX_NEST];
- X
- #undef input
- #define input() ((int) *(input_buf++))
- #undef unput
- /* The redundant =(c) insures side effects of expressions occur */
- #define unput(c) (*(--(input_buf))=(c))
- X
- /* define the look ahead buffer size to something big
- X * This is needed in case they have a very big text
- X * string in quotes.
- X */
- #undef YYLMAX
- #define YYLMAX 50000
- X
- #define yywrap() xtpanel_wrap()
- #define yylex() xtpanel_lexscan()
- #define yylook() xtpanel_yylook()
- X
- entry *tree_ent;
- entry *treetop;
- int len;
- int left=0;
- X
- static void syntax_err();
- static int massage();
- X
- /* workhorse to decode xtpanel files; */
- X
- entry* xtpanel_scan( buffer, root )
- char* buffer;
- entry* root;
- {
- X extern int yylex();
- X
- X /* note the input buffer should be null terminated */
- X input_buf = buffer;
- X input_buf_start = input_buf;
- X input_buf_end = input_buf + strlen(input_buf) - 1;
- X
- X /* all the info we find will be stored under the root entry */
- X push_entry( root );
- X
- X yylex();
- X if( left > 0 ) {
- X fprintf(stderr," %d unmatched left braces present \n",left);
- X exit(-1);
- X }
- X if( left < 0 ) {
- X fprintf(stderr," %d unmatched right braces present \n",-left);
- X exit(-1);
- X }
- X
- }
- X
- X
- %}
- %S FOUNDTAG
- %%
- <FOUNDTAG>{SQ} {
- X len = yyleng-2; tree_ent->value=malloc(len+1);
- X len = massage(yytext+1,tree_ent->value,len,yytext[0]);
- X tree_ent->value[len]='\0';
- X add_child( treetop, tree_ent );
- X BEGIN 0;
- X }
- <FOUNDTAG>{BQ} {
- X len = yyleng-2; yytext[yyleng-1] = '\0';
- X tree_ent->value = eval_command(yytext+1);
- X add_child( treetop, tree_ent );
- X BEGIN 0;
- X }
- <FOUNDTAG>{DQ} {
- X len = yyleng-2; tree_ent->value=malloc(len+1);
- X len = massage(yytext+1,tree_ent->value,len,yytext[0]);
- X tree_ent->value[len]='\0';
- X add_child( treetop, tree_ent );
- X BEGIN 0;
- X }
- <FOUNDTAG>[^'"]{NONSEPAR}* {
- X len=yyleng; tree_ent->value=malloc(len+1);
- X bcopy(yytext,tree_ent->value,len+1);
- X tree_ent->value[len]='\0';
- X add_child( treetop, tree_ent );
- X BEGIN 0;
- X }
- ^{TAGBRACE} { /* start of a new level of braces */
- X tree_ent = new_entry( yytext,
- X get_taglen(yytext,yyleng-1));
- X push_entry( tree_ent );
- X left++;
- X }
- ([ \t]){TAGBRACE} { /* start of a new level of braces */
- X tree_ent = new_entry( yytext+1,
- X get_taglen(yytext+1,yyleng-2));
- X push_entry(tree_ent);
- X left++;
- X }
- {TAG}/{NONSEPAR} {
- X tree_ent = new_entry( yytext, yyleng-1 );
- X BEGIN FOUNDTAG;
- X }
- {TAG}{WHITE} { /* an empty tag */
- X syntax_err("unexpected empty field ");
- X }
- {RIGHT} { /* end of a level of braces */
- X pop_entry();
- X left--;
- X if( left<0 ) {
- X syntax_err("unmatched right brace");
- X }
- X }
- {LEFT} { /* found a left brace in the wrong context */
- X syntax_err("left brace found in an unexpected place");
- X }
- ^\!.* /* skip comment lines */;
- . |
- \n ;
- %%
- X
- /* get the tag length from a string that may have spaces around the equal */
- int get_taglen( str, len )
- char *str; int len;
- {
- char *temp;
- int ret;
- temp = malloc( len+1); strncpy( temp, str, len ); temp[len]='\0';
- ret= strcspn( temp, " =" ) ;
- free(temp);
- return ret;
- }
- X
- /* print a syntax error, try and give them enough context to figure
- X * out where it is */
- static void syntax_err( message )
- char *message;
- {
- X char temp[41];
- X int lchar,rchar,nchar,i,j,ptrpos;
- X
- X /* print the error message */
- X fprintf(stderr,"Syntax Error: %s\n", message);
- X
- X /* back up to the character causing the error */
- X input_buf--;
- X
- X /* print enough characters on either side to give he user some context*/
- X lchar = MIN( 20, input_buf - input_buf_start );
- X rchar = MIN( 20, input_buf_end - input_buf);
- X nchar = lchar+rchar+1;
- X strncpy( temp, (input_buf-lchar), nchar ); temp[nchar] = '\0';
- X fprintf(stderr,"%s\n",temp);
- X
- X /* back up looking for a newline or the start of string */
- X ptrpos = lchar;
- X for( j=lchar-1; j>=0 ; j-- ){
- X if( temp[j] == '\n' ) {
- X ptrpos=lchar-j-1;
- X break;
- X }
- X }
- X
- X /* now put a marker that points at the error */
- X for( i=0; i<ptrpos; i++ ) temp[i]=' ';
- X temp[ptrpos]='^'; temp[ptrpos+1]='\0';
- X strcat( temp, "--- error here (I think) ");
- X fprintf(stderr,"%s\n",temp);
- X exit(-1);
- }
- X
- push_entry( ent )
- entry* ent;
- {
- if( stack_ptr >=0 ) add_child( entry_stack[stack_ptr], ent );
- stack_ptr++;
- if( stack_ptr >MAX_NEST ){
- X fprintf(stderr," items nested too deeply, only %d levels supported\n",
- X MAX_NEST);
- X exit(-1);
- }
- entry_stack[stack_ptr] = ent;
- treetop = entry_stack[stack_ptr];
- }
- X
- X
- pop_entry()
- {
- stack_ptr--;
- if( stack_ptr >= 0 ) treetop = entry_stack[stack_ptr] ;
- }
- X
- int
- yywrap()
- {
- X pop_entry();
- X if(stack_ptr < 0) return(1);
- X return(0);
- }
- X
- X
- /* play with quoted strings and newlines etc. */
- static int
- massage(string,out,len,quote)
- register char *string, *out;
- register int len, quote;
- {
- X register int i,j;
- X for(i=0,j=0; i<len-1; j++) {
- X out[j]=string[i++];
- X
- X if(out[j]==quote) /* compress doubled quotes */
- X if(string[i]==quote) i++;
- X
- X if(out[j]=='\\') {
- X if(string[i]== 'n') {
- X /* turn backslash n "\n" into a newline */
- X i++; out[j] = '\n';
- X }else if( string[i] == '\n' ){ /* remove backslash newline */
- X i++; j--;
- X }
- X }
- X
- X }
- X if(i<len) out[j++] = string[i];
- X return(j);
- }
- SHAR_EOF
- chmod 0664 xtpanel/xtpanel_scan.l ||
- echo 'restore of xtpanel/xtpanel_scan.l failed'
- Wc_c="`wc -c < 'xtpanel/xtpanel_scan.l'`"
- test 6855 -eq "$Wc_c" ||
- echo 'xtpanel/xtpanel_scan.l: original size 6855, current size' "$Wc_c"
- fi
- # ============= xtpanel/patchlevel.h ==============
- if test -f 'xtpanel/patchlevel.h' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/patchlevel.h (File already exists)'
- else
- echo 'x - extracting xtpanel/patchlevel.h (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/patchlevel.h' &&
- static char version[] = " xtpanel version 2.00 ";
- SHAR_EOF
- chmod 0664 xtpanel/patchlevel.h ||
- echo 'restore of xtpanel/patchlevel.h failed'
- Wc_c="`wc -c < 'xtpanel/patchlevel.h'`"
- test 51 -eq "$Wc_c" ||
- echo 'xtpanel/patchlevel.h: original size 51, current size' "$Wc_c"
- fi
- # ============= xtpanel/NoImake.cpp ==============
- if test -f 'xtpanel/NoImake.cpp' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/NoImake.cpp (File already exists)'
- else
- echo 'x - extracting xtpanel/NoImake.cpp (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/NoImake.cpp' &&
- /* Variable definition for NoImake */
- /* Martin Karrenbach 8-25-92 */
- X
- HOME =/usr/local
- X
- BINDIR =${HOME}/bin/X11
- MANDIR =${HOME}/man
- USRLIBDIR =${HOME}/lib
- LIBDIR =${USRLIBDIR}/X11
- INCDIR =${HOME}/include
- X
- #if defined(HP700)
- LIBDIR =/usr/lib/X11R4
- #endif
- X
- RESOURCES =${LIBDIR}/app-defaults
- APPDEFAULTS =Xtpanel
- X
- /* you normally should not have to modify below here, unless you add */
- /* specific options for new machines */
- X
- SUBDIRS = help generator examples
- X
- CPP = /lib/cpp
- X
- CCOPTIONS = -O
- X
- #if defined(SUN4)
- CCOPTIONS = -O -pipe
- #endif
- X
- #if defined(HP700)
- CCOPTIONS = -O -Aa -D_HPUX_SOURCE
- #endif
- X
- STD_DEFINES = -D_NO_PROTO
- X
- #if defined(RS6000)
- STD_DEFINES = -DSYSV -DAIXV3
- #endif
- X
- EXTRA_DEFINES = -DSYS_XTPANELDIR=\"$(SYS_XTPANELDIR)\"
- X
- STD_INCLUDES = -I$(INCDIR) -I.
- X
- XXAWCLIENTLIBS = -lXaw -lXmu -lXt -lXext -lX11
- X
- INCLUDES = $(EXTRA_INCLUDES) $(STD_INCLUDES)
- DEFINES = $(STD_DEFINES) $(EXTRA_DEFINES)
- X
- CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(DEFINES) $(INCLUDES)
- X
- SYSLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
- X
- LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(LIBDIR) \
- X -L$(USRLIBDIR) $(LIBS)
- X
- RM = /bin/rm -f *.o core
- X
- RM_CMD = /bin/rm -f
- X
- INSTALL = install
- X
- MKDIRHIER = mkdirhier
- X
- /* all makefiles will have these rules */
- all::
- X
- clean::
- X $(RM_CMD) "#"*
- SHAR_EOF
- chmod 0664 xtpanel/NoImake.cpp ||
- echo 'restore of xtpanel/NoImake.cpp failed'
- Wc_c="`wc -c < 'xtpanel/NoImake.cpp'`"
- test 1457 -eq "$Wc_c" ||
- echo 'xtpanel/NoImake.cpp: original size 1457, current size' "$Wc_c"
- fi
- # ============= xtpanel/NoImake.m4 ==============
- if test -f 'xtpanel/NoImake.m4' -a X"$1" != X"-c"; then
- echo 'x - skipping xtpanel/NoImake.m4 (File already exists)'
- else
- echo 'x - extracting xtpanel/NoImake.m4 (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/NoImake.m4' &&
- undefine(`include')
- X
- define(MakeSubdirs,
- all::
- X for dir in $1 ; do (echo Build in $$dir; cd $$dir ; make ) ; done
- clean::
- X for dir in $1 ; do (echo Clean in $$dir; cd $$dir ; make clean) ; done
- install::
- X for dir in $1; do (echo Install in $$dir; cd $$dir; make install); done
- )
- X
- define(DependSubdirs,
- depend::
- X for dir in $1 ; do (cd $$dir ; make depend) ; done
- )
- X
- define(NormalLibraryObjectRule,)
- X
- define(NormalLibraryTarget,
- lib$1.a: $2
- X rm -f lib$1.a
- X ar r lib$1.a $2
- X ranlib lib$1.a
- clean::
- X rm -f lib$1.a $2
- )
- X
- define(LintLibraryTarget,)
- X
- define(CleanTarget,)
- X
- define(TagsTarget,
- tags::
- X etags *.c *.h
- )
- X
- define(NormalLintTarget,)
- X
- define(NormalProgramTarget,
- $1: $2
- X ${CC} ${CFLAGS} -o $1 $2 $4 $5
- X clean::
- X rm -f $1 $2
- )
- X
- define(SingleProgramTarget,
- $1: $(OBJS)
- X ${CC} ${CFLAGS} -o $1 $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(SYSLIBS)
- clean:: rm -f $1 $2
- install::
- X MakeDir($(BINDIR))
- X install -c -s $1 $(BINDIR)
- )
- X
- define(ComplexProgramTarget,
- $1: $(OBJS)
- X ${CC} ${CFLAGS} -o $1 $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(SYSLIBS)
- clean::
- X rm -f $1 $2
- install::
- X MakeDir($(BINDIR))
- X install -c -s $1 $(BINDIR)
- )
- X
- define(InstallProgram,
- install:: $1
- X MakeDir($2)
- X install -c -s $1 $2
- )
- X
- define(InstallNonExec,
- install:: $1
- X MakeDir($2)
- X install -c $1 $2
- )
- X
- define(InstallScript,
- install:: $1.script
- X MakeDir($2)
- X install -c -m 555 $1.script $2/$1
- )
- X
- define(InstallManPage,
- install:: $1.man
- X MakeDir($2)
- X install -c $1.man $2/$1.1
- )
- X
- define(InstallAppDefaults,
- install:: $1.ad
- X MakeDir($(RESOURCES))
- X install -c $1.ad $(RESOURCES)/$1
- )
- define(DependTarget,)
- X
- define(XawClientLibs,$(XAWCLIENTLIBS))
- X
- define(MakeDir,
- X @if [ -d $1 ]; then set +x; \
- X else (set -x; mkdir $1 ); fi)
- X
- define(InstallSubdirs,
- install::
- X for dir in $1 ; \
- X do (cd $$dir ; \
- X echo "installing" "in $(CURRENT_DIR)/$$dir..."; \
- X $(MAKE) $(MFLAGS) DESTDIR='$(DESTDIR)' install); \
- X done
- )
- X
- define(CleanSubdirs,
- clean::
- X for i in $1 ; \
- X do \
- X (cd $$i ; echo "cleaning" "in $(CURRENT_DIR)/$$i..."; \
- X $(MAKE) $(MFLAGS) RM_CMD='$(RM_CMD)' clean); \
- X done
- )
- X
- define(NamedTargetSubdirs,
- $1::
- X for i in $2 ;\
- X do \
- X (cd $$i ; echo $3 "in $(CURRENT_DIR)/$$i..."; \
- X $(MAKE) $(MFLAGS) $4 $5); \
- X done
- )
- X
- X
- define(MakefileSubdirs,
- Makefile::
- X echo "Makefile created with NoImake"
- X echo "Rerun NoImake at the top level"
- )
- X
- define(InstallMultipleFlags,
- install:: $1
- X MakeDir($(DESTDIR) $2)
- X for i in $1; do \
- X (set -x; $(INSTALL) -c $3 $$i $(DESTDIR) $2); \
- X done
- )
- X
- define(MakeDirectories,
- $1::
- X for i in $2; do if [ -d $(DESTDIR)$$i ]; then \
- X set +x; else (set -x; $(MKDIRHIER) $(DESTDIR)$$i); fi \
- X done
- )
- SHAR_EOF
- chmod 0664 xtpanel/NoImake.m4 ||
- echo 'restore of xtpanel/NoImake.m4 failed'
- Wc_c="`wc -c < 'xtpanel/NoImake.m4'`"
- test 2598 -eq "$Wc_c" ||
- echo 'xtpanel/NoImake.m4: original size 2598, current size' "$Wc_c"
- fi
- true || echo 'restore of xtpanel/button.c failed'
- echo End of part 5, continue with part 6
- exit 0
- -----------------------------------------------------------------
- Steve Cole (steve@sep.stanford.edu, apple!sep!steve)
- Department of Geophysics, Stanford University, Stanford, CA 94305
-