home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / most423.zip / edit.c < prev    next >
C/C++ Source or Header  |  1994-01-28  |  2KB  |  104 lines

  1. /* editor functions */
  2. #include <stdio.h>
  3.  
  4. #ifdef VMS
  5. #include <ssdef.h>
  6. #include <rmsdef.h>
  7. #include <dvidef.h>
  8. #include <jpidef.h>
  9. /* #include <libdef.h> */
  10. #include <descrip.h>
  11. #include <iodef.h>
  12. #include <ttdef.h>
  13. #include <stdlib.h>
  14.  
  15. #include "externs.h"
  16. #include "window.h"
  17. #include "sysdep.h"
  18.  
  19. int call_edt_tpu(char *file, int line, int what)
  20. {
  21.     char the_file[256];
  22.     extern void edt$edit();
  23.     extern void tpu$tpu();
  24.     struct dsc$descriptor_s  file_desc;
  25.     if (what == 1)  /* tpu */
  26.       sprintf(the_file,"TPU /START=%d ", line);
  27.     else
  28.       the_file[0] = '\0';
  29.     
  30.     strcat(the_file,file);
  31.     
  32.     file_desc.dsc$w_length = strlen(the_file);
  33.     file_desc.dsc$a_pointer = the_file;
  34.     file_desc.dsc$b_class = DSC$K_CLASS_S; /* scalar, string type */
  35.     file_desc.dsc$b_dtype = DSC$K_DTYPE_T; /* ascii string */
  36.  
  37.     if (what == 1)
  38.       tpu$tpu(&file_desc);
  39.     else
  40.       edt$edit(&file_desc);
  41.  
  42.     return(1);
  43. }
  44.  
  45. int call_emacs(char *file, int line)
  46. {
  47.     int status;
  48.     char lstr[40];
  49.     (void) sprintf(lstr,"%d",line);
  50.     define_logical_name("EMACS_FILE_LINE",lstr);
  51.     define_logical_name("EMACS_FILE_NAME",file);
  52.     status = do_emacs_command();
  53.     delete_logical_name("EMACS_FILE_NAME");
  54.     delete_logical_name("EMACS_FILE_LINE");
  55.     return(status);
  56. }
  57.  
  58. void edit_cmd()
  59. {
  60.     char *editor, file[80], *strp;
  61.     int status = 1;
  62.     
  63.     if ((editor = getenv("MOST_EDITOR")) == NULL)  editor = "EDT";
  64.           
  65.     strcpy(file,WIN->buf->file);
  66.     strp = file;
  67.     /*  lose the version number */
  68.     while((*strp != '\0') && (*strp != ';')) strp++;
  69.     *strp = '\0';
  70.     
  71.     reset_tty();
  72.     reset_display();
  73.     fflush(stdout);
  74.     
  75.     if (!strcmp(editor,"EMACS"))
  76.       {
  77.           status = call_emacs(file,C_LINE);
  78.       }
  79.     else if (!strcmp(editor,"EDT"))
  80.       {
  81.           status = call_edt_tpu(file,C_LINE,0);
  82.       }
  83.     else if (!strcmp(editor,"TPU"))
  84.       {
  85.           status = call_edt_tpu(file,C_LINE,1);
  86.       }
  87.     else message("Unknown editor.",1);
  88.     if (status)
  89.       {
  90.           redraw_display();
  91.       }
  92.     else message("Unable to edit.",1);
  93. }
  94.     
  95. #else
  96.  
  97. void edit_cmd()
  98.   {
  99.       ;
  100.   }
  101.  
  102. #endif
  103.  
  104.