struct List
{
int type; /* 'p' for pointer, 'P' for Posn */
int nalloc;
int nused;
union{
void* listp;
void** voidp;
Posn* posnp;
String**stringp;
File** filep;
}g;
};
struct Block
{
uint addr; /* disk address in bytes */
union
{
uint n; /* number of used runes in block */
Block *next; /* pointer to next in free list */
};
};
struct Disk
{
int fd;
vlong addr; /* length of temp file */
Block *free[Maxblock/Blockincr+1];
};
struct Buffer
{
uint nc;
Rune *c; /* cache */
uint cnc; /* bytes in cache */
uint cmax; /* size of allocated cache */
uint cq; /* position of cache */
int cdirty; /* cache needs to be written */
uint cbi; /* index of cache Block */
Block **bl; /* array of blocks */
uint nbl; /* number of blocks */
};
void bufinsert(Buffer*, uint, Rune*, uint);
void bufdelete(Buffer*, uint, uint);
uint bufload(Buffer*, uint, int, int*);
void bufread(Buffer*, uint, Rune*, uint);
void bufclose(Buffer*);
void bufreset(Buffer*);
struct File
{
Buffer; /* the data */
Buffer delta; /* transcript of changes */
Buffer epsilon; /* inversion of delta for redo */
String name; /* name of associated file */
uvlong qidpath; /* of file when read */
uint mtime; /* of file when read */
int dev; /* of file when read */
int unread; /* file has not been read from disk */
long seq; /* if seq==0, File acts like Buffer */
long cleanseq; /* f->seq at last read/write of file */
int mod; /* file appears modified in menu */
char rescuing; /* sam exiting; this file unusable */
// Text *curtext; /* most recently used associated text */
// Text **text; /* list of associated texts */
// int ntext;
// int dumpid; /* used in dumping zeroxed windows */
Posn hiposn; /* highest address touched this Mod */
Address dot; /* current position */
Address ndot; /* new current position after update */
Range tdot; /* what terminal thinks is current range */
Range mark; /* tagged spot in text (don't confuse with Mark) */
List *rasp; /* map of what terminal's got */
short tag; /* for communicating with terminal */
char closeok; /* ok to close file? */
char deleted; /* delete at completion of command */
Range prevdot; /* state before start of change */
Range prevmark;
long prevseq;
int prevmod;
};
//File* fileaddtext(File*, Text*);
void fileclose(File*);
void filedelete(File*, uint, uint);
//void filedeltext(File*, Text*);
void fileinsert(File*, uint, Rune*, uint);
uint fileload(File*, uint, int, int*);
void filemark(File*);
void filereset(File*);
void filesetname(File*, String*);
void fileundelete(File*, Buffer*, uint, uint);
void fileuninsert(File*, Buffer*, uint, uint);
void fileunsetname(File*, Buffer*);
void fileundo(File*, int, int, uint*, uint*, int);
int fileupdate(File*, int, int);
int filereadc(File*, uint);
File *fileopen(void);
void loginsert(File*, uint, Rune*, uint);
void logdelete(File*, uint, uint);
void logsetname(File*, String*);
int fileisdirty(File*);
long undoseq(File*, int);
long prevseq(Buffer*);