home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / misc / sci / gfft / source / wbenchm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-25  |  3.8 KB  |  169 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        wbenchm.c
  13.  * Purpose:     workbench GUI main functions
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     19-Nov-1993 CPP; Created.
  16.  * Comments:    Workbench GUI.  Amiga Dependent!
  17.  */
  18.  
  19. #ifdef AMIGA
  20.  
  21. #include <stdlib.h>    /* exit()     */
  22. #include <stdio.h>     /* sprintf() */
  23. #include <string.h>
  24. /*
  25.  * Amiga includes
  26.  */
  27. #include <exec/types.h>
  28. #include <exec/exec.h>
  29. #include <workbench/workbench.h>
  30. #include <workbench/icon.h>
  31. #include <workbench/startup.h>
  32. #include <intuition/intuition.h>
  33. #include <clib/intuition_protos.h>
  34. #include <clib/exec_protos.h>
  35. #include <proto/icon.h>
  36. #include <proto/dos.h>
  37. #include <dos/dos.h>
  38.  
  39. /*
  40.  * GFFT includes
  41.  */
  42. #include "gfft.h"
  43. #include "settings.h"  /* for testing */
  44. #include "wbench.h"
  45.  
  46. /*
  47.  * Default console (Many thanks to SAS for making this possible.)
  48.  */
  49. char __stdiowin[] = "CON:0/160/640/40/GfftConsole";
  50.  
  51.  
  52. extern struct WBStartup *WBenchMsg;
  53.  
  54. /*
  55.  * Semi-static variables (used also by wbdialog)
  56.  */
  57. LONG num_files = 0;
  58. LONG file_index = 0;
  59.  
  60. /*
  61.  * Statics
  62.  */
  63. static int within_workbench_loop = FALSE;
  64. static void workbench_dialog_loop (void);
  65.  
  66.  
  67. void workbench_main (void)
  68. {
  69.     LONG olddir;
  70.  
  71.     open_libraries ();
  72.  
  73.     if (WBenchMsg && (num_files = WBenchMsg->sm_NumArgs - 1))
  74.     {
  75.     /*
  76.      * Loop through selected project icon(s)
  77.      */
  78.     for (file_index = 0; file_index < num_files; file_index++)
  79.     {
  80.         /*
  81.          * Change to directory containing selected object (file)
  82.          * then, open it
  83.          * then, change back
  84.          * then, run dialog window
  85.          * (if error, try next file)
  86.          */
  87.         LONG i = file_index;
  88.         CATCH_ERROR
  89.         {
  90.         olddir = CurrentDir (WBenchMsg->sm_ArgList[i+1].wa_Lock);
  91.         set_read (WBenchMsg->sm_ArgList[i+1].wa_Name);
  92.         CurrentDir (olddir);
  93.         workbench_dialog_loop ();
  94.         }
  95.         END_CATCH_ERROR;
  96.     }
  97.     }
  98.     else
  99.     {
  100.     /* 
  101.      * No project files selected
  102.      */
  103.     CATCH_ERROR
  104.     {
  105.         workbench_dialog_loop ();
  106.     }
  107.     END_CATCH_ERROR;
  108.     }
  109. }
  110.  
  111.  
  112. /*
  113.  * The following functions permit the CLI interactive mode to be activated
  114.  * from the workbench, and the CLI to be started from the workbench, and
  115.  * to return the the original mode.
  116.  */
  117.  
  118. static void workbench_dialog_loop (void)
  119. {
  120.     int next_action = WORKBENCH_MODE;
  121.     BOOLEAN help_displayed = FALSE;
  122.  
  123.     within_workbench_loop = TRUE;
  124.     Plot = ANY_PLOT;
  125.     while (next_action == WORKBENCH_MODE ||
  126.        next_action == INTERACTIVE_MODE)
  127.     {
  128.     switch (next_action)
  129.     {
  130.     case WORKBENCH_MODE:
  131.         next_action = workbench_dialog ();
  132.         break;
  133.     case INTERACTIVE_MODE:
  134.         if (!help_displayed)
  135.         {
  136.         printf ("Enter HELP for help...\n");
  137.         help_displayed = TRUE;
  138.         }
  139.         cli_interactive_loop (FALSE);
  140.         next_action = WORKBENCH_MODE;
  141.         break;
  142.     }
  143.     }
  144.     within_workbench_loop = FALSE;
  145. }
  146.           
  147. char *workbench_command (char *arguments)
  148. {
  149.     int previous_command_mode = CommandMode;
  150.  
  151.     if (within_workbench_loop)
  152.     {
  153.     CommandMode = WORKBENCH_MODE;
  154.     return arguments;
  155.     /*
  156.      * return to workbench through cli_interactive_loop
  157.      */
  158.     }
  159.     else
  160.     {
  161.     workbench_dialog_loop ();
  162.     CommandMode = previous_command_mode;
  163.     }
  164.     return arguments;
  165. }
  166.  
  167. #endif  /* ifdef AMIGA */
  168.  
  169.