Annotation of 43BSDReno/contrib/isode-beta/others/quipu/uips/xd/Xd.c, revision 1.1.1.1

1.1       root        1: /* $Header: /f/osi/others/quipu/uips/xd/RCS/Xd.c,v 7.0 90/06/12 13:10:46 mrose Exp $ */
                      2: #ifndef lint
                      3:        static char *rcsid = "$Id: Xd.c,v 7.0 90/06/12 13:10:46 mrose Exp $";
                      4: #endif
                      5: /*
                      6:  $Log: Xd.c,v $
                      7:  * Revision 7.0  90/06/12  13:10:46  mrose
                      8:  * *** empty log message ***
                      9:  * 
                     10:  * Revision 1.5  90/04/26  10:22:32  emsrssn
                     11:  * Installation fixed
                     12:  * 
                     13:  * 
                     14:  * Revision 1.4  90/04/25  17:28:02  emsrssn
                     15:  * Lint tidy up
                     16:  * 
                     17:  * 
                     18:  * Revision 1.3  90/04/19  13:54:00  emsrssn
                     19:  * keyboard accelerator now activates button highlight.
                     20:  * 
                     21:  * search types available is dependent on current position
                     22:  * to prevent unreasonable searches.
                     23:  * 
                     24:  * the help popup changes automatically depending on the 
                     25:  * position of the cursor
                     26:  * 
                     27:  * buttons remain a fixed size when the application is
                     28:  * resized
                     29:  * 
                     30:  * command line options are now handled properly
                     31:  * 
                     32:  * logging added
                     33:  * 
                     34:  * "reads" are now sorted to show mail address at top etc.
                     35:  * 
                     36:  * 
                     37:  * Revision 1.2  90/03/09  15:57:25  emsrssn
                     38:  * First public distribution
                     39:  * 
                     40:  * 
                     41:  * Revision 1.1  90/03/08  13:18:43  emsrssn
                     42:  * Initial revision
                     43:  * 
                     44:  * 
                     45: */
                     46: 
                     47: #include <stdio.h>
                     48: #include "sequence.h"
                     49: #include "dirtitle.h"
                     50: 
                     51: #include <X11/Xatom.h>
                     52: #include <X11/Intrinsic.h>
                     53: #include <X11/StringDefs.h>
                     54: 
                     55: #include <X11/Xaw/AsciiText.h>
                     56: #include <X11/Xaw/Box.h>
                     57: #include <X11/Xaw/Clock.h>
                     58: #include <X11/Xaw/Command.h>
                     59: #include <X11/Xaw/Dialog.h>
                     60: #include <X11/Xaw/Form.h>
                     61: #include <X11/Xaw/Label.h>
                     62: #include <X11/Xaw/List.h>
                     63: #include <X11/Xaw/Logo.h>
                     64: #include <X11/Xaw/MenuButton.h>
                     65: #include <X11/Xaw/Scrollbar.h>
                     66: #include <X11/Xaw/SimpleMenu.h>
                     67: #include <X11/Xaw/Sme.h>
                     68: #include <X11/Xaw/SmeBSB.h>
                     69: #include <X11/Xaw/SmeLine.h>
                     70: #include <X11/Xaw/StripChart.h>
                     71: #include <X11/Xaw/Paned.h>
                     72: #include <X11/Xaw/Text.h>
                     73: #include <X11/Xaw/Toggle.h>
                     74: #include <X11/Xaw/Viewport.h>
                     75: 
                     76: #include <X11/Xaw/Cardinals.h>
                     77: #include <X11/cursorfont.h>
                     78: 
                     79: #define ASIZELIMIT 50   /* used for result list size and directory limits */
                     80: 
                     81: #define MAXLOOKBACKLENGTH 10
                     82: #define MAXLENGTH 255
                     83: #define MAXRESULTLISTLENGTH ASIZELIMIT
                     84: #define NOHISTORY "You've not been anywhere yet"
                     85: 
                     86: extern char base_path[];
                     87: extern char friendly_base_path[];
                     88: extern char goto_path[];
                     89: extern char mvalue[];
                     90: extern int filt_num;
                     91: extern unsigned int typeindx;
                     92: extern char *filtvalue[];
                     93: extern char *filttype[];
                     94: extern char dua_help_dir[];
                     95: extern int *av_typeindx;
                     96: extern D_seq showseq, dnseq;
                     97: extern int entry_number;
                     98: 
                     99: int element_number = 0;
                    100: int asizelimit = ASIZELIMIT;
                    101: 
                    102: void add_to_lookback(), xprint(), CreatePopupHelp(), Change_Help();
                    103: 
                    104: static void Call_Change_Help();
                    105: static void Quit(), create_genform(), create_inputform();
                    106: static void create_viewlist(), create_commandform(), create_outputform();
                    107: static void PopupList(), PopupTypelist(), Quit_Popup();
                    108: static void PopupHelp(), PopdownHelp(), Change_Type(), Change_Search_Area();
                    109: static void Search(), List(), widen_search();
                    110: 
                    111: static Boolean lookback_open = False; /* is there a look back popup? */
                    112: static Boolean help_popped_up= False; /* is the help window up? */
                    113: 
                    114: String result_list[MAXRESULTLISTLENGTH];
                    115: String lookback_list[MAXLOOKBACKLENGTH];
                    116: Widget toplevel;
                    117: XtAppContext app_con;
                    118: 
                    119: static XtActionsRec buttonActionsTable[] = {
                    120:   {"Call_Change_Help", (XtActionProc) Call_Change_Help},
                    121: };
                    122: 
                    123: 
                    124: 
                    125: 
                    126: 
                    127: void
                    128: init_widgets ()
                    129: {
                    130:   Arg args[1];
                    131:   Widget outer;
                    132:   int count;
                    133: 
                    134:   outer = XtCreateManagedWidget("outer", panedWidgetClass, toplevel,
                    135:                                   args, 0);
                    136: 
                    137:   XtAppAddActions(app_con, buttonActionsTable, XtNumber(buttonActionsTable));
                    138: 
                    139:   create_genform(outer);
                    140:   create_inputform(outer);
                    141:   create_outputform(outer);
                    142:   create_commandform(outer);
                    143:   create_viewlist(outer);
                    144: 
                    145:   for(count=0; count < MAXRESULTLISTLENGTH; count++) {
                    146:     result_list[count] = XtMalloc(MAXLENGTH);
                    147:   }
                    148: 
                    149:   for(count=0; count < MAXLOOKBACKLENGTH; count++) {
                    150:     lookback_list[count] = XtMalloc(MAXLENGTH);
                    151:   }
                    152:   /* add text to stop widget assuming daft size */
                    153:   (void) strcpy(lookback_list[0], NOHISTORY );  
                    154:     
                    155: }
                    156: 
                    157: free_memory()
                    158: {
                    159:   int count;
                    160: 
                    161:   for(count=0; count < MAXRESULTLISTLENGTH; count++) {
                    162:     XtFree(result_list[count]);
                    163:   }
                    164: 
                    165:   for(count=0; count < MAXLOOKBACKLENGTH; count++) {
                    166:     XtFree(lookback_list[count]);
                    167:   }
                    168: }
                    169: 
                    170: 
                    171: void
                    172: Loop()
                    173: {
                    174:   Arg args[5];
                    175:   Pixmap title_pix;
                    176:   String title_name = "outer.genform.title";
                    177:   Widget title_widg = XtNameToWidget(toplevel,title_name);
                    178: 
                    179:   XtRealizeWidget(toplevel);
                    180:   XFlush(XtDisplay(toplevel));    /* this ensures that all requests are sent */
                    181:                                   /* without this line, linking with cc means */
                    182:                                  /* that the requests are not all sent */
                    183: 
                    184:   title_pix =  XCreateBitmapFromData(XtDisplay(title_widg),
                    185:                  XtWindow(title_widg), stef_bits, stef_width,
                    186:                  stef_height);
                    187:   XtSetArg(args[0], XtNbitmap, title_pix);
                    188:   XtSetValues(title_widg, args, 1);
                    189: 
                    190:   XtAppMainLoop(app_con);
                    191: }
                    192: 
                    193: 
                    194: /*ARGSUSED*/
                    195: static void
                    196: Call_Change_Help(w, event, params, num_params)
                    197: Widget w;
                    198: XEvent *event;
                    199: String *params;
                    200: int num_params;
                    201: {
                    202:   Change_Help(params[0]);
                    203: }
                    204: 
                    205: 
                    206: static void
                    207: create_viewlist(parent)
                    208: Widget parent;
                    209: {
                    210:   Widget view_list, list_area;
                    211:   Arg args[10];
                    212: 
                    213:   view_list = XtCreateManagedWidget("view_list", viewportWidgetClass, parent,
                    214:                                   args, 0);
                    215: 
                    216:   XtSetArg(args[0], XtNlist, result_list);
                    217:   XtSetArg(args[1], XtNdefaultColumns, (int) 1);
                    218:   XtSetArg(args[2], XtNverticalList, True );
                    219:   list_area = XtCreateManagedWidget("list_area", listWidgetClass,
                    220:                                          view_list, args, 3);
                    221:   XtAddCallback(list_area, XtNcallback, Change_Search_Area, (XtPointer) 0 );
                    222: 
                    223: }
                    224: 
                    225: 
                    226: 
                    227: static void
                    228: create_outputform(parent)
                    229: Widget parent;
                    230: {
                    231:   Arg args[10];
                    232:   static XawTextSelectType sarray[] = {
                    233:     XawselectLine,
                    234:     XawselectPosition,
                    235:     XawselectAll,
                    236:     XawselectNull
                    237:   };
                    238: 
                    239:   XtSetArg(args[0], XtNselectTypes, sarray);
                    240:   (void) XtCreateManagedWidget("result_area", asciiTextWidgetClass,
                    241:                                 parent, args, 1);
                    242: 
                    243: }
                    244: 
                    245: 
                    246: 
                    247: static void
                    248: create_commandform(parent)
                    249: Widget parent;
                    250: {
                    251:   Arg args[1];      /* used to pass zero args...to be consistent for lint */
                    252:   Widget form, widen_but;
                    253:   Widget search_but, list_but, lookback_but;
                    254: 
                    255: 
                    256:   form = XtCreateManagedWidget("commandform", formWidgetClass, parent,
                    257:                                args, 0 );
                    258: 
                    259:   search_but = XtCreateManagedWidget("search_but", commandWidgetClass,
                    260:                                form, args, 0 );
                    261:   XtAddCallback(search_but, XtNcallback, Search, (XtPointer)0 );
                    262: 
                    263:  
                    264:   list_but = XtCreateManagedWidget("list_but", commandWidgetClass,
                    265:                                form, args, 0 );
                    266:   XtAddCallback(list_but,  XtNcallback, List, (XtPointer)0 );
                    267: 
                    268: 
                    269:   lookback_but = XtCreateManagedWidget("lookback_but", commandWidgetClass,
                    270:                                form, args, 0);
                    271:   XtAddCallback(lookback_but, XtNcallback, PopupList, (XtPointer)0 );
                    272: 
                    273: 
                    274:   widen_but = XtCreateManagedWidget("widen_but", commandWidgetClass, form,
                    275:                                args, 0 );
                    276:   XtAddCallback(widen_but, XtNcallback, widen_search, (XtPointer)0 );
                    277: }
                    278: 
                    279: 
                    280: 
                    281:   
                    282: void
                    283: Searchpress()
                    284: {
                    285:   XEvent search_event;
                    286:   Widget search_but = XtNameToWidget(toplevel, "outer.commandform.search_but");
                    287: 
                    288:   search_event.type = ButtonPress;
                    289:   search_event.xbutton.button = Button1;
                    290:   search_event.xany.display = XtDisplay(search_but);
                    291:   search_event.xany.window = XtWindow(search_but);
                    292: 
                    293:   XSendEvent(XtDisplay(search_but), XtWindow(search_but), True, 
                    294:             ButtonPressMask | ButtonReleaseMask, &search_event);
                    295: 
                    296:   search_event.type = ButtonRelease;
                    297:   XSendEvent(XtDisplay(search_but), XtWindow(search_but), True,
                    298:              ButtonPressMask | ButtonReleaseMask, &search_event);
                    299: }
                    300: 
                    301: 
                    302: 
                    303: static Widget
                    304: create_type_menu(parent)
                    305: Widget parent;
                    306: {
                    307:   Arg args[1];    /* used to pass zero args...to be consistent for lint */
                    308:   Widget menu, button;
                    309:   int n;
                    310: 
                    311:   menu = XtCreatePopupShell("menu", simpleMenuWidgetClass,
                    312:                                 parent, args, 0 );
                    313: 
                    314:   n = 0;
                    315:   while (av_typeindx[n] != -1) {
                    316:     button = XtCreateManagedWidget((String) filttype[av_typeindx[n]],
                    317:                                    smeBSBObjectClass,
                    318:                                    menu, args, 0);
                    319:     XtAddCallback(button, XtNcallback, Change_Type, (XtPointer) av_typeindx[n]);
                    320:     n++;
                    321:   }
                    322:   return menu;
                    323: }
                    324: 
                    325:   
                    326: 
                    327: static void
                    328: create_inputform(parent)
                    329: Widget parent;
                    330: {
                    331:   Widget form, area_form, for_form, type_form;
                    332:   Widget type_but;
                    333:   Widget search_for;
                    334: 
                    335:   Arg args[10];
                    336: 
                    337: 
                    338:   static XtActionsRec actionsTable[] = {
                    339:     {"Searchpress", (XtActionProc) Searchpress},
                    340:   };
                    341: 
                    342:   static char defaultTranslations[] =
                    343:     "<Key>Return: Searchpress() \n\
                    344:      Ctrl<Key>M:  Searchpress() \n\
                    345:      Ctrl<Key>O:  Searchpress()";
                    346: 
                    347:   XtTranslations trans_table;
                    348: 
                    349:   form = XtCreateManagedWidget("inputform", formWidgetClass, parent,
                    350:                                args, 0 );
                    351: 
                    352:   area_form = XtCreateManagedWidget("area_form", formWidgetClass, form,
                    353:                                args, 0 );
                    354: 
                    355:   (void) XtCreateManagedWidget("search_area_label", 
                    356:                                labelWidgetClass, area_form, args, 0);
                    357: 
                    358: 
                    359:   XtSetArg(args[0], XtNstring, friendly_base_path);
                    360:   XtSetArg(args[1], XtNwidth, (Dimension) 300);
                    361:   (void) XtCreateManagedWidget("search_area", asciiTextWidgetClass,
                    362:                                      area_form, args, 2);
                    363: 
                    364:   for_form = XtCreateManagedWidget("for_form", formWidgetClass, form,
                    365:                                args, 0);
                    366: 
                    367:   (void) XtCreateManagedWidget("search_for_label", labelWidgetClass,
                    368:                                     for_form, args, 0);
                    369: 
                    370:   search_for = XtCreateManagedWidget("search_for", asciiTextWidgetClass,
                    371:                                      for_form, args, 0);
                    372:   
                    373:   XtAppAddActions(app_con, actionsTable, XtNumber(actionsTable));
                    374:   trans_table = XtParseTranslationTable(defaultTranslations);
                    375:   XtOverrideTranslations(search_for, trans_table);
                    376: 
                    377:   type_form = XtCreateManagedWidget("type_form", formWidgetClass, form,
                    378:                                args, 0 );
                    379: 
                    380:   type_but = XtCreateManagedWidget("type_but", menuButtonWidgetClass,
                    381:                                      type_form, args, 0);
                    382: 
                    383:   (void) XtCreateManagedWidget("search_type", asciiTextWidgetClass,
                    384:                                      type_form, args, 0);
                    385: 
                    386:   (void) create_type_menu(type_but);
                    387: }  
                    388: 
                    389: 
                    390: 
                    391: 
                    392:   
                    393: static void
                    394: create_genform(parent)
                    395: Widget parent;
                    396: {
                    397:   Widget form, quit_but, help_but;
                    398:   Arg args[10];
                    399: 
                    400:   form = XtCreateManagedWidget("genform", formWidgetClass, parent,
                    401:                               args, 0 );
                    402: 
                    403:   XtSetArg(args[0], XtNheight, stef_height);
                    404:   XtSetArg(args[1], XtNwidth, stef_width);
                    405:   (void) XtCreateManagedWidget("title", labelWidgetClass,form,
                    406:                                    args, 2);
                    407: 
                    408:   quit_but = XtCreateManagedWidget("quit_but", commandWidgetClass, form,
                    409:                                   args, 0);
                    410:   XtAddCallback(quit_but, XtNcallback, Quit, (XtPointer) toplevel);
                    411:                           
                    412: 
                    413:   help_but = XtCreateManagedWidget("help_but", commandWidgetClass, form, 
                    414:                                   args, 0);
                    415:   CreatePopupHelp(help_but);
                    416:   XtAddCallback(help_but, XtNcallback, PopupHelp, (XtPointer)0 );
                    417: }
                    418: 
                    419: 
                    420: 
                    421: /*ARGSUSED*/  
                    422: static void
                    423: Quit(widget, closure, callData)
                    424: Widget widget;
                    425: XtPointer closure, callData;
                    426: {
                    427:   XtDestroyWidget((Widget) closure);
                    428:   exit(0);
                    429: }
                    430: 
                    431: 
                    432: void
                    433: CreatePopupHelp(button)
                    434: Widget  button;
                    435: {
                    436:   Widget      popup, form, quit_but;
                    437:   Arg args[5];
                    438:   FILE *file;
                    439:   char fullname[MAXLENGTH];
                    440:   char filename[MAXLENGTH];
                    441: 
                    442:   (void) strcpy(filename, "xd.help");
                    443: 
                    444:   popup = XtCreatePopupShell("popup", transientShellWidgetClass, button,
                    445:                                args, 0);
                    446: 
                    447:   form = XtCreateManagedWidget("form", formWidgetClass, popup,
                    448:                                    args, 0);
                    449: 
                    450:   quit_but = XtCreateManagedWidget("quit_but", commandWidgetClass, form,
                    451:                                    args, 0);
                    452:   XtAddCallback(quit_but, XtNcallback, PopdownHelp, (XtPointer)0 );
                    453: 
                    454:   (void) strcpy(fullname, dua_help_dir);
                    455:   (void) strcat(fullname, filename);
                    456:   if (!(file = fopen(fullname, "r"))) {
                    457:     (void) strcpy(fullname, "./xd/helpdir/");
                    458:     (void) strcat(fullname, filename);
                    459:     if (!(file = fopen(fullname, "r"))) (void) printf("Helpfile not found");
                    460:   }
                    461: 
                    462:   if(file != NULL) {
                    463:     (void) fclose(file);
                    464:     XtSetArg(args[0], XtNstring, fullname );
                    465:   }
                    466:   (void) XtCreateManagedWidget("help_text", asciiTextWidgetClass, form,
                    467:                                args, 1);
                    468: }
                    469: 
                    470: 
                    471: /*ARGSUSED*/
                    472: static void
                    473: PopupHelp(button, client_data, call_data)
                    474: Widget  button;
                    475: XtPointer client_data, call_data;
                    476: {
                    477:   Widget pop_widg = XtNameToWidget(button, "popup");
                    478:   Arg         args[5];
                    479:   Position    x, y;
                    480:   Cardinal    n;
                    481: 
                    482: 
                    483:   XtTranslateCoords(button, (Position) 0, (Position) 0,
                    484:                     &x, &y);
                    485: 
                    486:   n = 0;
                    487:   XtSetArg(args[n], XtNx, x);           n++;
                    488:   XtSetArg(args[n], XtNy, y-245);       n++;
                    489:   XtSetValues(pop_widg, args, n);
                    490: 
                    491:   help_popped_up = TRUE;
                    492:   XtPopup(pop_widg, XtGrabNone);
                    493: 
                    494: }
                    495: 
                    496: /*ARGSUSED*/
                    497: static void
                    498: PopdownHelp(button, client_data, call_data)
                    499: Widget  button;
                    500: XtPointer client_data, call_data;
                    501: {
                    502:   Widget pop_widg = XtParent( XtParent(button) );
                    503: 
                    504:   help_popped_up = FALSE;
                    505:   XtPopdown(pop_widg);
                    506: }
                    507: 
                    508: void
                    509: Change_Help(filename)
                    510: String filename;
                    511: {
                    512:   Arg args[5];
                    513:   FILE *file;
                    514:   char *fullname;
                    515:   static char * old_pointer = 0;
                    516: 
                    517:   /* this gets around a problem  mine or athena widgets ? */
                    518:   /* does usestringinplace=false work for type = file */
                    519:   /*  when using asciitext widgets? */
                    520: 
                    521:   if(help_popped_up){
                    522:     fullname = XtMalloc(MAXLENGTH * sizeof(char));
                    523:     if(old_pointer != 0) {
                    524:       XtFree((char *) old_pointer);
                    525:       old_pointer = fullname;
                    526:     }
                    527: 
                    528:     (void) strcpy(fullname, dua_help_dir);
                    529:     (void) strcat(fullname, filename);
                    530:     if (!(file = fopen(fullname, "r"))) {
                    531:       (void) strcpy(fullname, "./Xd/helpdir/");
                    532:       (void) strcat(fullname, filename);
                    533:       if (!(file = fopen(fullname, "r"))) (void) fprintf(stderr, "Helpfile not found\n");
                    534:     }
                    535: 
                    536:     if(file != NULL) {
                    537:       (void) fclose(file);
                    538:       XtSetArg(args[0], XtNstring, fullname );
                    539:       XtSetValues( XtNameToWidget(toplevel,
                    540:                "outer.genform.help_but.popup.form.help_text"), args, 1);
                    541:     }
                    542:     XFlush(XtDisplay(toplevel));
                    543:   }
                    544: }
                    545: 
                    546: 
                    547: /*ARGSUSED*/
                    548: static void
                    549: PopupList(button, client_data, call_data)
                    550: Widget  button;
                    551: XtPointer client_data, call_data;
                    552: {
                    553:   Arg         args[5];
                    554:   Widget      popup, form, list_places, quit_but;
                    555:   Position    x, y;
                    556:   Dimension   width, height;
                    557:   Cardinal    n;
                    558:   String widget_name = "outer.commandform.lookback_but.popup";
                    559: 
                    560: 
                    561:   if(lookback_open == True) {
                    562:     XtPopup(XtNameToWidget(toplevel, widget_name), XtGrabNone);
                    563:     return;
                    564:   }
                    565: 
                    566: 
                    567:   n = 0;
                    568:   XtSetArg(args[0], XtNwidth, &width); n++;
                    569:   XtSetArg(args[1], XtNheight, &height); n++;
                    570:   XtGetValues(button, args, n);
                    571:   XtTranslateCoords(button, (Position) (width / 2), (Position) (height / 2),
                    572:                     &x, &y);
                    573: 
                    574:   n = 0;
                    575:   XtSetArg(args[n], XtNx, x);                         n++;
                    576:   XtSetArg(args[n], XtNy, y);                         n++;
                    577: 
                    578:   popup = XtCreatePopupShell("popup", transientShellWidgetClass, button,
                    579:                                args, n);
                    580:   
                    581:   form = XtCreateManagedWidget("form", formWidgetClass, popup,
                    582:                                    args, 0);
                    583: 
                    584:   XtSetArg(args[0], XtNlabel, (String) "Quit");
                    585:   quit_but = XtCreateManagedWidget("quit_but", commandWidgetClass, form,
                    586:                                    args, 1);
                    587:   XtAddCallback(quit_but, XtNcallback, Quit_Popup, (XtPointer) form);
                    588: 
                    589:   XtSetArg(args[0], XtNlist, lookback_list);
                    590:   XtSetArg(args[1], XtNfromVert, quit_but);
                    591:   XtSetArg(args[2], XtNverticalList, True );
                    592:   XtSetArg(args[3], XtNnumberStrings, MAXLOOKBACKLENGTH );
                    593:   list_places = XtCreateManagedWidget("list_places", listWidgetClass, form,
                    594:                                args, 4);
                    595:   XtAddCallback(list_places, XtNcallback, Change_Search_Area, (XtPointer)0 );
                    596: 
                    597:   lookback_open = True;
                    598: 
                    599:   XtPopup(popup, XtGrabNone);
                    600: }
                    601: 
                    602: 
                    603: 
                    604: 
                    605: void
                    606: Add_To_Results(add_this)
                    607: String add_this;
                    608: {
                    609:   Arg args[10];
                    610:   String str;
                    611:   char new_str[2000];
                    612:   Widget result_widg = XtNameToWidget(toplevel, "outer.result_area");
                    613: 
                    614:   XtSetArg(args[0], XtNstring, &str);
                    615:   XtGetValues(result_widg, args, ONE);
                    616: 
                    617:   if(*str == '\0')
                    618:     (void) strcpy(new_str, add_this);
                    619:   else
                    620:     (void) sprintf((char *)new_str,"%s\n%s", str, add_this);
                    621: 
                    622:   XtSetArg(args[0], XtNstring, new_str);
                    623:   XtSetValues(result_widg, args, 1);
                    624: }
                    625: 
                    626: 
                    627: 
                    628: void Clear_Results()
                    629: {
                    630:   Arg args[10];
                    631:   Widget result_widg = XtNameToWidget(toplevel, "outer.result_area");
                    632: 
                    633:   XtSetArg(args[0], XtNstring, "\0");
                    634:   XtSetValues(result_widg, args, 1);
                    635: }
                    636: 
                    637: 
                    638: 
                    639: Switch_Off_Result_Update()
                    640: {
                    641:   Widget result_widg = XtNameToWidget(toplevel, "outer.result_area");
                    642:   XawTextDisableRedisplay(result_widg);
                    643: }
                    644: 
                    645: 
                    646: Switch_On_Result_Update()
                    647: {
                    648:   Widget result_widg = XtNameToWidget(toplevel, "outer.result_area");
                    649:   XawTextEnableRedisplay(result_widg);
                    650: }
                    651: 
                    652: 
                    653: 
                    654: /*ARGSUSED*/
                    655: static void
                    656: Search(w, client_data, call_data)
                    657: Widget w;
                    658: XtPointer client_data, call_data;
                    659: {
                    660:   Arg args[10];
                    661:   int n, numb;
                    662:   String str;
                    663:   String string;
                    664:   Widget list_widg = XtNameToWidget(toplevel, "outer.view_list.list_area");
                    665:   Widget widg = XtNameToWidget(toplevel, 
                    666:                              "outer.inputform.for_form.search_for");
                    667: 
                    668:   Clear_Results();
                    669:   XtSetArg(args[0], XtNstring, &str);
                    670:   XtGetValues(widg, args, ONE);
                    671:   (void) strcpy(mvalue, str);
                    672:   srch_start();
                    673:   xprint("Search completed");
                    674:   showseq = dnseq;
                    675:   element_number = entry_number;
                    676: 
                    677:   numb = element_number;
                    678:   if(numb >= MAXRESULTLISTLENGTH)
                    679:     numb = MAXRESULTLISTLENGTH-1;
                    680: 
                    681:   for (n = 0; n < numb; n++) {
                    682:     string = get_from_seq(n+1, showseq);
                    683:     (void) strcpy(result_list[n], string);
                    684:   }
                    685: 
                    686:   for(; n<MAXRESULTLISTLENGTH; n++) {
                    687:     (void) strcpy(result_list[n], "");
                    688:   }
                    689: 
                    690:   XawListChange(list_widg, result_list, MAXRESULTLISTLENGTH, 0, True);
                    691: }
                    692: 
                    693: 
                    694: 
                    695: /*ARGSUSED*/
                    696: static void
                    697: List(w, client_data, call_data)
                    698: Widget w;
                    699: XtPointer client_data, call_data;
                    700: {
                    701:   String string;
                    702:   int n, numb;
                    703:   Arg args[10];
                    704:   Widget list_widg = XtNameToWidget(toplevel, "outer.view_list.list_area");
                    705:   Widget top_widg= XtNameToWidget(toplevel, "outer");
                    706:   Display *this_display = XtDisplay(top_widg);
                    707:   Cursor time_cur = XCreateFontCursor(this_display, XC_watch);
                    708:   Cursor normal_cur;
                    709: 
                    710:   Clear_Results();
                    711:   (void) strcpy(mvalue, "");
                    712: 
                    713:   XtSetArg(args[0], XtNcursor, &normal_cur );
                    714:   XtGetValues(top_widg, args, 1);
                    715: 
                    716:   XtSetArg(args[0], XtNcursor, time_cur );
                    717:   XtSetValues(top_widg, args, 1);
                    718:   XFlush(this_display);
                    719: 
                    720: 
                    721:   srch_start();
                    722:   set_default_type();
                    723:   showseq = dnseq;
                    724:   element_number = entry_number;
                    725: 
                    726:   numb = element_number;
                    727:   if(numb >= MAXRESULTLISTLENGTH)
                    728:     numb = MAXRESULTLISTLENGTH-1;
                    729: 
                    730:   for (n = 0; n < numb; n++) {
                    731:     string = get_from_seq(n+1, showseq);
                    732:     (void) strcpy(result_list[n], string);
                    733:   }
                    734: 
                    735:   for(; n<MAXRESULTLISTLENGTH; n++) {
                    736:     (void) strcpy(result_list[n], "");
                    737:   }
                    738: 
                    739:   XtSetArg(args[0], XtNcursor, normal_cur);
                    740:   XtSetValues(top_widg, args, 1);
                    741: 
                    742:   XawListChange(list_widg, result_list, MAXRESULTLISTLENGTH, 0, True);
                    743: }
                    744: 
                    745: 
                    746: 
                    747: /*ARGSUSED*/
                    748: static void
                    749: Change_Type(w, client_data, call_data)
                    750: Widget w;
                    751: XtPointer client_data, call_data;
                    752: {
                    753:   typeindx = (unsigned int) client_data;
                    754:   Set_Search_Type(filttype[(int) client_data]);
                    755: }
                    756: 
                    757: 
                    758: 
                    759: Set_Search_Type(string)
                    760: String string;
                    761: {
                    762:   Arg         args[5];
                    763:   Widget search_w = XtNameToWidget(toplevel, "outer.inputform.type_form.search_type");
                    764:   Widget typebut_w = XtNameToWidget(toplevel,
                    765:                                     "outer.inputform.type_form.type_but");
                    766:   Widget typemenu_w = XtNameToWidget(toplevel,
                    767:                                     "outer.inputform.type_form.type_but.menu");
                    768: 
                    769:   XtDestroyWidget(typemenu_w);
                    770:   (void) create_type_menu(typebut_w);
                    771: 
                    772:   XtSetArg(args[0], XtNstring, string);
                    773:   XtSetValues( search_w, args, 1);
                    774: }
                    775: 
                    776: 
                    777: /*ARGSUSED*/
                    778: static void
                    779: Change_Search_Area(w, client_data, call_data)
                    780: Widget w;
                    781: XtPointer client_data, call_data;
                    782: {
                    783: 
                    784:   XawListReturnStruct *item = (XawListReturnStruct*)call_data;
                    785: 
                    786:   Clear_Results();
                    787: 
                    788:   if((strlen(item->string) != 0) && (strcmp(item->string, NOHISTORY))){
                    789:     Set_Search_Area(item->string);
                    790:     rd_start();
                    791:     add_to_lookback(base_path);
                    792:   }
                    793: 
                    794:   XawListUnhighlight(w);
                    795: }
                    796: 
                    797: 
                    798: 
                    799: Set_Search_Area(string)
                    800: String string;
                    801: {
                    802:   Arg   args[10];
                    803:   String widget_name = "outer.inputform.area_form.search_area";
                    804:   Widget search_w = XtNameToWidget(toplevel, widget_name);
                    805: 
                    806:   XtSetArg(args[0], XtNstring, string);
                    807:   XtSetValues(search_w, args, 1);
                    808: 
                    809:   (void) strcpy(base_path, string);
                    810:   set_default_type();
                    811: }
                    812: 
                    813: /*ARGSUSED*/
                    814: static void
                    815: Quit_Popup(widget, client_data, call_data)
                    816: Widget  widget;
                    817: XtPointer client_data, call_data;
                    818: {
                    819:     Widget popup = XtParent((Widget) client_data);
                    820: 
                    821:     if(lookback_open == True)
                    822:       if(XtNameToWidget(toplevel,
                    823:          "outer.commandform.lookback_but.popup.form.quit_but") == widget)
                    824:              lookback_open = False; 
                    825: 
                    826:     XtDestroyWidget(popup);
                    827: }
                    828: 
                    829: 
                    830: void
                    831: xprint(str)
                    832: String str;
                    833: {
                    834:   Add_To_Results(str);  
                    835: }
                    836: 
                    837: /*ARGSUSED*/
                    838: static void
                    839: widen_search()
                    840: {
                    841:   Arg   args[10];
                    842:   String widget_name = "outer.inputform.area_form.search_area";
                    843:   Widget search_w = XtNameToWidget(toplevel, widget_name);
                    844: 
                    845:   widen();
                    846:   XtSetArg(args[0], XtNstring, base_path);
                    847:   XtSetValues(search_w, args, 1);
                    848: }
                    849:  
                    850: 
                    851: void
                    852: add_to_lookback(addthis)
                    853: String addthis;
                    854: {
                    855:   int count;
                    856:   String widget_name = "outer.commandform.lookback_but.popup.form.list_places";
                    857:   Widget list_w;
                    858: 
                    859:   for(count=0; count<MAXLOOKBACKLENGTH; count++ ) 
                    860:     if(!strcmp(lookback_list[count], addthis))
                    861:       return;    /* no duplicates thankyou! */
                    862: 
                    863:   for(count=0; count<MAXLOOKBACKLENGTH-1; ) {
                    864:     (void) strcpy(lookback_list[count], lookback_list[count+1]);
                    865:     count++;
                    866:   }
                    867:   (void) strcpy(lookback_list[count++], addthis);
                    868:   
                    869:   if(lookback_open == True) {
                    870:     list_w = XtNameToWidget(toplevel,widget_name);
                    871:     XawListChange(list_w, lookback_list, MAXLOOKBACKLENGTH, 0, True);
                    872:   }
                    873:  
                    874:   XFlush(XtDisplay(toplevel));
                    875: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.