home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / text / tex / pastex / source / driver / show / amiga / newcli.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-06  |  6.0 KB  |  269 lines

  1.  
  2. #include "defines.h"
  3.  
  4. #include <stdio.h>
  5. #include <exec/types.h>
  6. #include <exec/memory.h>
  7. #include <intuition/intuition.h>
  8. #include <libraries/dos.h>
  9. #include <libraries/dosextens.h>
  10. #include <dos/dostags.h>
  11. #include <dos/var.h>
  12.  
  13. #ifdef AZTEC_C
  14. #  include <functions.h>
  15. #  define __stdargs
  16. #  define ACTION_END    1007L
  17. #endif
  18.  
  19. #ifdef ANSI
  20. #  include <stdlib.h>
  21. #endif
  22.  
  23. #include <dos.h>
  24. #include <clib/intuition_protos.h>
  25. #include <clib/exec_protos.h>
  26. #include <clib/dos_protos.h>
  27. #include <pragmas/intuition_pragmas.h>
  28. #include <pragmas/exec_pragmas.h>
  29. #include <pragmas/dos_pragmas.h>
  30.  
  31. #include "globals.h"
  32. #include "amscreen.h"
  33. #include "amscreen.i"
  34. #include "newcli.i"
  35. #include "globals.i"
  36. #include "am_requ.i"
  37.  
  38. #define ZERO    0L
  39.  
  40. #if defined(REQ_LIBRARY)
  41. # include <libraries/reqbase.h>
  42. # include <clib/req_protos.h>
  43. #endif
  44.  
  45.  
  46.  
  47. /*
  48.  * Fuer die locale-Library:
  49.  *
  50.  * Hier duerfen *nur* die MSG_#? Nummern eingebunden werden!
  51.  * Achtung:
  52.  * Es muss/sollte 'multiple-include' erlaubt sein!
  53.  */
  54. #include "local.i"
  55.  
  56. #undef  CATCOMP_ARRAY
  57. #undef  CATCOMP_BLOCK
  58. #undef  CATCOMP_STRINGS
  59. #define CATCOMP_NUMBERS
  60. #include "localstr.h"
  61.  
  62.  
  63.  
  64. #if 0
  65. /* ausgeklammert, da nur noch os2 unterstuetzt wird!!! */
  66. struct MsgPort * __stdargs NewConsole        Args((struct Window *w, struct DosLibrary *DOSBase));
  67.  
  68. /* die folgenden Funktionen werden bei is_os2 nur zu Dummy-Funktionen */
  69. static struct StandardPacket *CreateStdPkt    Args((void));
  70. static void DeleteStdPkt            Args((struct StandardPacket *sp));
  71. static LONG DoStdPkt                Args((struct StandardPacket *sp,
  72.                               struct MsgPort *mp,
  73.                               LONG *pres2));
  74. #endif
  75. static struct Window *Open_cli_Win        Args((void));
  76.  
  77.  
  78. extern struct DosLibrary    *DOSBase;
  79.  
  80.  
  81. #ifdef AZTEC_C
  82. #pragma regcall( DeleteStdPkt(a0))
  83. #pragma regcall( /* d0 = */ DoStdPkt(a0,a1,a2))
  84. #endif
  85.  
  86.  
  87. static struct TagItem system_tags[] = {
  88.             { SYS_Input,     NULL    },
  89.             { SYS_Output,     NULL    },
  90.             { SYS_Asynch,     NULL    },
  91.             { SYS_UserShell, TRUE     },
  92.             { NP_Priority,   0        },
  93.             { NP_StackSize,  4096     },
  94.             { NP_WindowPtr,  NULL     },
  95.             { TAG_DONE,      NULL     },
  96.                         { TAG_DONE,     0L    }
  97.   };
  98.  
  99.  
  100.  
  101.  
  102. void execute_script(char *script, int new)
  103. {
  104.   char con[150], file[40], dir[60];
  105.   int ret;
  106.  
  107.   if (!is_dvif) {
  108.     Message(MSG_NO_DVI_FILE);
  109.   }
  110.   else {
  111.  
  112.     if (is_os2 && is_pubscr && script != NULL && win2 != NULL) {
  113.     ret = GetVar("TEXFORMAT", m_string, 50, GVF_GLOBAL_ONLY);
  114.     if (ret == -1 || new) {
  115.       ChangeFormatFile();
  116.     }
  117.     if (GetVar("ShowDVI-file", file, 39, GVF_LOCAL_ONLY) != -1 &&
  118.         GetVar("ShowDVI-dir", dir, 59, GVF_LOCAL_ONLY) != -1) {
  119.         sprintf(con, "%s \"%s\" \"%s\" screenname=\"%s\"", script, file, dir, GetCurrentPubScr());
  120.         if (start_command(GetTeXString(MSG_EXECUTE_TEX_SCRIPT), con, NULL) != 0) {
  121.           Warning(MSG_CANT_START, con);
  122.         }
  123.     }
  124.     }
  125.   }
  126. }
  127.  
  128. void make_newcli(struct Screen *screen)
  129. {
  130. //    struct StandardPacket    *sp;
  131.     struct Window        *w;
  132. //    struct MsgPort        *mp;
  133. //    struct Process        *pr;
  134.     char             con[90];
  135. //    APTR            oldConsoleTask;
  136. //    APTR            oldWindowPtr;
  137.     BPTR            fh;
  138. //    LONG            res2;
  139.  
  140.  
  141.     if (is_os2) {
  142.       if (is_pubscr) {
  143.         sprintf(con, "newshell \"CON:%d/%d/%d/%d/ShowDVI - new CLI/CLOSE/SCREEN %s\"",
  144.         win2->LeftEdge+win2->BorderLeft+3, win2->TopEdge+2*win2->BorderTop+6,
  145.         win2->Width-win2->BorderLeft-win2->BorderRight-42,
  146.         (is_lace) ? 200 : 120, GetCurrentPubScr());
  147.         system_tags[6].ti_Data = (ULONG)win2;
  148.           (void)SystemTagList(con, &(system_tags[0]));
  149.       }
  150.       else {
  151.         if ((w = Open_cli_Win()) != NULL) {
  152.         sprintf(con, "CON://////WINDOW 0x%0.p/CLOSE", w);
  153.         if ((fh = Open(con, MODE_NEWFILE)) != ZERO) {
  154.             (void)Execute("", fh, ZERO);
  155.             Close(fh);
  156.                 /** hier KEIN CloseWindow(w); das macht schon die Shell!! **/
  157.         }
  158.         else {
  159.           CloseWindow(w);    /* CON: ist nicht aufgegangen??? */
  160.         }
  161.         }
  162.       }
  163.     }
  164. #if 0
  165.     else {
  166.       if ((sp = CreateStdPkt()) != NULL) {
  167.         if ((w = Open_cli_Win()) != NULL) {
  168.         if ((mp = NewConsole(w, DOSBase)) != NULL) {
  169.             pr = (struct Process *)FindTask(NULL);
  170.             oldConsoleTask    = pr->pr_ConsoleTask;
  171.             oldWindowPtr    = pr->pr_WindowPtr;
  172.             pr->pr_ConsoleTask    = (APTR)mp;
  173.             pr->pr_WindowPtr    = (APTR)w;
  174.  
  175.             if ((fh = Open("*", MODE_NEWFILE)) != ZERO) {
  176.             sp->sp_Pkt.dp_Type    = ACTION_SCREEN_MODE;
  177.             sp->sp_Pkt.dp_Arg1    = DOSFALSE;
  178.             (void)DoStdPkt(sp, mp, &res2);
  179.             (void)Execute("", fh, ZERO);
  180.             Close(fh);
  181.             }
  182.  
  183.             pr->pr_ConsoleTask    = oldConsoleTask;
  184.             pr->pr_WindowPtr    = oldWindowPtr;
  185.             if (fh == ZERO) {
  186.             sp->sp_Pkt.dp_Type    = ACTION_END;
  187.             (void)DoStdPkt(sp, mp, &res2);
  188.             }
  189.           }
  190.         }
  191.         else {
  192.           CloseWindow(w);
  193.         }
  194.         DeleteStdPkt(sp);
  195.       }
  196.     }
  197. #endif
  198. }
  199.  
  200.  
  201.  
  202. static struct Window *Open_cli_Win(void)
  203. {
  204.   struct NewWindow nw;
  205.  
  206.   nw.LeftEdge    = 5;
  207.   nw.TopEdge    = 25;
  208.   nw.Width    = screen->Width-30;
  209.   nw.Height    = (is_lace) ? 280 : 160;
  210.   nw.DetailPen    = 0;
  211.   nw.BlockPen    = 1;
  212.   nw.IDCMPFlags    = 0;
  213.   nw.Flags    = WINDOWSIZING | WINDOWDRAG | SIZEBBOTTOM | WFLG_DEPTHGADGET |
  214.           SMART_REFRESH | NOCAREREFRESH | ACTIVATE |
  215.           ((is_os2) ? WINDOWCLOSE : 0);
  216.   nw.FirstGadget= NULL;
  217.   nw.CheckMark    = NULL;
  218.   nw.Title    = GetTeXString(MSG_NEWCLI_TITLE);
  219.   nw.Screen    = screen;
  220.   nw.BitMap    = NULL;
  221.   nw.MinWidth    = 100;
  222.   nw.MinHeight    = 50;
  223.   nw.MaxWidth    = screen->Width;
  224.   nw.MaxHeight    = screen->Height;
  225.   nw.Type    = CUSTOMSCREEN;
  226.   
  227.   return OpenWindow(&nw);
  228. }
  229.  
  230. #if 0
  231.  
  232. static struct StandardPacket *CreateStdPkt(void)
  233. {
  234.     struct StandardPacket    *sp;
  235.  
  236.     if ((sp = (struct StandardPacket *)
  237.         AllocMem(sizeof(struct StandardPacket), MEMF_PUBLIC)) != NULL) {
  238.         if ((sp->sp_Msg.mn_ReplyPort = CreatePort(NULL, 0)) != NULL) {
  239.             sp->sp_Msg.mn_Node.ln_Name    = (char *)&sp->sp_Pkt;
  240.             sp->sp_Pkt.dp_Link        = &sp->sp_Msg;
  241.  
  242.             return sp;
  243.         }
  244.         FreeMem((APTR)sp, sizeof(struct StandardPacket));
  245.     }
  246.     return NULL;
  247. }
  248.  
  249. static void DeleteStdPkt(struct StandardPacket *sp)
  250. {
  251.     DeletePort(sp->sp_Msg.mn_ReplyPort);
  252.     FreeMem((APTR)sp, sizeof(struct StandardPacket));
  253. }
  254.  
  255. static LONG DoStdPkt(struct StandardPacket *sp, struct MsgPort *mp, LONG *pres2)
  256. {
  257.     sp->sp_Pkt.dp_Port    = sp->sp_Msg.mn_ReplyPort;
  258.  
  259.     PutMsg(mp, &sp->sp_Msg);
  260.     (void)WaitPort(sp->sp_Msg.mn_ReplyPort);
  261.     (void)GetMsg(sp->sp_Msg.mn_ReplyPort);
  262.  
  263.     *pres2    = sp->sp_Pkt.dp_Res2;
  264.  
  265.     return sp->sp_Pkt.dp_Res1;
  266. }
  267.  
  268. #endif
  269.