home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 125.img / PRO-C4.ZIP / BENCH1.ZIP / HELP / EDIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-28  |  2.5 KB  |  123 lines

  1. /* ==( help/edit.c )== */
  2. /* ----------------------------------------------- */
  3. /* Pro-C  Copyright (C) 1988 - 1990 Vestronix Inc. */
  4. /* Modification to this source is not supported    */
  5. /* by Vestronix Inc.                               */
  6. /*            All Rights Reserved                  */
  7. /* ----------------------------------------------- */
  8. /* Written   JPK  26-Sep-88                        */
  9. /* Modified  SBF   1-Mar-90  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *   1-Mar-90  SBF - multi-user and cleanup
  17.  *  12-Dec-89  Geo - V2 version with variable lines
  18.  *  25-Oct-89  Geo - 1.32 Merge
  19.  *
  20.  *
  21. */
  22.  
  23. /* 
  24.  * Routines in this file :
  25.  *
  26.  * static void get_editor(void); 
  27.  *     prompts the user for their choice of editors
  28.  *
  29.  * int invoke_editor(void);
  30.  *    copies the help text into the edit file, invokes the editor
  31.  *
  32.  */
  33.  
  34. # include <stdio.h>
  35. # include <bench.h>
  36. # include "field.h"
  37. # include "help.h"
  38.  
  39. # ifdef ANSI
  40. static void get_editor(void);
  41. # else
  42. static void get_editor();
  43. # endif
  44.  
  45.  
  46. /*
  47.  * TurboC turns PHXXXXXX into PHAA.AAA, therefore 
  48.  * we cannot append .txt because the file name becomes
  49.  * jibberish.
  50. */
  51. int invoke_editor()
  52. {
  53.     char editfile[20];
  54.  
  55.     strcpy(editfile, "PHXXXXXX");
  56.     mktemp(editfile);
  57. #ifndef __TURBOC__
  58.     strcat(editfile, ".txt");
  59. #endif
  60.  
  61.     /* invoke the editor chosen by the user passing it the filename to use*/
  62.     if (*editorname == '\0')
  63.     {
  64.         get_editor();
  65.         if (*editorname  ==  '\0')
  66.             return(FALSE);
  67.     }
  68.     if (helptofile(editfile) == FALSE)
  69.     {
  70. #ifdef HDEBUG
  71.         errmsg("invoke_editor(): helptofile failed");
  72. #endif
  73.         unlink(editfile);
  74.         return(FALSE);
  75.     }
  76.  
  77.     resetscr();
  78.     if (do_cmd(editorname, editfile, NULL) == -1)
  79.     {
  80. # ifdef HDEBUG
  81.         perror("Error from editor call");
  82.         getchar();
  83. # endif
  84.         redraws();
  85.         unlink(editfile);
  86.         return(FALSE);
  87.     }
  88.  
  89.     if (filetohelp(editfile) == FALSE)
  90.         errmsg("invoke_editor(): filetohelp failed");
  91.  
  92.     unlink(editfile);
  93.  
  94.     redraws();
  95.     return(TRUE);
  96. }
  97.  
  98. char editorname_mask[] = "BVVVVVVVVV";
  99.  
  100. FIELD f_editorname =
  101. {
  102.     5, 9, 1, editorname, editorname_mask, 1,
  103.     10, F_TEXT, UNDERLINED, REVVID,
  104.     CONFIRM_NEEDED | NO_BLANK,
  105.     NULL, text_input, NULL, NULL
  106. };
  107.  
  108. static void get_editor()
  109. {
  110.     /* setup the editor input window */
  111.     create_w(9, 30, 7, 20);
  112.     border_w(0, BOLD);
  113.     underln_w(3, 1, BOLD, 20);
  114.     disp_w(2, 2, REVVID, " Editor Selection ");
  115.     disp_w(5, 3, NORMAL, "Name: ");
  116.  
  117.     /* get editor name */
  118.     input_wx(&f_editorname, K_ESC, 0);
  119.  
  120.     delete_w();
  121. }
  122.  
  123.