struct Block
{
vlong 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 Elog
{
short type; /* Delete, Insert, Filename */
uint q0; /* location of change (unused in f) */
uint nd; /* number of deleted characters */
uint nr; /* # runes in string or file name */
Rune *r;
};
void elogterm(File*);
void elogclose(File*);
void eloginsert(File*, int, Rune*, int);
void elogdelete(File*, int, int);
void elogreplace(File*, int, int, Rune*, int);
void elogapply(File*);
struct File
{
Buffer; /* the data */
Buffer delta; /* transcript of changes */
Buffer epsilon; /* inversion of delta for redo */
Buffer *elogbuf; /* log of pending editor changes */
Elog elog; /* current pending change */
Rune *name; /* name of associated file */
int nname; /* size of name */
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 */
int editclean; /* mark clean after edit command */
int seq; /* if seq==0, File acts like Buffer */
int mod;
Text *curtext; /* most recently used associated text */
Text **text; /* list of associated texts */
int ntext;
int dumpid; /* used in dumping zeroxed windows */
};
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*, Rune*, int);
void fileundelete(File*, Buffer*, uint, uint);
void fileuninsert(File*, Buffer*, uint, uint);
void fileunsetname(File*, Buffer*);
void fileundo(File*, int, uint*, uint*);
uint fileredoseq(File*);
struct Text
{
File *file;
Frame;
Reffont *reffont;
uint org;
uint q0;
uint q1;
int what;
int tabstop;
Window *w;
Rectangle scrollr;
Rectangle lastsr;
Rectangle all;
Row *row;
Column *col;
uint eq0; /* start of typing for ESC */
uint cq0; /* cache position */
int ncache; /* storage for insert */
int ncachealloc;
Rune *cache;
int nofill;
int needundo;
};
struct Window
{
QLock;
Ref;
Text tag;
Text body;
Rectangle r;
uchar isdir;
uchar isscratch;
uchar filemenu;
uchar dirty;
uchar indent[NINDENT];
uchar showdel;
uint noredraw;
int id;
Range addr;
Range limit;
uchar nopen[QMAX];
uchar nomark;
uchar noscroll;
Range wrselrange;
int rdselfd;
Column *col;
Xfid *eventx;
char *events;
int nevents;
int owner;
int maxlines;
Dirlist **dlp;
int ndl;
int putseq;
int nincl;
Rune **incl;
Reffont *reffont;
QLock ctllock;
uint ctlfid;
char *dumpstr;
char *dumpdir;
int dumpid;
int utflastqid;
int utflastboff;
int utflastq;
int tagsafe; /* taglines is correct */
int tagexpand;
int taglines;
Rectangle tagtop;
};
struct Expand
{
uint q0;
uint q1;
Rune *name;
int nname;
char *bname;
int jump;
union{
Text *at;
Rune *ar;
};
int (*agetc)(void*, uint);
int a0;
int a1;
};
enum
{
/* fbufalloc() guarantees room off end of BUFSIZE */
BUFSIZE = Maxblock+IOHDRSZ, /* size from fbufalloc() */
RBUFSIZE = BUFSIZE/sizeof(Rune),
EVENTSIZE = 256,
Scrollwid = 12, /* width of scroll bar */
Scrollgap = 4, /* gap right of scroll bar */
Margin = 4, /* margin around text */
Border = 2, /* line between rows, cols, windows */
};
uint globalincref;
uint seq;
uint maxtab; /* size of a tab, in units of the '0' character */
Display *display;
Image *screen;
Font *font;
Mouse *mouse;
Mousectl *mousectl;
Keyboardctl *keyboardctl;
Reffont reffont;
Image *modbutton;
Image *colbutton;
Image *button;
Image *but2col;
Image *but3col;
Cursor boxcursor;
Row row;
int timerpid;
Disk *disk;
Text *seltext;
Text *argtext;
Text *mousetext; /* global because Text.close needs to clear it */
Text *typetext; /* global because Text.close needs to clear it */
Text *barttext; /* shared between mousetask and keyboardthread */
int bartflag;
Window *activewin;
Column *activecol;
Buffer snarfbuf;
Rectangle nullrect;
int fsyspid;
char *cputype;
char *objtype;
char *home;
char *fontnames[2];
char acmeerrorfile[128];
Image *tagcols[NCOL];
Image *textcols[NCOL];
int plumbsendfd;
int plumbeditfd;
char wdir[];
int editing;
int messagesize; /* negotiated in 9P version setup */
int globalindent[NINDENT];
Rune *delcmd; /* what command deleted the window. eg, Del, Delete, Delmesg */