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

  1. #ifndef _DAVIS_BUFFER_H_
  2. #define _DAVIS_BUFFER_H_
  3.  
  4. typedef struct
  5. {
  6.    char file[255];            /* filename */
  7.    unsigned char *beg;       /* beginning of buffer */
  8.    unsigned char *end;       /* end of buffer */
  9.    int mark;                 /* marked line in buffer */
  10.    unsigned int flags;
  11.    int fd;                   /* file descriptor--- -1 if closed */
  12.    int size;
  13. #ifdef VMS
  14.    int rec;                   /* record size for reads */
  15. #endif
  16. } Buffer;
  17.  
  18.  
  19. extern int NUM_LINES;
  20. extern Buffer *BUF;
  21. extern unsigned char *BEG, *EOB;
  22. extern unsigned char MINI_BUF[132];
  23. /* The buffer.
  24.  
  25.    The beginning of the first character is at BUF.  The last character
  26.    in the file is located at position EOB-1.  So if we are at position EOB,
  27.    then we can insert a character past the last point.  EOB = BUF + BUF_SIZE;
  28. .
  29. */
  30.   
  31. extern unsigned char *C_POS;
  32. /* 
  33.  *  current position of point.  Considered to be between the previous
  34.  *  character and the next character.  There is no current character.
  35.  *  If we are at the beginning of the buffer BUF, then its value is BUF.
  36.  *  If we are at the end of the buffer it is BUF + BUF_SIZE = EOB.
  37.  */
  38.  
  39. extern int C_LINE;
  40. /* 
  41.  *  Current line number.  If at the beginning of the buffer, it is 1.  If
  42.  *  we are at the last point of the buffer it is the number of lines.
  43.  */
  44.  
  45. /* These two routines do not move the point */  
  46. extern unsigned char *beg_of_line();
  47. extern unsigned char *end_of_line();
  48.  
  49. extern int forward_line(int);
  50. /* This routine moves the point forward n lines. n can be negative. 
  51.    It returns the number moved. */
  52.  
  53. extern void goto_line(int);
  54. /* Move the point somewhere on the nth line of the buffer returning
  55.    C_POS */
  56.  
  57. extern int what_line(unsigned char *);
  58. /* return the line number of position 'argument'. Does not move point */
  59.  
  60. /* count the number of lines in the region delimited by beg and end.
  61.    Counts lines from beg up to end but does not count end.
  62.    Does not move point. */
  63. extern int count_lines(unsigned char *, unsigned char *);
  64. extern int extract_line(unsigned char **, unsigned char **);
  65.  
  66. extern Buffer *switch_to_buffer(Buffer *);
  67. extern void delete_buffer(Buffer *);
  68. extern Buffer *create_buffer(char *);
  69. extern void find_row_column(unsigned char *, int *, int *);
  70.  
  71.  
  72. #endif
  73.   
  74.  
  75.