Wily Text Internals

struct Text {
	Rune	*text;		/* where we store stuff */
	ulong	alloced,length;
	Range	gap;			/* buffer gap */
	Data		*data;		/* 0 for wilytag or columntag */
	Bool		isbody;
	View		*v;			/* list of views of this text */
	Bool		needsbackup;	/* this text can become dirty */

	/* temporary buffer for search operations */
	Rune	getcbuf[NGETC];	
	int		ngetc;		
	int		getci;		
	ulong	getcp;		

	Undo	*did,*undone, *mark;
	enum {NoUndo, StartUndo, MoreUndo} undoing;
};

The text buffer uses a simple "buffer gap" strategy. The text is stored in a contiguous block of Runes t->text. t->alloced is the maximum number of Runes that can be stored in t->text. t->length is the number of Runes actually being used in t->text.

The 'gap' is a region somewhere inside t->text which is not being used for