home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume17 / tcl-editor / part02 / file.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-18  |  3.2 KB  |  88 lines

  1. /* $Header: /nfs/unmvax/faculty/crowley/x/pt/RCS/file.h,v 1.2 91/08/01 16:57:49 crowley Exp Locker: crowley $ */
  2.  
  3. /* a PIECE is a sequence of characters that is contiguous in the logical */
  4. /* and physical files.  Originally the file is one (big) piece.  As edits */
  5. /* are made it is divided into more pieces.  The characters in a piece */
  6. /* are either in the original (unchanged) file or in the add file (which) */
  7. /* contains all characters that have been added to the file in this editing */
  8. /* session */
  9.  
  10. struct piece {
  11.     char flags;        /* record various Boolean data */
  12.     int file;        /* Unix file handle */
  13.     BlockID blockID;    /* block piece comes from or NullObject */
  14.                 /* if it comes from a format string */
  15.     Offset position;    /* start of the piece */
  16.     Offset length;        /* length of the piece */
  17.     struct piece *nextClone;/* next piece in the clone list */
  18.     struct piece *nextPiece;/* next piece in the list */
  19.     struct piece *prevPiece;/* previous piece in the list */
  20. };
  21.  
  22. /* piece.flags constants */
  23. #define IS_CLONED_PIECE        1
  24. #define IS_DECORATION        2
  25.  
  26. typedef struct piece *Piece;
  27.  
  28. /* An open file consists of the original file (which is not changed during */
  29. /* an editing session) and an add file (where all new characters go). */
  30. /* The logical file is described in the pieces table which shows where */
  31. /* the logically contiguous characters in the file are physically located */
  32.  
  33. struct openFile {
  34.  
  35.     /* flag to keep track of whether this is a view or not */
  36.     int isView;
  37.  
  38.     /* the original file size */
  39.     Offset origFileSize;
  40.  
  41.     /* the current logical file size -- changed as the file is edited */
  42.     /* NOT the same as the size of origfile or addfile or their sum */
  43.     Offset fileSize;
  44.  
  45.     /* the file being edited -- this is read only */
  46.     char origName[FILENAMESIZE];
  47.     int origHandle;
  48.  
  49.     /* the piece list */
  50.     Piece pieceList;
  51.     
  52.     /* the command history */
  53.     struct changeItem * cmdHistory;
  54.  
  55.     /* optimization fields */
  56.     /* loLogPiece and hiLogPiece are the low and high logical addresses */
  57.     /* that are mapped by piece number logPiece which is the last piece */
  58.     /* where a byte was found and is initialized to the one big piece */
  59.     /* that is the whole file when you start editing. */
  60.     /* The idea is that once you map a logical byte to a piece, it is */
  61.     /* likely that the next mapping is in the same piece. */
  62.     /* loLogBuffer and hiLogBuffer are the logical character limits of */
  63.     /* some valid characters in a buffer pointed to by logBuffer. */
  64.     Offset loLogPiece, hiLogPiece, loLogBuffer, hiLogBuffer;
  65.     Piece logPiece;
  66.     unsigned char *logBuf;
  67.  
  68.     /* some file status flags */
  69.     char useCount;    /* the number of windows using the file */
  70.     char flags;    /* various information (see below) */
  71. };
  72.  
  73. /* flags */
  74. #define BAK_MADE    1    /* a backup copy has been made */
  75. #define READ_ONLY    2    /* file cannot be written (changeable) */
  76. #define IS_CHANGED    4    /* file has been changed but not yet saved */
  77. #define NO_WRITES    8    /* file can never be written (no changeable) */
  78.  
  79. /* a disk buffer (both in and out of the address space) */
  80. struct diskBuffer {
  81.     int handle;    /* DOS file handle */
  82.     /* double linked hash chain links */
  83.     struct diskBuffer *forwardHash, *backwardHash;
  84.     int blockNumber;
  85.     unsigned char *bufferAddress;
  86.     char written;    /* =1 if an add file block */
  87. };
  88.