home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff256.lzh / Stevie / macros.h < prev    next >
Text File  |  1989-10-19  |  2KB  |  81 lines

  1. /*
  2.  * STEVIE - Simply Try this Editor for VI Enthusiasts
  3.  *
  4.  * Code Contributions By : Tim Thompson           twitch!tjt
  5.  *                         Tony Andrews           onecom!wldrdg!tony 
  6.  *                         G. R. (Fred) Walter    watmath!grwalter 
  7.  */
  8.  
  9. /*
  10.  * gchar(lp) - get the character at position "lp" 
  11.  */
  12. #define gchar(lp) ((lp)->linep->s[(lp)->index])
  13.  
  14. /*
  15.  * pchar(lp, c) - put character 'c' at position 'lp' 
  16.  */
  17. #define pchar(lp, c) ((lp)->linep->s[(lp)->index] = (c))
  18.  
  19. /*
  20.  * pswap(a, b) - swap two position pointers 
  21.  */
  22. #define pswap(a, b) { LPtr pswaptmp; pswaptmp = a; a = b; b = pswaptmp; }
  23.  
  24. /*
  25.  * Position comparisons 
  26.  */
  27. #define lt(a, b) ((LINEOF(a) != LINEOF(b)) \
  28.                    ? (LINEOF(a) < LINEOF(b)) : ((a)->index < (b)->index))
  29.  
  30. #define ltoreq(a, b) ((LINEOF(a) != LINEOF(b)) \
  31.                    ? (LINEOF(a) < LINEOF(b)) : ((a)->index <= (b)->index))
  32.  
  33. #define gt(a, b) ((LINEOF(a) != LINEOF(b)) \
  34.                    ? (LINEOF(a) > LINEOF(b)) : ((a)->index > (b)->index))
  35.  
  36. #define gtoreq(a, b) ((LINEOF(a) != LINEOF(b)) \
  37.                    ? (LINEOF(a) > LINEOF(b)) : ((a)->index >= (b)->index))
  38.  
  39. #define equal(a, b) (((a)->linep == (b)->linep) && ((a)->index == (b)->index))
  40.  
  41. /*
  42.  * anyinput
  43.  *
  44.  * Return non-zero if input is pending.
  45.  */
  46. #define anyinput() (Readbuffptr != NULL)
  47.  
  48. /*
  49.  * buf1line() - return TRUE if there is only one line in file buffer
  50.  */
  51. #define buf1line() (Filemem->linep->next == Fileend->linep)
  52.  
  53. /*
  54.  * bufempty() - return TRUE if the file buffer is empty 
  55.  */
  56. #define bufempty() (buf1line() && Filemem->linep->s[0] == NUL)
  57.  
  58. /*
  59.  * lineempty() - return TRUE if the line is empty 
  60.  */
  61. #define lineempty(p) ((p)->linep->s[0] == NUL)
  62.  
  63. /*
  64.  * startofline() - return TRUE if the given position is at start of line 
  65.  */
  66. #define startofline(p) ((p)->index == 0)
  67.  
  68. /*
  69.  * endofline() - return TRUE if the given position is at end of line 
  70.  *
  71.  * This routine will probably never be called with a position resting on the NUL
  72.  * byte, but handle it correctly in case it happens. 
  73.  */
  74. #define endofline(p) \
  75.      ((p)->linep->s[(p)->index] == NUL || (p)->linep->s[(p)->index + 1] == NUL)
  76.  
  77. /*
  78.  * RowNumber() - return the row number (if no UndoInProgress)
  79.  */
  80. #define RowNumber(p) (UndoInProgress ? 0 : cntllines(Filemem, (p)))
  81.