home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / rvi / part2 / rv.h < prev   
Encoding:
C/C++ Source or Header  |  1986-11-30  |  7.5 KB  |  208 lines

  1. #include <curses.h>
  2. /*
  3.  *    Rvi - Portable distributed screen editor (DSE).
  4.  *    86/07/16.  Alan Klietz
  5.  *    Copyright (c) 1986, Research Equipment Incorporated
  6.  *                          Minnesota Supercomputer Center
  7.  *
  8.  * Permission is hereby granted to use this software on any computer system
  9.  * and to copy this software, including for purposes of redistribution, subject
  10.  * to the conditions that 
  11.  *
  12.  *  o  The full text of this copyright message is retained and prominently
  13.  *      displayed
  14.  *
  15.  *  o  No misrepresentation is made as to the authorship of this software
  16.  *
  17.  *  o  The software is not used for resale or direct commercial advantage
  18.  *
  19.  *  By copying, installing, or using this software, the user agrees to abide
  20.  *  by the above terms and agrees that the software is accepted on an "as is"
  21.  *  basis, WITHOUT WARRANTY expressed or implied, and relieves Research Equip-
  22.  *  ment Inc., its affiliates, officers, agents, and employees of any and all
  23.  *  liability, direct of consequential, resulting from copying, installing
  24.  *  or using this software.
  25.  */
  26. #ifdef CRAY
  27. #    define un_firstline    un_fline
  28. #    define un_firstcol    un_fcol
  29. #    define sc_firstline    sc_fline
  30. #    define sc_firstcol    sc_fcol
  31. #    define rv_scroll_backward    rv_scr_bk
  32. #endif
  33.  
  34. /*
  35.  * Make initial program
  36.  * Alan Klietz, Nov 11, 1985.
  37.  */
  38.  
  39. /*
  40.  * Definitions
  41.  */
  42. #ifndef CTRL
  43. #define CTRL(c)     ('c'&037)
  44. #endif
  45.  
  46. #ifdef CRAY
  47. #    define    INT    long  /* for speed */
  48. #    define    boolean    long  /* for speed */
  49. #else
  50. #    define    INT    int
  51. #    define    boolean    char
  52. #endif
  53.  
  54. #ifdef USG
  55. #define    zero(ptr, len)        memset(ptr, 0, len)
  56. #define copy(to, from, len)    memcpy(to, from, len)
  57. #endif
  58.  
  59. #define CURLINE            (stdscr->_cury)
  60. #define CURCOLUMN        (stdscr->_curx)
  61.  
  62. #define COL_FIRST_NONWHITE    (-1023)    /* Column cookie for move_cursor(),
  63.                        move to first non-white char */
  64. #define COL_SAME        (-1024) /* Column cookie for move_cursor(),
  65.                        move to same column as previous */
  66.  
  67. #define RV_TIMEOUT    20        /* Seconds until ed request times out */
  68.  
  69.  
  70. /*
  71.  *  Five major structures,
  72.  *      struct line     -  A line of text.
  73.  *       struct yank     -  A yank buffer.
  74.  *     struct undo     -  The undo-last-change structure. 
  75.  *      struct screen   -  The screen proper.
  76.  *      struct window   -  Sliding window into file. (Larger than screen)
  77.  *     struct file     -  General information about the file.
  78.  */
  79.  
  80. struct li_line { /* A line of text */
  81.     INT    li_width;    /* Width of this line */
  82.     INT    li_segments;    /* Number of screen segments required */
  83.     char    *li_text;    /* Pointer to actual text. (malloc) */
  84. };
  85.  
  86. struct ya_yank { /* A yank buffer */
  87.     INT    ya_type;    /* YANK_COLS, YANK_SINGLE, or YANK_LINES */
  88.     char    *ya_text;    /* Pointer to text (malloc) */
  89.     INT    ya_width;    /* # of bytes yanked, if YANK_COLS or
  90.                    YANK_SINGLE */
  91.     INT    ya_numlines;    /* # of lines yanked, if YANK_LINES */
  92.     boolean    ya_madefile;    /* TRUE if tempfile was created */
  93. };
  94. #define YANK_EMPTY  0
  95. #define YANK_COLS   1
  96. #define YANK_SINGLE 2
  97. #define YANK_LINES  3
  98. #define NUM_YANK_BUFS  38   /* 0-9, a-z, '.', and $ */
  99.  
  100.  
  101. struct un_undo { /* Structure for recalling last change */
  102.     INT    un_firstline,        /* First line # of change */
  103.         un_firstcol,        /* First column # of change */
  104.         un_lastline,        /* Last line # of change */
  105.         un_lastcol;        /* Last column # of change */
  106.     boolean    un_validcol;        /* TRUE if first/last column defined */
  107.     boolean    un_inserted;        /* TRUE if insertion was done */
  108.     boolean    un_deleted;        /* TRUE if deleting was done */
  109. };
  110.  
  111.  
  112. struct sc_screen { /* The screen proper */
  113.     INT    sc_column;        /* Cursor position in current line */
  114.     INT    sc_lineno;        /* Current line number */
  115.     struct  li_line *sc_topline;    /* Ptr to first line on screen */
  116.     struct    li_line    *sc_curline;    /* Ptr to current line on screen */
  117.     struct  li_line *sc_botline;    /* Ptr to last line on screen */
  118.     INT    sc_abovetop;        /* # of segments above the top line
  119.                        after a downwards scroll */
  120.     INT    sc_firstline,        /* First line # of operation */
  121.         sc_firstcol,        /* First column # of operation */
  122.         sc_lastline,        /* Last line # of operation */
  123.         sc_lastcol;        /* Last column # of operation */
  124.     boolean    sc_validcol;        /* TRUE if first/last column defined
  125.                        above is valid */
  126.     struct    li_line sc_origline;    /* Current line before modification, if
  127.                        not modified text is null. */
  128. };
  129.  
  130. struct wi_window { /* Sliding window into file */
  131.     struct    li_line    *wi_topline;    /* Ptr to first line in window */
  132.     struct    li_line    *wi_botline;    /* Ptr to last line in window */
  133. };
  134.  
  135. struct fi_file { /* General information about the file */
  136.     INT    fi_numlines;    /* # of lines in file */
  137.     boolean    fi_modified;    /* TRUE if file modified */
  138.     boolean    fi_sysv;    /* TRUE if ed has System V 'H' command */
  139.     boolean    fi_cray;    /* TRUE if ed has Cray style error msgs */
  140.     FILE    *fi_fpin;    /* Input file pointer from ed */
  141.     FILE    *fi_fpout;    /* Output file pointer to ed */
  142.     char    fi_name[128];    /* Name of edited file */
  143. };
  144.  
  145. /*
  146.  * Global externals
  147.  */
  148. extern struct    fi_file        file;
  149. extern struct    wi_window    window;
  150. extern struct    sc_screen    screen;
  151. extern struct    li_line        *line_array;
  152. extern struct    ya_yank        yank_array[NUM_YANK_BUFS];
  153. extern struct    un_undo        undo;
  154.  
  155. extern char    **Argv;
  156. extern boolean    use_linemode;    /* TRUE to use line mode in shell escapes */
  157. extern boolean    ed_undo;    /* TRUE if last mod was direct ed cmd */
  158. extern INT    errflag;    /* 1 if error in function call */
  159. extern boolean    input_mode;    /* TRUE if input mode */
  160. extern boolean    change_flag;    /* TRUE if change in progress */
  161. extern boolean    replace_flag;    /* TRUE if R command */
  162. extern char    *nextfile;    /* Next file to edit via 'n' cmd */
  163. extern INT    nwin_lines;    /* Number of window lines */
  164. extern boolean    opened_line;    /* TRUE if openline() called */
  165. extern INT    yank_shift;    /* Shift offset for yank */
  166. extern INT    yank_cmd;    /* "x yank buf command letter x. */
  167.  
  168. extern boolean    set_autoindent; /* TRUE if margins automatically indented */
  169. extern INT    set_debug;    /* Debugging level */
  170. extern boolean    set_list;    /* TRUE if list mode set (show tabs and EOL) */
  171. extern boolean    set_fortran;    /* TRUE if Fortran-style tabs */
  172. extern INT    set_scroll;    /* # of lines per ^D or ^U */
  173. extern INT    set_tabstops;    /* Tabstop width */
  174. extern boolean    set_timeout;    /* Timeout on function key */
  175. extern INT    set_shiftwidth;    /* # of columns per tab char on input */
  176. extern boolean    set_wrapscan;    /* TRUE if wrap around on string search */
  177.  
  178. #define NUM_WINDOW_LINES    nwin_lines
  179.  
  180. void        botprint();       /* Print msg on bottom line */
  181. void        change();       /* Change text */
  182. void        delete();       /* Delete text */
  183. void        dup_insert();       /* Duplicate inserted text n times */
  184. INT        file_column();       /* Convert screen column to file column */
  185. void        insert();       /* Insert text into current line */
  186. void        move_abs_cursor(); /* Move to (lineno, column) from anywhere */
  187. void        move_cursor();       /* Set cursor to (lineno, column).  Must
  188.                       already be on screen. */
  189. void        openline();       /* Open new line in specified direction */
  190. void        panic();       /* Print msg and halt */
  191. void        put();           /* Put text in specified direction */
  192. void        print_line();       /* Print text at current cursor */
  193. void        quit();
  194. boolean        read_cmd();       /* Read a command character */
  195. boolean        recv_sync();       /* Receive sync */
  196. void        redraw_screen();   /* Update screen to curses */
  197. INT        rv_getchar();
  198. char        *rv_getline();
  199. void        save_Undo();       /* Save current line to Undo buffer */
  200. INT        screen_column();   /* Convert file column to screen column */
  201. void        sizemsg();       /* Print file size */
  202. void        toss_undo();       /* Forget last undo */
  203. char        *xalloc();       /* Allocate memory */
  204. void        xmit_curline();       /* Transmit current line if modified */
  205. void        xmit_ed();       /* Transmit command */
  206. void        xmit_sync();       /* Transmit sync */
  207. void        yank();           /* Yank text */
  208.