/* Generated by wbuild from "LinkText.w"
** (generator version $Revision: 3.0 $ of $Date: 95/08/30 17:50:38 $)
*/
#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#line 2796 "LinkText.w"
#include <assert.h>
#line 2797 "LinkText.w"
#include <ctype.h>
#line 2798 "LinkText.w"
#include <stdio.h>
#line 2799 "LinkText.w"
#include <string.h>
#line 2800 "LinkText.w"
#include "buffer.h"
#line 2801 "LinkText.w"
#include "LinkView.h"
#line 2802 "LinkText.w"
#include <X11/Xatom.h>
#line 2803 "LinkText.w"
#include <X11/Xmu/Xmu.h>
#line 2804 "LinkText.w"
#include "hand.bm"
#line 2805 "LinkText.w"
#include "handmask.bm"
#line 2806 "LinkText.w"
#include "trav.xbm"
#line 2807 "LinkText.w"
#include "stip4.bm"
#include <./LinkTextP.h>
#line 1960 "LinkText.w"
static void chaselink(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2000 "LinkText.w"
static void grabpage(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2010 "LinkText.w"
static void movepage(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2022 "LinkText.w"
static void releasepage(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2029 "LinkText.w"
static void cursortype(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2063 "LinkText.w"
static void start_selection(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2087 "LinkText.w"
static void move_selection(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2176 "LinkText.w"
static void extend_selection(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);
#line 2249 "LinkText.w"
static void end_selection(
#if NeedFunctionPrototypes
Widget,XEvent*,String*,Cardinal*
#endif
);

static XtActionsRec actionsList[] = {
{"chaselink", chaselink},
{"grabpage", grabpage},
{"movepage", movepage},
{"releasepage", releasepage},
{"cursortype", cursortype},
{"start_selection", start_selection},
{"move_selection", move_selection},
{"extend_selection", extend_selection},
{"end_selection", end_selection},
};

static char defaultTranslations[] = "\
<Btn2Down>: grabpage() \n\
<Btn2Motion>: movepage() \n\
<Btn2Up>: releasepage() \n\
<Btn1Up>: chaselink() end_selection() \n\
<Btn1Down>: start_selection() \n\
<Btn1Motion>: move_selection() \n\
<Btn3Down>: extend_selection() \n\
<Motion>: cursortype() \n\
";
static void _resolve_inheritance(
#if NeedFunctionPrototypes
WidgetClass
#endif
);
#line 1427 "LinkText.w"
static void initialize(
#if NeedFunctionPrototypes
Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 1475 "LinkText.w"
static void realize(
#if NeedFunctionPrototypes
Widget,XtValueMask *,XSetWindowAttributes *
#endif
);
#line 1485 "LinkText.w"
static void destroy(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 1495 "LinkText.w"
static Boolean  set_values(
#if NeedFunctionPrototypes
Widget ,Widget ,Widget,ArgList ,Cardinal *
#endif
);
#line 1563 "LinkText.w"
static XtGeometryResult  query_geometry(
#if NeedFunctionPrototypes
Widget,XtWidgetGeometry *,XtWidgetGeometry *
#endif
);
#line 1574 "LinkText.w"
static void expose(
#if NeedFunctionPrototypes
Widget,XEvent *,Region 
#endif
);
#line 379 "LinkText.w"
static Boolean  IsTextual(
#if NeedFunctionPrototypes
TextChunk *
#endif
);
#line 385 "LinkText.w"
static void add_to_list(
#if NeedFunctionPrototypes
Widget,TextChunk *
#endif
);
#line 402 "LinkText.w"
static void add_link(
#if NeedFunctionPrototypes
Widget,char *,int ,int ,char *,int ,int ,int 
#endif
);
#line 440 "LinkText.w"
static void add_traverser(
#if NeedFunctionPrototypes
Widget,TextChunk *,TextChunk *,int ,int 
#endif
);
#line 467 "LinkText.w"
static void add_text(
#if NeedFunctionPrototypes
Widget,char *,int ,int ,int ,int ,int 
#endif
);
#line 495 "LinkText.w"
static void add_dottab(
#if NeedFunctionPrototypes
Widget,int ,int ,int 
#endif
);
#line 515 "LinkText.w"
static void add_linebreak(
#if NeedFunctionPrototypes
Widget,int ,int ,int 
#endif
);
#line 533 "LinkText.w"
static void add_bullet(
#if NeedFunctionPrototypes
Widget,int ,int 
#endif
);
#line 568 "LinkText.w"
static void EraseLinkText(
#if NeedFunctionPrototypes
TextChunk *
#endif
);
#line 585 "LinkText.w"
static void hyperchunkit(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 825 "LinkText.w"
static void make_gc(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 844 "LinkText.w"
static void make_graygc(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 862 "LinkText.w"
static int  newline(
#if NeedFunctionPrototypes
char *
#endif
);
#line 874 "LinkText.w"
static void compute_line_height(
#if NeedFunctionPrototypes
Widget,TextChunk *,int *,int *
#endif
);
#line 902 "LinkText.w"
static void set_color(
#if NeedFunctionPrototypes
Widget,int ,Boolean 
#endif
);
#line 938 "LinkText.w"
static void draw_string(
#if NeedFunctionPrototypes
Widget,XFontStruct *,TextChunk *,char *,int ,int ,int ,Boolean 
#endif
);
#line 963 "LinkText.w"
static void draw_chunktext(
#if NeedFunctionPrototypes
Widget,XFontStruct *,TextChunk *,char *,int ,int ,int 
#endif
);
#line 1022 "LinkText.w"
static void remove_page_breaks(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 1052 "LinkText.w"
static void dump_positions(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 1097 "LinkText.w"
static void split_chunk(
#if NeedFunctionPrototypes
Widget,TextChunk *,int 
#endif
);
#line 1129 "LinkText.w"
static void compute_linebreaks(
#if NeedFunctionPrototypes
Widget,TextChunk *,XFontStruct *,int *,int *,int 
#endif
);
#line 1185 "LinkText.w"
static void pin_chunk(
#if NeedFunctionPrototypes
Widget,TextChunk *,XFontStruct *,int *,int *
#endif
);
#line 1202 "LinkText.w"
static void compute_positions(
#if NeedFunctionPrototypes
Widget,int 
#endif
);
#line 1755 "LinkText.w"
static void find_position(
#if NeedFunctionPrototypes
Widget,int ,int ,SelectionMarker *
#endif
);
#line 1865 "LinkText.w"
static SelectionMarker  minimum_marker(
#if NeedFunctionPrototypes
SelectionMarker ,SelectionMarker 
#endif
);
#line 1878 "LinkText.w"
static SelectionMarker  maximum_marker(
#if NeedFunctionPrototypes
SelectionMarker ,SelectionMarker 
#endif
);
#line 1891 "LinkText.w"
static Boolean  equal_marker(
#if NeedFunctionPrototypes
SelectionMarker ,SelectionMarker 
#endif
);
#line 1901 "LinkText.w"
static Boolean  smaller(
#if NeedFunctionPrototypes
SelectionMarker ,SelectionMarker 
#endif
);
#line 1913 "LinkText.w"
static void scroll_display_up(
#if NeedFunctionPrototypes
XtPointer ,XtIntervalId *
#endif
);
#line 1935 "LinkText.w"
static void scroll_display_down(
#if NeedFunctionPrototypes
XtPointer ,XtIntervalId *
#endif
);
#line 2273 "LinkText.w"
static void clear_selection(
#if NeedFunctionPrototypes
Widget
#endif
);
#line 2303 "LinkText.w"
static void lose_ownership_proc(
#if NeedFunctionPrototypes
Widget,Atom *
#endif
);
#line 2310 "LinkText.w"
static void convert_done_proc(
#if NeedFunctionPrototypes
Widget,Atom *,Atom *
#endif
);
#line 2318 "LinkText.w"
static Boolean  convert_proc(
#if NeedFunctionPrototypes
Widget,Atom *,Atom *,Atom *,XtPointer *,unsigned  long *,int *
#endif
);
#line 2365 "LinkText.w"
static void SmartAddToBuffer(
#if NeedFunctionPrototypes
Widget,int *,char *,int ,Boolean ,Boolean 
#endif
);
#line 2415 "LinkText.w"
static void get_text(
#if NeedFunctionPrototypes
Widget,Boolean 
#endif
);
#line 2541 "LinkText.w"
static void  ConvertToLowerCase(
#if NeedFunctionPrototypes
char *
#endif
);
#line 2551 "LinkText.w"
static void AppendToBuf(
#if NeedFunctionPrototypes
char *,int ,char *
#endif
);
#line 2569 "LinkText.w"
static void  FetchLowerCase(
#if NeedFunctionPrototypes
char *,int ,TextChunk *,int 
#endif
);
#line 2593 "LinkText.w"
static void  TextOffset(
#if NeedFunctionPrototypes
Widget,TextChunk *,int ,int ,TextChunk **,int *
#endif
);
#line 379 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 379 "LinkText.w"
static Boolean  IsTextual(TextChunk * chunk)
#else
#line 379 "LinkText.w"
static Boolean  IsTextual(chunk)TextChunk * chunk;
#endif
#line 380 "LinkText.w"
{
	return ((chunk->type == CT_LINK) || (chunk->type == CT_TEXT));
	}
#line 385 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 385 "LinkText.w"
static void add_to_list(Widget self,TextChunk * chunk)
#else
#line 385 "LinkText.w"
static void add_to_list(self,chunk)Widget self;TextChunk * chunk;
#endif
#line 386 "LinkText.w"
{
	if(((LinkTextWidget)self)->linkText.head==NULL) {
		chunk->chunknum=1;
		((LinkTextWidget)self)->linkText.head=chunk;
		}
	else {
		chunk->chunknum = ((LinkTextWidget)self)->linkText.tail->chunknum + 1;
		((LinkTextWidget)self)->linkText.tail->next=chunk;
		}

	((LinkTextWidget)self)->linkText.tail=chunk;
	}
#line 402 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 402 "LinkText.w"
static void add_link(Widget self,char * txt,int  size,int  f,char * linkname,int  linksize,int  attributes,int  indent)
#else
#line 402 "LinkText.w"
static void add_link(self,txt,size,f,linkname,linksize,attributes,indent)Widget self;char * txt;int  size;int  f;char * linkname;int  linksize;int  attributes;int  indent;
#endif
#line 403 "LinkText.w"
{
	TextChunk *chunk;

	if (size<0)
		return;

	chunk=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk->type=CT_LINK;
	chunk->next=NULL;
	chunk->font=f;
	chunk->color=-1;
	chunk->text_attributes=attributes;
	chunk->indent=indent;

	/* store the chunk text */

	chunk->text=XtMalloc(1+size);
	strncpy(chunk->text,txt, size);
	chunk->text[size]='\0';

	/* store the link text */

	if (linksize<=0)
		chunk->link = chunk->text;
	else {
		chunk->link=XtMalloc(1+linksize);
		strncpy(chunk->link,linkname, linksize);
		chunk->link[linksize]='\0';
		}

	add_to_list(self, chunk);
	}
#line 440 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 440 "LinkText.w"
static void add_traverser(Widget self,TextChunk * prev,TextChunk * next,int  pagenum,int  y)
#else
#line 440 "LinkText.w"
static void add_traverser(self,prev,next,pagenum,y)Widget self;TextChunk * prev;TextChunk * next;int  pagenum;int  y;
#endif
#line 441 "LinkText.w"
{
	TextChunk *chunk;

	/* printf("Adding traverser for page %d at position %d\n", pagenum, y); */
	chunk=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk->type=CT_TRAVERSER;
	chunk->next=next;
	chunk->pagenum=pagenum;
	chunk->x = 20;
	chunk->y = y;
	chunk->width = trav_width;
	chunk->height = trav_height;
	chunk->depth = 0;
	chunk->text=NULL;
	chunk->link=NULL;

	/* splice into the list */
	if (prev==NULL)
		((LinkTextWidget)self)->linkText.head=chunk;
	else
		prev->next = chunk;
	}
#line 467 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 467 "LinkText.w"
static void add_text(Widget self,char * txt,int  size,int  f,int  c,int  attributes,int  indent)
#else
#line 467 "LinkText.w"
static void add_text(self,txt,size,f,c,attributes,indent)Widget self;char * txt;int  size;int  f;int  c;int  attributes;int  indent;
#endif
#line 468 "LinkText.w"
{
	TextChunk *chunk;

	if (size<0)
		return;

	chunk=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk->type=CT_TEXT;
	chunk->next=NULL;
	chunk->font=f;
	chunk->color=c;
	chunk->text_attributes=attributes;
	chunk->indent=indent;
	chunk->link=NULL;

	/* store the chunk text */

	chunk->text=XtMalloc(1+size);
	strncpy(chunk->text,txt, size);
	chunk->text[size]='\0';

	add_to_list(self, chunk);
	}
#line 495 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 495 "LinkText.w"
static void add_dottab(Widget self,int  f,int  c,int  indent)
#else
#line 495 "LinkText.w"
static void add_dottab(self,f,c,indent)Widget self;int  f;int  c;int  indent;
#endif
#line 496 "LinkText.w"
{
	TextChunk *chunk;

	chunk=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk->type=CT_DOTTAB;
	chunk->next=NULL;
	chunk->font=f;
	chunk->color=c;
	chunk->indent=indent;
	chunk->text=NULL;
	chunk->link=NULL;
	chunk->text_attributes=0;

	add_to_list(self, chunk);
	}
#line 515 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 515 "LinkText.w"
static void add_linebreak(Widget self,int  f,int  attributes,int  indent)
#else
#line 515 "LinkText.w"
static void add_linebreak(self,f,attributes,indent)Widget self;int  f;int  attributes;int  indent;
#endif
#line 516 "LinkText.w"
{
	TextChunk *chunk;

	chunk=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk->type=CT_LINEBREAK;
	chunk->next=NULL;
	chunk->text=NULL;
	chunk->link=NULL;
	chunk->font=f;
	chunk->indent=indent;
	chunk->text_attributes=attributes;

	add_to_list(self, chunk);
	}
#line 533 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 533 "LinkText.w"
static void add_bullet(Widget self,int  f,int  c)
#else
#line 533 "LinkText.w"
static void add_bullet(self,f,c)Widget self;int  f;int  c;
#endif
#line 534 "LinkText.w"
{
	TextChunk *chunk;

	chunk=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk->type=CT_BULLET;
	chunk->next=NULL;
	chunk->text=NULL;
	chunk->link=NULL;
	chunk->indent=0;
	chunk->color=c;
	chunk->font=f;
	chunk->text_attributes=0;

	add_to_list(self, chunk);
	}
#line 568 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 568 "LinkText.w"
static void EraseLinkText(TextChunk * c)
#else
#line 568 "LinkText.w"
static void EraseLinkText(c)TextChunk * c;
#endif
#line 569 "LinkText.w"
{
	TextChunk *n;
	
	while(c) {
		n=c->next;
		if ((c->link != NULL) && (c->link != c->text))
			XtFree((char *)c->link);
		XtFree((char *)c->text);
		XtFree((char *)c);
		c=n;
		}
	}
#line 585 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 585 "LinkText.w"
static void hyperchunkit(Widget self)
#else
#line 585 "LinkText.w"
static void hyperchunkit(self)Widget self;
#endif
#line 586 "LinkText.w"
{
	char *cp, *start, *end;
	char *linkstart, *linkend;
	int font=1, newfont, color=1, newcolor;
	int newindent, indent=0;
	ParseState cstate=PS_TEXT;
	int dottab;
	int attributes=0;
	int new_attributes;
	Boolean inbullet=False;
		
	/* printf("Hyperchunking\n"); */
	assert(XtIsSubclass(self, linkTextWidgetClass));

	EraseLinkText(((LinkTextWidget)self)->linkText.head);
	((LinkTextWidget)self)->linkText.head=((LinkTextWidget)self)->linkText.tail=((LinkTextWidget)self)->linkText.lastFindChunk=NULL;
	((LinkTextWidget)self)->linkText.lastFindPos=0;


	cp=((LinkTextWidget)self)->linkText.hypertext;
	start=end=cp;
	linkstart=linkend=NULL;

	while (*cp != '\0') {
		switch (cstate) {
			case PS_DOTTAB:
				if (*cp=='>') {
					add_dottab(self, font, color, dottab);
					start=cp+1;
					cstate=PS_TEXT;
					}
				else if (isdigit(*cp))
					dottab = dottab*10 + (*cp-'0');
				else if (*cp != ' ')
					cstate=PS_TEXT;
				break;

			case PS_INDENT:
				if (*cp=='>') {
					indent=newindent;
					start=cp+1;
					cstate=PS_TEXT;
					}
				else if (isdigit(*cp))
					newindent = newindent*10 + (*cp-'0');
				else if (*cp != ' ')
					cstate=PS_TEXT;
				break;


			case PS_HANGINGINDENT:
				if (*cp=='>') {
					indent=newindent;
					attributes |= ATTR_HANGINGINDENT;
					start=cp+1;
					cstate=PS_TEXT;
					}
				else if (isdigit(*cp))
					newindent = newindent*10 + (*cp-'0');
				else if (*cp != ' ')
					cstate=PS_TEXT;
				break;


			case PS_ENDATTR:
				if (*cp=='>') {
					attributes=new_attributes;
					start=cp+1;
					}
				cstate=PS_TEXT;
				break;
			case PS_MIDDLE:
				if (*cp=='1') {
					new_attributes = attributes | ATTR_CENTERED; 
					cstate=PS_ENDATTR;
					}
				else if (*cp=='0') {
					new_attributes = attributes & ~ATTR_CENTERED; 
					cstate=PS_ENDATTR;
					}
				else
					cstate=PS_TEXT;
				break;

			case PS_WRAP:
				if (*cp=='1') {
					new_attributes = attributes | ATTR_WRAPPED; 
					cstate=PS_ENDATTR;
					}
				else if (*cp=='0') {
					new_attributes = attributes & ~ATTR_WRAPPED; 
					cstate=PS_ENDATTR;
					}
				else
					cstate=PS_TEXT;
				break;


			case PS_BULLET:
				if (*cp=='>') {
					add_bullet(self, font, color);
					indent=3*((LinkTextWidget)self)->linkText.bulletDiameter;
					inbullet=True;
					start=cp+1;
					}
				cstate=PS_TEXT;
				break;

			case PS_LINKEND:
				if (*cp=='>') {
					start=cp+1;
					cstate=PS_TEXT;
					}
				break;


			case PS_LINK:
				if (*cp=='>') {
					linkend=cp;
					cstate=PS_LINKTEXT;
					start=cp+1;
					}
				break;


			case PS_FONT:
				if (*cp=='>') {
					font=newfont;
					start=cp+1;
					cstate=PS_TEXT;
					}
				else if (isdigit(*cp))
					newfont = newfont*10 + (*cp-'0');
				else if (*cp != ' ')
					cstate=PS_TEXT;
				break;


			case PS_COLOR:
				if (*cp=='>') {
					color=newcolor;
					start=cp+1;
					cstate=PS_TEXT;
					}
				else if (isdigit(*cp))
					newcolor = newcolor*10 + (*cp-'0');
				else if (*cp != ' ')
					cstate=PS_TEXT;
				break;


			case PS_TAG:
				switch (*cp) {
					case 'b':	cstate=PS_BULLET; break;
					case 'w':	cstate=PS_WRAP; break;
					case 'm':	cstate=PS_MIDDLE; break;
					case 'c':	cstate=PS_COLOR; newcolor=0; break;
					case 'd':	cstate=PS_DOTTAB; dottab=0; break;
					case 'i':	cstate=PS_INDENT; newindent=0; break;
					case 'h':	cstate=PS_HANGINGINDENT; newindent=0; break;
					case 'f':	cstate=PS_FONT; newfont=0; break;
					case 'l':	if (*(cp+1)==' ') {
									cstate=PS_LINK; 
									linkstart=cp+2; 
									}
								break;
					default:	cstate=PS_TEXT;
					}
				break;


			case PS_LINKTEXT:
				if (*cp=='\n') {
					/* for when a newline appears in the middle of a link */
					add_link(self, start, cp-start, font, linkstart, 
						linkend-linkstart, attributes, indent);
					if (inbullet) {
						inbullet=False;
						indent=0;
						}
					add_linebreak(self, font, attributes, indent);
					if (attributes | ATTR_HANGINGINDENT) {
						attributes &= ~ATTR_HANGINGINDENT;
						indent=0;
						}
					start=cp+1;
					}
				else if (*cp=='<') {
					add_link(self, start, cp-start, font, linkstart, 
						linkend-linkstart, attributes, indent);
					start=cp;
					cstate=PS_LINKEND;
					}
				break;


			case PS_TEXT:
				if (*cp=='\n') {
					if (cp!=start)
						add_text(self, start, cp-start, font, color, 
							attributes, indent);
					if (inbullet) {
						inbullet=False;
						indent=0;
						}
					if (attributes | ATTR_HANGINGINDENT) {
						attributes &= ~ATTR_HANGINGINDENT;
						indent=0;
						}
					add_linebreak(self, font, attributes, indent);
					start=cp+1;
					break;
					}
				else if (*cp=='<') {
					if (cp > start)
						add_text(self, start, cp-start, font, color, 
							attributes, indent);
					start=cp;
					cstate=PS_TAG;
					}
				break;
			

			default:
				XtAppWarning(XtWidgetToApplicationContext(self), 
					"hyperchunkit: unknown state!");
			}
		cp++;	
		}

	if ((cstate==PS_TEXT) && (cp > start))
		add_text(self, start, cp-start, font, color, attributes, indent);


	}
#line 825 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 825 "LinkText.w"
static void make_gc(Widget self)
#else
#line 825 "LinkText.w"
static void make_gc(self)Widget self;
#endif
#line 826 "LinkText.w"
{
	XtGCMask mask, dynmask, dontcaremask;
	XGCValues values;

	values.foreground=((LinkTextWidget)self)->linkText.color1;
	values.background=((LinkTextWidget)self)->core.background_pixel;
	values.font=((LinkTextWidget)self)->linkText.font1->fid;
	dynmask = GCForeground | GCBackground | GCFont;
	dontcaremask = GCJoinStyle | GCFillRule | GCTile
		| GCTileStipXOrigin | GCTileStipYOrigin | GCDashOffset | GCDashList
		| GCStipple | GCGraphicsExposures | GCArcMode | GCLineWidth | GCClipMask;
	mask=0;
	((LinkTextWidget)self)->linkText.ngc=XtAllocateGC(self,((LinkTextWidget)self)->core.depth,mask,&values,dynmask,dontcaremask);
	}
#line 844 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 844 "LinkText.w"
static void make_graygc(Widget self)
#else
#line 844 "LinkText.w"
static void make_graygc(self)Widget self;
#endif
#line 845 "LinkText.w"
{
    XtGCMask mask;
    XGCValues values;

    if (((LinkTextWidget)self)->linkText.graygc != NULL) XtReleaseGC(self, ((LinkTextWidget)self)->linkText.graygc);
    values.foreground = ((LinkTextWidget)self)->core.background_pixel;
    values.stipple =
        XCreateBitmapFromData(XtDisplay(self),
                              RootWindowOfScreen(XtScreen(self)),
                              stip4_bits, stip4_width, stip4_height);
    values.fill_style = FillStippled;
    mask = GCForeground | GCStipple | GCFillStyle;
    ((LinkTextWidget)self)->linkText.graygc = XtGetGC(self, mask, &values);
	}
#line 862 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 862 "LinkText.w"
static int  newline(char * s)
#else
#line 862 "LinkText.w"
static int  newline(s)char * s;
#endif
#line 863 "LinkText.w"
{
	if (s == NULL)
		return 0;
	return (s[strlen(s)-1] == '\n');
	}
#line 874 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 874 "LinkText.w"
static void compute_line_height(Widget self,TextChunk * chunk,int * ma,int * md)
#else
#line 874 "LinkText.w"
static void compute_line_height(self,chunk,ma,md)Widget self;TextChunk * chunk;int * ma;int * md;
#endif
#line 875 "LinkText.w"
{
	XFontStruct *f;
	char *s;

	*ma=0, *md=0;
	if(chunk==NULL) return;
	do {
		switch(chunk->font)
		{
			case 2:		f=((LinkTextWidget)self)->linkText.font2;	break;
			case 3:		f=((LinkTextWidget)self)->linkText.font3;	break;
			case 4:		f=((LinkTextWidget)self)->linkText.font4;	break;
			case 5:		f=((LinkTextWidget)self)->linkText.font5;	break;
			default:	f=((LinkTextWidget)self)->linkText.font1;	break;
		}

		*ma = *ma>f->ascent ? *ma : f->ascent;
		*md = *md>f->descent ? *md : f->descent;
		s = chunk->text;
 		chunk = chunk->next;
		} 
	while (chunk && !newline(s) && (chunk->type!=CT_LINEBREAK));
	}
#line 902 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 902 "LinkText.w"
static void set_color(Widget self,int  c,Boolean  reverse)
#else
#line 902 "LinkText.w"
static void set_color(self,c,reverse)Widget self;int  c;Boolean  reverse;
#endif
#line 903 "LinkText.w"
{
	if (reverse) {
		XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectForeground);
		XSetBackground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectBackground);
		}
	else {
		XSetBackground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->core.background_pixel);
		switch(c) {
			case -1:	
				XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.linkColor);
				break;
			case 2:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color2);
				break;
			case 3:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color3);
				break;
			case 4:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color4);
				break;
			case 5:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color5);
				break;
			case 6:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color6);
				break;
			case 7:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color7);
				break;
			case 8:	XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color8);
				break;
			default:XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.color1);
				break;
			}
		}
	}
#line 938 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 938 "LinkText.w"
static void draw_string(Widget self,XFontStruct * f,TextChunk * c,char * s,int  length,int  x,int  y,Boolean  reverse)
#else
#line 938 "LinkText.w"
static void draw_string(self,f,c,s,length,x,y,reverse)Widget self;XFontStruct * f;TextChunk * c;char * s;int  length;int  x;int  y;Boolean  reverse;
#endif
#line 939 "LinkText.w"
{
	int w;

	XSetFont(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, f->fid);
	set_color(self, c->color, reverse);			
	XDrawImageString(XtDisplay(self),XtWindow(self),((LinkTextWidget)self)->linkText.ngc,
			x,y,s,length);


	/* draw the underline for links */
	if ((c->link!=NULL) && ((LinkTextWidget)self)->linkText.underlineLinks) {
		w = XTextWidth(f,s,length);
		XDrawLine(XtDisplay(self),XtWindow(self),((LinkTextWidget)self)->linkText.ngc,
			x, y+1, x+w, y+1);
		}
	}
#line 963 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 963 "LinkText.w"
static void draw_chunktext(Widget self,XFontStruct * f,TextChunk * c,char * s,int  length,int  x,int  y)
#else
#line 963 "LinkText.w"
static void draw_chunktext(self,f,c,s,length,x,y)Widget self;XFontStruct * f;TextChunk * c;char * s;int  length;int  x;int  y;
#endif
#line 964 "LinkText.w"
{
	SelectionMarker top, bottom;
	int offs;

	/* if nothing is selected then just draw it */
	if (!((LinkTextWidget)self)->linkText.selected) {
		draw_string(self, f, c, s, length, x, y, False);
		return;
		}

	/* compute the top and bottom point of the text selection */
	top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
	bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);

	/* are we above or below the affected chunks? */
	if ((c->chunknum < top.chunknum) || (c->chunknum > bottom.chunknum)) {
		draw_string(self, f, c, s, length, x, y, False);
		return;
		}

	if (top.chunknum==bottom.chunknum) {
		offs=0;
		if (top.pos>0) {
			draw_string(self, f, c, s, top.pos, x, y, False);
			offs += XTextWidth(f, s, top.pos);
			}
		if (bottom.pos > top.pos) {
			draw_string(self, f, c, s+top.pos, bottom.pos-top.pos, x+offs, y, True);
			offs += XTextWidth(f, s+top.pos, bottom.pos-top.pos);
			}
		if (bottom.pos<length)
			draw_string(self, f, c, s+bottom.pos, length-bottom.pos+1, x+offs, y, False);
		}
	else if (c->chunknum==top.chunknum) {
		offs=0;
		if (top.pos>0) {
			draw_string(self, f, c, s, top.pos, x, y, False);
			offs += XTextWidth(f, s, top.pos);
			}
		if (top.pos<length)
			draw_string(self, f, c, s+top.pos, length-top.pos, x+offs, y, True);
		}
	else if (c->chunknum==bottom.chunknum) {
		offs=0;
		if (bottom.pos>0) {
			draw_string(self, f, c, s, bottom.pos, x, y, True);
			offs += XTextWidth(f, s, bottom.pos);
			}
		if (bottom.pos<length)
			draw_string(self, f, c, s+bottom.pos, length-bottom.pos+1, x+offs, y, False);
		}
	else
		draw_string(self, f, c, s, length, x, y, True);
	}
#line 1022 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1022 "LinkText.w"
static void remove_page_breaks(Widget self)
#else
#line 1022 "LinkText.w"
static void remove_page_breaks(self)Widget self;
#endif
#line 1023 "LinkText.w"
{
	TextChunk *chunk, *prev;

	if (((LinkTextWidget)self)->linkText.head==NULL)
		return;

	chunk=((LinkTextWidget)self)->linkText.head;
	if (((LinkTextWidget)self)->linkText.head->type == CT_TRAVERSER) {
		((LinkTextWidget)self)->linkText.head=((LinkTextWidget)self)->linkText.head->next;
		XtFree((char*) chunk);
		chunk=((LinkTextWidget)self)->linkText.head;
		}

	prev=((LinkTextWidget)self)->linkText.head;
	while (chunk!=NULL) {
		if (chunk->type == CT_TRAVERSER) {
			prev->next = chunk->next;
			XtFree((char*) chunk);
			chunk = prev->next;
			}
		else {
			prev=chunk;
			chunk=chunk->next;
			}
		}
	}
#line 1052 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1052 "LinkText.w"
static void dump_positions(Widget self)
#else
#line 1052 "LinkText.w"
static void dump_positions(self)Widget self;
#endif
#line 1053 "LinkText.w"
{
	TextChunk *chunk;

	for(chunk=((LinkTextWidget)self)->linkText.head ; chunk ; chunk=chunk->next) {
		printf("%3d: ", chunk->chunknum);
		switch (chunk->type) {
			case CT_TRAVERSER:
				printf("Page traverser - page=%d: (%d, %d) h=%d, d=%d, w=%d\n",
					chunk->pagenum, chunk->x, chunk->y, chunk->height, chunk->depth, chunk->width);
				break;
			case CT_BULLET:
				printf("Bullet: (%d, %d) h=%d, d=%d, w=%d\n",
					chunk->x, chunk->y, chunk->height, chunk->depth, chunk->width);
				break;
			case CT_LINEBREAK:
				printf("Linebreak: (%d, %d) h=%d, d=%d, w=%d\n",
					chunk->x, chunk->y, chunk->height, chunk->depth, chunk->width);
				break;
			case CT_DOTTAB:
				printf("Dottab: (%d, %d) h=%d, d=%d, w=%d\n",
					chunk->x, chunk->y, chunk->height, chunk->depth, chunk->width);
				break;
			case CT_TEXT:
				printf("Text: (%d, %d) h=%d, d=%d, w=%d, attr=%d, indent=%d, text=\"%s\"\n",
					chunk->x, chunk->y, chunk->height, chunk->depth, 
					chunk->width, chunk->text_attributes, chunk->indent, chunk->text);
				break;
			case CT_LINK:
				printf("Link: (%d, %d) h=%d, d=%d, w=%d, attr=%d, indent=%d, text=%s, link=%s\n",
					chunk->x, chunk->y, chunk->height, chunk->depth, 
					chunk->width, chunk->text_attributes, chunk->indent, chunk->text, 
					chunk->link);
				break;
			default:
				XtAppWarning(XtWidgetToApplicationContext(self), 
					"dump_positions() - unknown type!");
			}
		}
	}
#line 1097 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1097 "LinkText.w"
static void split_chunk(Widget self,TextChunk * chunk,int  p)
#else
#line 1097 "LinkText.w"
static void split_chunk(self,chunk,p)Widget self;TextChunk * chunk;int  p;
#endif
#line 1098 "LinkText.w"
{
	TextChunk *chunk2;
	char *c = chunk->text + p;

	/* sanity check */
	if ((p==0) || (p>strlen(chunk->text)))
		return;

	chunk2=(TextChunk*)XtMalloc(sizeof(TextChunk));
	chunk2->type=chunk->type;
	chunk2->next=chunk->next;
	chunk2->font=chunk->font;
	chunk2->color=chunk->color;
	chunk2->text_attributes=chunk->text_attributes;
	chunk2->indent=chunk->indent;
	if (chunk->link != NULL)
		chunk2->link=XtNewString(chunk->link);
	else
		chunk2->link=NULL;
	chunk2->text=XtNewString(c);
	*c='\0';
	c=XtNewString(chunk->text);
	XtFree(chunk->text);
	chunk->text=c;
	chunk->next=chunk2;
	}
#line 1129 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1129 "LinkText.w"
static void compute_linebreaks(Widget self,TextChunk * chunk,XFontStruct * f,int * x,int * y,int  width)
#else
#line 1129 "LinkText.w"
static void compute_linebreaks(self,chunk,f,x,y,width)Widget self;TextChunk * chunk;XFontStruct * f;int * x;int * y;int  width;
#endif
#line 1130 "LinkText.w"
{
	char *c, *n;
	int w;
	Boolean atomic=False;

	c=NULL;
	n=strchr(chunk->text, ' ');
	if (n==NULL)
		atomic=True;
	else
		atomic= (*(n+1)=='\0');

	/* if the chunk is unbreakable, insert a soft line break only if we
	   are not at the start of a new line */
	if (atomic)  {
		if (*x>((LinkTextWidget)self)->linkText.internalOffset+chunk->indent) {
			*x=((LinkTextWidget)self)->linkText.internalOffset+chunk->indent;
			*y += f->descent + f->ascent;
			}
		pin_chunk(self, chunk, f, x, y);
		return;
		}

	/* if the first unit in the chunk doesn't fit then insert a soft line
	   break only if we are not at the start of a new line */
	w=XTextWidth(f, chunk->text, n - chunk->text +1);
	if (*x + w > width) {
		split_chunk(self, chunk, n-chunk->text+1);
		if (*x>((LinkTextWidget)self)->linkText.internalOffset+chunk->indent) {
			*x=((LinkTextWidget)self)->linkText.internalOffset+chunk->indent;
			*y += f->descent + f->ascent;
			}
		pin_chunk(self, chunk, f, x, y);
		return;
		}

	c=n;
	n=strchr(n+1, ' ');
	while (n!=NULL) {
		w=XTextWidth(f, chunk->text, n - chunk->text +1);
		if (*x+w >= width) 
			break;
		c=n;
		n=strchr(n+1, ' ');
		}
	split_chunk(self, chunk, c-chunk->text+1);
	pin_chunk(self, chunk, f, x, y);
	*x=((LinkTextWidget)self)->linkText.internalOffset+chunk->indent;
	*y += f->descent + f->ascent;
	}
#line 1185 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1185 "LinkText.w"
static void pin_chunk(Widget self,TextChunk * chunk,XFontStruct * f,int * x,int * y)
#else
#line 1185 "LinkText.w"
static void pin_chunk(self,chunk,f,x,y)Widget self;TextChunk * chunk;XFontStruct * f;int * x;int * y;
#endif
#line 1186 "LinkText.w"
{
	int w;

	w = XTextWidth(f,chunk->text,strlen(chunk->text));
	chunk->width = w;
	chunk->height = f->ascent;
	chunk->depth = f->descent;
	chunk->x = *x;
	chunk->y = *y;
	*x += chunk->width;
	}
#line 1202 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1202 "LinkText.w"
static void compute_positions(Widget self,int  preferred_width)
#else
#line 1202 "LinkText.w"
static void compute_positions(self,preferred_width)Widget self;int  preferred_width;
#endif
#line 1203 "LinkText.w"
{
	TextChunk *chunk, *prev;
	TextChunk *chunkc;
	int x, y, w, n;
	int endx, coffset, cy;
	int maxw=0;
	int ma, md;
	XFontStruct *f;
	char *s;
	int tabpos;
	Boolean inhanging=False;
	Boolean firstline;
	int page, yoffset;
	static PageRecord pr;

	/* remove all page breaks */
	remove_page_breaks(self);

	/* initial position of text */
	compute_line_height(self, ((LinkTextWidget)self)->linkText.head, &ma, &md);
	y = ((LinkTextWidget)self)->linkText.internalOffset + ma;
	x = ((LinkTextWidget)self)->linkText.internalOffset;
	
	/* printf("%s", $hypertext); */

	/* consider each chunk of text in turn and work out where it will be put */
	for (chunk=((LinkTextWidget)self)->linkText.head ; chunk ; chunk=chunk->next) {

		switch(chunk->font)	{
			case 2:		f=((LinkTextWidget)self)->linkText.font2;	break;
			case 3:		f=((LinkTextWidget)self)->linkText.font3;	break;
			case 4:		f=((LinkTextWidget)self)->linkText.font4;	break;
			case 5:		f=((LinkTextWidget)self)->linkText.font5;	break;
			default:	f=((LinkTextWidget)self)->linkText.font1;	break;
			}

		switch (chunk->type) {
			case CT_BULLET:
				chunk->x = x;
				chunk->y = y;
				chunk->width=3 * ((LinkTextWidget)self)->linkText.bulletDiameter;
				chunk->depth=f->descent;
				chunk->height=f->ascent; /*$bulletDiameter;*/
				x += chunk->width;
				break;
			case CT_LINEBREAK:
				chunk->x = x;
				chunk->y = y;
				chunk->width=1000;	/* used in text selections */
				chunk->depth=0;
				chunk->height=10;
				inhanging=False;
				break;
			case CT_DOTTAB:
				if (chunk->indent > 0) {
						tabpos = chunk->indent + ((LinkTextWidget)self)->linkText.internalOffset;
					if (tabpos <= x) {
						/* check for a line width maxima */
						maxw = maxw>x ? maxw : x;
						x = tabpos-(chunk->indent/2); 
						if (x<((LinkTextWidget)self)->linkText.internalOffset)
							x=((LinkTextWidget)self)->linkText.internalOffset;
						compute_line_height(self, chunk->next, &ma, &md);
						y += ma + md;
						}
					/* record the chunk co-ordinates */
					chunk->x = x;
					chunk->y = y;
					chunk->height = 5;   /* a guess is good enough here ? */
					chunk->depth = 0;
					chunk->width = tabpos - x;
					x = tabpos;
					}
				break;
			case CT_TEXT:
			case CT_LINK:
				s=chunk->text;
				if (s==NULL)
					XtError("compute_positions: null text");
				if (*s=='\0')
					XtError("compute_positions: empty text");
				
				if ((chunk->text_attributes & ATTR_HANGINGINDENT) && !inhanging)
					firstline=True;
				inhanging=(chunk->text_attributes & ATTR_HANGINGINDENT);
				if (x<chunk->indent+((LinkTextWidget)self)->linkText.internalOffset) 
					if ((inhanging && !firstline) || (!inhanging))
						x=chunk->indent+((LinkTextWidget)self)->linkText.internalOffset;

				/* compute the width */
				w = XTextWidth(f,s,strlen(s));
				if ((chunk->text_attributes & ATTR_WRAPPED) &&
						(x+w > preferred_width-((LinkTextWidget)self)->linkText.internalOffset)) {
					compute_linebreaks(self, chunk, f, &x, &y, preferred_width-((LinkTextWidget)self)->linkText.internalOffset);
					firstline=False;
					}
				else
					pin_chunk(self, chunk, f, &x, &y);
				break;

			default:
				XtAppWarning(XtWidgetToApplicationContext(self), 
					"compute_position: unknown chunk!");
			}

		/* if we're moving to a new line, check if the current line
		   is the widest we've seen so far */
		if (newline(chunk->text) || (chunk->type==CT_LINEBREAK)) {
			maxw = maxw>x ? maxw : x;
			x=((LinkTextWidget)self)->linkText.internalOffset;
			y += md;
			compute_line_height(self, chunk->next, &ma, &md);
			((LinkTextWidget)self)->linkText.maxheight = ((LinkTextWidget)self)->linkText.maxheight> ma ? ((LinkTextWidget)self)->linkText.maxheight : ma;
			y += ma;
		}
	}

	((LinkTextWidget)self)->linkText.pages[0].height= y + md + ((LinkTextWidget)self)->linkText.internalOffset;

	/* paginate if height exceeds maximum window height */
	((LinkTextWidget)self)->linkText.pages[0].start=((LinkTextWidget)self)->linkText.head;
	((LinkTextWidget)self)->linkText.numPages=1;
	((LinkTextWidget)self)->linkText.currentPage=0;
	if (((LinkTextWidget)self)->linkText.pages[0].height > 32767) {
		yoffset=trav_height+30;
		page=0;
		chunk=((LinkTextWidget)self)->linkText.head;
		add_traverser(self, NULL, ((LinkTextWidget)self)->linkText.head, page, 10+trav_height);
		chunk = ((LinkTextWidget)self)->linkText.head->next;
		prev=((LinkTextWidget)self)->linkText.head;
		((LinkTextWidget)self)->linkText.pages[0].start=((LinkTextWidget)self)->linkText.head;
		for ( ; chunk ; prev=chunk, chunk=chunk->next) {
			chunk->y += yoffset;
			if (chunk->y > 32000) {
				add_traverser(self, prev, chunk, page, prev->y+20+trav_height);
				((LinkTextWidget)self)->linkText.pages[page].height=prev->y+30+trav_height;
				prev=prev->next;
				page++;
				chunk->y -= yoffset;  	/* restore original y pos */
				yoffset=trav_height+30 - chunk->y;
				chunk->y += yoffset;
				add_traverser(self, prev, chunk, page, 10+trav_height);
				prev=prev->next;
				((LinkTextWidget)self)->linkText.pages[page].start=prev;
				}
			}	
		add_traverser(self, prev, NULL, page, prev->y+20+trav_height);
		((LinkTextWidget)self)->linkText.numPages=page+1;
		((LinkTextWidget)self)->linkText.pages[page].height=prev->y+30+trav_height;
		}

	((LinkTextWidget)self)->core.height=((LinkTextWidget)self)->linkText.preferred_height = ((LinkTextWidget)self)->linkText.pages[0].height;

	/* scan through the list:
		- recompute chunknums
		- compute maximum width
		- compute maximum line height
	 */

	n=1;
	((LinkTextWidget)self)->linkText.maxheight=0;
	page=0;
	((LinkTextWidget)self)->linkText.pages[0].width=0;
	for (chunk=((LinkTextWidget)self)->linkText.head ; chunk ; chunk=chunk->next) {
		chunk->chunknum = n++;
		if (chunk->type==CT_TRAVERSER) {
			if (page!=chunk->pagenum) {
				page=chunk->pagenum;
				((LinkTextWidget)self)->linkText.pages[page].width=((LinkTextWidget)self)->linkText.internalOffset*2 + trav_width;
				}
			}

		if (chunk->height > ((LinkTextWidget)self)->linkText.maxheight)
			((LinkTextWidget)self)->linkText.maxheight = chunk->height;
		if (chunk->type != CT_LINEBREAK)
			if (chunk->x + chunk->width + ((LinkTextWidget)self)->linkText.internalOffset > ((LinkTextWidget)self)->linkText.pages[page].width)
				((LinkTextWidget)self)->linkText.pages[page].width = chunk->x + chunk->width + ((LinkTextWidget)self)->linkText.internalOffset;
		}

	((LinkTextWidget)self)->core.width=((LinkTextWidget)self)->linkText.preferred_width =  ((LinkTextWidget)self)->linkText.pages[0].width;

	/* scan through the list and center lines	*/

	for(chunk=((LinkTextWidget)self)->linkText.head ; chunk ; chunk=chunk->next) {
		if (!(chunk->text_attributes&ATTR_CENTERED))
			continue;
		if (chunk->x!=((LinkTextWidget)self)->linkText.internalOffset)
			continue;

		/* find out how wide the line is */
		chunkc=chunk;
		cy=chunkc->y;
		endx=0;
		while (chunkc && (chunkc->text_attributes&ATTR_CENTERED) && (chunkc->y == cy)) {
			if (chunkc->type != CT_LINEBREAK)
				endx=chunkc->x + chunkc->width;
			chunkc=chunkc->next;
			}

		/* now adjust the x positions */
		chunkc=chunk;
		coffset=(preferred_width-((LinkTextWidget)self)->linkText.internalOffset-endx)/2;
		if (coffset>0)
			while (chunkc && (chunkc->text_attributes&ATTR_CENTERED) && (chunkc->y == cy)) {
				chunkc->x += coffset;
				chunkc=chunkc->next;
				}
		}

	/* dump_positions($); */
	pr.current=((LinkTextWidget)self)->linkText.currentPage;
	pr.total=((LinkTextWidget)self)->linkText.numPages;
	XtCallCallbackList(self, ((LinkTextWidget)self)->linkText.newpage, &pr);
	}
#line 1755 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1755 "LinkText.w"
static void find_position(Widget self,int  x,int  y,SelectionMarker * marker)
#else
#line 1755 "LinkText.w"
static void find_position(self,x,y,marker)Widget self;int  x;int  y;SelectionMarker * marker;
#endif
#line 1756 "LinkText.w"
{
	TextChunk *c, *prev;
	int cury, i, xpos, slen;
	XFontStruct *f;
	
	if (((LinkTextWidget)self)->linkText.head==NULL)
		return;

	(*marker).chunk=NULL;
	(*marker).chunknum=((LinkTextWidget)self)->linkText.tail->chunknum+1;
	(*marker).pos=0;
	/* search vertically down the page */
	prev=((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].start;
	for (c=((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].start; c!=NULL; prev=c, c = c->next) {
		if (c->type==CT_TRAVERSER)
			if (c->pagenum!=((LinkTextWidget)self)->linkText.currentPage)
				break;

		if (y <= c->y+c->depth)
			break;
		}

	if (c==NULL)
		return;

	/* is the mouse pointer between lines? */
	if (y <= c->y - c->height) {
		(*marker).chunk=prev;
		(*marker).chunknum=prev->chunknum;
		if (prev->text != NULL)
			(*marker).pos=strlen(prev->text)+1;
		else
			(*marker).pos=0;
		return;
		}

	/* search horizontally across the page */
	cury =c->y;
	for ( ; (c!=NULL) && (cury==c->y); prev=c, c = c->next) {
		if (x <= c->x+c->width)
			break;
		}
	if (c==NULL)
		return;

	/* at the end of the line? */
	if (cury!=c->y) {
		(*marker).chunk=prev;
		(*marker).chunknum=prev->chunknum;
		if (prev->text != NULL)
			(*marker).pos=strlen(prev->text)+1;
		else
			(*marker).pos=0;
		return;
		}

	/* between chunks? */
	if (x < c->x) {
		(*marker).chunk=c;
		(*marker).chunknum=c->chunknum;
		return;
		}

	if (c->type==CT_LINEBREAK) {
		if (prev->text != NULL) {
			(*marker).chunk=prev;
			(*marker).chunknum=prev->chunknum;
			(*marker).pos=strlen(prev->text)+1;
			}
		else {
			(*marker).chunk=c;
			(*marker).chunknum=c->chunknum;
			}
		return;
		}

	/* treat a dottab/bullet/traverser as a single chunk */
	if ((c->type==CT_DOTTAB) || (c->type==CT_BULLET) || (c->type==CT_TRAVERSER)) {
		(*marker).chunknum = c->chunknum + 1;
		c=c->next;  /* assumes we never get two dottabs/bullets in a row */
		(*marker).chunk=c;
		return;
		}

	switch(c->font)     {
		case 2: f=((LinkTextWidget)self)->linkText.font2; break;
		case 3: f=((LinkTextWidget)self)->linkText.font3; break;
		case 4: f=((LinkTextWidget)self)->linkText.font4; break;
		case 5: f=((LinkTextWidget)self)->linkText.font5; break;
		default: f=((LinkTextWidget)self)->linkText.font1; break;
		}
	slen=strlen(c->text);
	if (newline(c->text))
		slen--;
	
	for (i=1; i<slen; i++) {
		xpos=c->x + XTextWidth(f,c->text,i);
		if (xpos>=x)
			break;
		}

	(*marker).chunk=c;
	(*marker).chunknum=c->chunknum;
	(*marker).pos=i-1;
	}
#line 1865 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1865 "LinkText.w"
static SelectionMarker  minimum_marker(SelectionMarker  a,SelectionMarker  b)
#else
#line 1865 "LinkText.w"
static SelectionMarker  minimum_marker(a,b)SelectionMarker  a;SelectionMarker  b;
#endif
#line 1866 "LinkText.w"
{
	if (a.chunknum==b.chunknum) {
		return ((a.pos < b.pos) ? a : b);
		}
	else if (a.chunknum < b.chunknum)
		return a;
	return b;
	}
#line 1878 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1878 "LinkText.w"
static SelectionMarker  maximum_marker(SelectionMarker  a,SelectionMarker  b)
#else
#line 1878 "LinkText.w"
static SelectionMarker  maximum_marker(a,b)SelectionMarker  a;SelectionMarker  b;
#endif
#line 1879 "LinkText.w"
{
	if (a.chunknum==b.chunknum) {
		return ((a.pos > b.pos) ? a : b);
		}
	else if (a.chunknum > b.chunknum)
		return a;
	return b;
	}
#line 1891 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1891 "LinkText.w"
static Boolean  equal_marker(SelectionMarker  a,SelectionMarker  b)
#else
#line 1891 "LinkText.w"
static Boolean  equal_marker(a,b)SelectionMarker  a;SelectionMarker  b;
#endif
#line 1892 "LinkText.w"
{
	if (a.chunknum!=b.chunknum) 
		return False;
	return (a.pos==b.pos);
	}
#line 1901 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1901 "LinkText.w"
static Boolean  smaller(SelectionMarker  a,SelectionMarker  b)
#else
#line 1901 "LinkText.w"
static Boolean  smaller(a,b)SelectionMarker  a;SelectionMarker  b;
#endif
#line 1902 "LinkText.w"
{
	if (a.chunknum<b.chunknum) 
		return True;
	if (a.chunknum>b.chunknum) 
		return False;
	return (a.pos<=b.pos);
	}
#line 1913 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1913 "LinkText.w"
static void scroll_display_up(XtPointer  client_data,XtIntervalId * timer)
#else
#line 1913 "LinkText.w"
static void scroll_display_up(client_data,timer)XtPointer  client_data;XtIntervalId * timer;
#endif
#line 1914 "LinkText.w"
{
    Widget self = (Widget) client_data;
	Window rwin, chwin;
	int rx, ry, wx, wy;
	unsigned int mask;

	/* scroll the display up one line */
	XtCallActionProc(XtParent(self), "lineDown", CurrentTime, NULL, 0);

	/* recompute the selection end point */
	XQueryPointer(XtDisplay(self), XtWindow(self), &rwin, &chwin, &rx, &ry,
		&wx, &wy, &mask);
	find_position(self, wx, wy, &(((LinkTextWidget)self)->linkText.selectEnd));

	/* set the timer running again */
	((LinkTextWidget)self)->linkText.scrollTimer = XtAppAddTimeOut(XtWidgetToApplicationContext(self), 
		((LinkTextWidget)self)->linkText.scrollInterval, scroll_display_up, self);
        }
#line 1935 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1935 "LinkText.w"
static void scroll_display_down(XtPointer  client_data,XtIntervalId * timer)
#else
#line 1935 "LinkText.w"
static void scroll_display_down(client_data,timer)XtPointer  client_data;XtIntervalId * timer;
#endif
#line 1936 "LinkText.w"
{
    Widget self = (Widget) client_data;
	Window rwin, chwin;
	int rx, ry, wx, wy;
	unsigned int mask;

	/* scroll the display up one line */
	XtCallActionProc(XtParent(self), "lineUp", CurrentTime, NULL, 0);

	/* recompute the selection end point */
	XQueryPointer(XtDisplay(self), XtWindow(self), &rwin, &chwin, &rx, &ry,
		&wx, &wy, &mask);
	find_position(self, wx, wy, &(((LinkTextWidget)self)->linkText.selectEnd));

	/* set the timer running again */
	((LinkTextWidget)self)->linkText.scrollTimer = XtAppAddTimeOut(XtWidgetToApplicationContext(self), 
		((LinkTextWidget)self)->linkText.scrollInterval, scroll_display_down, self);
        }
#line 2273 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2273 "LinkText.w"
static void clear_selection(Widget self)
#else
#line 2273 "LinkText.w"
static void clear_selection(self)Widget self;
#endif
#line 2274 "LinkText.w"
{
	XExposeEvent ev;
	SelectionMarker top, bottom;

	if (!((LinkTextWidget)self)->linkText.selected) 
		return;

	top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
	bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);

	ev.x=0;
	ev.width=((LinkTextWidget)self)->core.width;
	ev.y=top.chunk->y - top.chunk->height;
	if (bottom.chunk==NULL)
		ev.height=((LinkTextWidget)self)->core.height - ev.y;
	else
		ev.height=bottom.chunk->y + bottom.chunk->depth - ev.y;

	/* Note: if I wanted to be a real smarty-pants I could trim the exposure
 	   region according to what's visible in the parent viewport - in practice
	   this works well enough. */

	((LinkTextWidget)self)->linkText.selected=False;
	expose(self, (XEvent*) &ev, NULL);
	}
#line 2303 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2303 "LinkText.w"
static void lose_ownership_proc(Widget self,Atom * selection)
#else
#line 2303 "LinkText.w"
static void lose_ownership_proc(self,selection)Widget self;Atom * selection;
#endif
#line 2304 "LinkText.w"
{
	clear_selection(self);
	((LinkTextWidget)self)->linkText.selectStart.chunknum=0;
	}
#line 2310 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2310 "LinkText.w"
static void convert_done_proc(Widget self,Atom * selection,Atom * target)
#else
#line 2310 "LinkText.w"
static void convert_done_proc(self,selection,target)Widget self;Atom * selection;Atom * target;
#endif
#line 2311 "LinkText.w"
{
	/* we could free the asciitext buffer if we wanted to */
	}
#line 2318 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2318 "LinkText.w"
static Boolean  convert_proc(Widget self,Atom * selection,Atom * target,Atom * type,XtPointer * value,unsigned  long * length,int * format)
#else
#line 2318 "LinkText.w"
static Boolean  convert_proc(self,selection,target,type,value,length,format)Widget self;Atom * selection;Atom * target;Atom * type;XtPointer * value;unsigned  long * length;int * format;
#endif
#line 2319 "LinkText.w"
{
#ifdef SVR4                                     /* BB, 27 Mar '96 */
#define bcopy(b1, b2, length) memcpy(b2, b1, length)
#endif
    Display* d = XtDisplay(self);
    XSelectionRequestEvent* req = XtGetSelectionRequest(self, *selection, NULL);

    if (*target == XA_TARGETS(d)) {
        Atom* targetP;
        Atom* std_targets;
        unsigned long std_length;
        XmuConvertStandardSelection(self, req->time, selection, target,
                                    type, (XPointer*)&std_targets,
                                    &std_length, format);
        *value = XtMalloc(sizeof(Atom) * (std_length + 1));
        targetP = *(Atom**) value;
        *targetP++ = XA_STRING;
        *length = std_length + (targetP - (*(Atom **) value));
        bcopy((char*)std_targets, (char*)targetP, sizeof(Atom)*std_length);
        XtFree((char*)std_targets);
        *type = XA_ATOM;
        *format = 32;   /* ORA code example bombs out on 64 bit platforms */
        return True;
    }
    if (*target == XA_STRING) {
        *type = XA_STRING;
        get_text(self, False);
        *value = ((LinkTextWidget)self)->linkText.asciitext->buf;
		if (*value==NULL)
			return False;
        *length = sizeof(char) * (strlen(*value));
        *format = 8;
        return True;
    }
    if (XmuConvertStandardSelection(self, req->time, selection, target,
                                    type, (XPointer*) value, length, format))
        return True;

    return False;
}
#line 2365 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2365 "LinkText.w"
static void SmartAddToBuffer(Widget self,int * x,char * str,int  font,Boolean  inbullet,Boolean  need_indent)
#else
#line 2365 "LinkText.w"
static void SmartAddToBuffer(self,x,str,font,inbullet,need_indent)Widget self;int * x;char * str;int  font;Boolean  inbullet;Boolean  need_indent;
#endif
#line 2366 "LinkText.w"
{
	char *cp, *start;

	cp=str;
	start=str;
	while (*cp != '\0') {
		if (*cp==' ') {
			if (*x + cp-start+1> 78) {
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "\n");
				*x=0;
				if (inbullet) {
					AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "   ");
					*x=3;
					}
				}
			/* indent 'normal' text - makes headings stand out */
			if ((*x==0) && (font<=2) && need_indent) {
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "  ");
				*x += 2;
				}
			AddToBufferN(((LinkTextWidget)self)->linkText.asciitext, start, cp-start+1);
			*x += cp-start+1;
			start=cp+1;
			}
		cp++;
		}

	/* tack on the final piece */
	if (*start != '\0') {
		if (*x + cp-start> 78) {
			AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "\n");
			*x=0;
			if (inbullet) {
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "   ");
				*x=3;
				}
			}
		/* indent 'normal' text - makes headings stand out */
		if ((*x==0) && (font<=2) && need_indent) {
			AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "  ");
			*x += 2;
			}
		AddToBufferN(((LinkTextWidget)self)->linkText.asciitext, start, cp-start);
		*x += cp-start;
		}
	}
#line 2415 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2415 "LinkText.w"
static void get_text(Widget self,Boolean  getall)
#else
#line 2415 "LinkText.w"
static void get_text(self,getall)Widget self;Boolean  getall;
#endif
#line 2416 "LinkText.w"
{
	TextChunk *c, *start;
	SelectionMarker top, bottom;
	int x, tab;
	Boolean inbullet=False;
	Boolean need_indent;

	if (((LinkTextWidget)self)->linkText.asciitext==NULL)
		((LinkTextWidget)self)->linkText.asciitext=CreateBuffer("LinkTxt", 512, 512, 262144);

	ClearBuffer(((LinkTextWidget)self)->linkText.asciitext);

	if (((LinkTextWidget)self)->linkText.head==NULL)
		return;

	if (getall) {
		top.chunk=((LinkTextWidget)self)->linkText.head;
		top.chunknum=1;
		top.pos=0;
		bottom.chunk=((LinkTextWidget)self)->linkText.tail;
		bottom.chunknum=((LinkTextWidget)self)->linkText.tail->chunknum;
		if (IsTextual(((LinkTextWidget)self)->linkText.tail))
			bottom.pos=strlen(((LinkTextWidget)self)->linkText.tail->text);
		else
			bottom.pos=0;
		}
	else {
		if (!((LinkTextWidget)self)->linkText.selected)
			return;
		if (equal_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd))
			return;
		top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
		bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
		}

	start=top.chunk;
	if (start==NULL)
		return;

	if (top.chunknum==bottom.chunknum) {
		if (top.chunk->type==CT_DOTTAB)
			AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, " ..... ");
		else
			AddToBufferN(((LinkTextWidget)self)->linkText.asciitext, top.chunk->text+top.pos, 
			bottom.pos-top.pos);
		return;
		}

	/* see if there are any headings to be converted */
	need_indent=False;
	if (((LinkTextWidget)self)->linkText.indentAscii)
		for (c=start; c!=NULL; c = c->next) {
			if (c->chunknum > bottom.chunknum)
				break;
			if ((c->type==CT_TEXT) && (c->font > 2)) {
				need_indent=True;
				break;
				}
			}

	x=0;
	for (c=start; c!=NULL; c = c->next) {
		if (c->chunknum > bottom.chunknum)
			break;
		switch (c->type) {
			case CT_LINK:
			case CT_TEXT:
				/* indent 'normal' text - makes headings stand out */
				if ((x==0) && (c->font<=2) && need_indent) {
					AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "  ");
					x += 2;
					}
				if (c->chunknum == top.chunknum) 
					SmartAddToBuffer(self, &x, c->text + top.pos, c->font, inbullet, need_indent);
				else if (c->chunknum == bottom.chunknum) {
					if (bottom.pos>0) {
						AddToBufferN(((LinkTextWidget)self)->linkText.asciitext, c->text, bottom.pos);
						}
					}
				else 
					SmartAddToBuffer(self, &x, c->text, c->font, inbullet, need_indent);
				if (newline(c->text))
					x=0;
				break;
			case CT_BULLET:
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, " * ");
				x=3;
				inbullet=True;
				break;
			case CT_LINEBREAK:
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "\n");
				inbullet=False;
				x=0;
				break;
			case CT_DOTTAB:
				tab=c->indent/((LinkTextWidget)self)->linkText.spaceWidth;
				if (x>tab-5) {
					AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, "\n");
					x=0;
					while (x<tab/2) {
						AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, " ");
						x++;
						}
					}
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, " ");
				x++;
				while (x<tab-1) {
					AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, ".");
					x++;
					}
				AddToBuffer(((LinkTextWidget)self)->linkText.asciitext, " ");
				x=tab;
				break;
			case CT_TRAVERSER:
				/* ignore page traversers */
				break;
			default:
				XtWarning("get_selected_text: unhandled case");
			}
		}
	}
#line 2541 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2541 "LinkText.w"
static void  ConvertToLowerCase(char * cp)
#else
#line 2541 "LinkText.w"
static void  ConvertToLowerCase(cp)char * cp;
#endif
#line 2542 "LinkText.w"
{
	while (*cp != '\0') {
		*cp = tolower(*cp);
		cp++;
		}
	}
#line 2551 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2551 "LinkText.w"
static void AppendToBuf(char * buf,int  bufsize,char * str)
#else
#line 2551 "LinkText.w"
static void AppendToBuf(buf,bufsize,str)char * buf;int  bufsize;char * str;
#endif
#line 2552 "LinkText.w"
{
	int bufl, strl;

	bufl = strlen(buf);
	strl = strlen(str);

	if (strl + bufl < bufsize - 1)
		strcat(buf, str);
	else {
		strncat(buf, str, bufsize - bufl-1);
		buf[bufsize] = '\0';
		}
	}
#line 2569 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2569 "LinkText.w"
static void  FetchLowerCase(char * buf,int  bufsize,TextChunk * chunk,int  n)
#else
#line 2569 "LinkText.w"
static void  FetchLowerCase(buf,bufsize,chunk,n)char * buf;int  bufsize;TextChunk * chunk;int  n;
#endif
#line 2570 "LinkText.w"
{
	int size;

	buf[0] = '\0';
	AppendToBuf(buf, bufsize, chunk->text);
	chunk = chunk->next;

	size = 0;
	while ((chunk != NULL) && (size < n)) {
		if (IsTextual(chunk)) {
			AppendToBuf(buf, bufsize, chunk->text);
			size += strlen(chunk->text);
			}
		else if (chunk->type == CT_LINEBREAK)
			AppendToBuf(buf, bufsize, " ");
		chunk = chunk->next;
		}

	ConvertToLowerCase(buf);
	}
#line 2593 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2593 "LinkText.w"
static void  TextOffset(Widget self,TextChunk * chunk,int  pos,int  n,TextChunk ** endchunk,int * endpos)
#else
#line 2593 "LinkText.w"
static void  TextOffset(self,chunk,pos,n,endchunk,endpos)Widget self;TextChunk * chunk;int  pos;int  n;TextChunk ** endchunk;int * endpos;
#endif
#line 2594 "LinkText.w"
{
	while (chunk != NULL) {
		if (IsTextual(chunk)) {
			if (pos+n <= strlen(chunk->text)) {
				*endchunk = chunk;
				*endpos = pos + n;
				return;
				}
			n -= (strlen(chunk->text)-pos);
			pos = 0;
			}
		else if (chunk->type == CT_LINEBREAK) {
			n--;
			pos = 0;
			}
		chunk = chunk->next;
		}

	/* end of list has been reached */
	*endchunk = ((LinkTextWidget)self)->linkText.tail;
	*endpos = 0;
	}

static XtResource resources[] = {
#line 61 "LinkText.w"
{XtNhypertext,XtCHypertext,XtRString,sizeof(((LinkTextRec*)NULL)->linkText.hypertext),XtOffsetOf(LinkTextRec,linkText.hypertext),XtRImmediate,(XtPointer)NULL },
#line 66 "LinkText.w"
{XtNactivate,XtCActivate,XtRCallback,sizeof(((LinkTextRec*)NULL)->linkText.activate),XtOffsetOf(LinkTextRec,linkText.activate),XtRImmediate,(XtPointer)NULL },
#line 76 "LinkText.w"
{XtNnewpage,XtCNewpage,XtRCallback,sizeof(((LinkTextRec*)NULL)->linkText.newpage),XtOffsetOf(LinkTextRec,linkText.newpage),XtRImmediate,(XtPointer)NULL },
#line 80 "LinkText.w"
{XtNinternalOffset,XtCInternalOffset,XtRDimension,sizeof(((LinkTextRec*)NULL)->linkText.internalOffset),XtOffsetOf(LinkTextRec,linkText.internalOffset),XtRImmediate,(XtPointer)4 },
#line 87 "LinkText.w"
{XtNfont1,XtCFont1,XtRFontStruct,sizeof(((LinkTextRec*)NULL)->linkText.font1),XtOffsetOf(LinkTextRec,linkText.font1),XtRString,(XtPointer)XtDefaultFont },
#line 88 "LinkText.w"
{XtNfont2,XtCFont2,XtRFontStruct,sizeof(((LinkTextRec*)NULL)->linkText.font2),XtOffsetOf(LinkTextRec,linkText.font2),XtRString,(XtPointer)XtDefaultFont },
#line 89 "LinkText.w"
{XtNfont3,XtCFont3,XtRFontStruct,sizeof(((LinkTextRec*)NULL)->linkText.font3),XtOffsetOf(LinkTextRec,linkText.font3),XtRString,(XtPointer)XtDefaultFont },
#line 90 "LinkText.w"
{XtNfont4,XtCFont4,XtRFontStruct,sizeof(((LinkTextRec*)NULL)->linkText.font4),XtOffsetOf(LinkTextRec,linkText.font4),XtRString,(XtPointer)XtDefaultFont },
#line 91 "LinkText.w"
{XtNfont5,XtCFont5,XtRFontStruct,sizeof(((LinkTextRec*)NULL)->linkText.font5),XtOffsetOf(LinkTextRec,linkText.font5),XtRString,(XtPointer)XtDefaultFont },
#line 98 "LinkText.w"
{XtNcolor1,XtCColor1,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color1),XtOffsetOf(LinkTextRec,linkText.color1),XtRString,(XtPointer)XtDefaultForeground },
#line 99 "LinkText.w"
{XtNcolor2,XtCColor2,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color2),XtOffsetOf(LinkTextRec,linkText.color2),XtRString,(XtPointer)XtDefaultForeground },
#line 100 "LinkText.w"
{XtNcolor3,XtCColor3,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color3),XtOffsetOf(LinkTextRec,linkText.color3),XtRString,(XtPointer)XtDefaultForeground },
#line 101 "LinkText.w"
{XtNcolor4,XtCColor4,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color4),XtOffsetOf(LinkTextRec,linkText.color4),XtRString,(XtPointer)XtDefaultForeground },
#line 102 "LinkText.w"
{XtNcolor5,XtCColor5,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color5),XtOffsetOf(LinkTextRec,linkText.color5),XtRString,(XtPointer)XtDefaultForeground },
#line 103 "LinkText.w"
{XtNcolor6,XtCColor6,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color6),XtOffsetOf(LinkTextRec,linkText.color6),XtRString,(XtPointer)XtDefaultForeground },
#line 104 "LinkText.w"
{XtNcolor7,XtCColor7,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color7),XtOffsetOf(LinkTextRec,linkText.color7),XtRString,(XtPointer)XtDefaultForeground },
#line 105 "LinkText.w"
{XtNcolor8,XtCColor8,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.color8),XtOffsetOf(LinkTextRec,linkText.color8),XtRString,(XtPointer)XtDefaultForeground },
#line 109 "LinkText.w"
{XtNlinkColor,XtCLinkColor,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.linkColor),XtOffsetOf(LinkTextRec,linkText.linkColor),XtRString,(XtPointer)"mediumblue"},
#line 114 "LinkText.w"
{XtNselectForeground,XtCSelectForeground,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.selectForeground),XtOffsetOf(LinkTextRec,linkText.selectForeground),XtRString,(XtPointer)XtDefaultBackground },
#line 115 "LinkText.w"
{XtNselectBackground,XtCSelectBackground,XtRPixel,sizeof(((LinkTextRec*)NULL)->linkText.selectBackground),XtOffsetOf(LinkTextRec,linkText.selectBackground),XtRString,(XtPointer)XtDefaultForeground },
#line 119 "LinkText.w"
{XtNunderlineLinks,XtCUnderlineLinks,XtRBoolean,sizeof(((LinkTextRec*)NULL)->linkText.underlineLinks),XtOffsetOf(LinkTextRec,linkText.underlineLinks),XtRImmediate,(XtPointer)True },
#line 123 "LinkText.w"
{XtNnormalCursor,XtCNormalCursor,XtRCursor,sizeof(((LinkTextRec*)NULL)->linkText.normalCursor),XtOffsetOf(LinkTextRec,linkText.normalCursor),XtRString,(XtPointer)"top_left_arrow"},
#line 127 "LinkText.w"
{XtNlinkCursor,XtCLinkCursor,XtRCursor,sizeof(((LinkTextRec*)NULL)->linkText.linkCursor),XtOffsetOf(LinkTextRec,linkText.linkCursor),XtRString,(XtPointer)"hand2"},
#line 132 "LinkText.w"
{XtNbusyCursor,XtCBusyCursor,XtRCursor,sizeof(((LinkTextRec*)NULL)->linkText.busyCursor),XtOffsetOf(LinkTextRec,linkText.busyCursor),XtRString,(XtPointer)"watch"},
#line 138 "LinkText.w"
{XtNselectThreshold,XtCSelectThreshold,XtRInt,sizeof(((LinkTextRec*)NULL)->linkText.selectThreshold),XtOffsetOf(LinkTextRec,linkText.selectThreshold),XtRImmediate,(XtPointer)5 },
#line 144 "LinkText.w"
{XtNspaceWidth,XtCSpaceWidth,XtRInt,sizeof(((LinkTextRec*)NULL)->linkText.spaceWidth),XtOffsetOf(LinkTextRec,linkText.spaceWidth),XtRImmediate,(XtPointer)5 },
#line 152 "LinkText.w"
{XtNindentAscii,XtCIndentAscii,XtRBoolean,sizeof(((LinkTextRec*)NULL)->linkText.indentAscii),XtOffsetOf(LinkTextRec,linkText.indentAscii),XtRImmediate,(XtPointer)True },
#line 156 "LinkText.w"
{XtNbulletDiameter,XtCBulletDiameter,XtRInt,sizeof(((LinkTextRec*)NULL)->linkText.bulletDiameter),XtOffsetOf(LinkTextRec,linkText.bulletDiameter),XtRImmediate,(XtPointer)7 },
#line 161 "LinkText.w"
{XtNscrollInterval,XtCScrollInterval,XtRInt,sizeof(((LinkTextRec*)NULL)->linkText.scrollInterval),XtOffsetOf(LinkTextRec,linkText.scrollInterval),XtRImmediate,(XtPointer)80 },
};

LinkTextClassRec linkTextClassRec = {
{ /* core_class part */
/* superclass   	*/  (WidgetClass) &compositeClassRec,
/* class_name   	*/  "LinkText",
/* widget_size  	*/  sizeof(LinkTextRec),
/* class_initialize 	*/  NULL,
/* class_part_initialize*/  _resolve_inheritance,
/* class_inited 	*/  FALSE,
/* initialize   	*/  initialize,
/* initialize_hook 	*/  NULL,
/* realize      	*/  realize,
/* actions      	*/  actionsList,
/* num_actions  	*/  9,
/* resources    	*/  resources,
/* num_resources 	*/  29,
/* xrm_class    	*/  NULLQUARK,
/* compres_motion 	*/  False ,
/* compress_exposure 	*/  XtExposeCompressMultiple |XtExposeGraphicsExposeMerged ,
/* compress_enterleave 	*/  False ,
/* visible_interest 	*/  False ,
/* destroy      	*/  destroy,
/* resize       	*/  XtInheritResize,
/* expose       	*/  expose,
/* set_values   	*/  set_values,
/* set_values_hook 	*/  NULL,
/* set_values_almost 	*/  XtInheritSetValuesAlmost,
/* get_values+hook 	*/  NULL,
/* accept_focus 	*/  XtInheritAcceptFocus,
/* version      	*/  XtVersion,
/* callback_private 	*/  NULL,
/* tm_table      	*/  defaultTranslations,
/* query_geometry 	*/  query_geometry,
/* display_acceleator 	*/  XtInheritDisplayAccelerator,
/* extension    	*/  NULL 
},
{ /* composite_class part */
XtInheritGeometryManager,
XtInheritChangeManaged,
XtInheritInsertChild,
XtInheritDeleteChild,
NULL
},
{ /* LinkText_class part */
 /* dummy */  0
},
};
WidgetClass linkTextWidgetClass = (WidgetClass) &linkTextClassRec;
/*ARGSUSED*/
#line 1960 "LinkText.w"
static void chaselink(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	int mx, my;
	TextChunk *c;
	static LinkRecord lr;
	
	if (((LinkTextWidget)self)->linkText.selecting)
		return;

	mx=event->xbutton.x;
	my=event->xbutton.y;


	for (c=((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].start; c!=NULL; c = c->next) {
		if ((c->type != CT_LINK) && (c->type != CT_TRAVERSER))
			continue;
		if (c->type == CT_TRAVERSER)
			if (c->pagenum != ((LinkTextWidget)self)->linkText.currentPage)
				break;

		if ((mx >= c->x) && (mx <= c->x + c->width) && 
			(my <= c->y + c->depth) && (my >= c->y - c->height)) {
			lr.text = c->text;
			lr.link = c->link;
			if (c->type == CT_TRAVERSER) {
				if (mx > c->x + trav_width/2)
					LinkTextNextPage(self, True);
				else
					LinkTextPrevPage(self, True);
				}
			else
				XtCallCallbackList(self, ((LinkTextWidget)self)->linkText.activate, &lr);
			return;
			}
		}
	}

/*ARGSUSED*/
#line 2000 "LinkText.w"
static void grabpage(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    ((LinkTextWidget)self)->linkText.grabx=event->xbutton.x_root;
    ((LinkTextWidget)self)->linkText.graby=event->xbutton.y_root;
	LinkViewGetCoordinates(XtParent(self), &(((LinkTextWidget)self)->linkText.viewx), &(((LinkTextWidget)self)->linkText.viewy));
    XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.grabCursor);
	}

/*ARGSUSED*/
#line 2010 "LinkText.w"
static void movepage(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	int mx, my;

    mx=event->xbutton.x_root;
    my=event->xbutton.y_root;
	LinkViewSetCoordinates(XtParent(self), ((LinkTextWidget)self)->linkText.viewx-mx+((LinkTextWidget)self)->linkText.grabx, ((LinkTextWidget)self)->linkText.viewy-my+((LinkTextWidget)self)->linkText.graby);
	}

/*ARGSUSED*/
#line 2022 "LinkText.w"
static void releasepage(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
    XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.normalCursor);
	}

/*ARGSUSED*/
#line 2029 "LinkText.w"
static void cursortype(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	int mx, my;
	TextChunk *c;
	
	if (((LinkTextWidget)self)->linkText.busy) {
        XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.busyCursor);
		return;
		}

	mx=event->xbutton.x;
	my=event->xbutton.y;

	for (c=((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].start; c!=NULL; c = c->next) {
		if ((c->type != CT_LINK) && (c->type != CT_TRAVERSER))
			continue;

		/* check for end of page */
		if (c->type == CT_TRAVERSER)
			if (c->pagenum != ((LinkTextWidget)self)->linkText.currentPage)
				break;

		if ((mx >= c->x) && (mx <= c->x + c->width) && 
			(my <= c->y + c->depth) && (my >= c->y - c->height)) {
	        XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.linkCursor);
			return;
			}
		}
    XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.normalCursor);
	}

/*ARGSUSED*/
#line 2063 "LinkText.w"
static void start_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	if (((LinkTextWidget)self)->linkText.head==NULL)
		return;

	/* don't start selecting until the mouse has moved a certain number
	   of pixels */
	((LinkTextWidget)self)->linkText.selecting=False;
	clear_selection(self);


	/* remember where the mouse is */
    ((LinkTextWidget)self)->linkText.selectx_root=event->xbutton.x_root;
    ((LinkTextWidget)self)->linkText.selecty_root=event->xbutton.y_root;
    ((LinkTextWidget)self)->linkText.selectx=event->xbutton.x;
    ((LinkTextWidget)self)->linkText.selecty=event->xbutton.y;

	find_position(self, ((LinkTextWidget)self)->linkText.selectx, ((LinkTextWidget)self)->linkText.selecty, &(((LinkTextWidget)self)->linkText.selectStart));
	}

/*ARGSUSED*/
#line 2087 "LinkText.w"
static void move_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	int mx_root, my_root;
	int mx, my;
	SelectionMarker top, bottom;
	XExposeEvent ev;
	Boolean selection_started=False;
	Dimension lvh;
	int lvx, lvy;

	if (((LinkTextWidget)self)->linkText.head==NULL)
		return;

    mx_root=event->xbutton.x_root;
    my_root=event->xbutton.y_root;
	if (! ((LinkTextWidget)self)->linkText.selecting)
		/* has the mouse moved far enough to start selection? */
		if ((abs(mx_root-((LinkTextWidget)self)->linkText.selectx_root) >= ((LinkTextWidget)self)->linkText.selectThreshold) ||
			(abs(my_root-((LinkTextWidget)self)->linkText.selecty_root) >= ((LinkTextWidget)self)->linkText.selectThreshold))	{
			((LinkTextWidget)self)->linkText.selected=True;
			((LinkTextWidget)self)->linkText.selecting=True;
			selection_started=True;
		    XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.normalCursor);

			/* find y position in root window of top and bottom border */
			LinkViewGetCoordinates(XtParent(self), &lvx, &lvy);
			XtVaGetValues(XtParent(self), XtNheight, &lvh, NULL);
			((LinkTextWidget)self)->linkText.topBorder=my_root - event->xbutton.y + lvy;
			((LinkTextWidget)self)->linkText.bottomBorder=((LinkTextWidget)self)->linkText.topBorder+lvh;
			}
	if (! ((LinkTextWidget)self)->linkText.selecting)
		return;

    mx=event->xbutton.x;
    my=event->xbutton.y;
	find_position(self, mx, my, &(((LinkTextWidget)self)->linkText.selectEnd));


	/* scroll the display if we need to */

	if (my_root<((LinkTextWidget)self)->linkText.topBorder) {
		if (! ((LinkTextWidget)self)->linkText.scrollTimer) {
			((LinkTextWidget)self)->linkText.scrollTimer = XtAppAddTimeOut(XtWidgetToApplicationContext(self), 
				((LinkTextWidget)self)->linkText.scrollInterval, scroll_display_down, self);
			}
		}
	else if (my_root>((LinkTextWidget)self)->linkText.bottomBorder) {
		if (! ((LinkTextWidget)self)->linkText.scrollTimer) {
			((LinkTextWidget)self)->linkText.scrollTimer = XtAppAddTimeOut(XtWidgetToApplicationContext(self), 
				((LinkTextWidget)self)->linkText.scrollInterval, scroll_display_up, self);
			}
		}
	else if (((LinkTextWidget)self)->linkText.scrollTimer) {
		XtRemoveTimeOut(((LinkTextWidget)self)->linkText.scrollTimer);
		((LinkTextWidget)self)->linkText.scrollTimer=0;
		}


	/* if the selection end has moved (or just begun) we need to update the display */

	if (!equal_marker(((LinkTextWidget)self)->linkText.selectEnd, ((LinkTextWidget)self)->linkText.lastend) || selection_started) {
		/* printf("selectEnd=%d,%d\n", $selectEnd.chunknum, $selectEnd.pos);*/
		if (selection_started) {
			top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
			bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
			}
		else {
			top=minimum_marker(((LinkTextWidget)self)->linkText.selectEnd, ((LinkTextWidget)self)->linkText.lastend);
			bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectEnd, ((LinkTextWidget)self)->linkText.lastend);
			}

		/* construct an exposure bounding box */
		ev.x=0;
		ev.width=((LinkTextWidget)self)->core.width;
		ev.y=top.chunk->y - top.chunk->height-5;
		if (bottom.chunk==NULL)
			ev.height=((LinkTextWidget)self)->core.height - ev.y;
		else
			ev.height=bottom.chunk->y + bottom.chunk->depth - ev.y;
		expose(self, (XEvent*) &ev, NULL);

		/* remember where we last updated the screen */
		((LinkTextWidget)self)->linkText.lastend=((LinkTextWidget)self)->linkText.selectEnd;
		}
	}

/*ARGSUSED*/
#line 2176 "LinkText.w"
static void extend_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	int mx, my;
	SelectionMarker newend, top, bottom;
	XExposeEvent ev;

	if ((((LinkTextWidget)self)->linkText.selectStart.chunknum<=0) || (((LinkTextWidget)self)->linkText.head==NULL))
		return;

    mx=event->xbutton.x;
    my=event->xbutton.y;
	find_position(self, mx, my, &newend);

	if (!((LinkTextWidget)self)->linkText.selected) {
		((LinkTextWidget)self)->linkText.selected=True;
		if (XtOwnSelection(self, XA_PRIMARY, event->xbutton.time, 
			convert_proc, lose_ownership_proc, convert_done_proc) == False) {
			XtWarning("LinkText: failed to become selection owner\n");
			return;
			}
		((LinkTextWidget)self)->linkText.selectEnd=newend;
		top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
		bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
		}
	else if (smaller(newend, ((LinkTextWidget)self)->linkText.selectStart) && smaller(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd)) {
		top=newend;
		bottom=((LinkTextWidget)self)->linkText.selectStart;
		((LinkTextWidget)self)->linkText.selectStart=newend;
		}
	else if (smaller(((LinkTextWidget)self)->linkText.selectStart, newend) && smaller(newend, ((LinkTextWidget)self)->linkText.selectEnd)) {
		top=newend;
		bottom=((LinkTextWidget)self)->linkText.selectEnd;
		((LinkTextWidget)self)->linkText.selectEnd=newend;
		}
	else if (smaller(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd) && smaller(((LinkTextWidget)self)->linkText.selectEnd, newend)) {
		top=((LinkTextWidget)self)->linkText.selectEnd;
		bottom=newend;
		((LinkTextWidget)self)->linkText.selectEnd=newend;
		}
	else if (smaller(newend, ((LinkTextWidget)self)->linkText.selectEnd) && smaller(((LinkTextWidget)self)->linkText.selectEnd, ((LinkTextWidget)self)->linkText.selectStart)) {
		top=newend;
		bottom=((LinkTextWidget)self)->linkText.selectEnd;
		((LinkTextWidget)self)->linkText.selectEnd=newend;
		}
	else if (smaller(((LinkTextWidget)self)->linkText.selectEnd, newend) && smaller(newend, ((LinkTextWidget)self)->linkText.selectStart)) {
		top=((LinkTextWidget)self)->linkText.selectEnd;
		bottom=newend;
		((LinkTextWidget)self)->linkText.selectEnd=newend;
		}
	else {
		top=((LinkTextWidget)self)->linkText.selectStart;
		bottom=newend;
		((LinkTextWidget)self)->linkText.selectStart=newend;
		}

	if (top.chunk==NULL) {
		XtError("extend_selection error - contact author");
		return;
		}

	/* construct an exposure bounding box */
	ev.x=0;
	ev.width=((LinkTextWidget)self)->core.width;
	ev.y=top.chunk->y - top.chunk->height;
	if (bottom.chunk==NULL)
		ev.height=((LinkTextWidget)self)->core.height - ev.y;
	else
		ev.height=bottom.chunk->y + bottom.chunk->depth - ev.y;

	expose(self, (XEvent*) &ev, NULL);
	}

/*ARGSUSED*/
#line 2249 "LinkText.w"
static void end_selection(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
{
	if (!((LinkTextWidget)self)->linkText.selecting)
		return;

	if (((LinkTextWidget)self)->linkText.scrollTimer) {
		XtRemoveTimeOut(((LinkTextWidget)self)->linkText.scrollTimer);
		((LinkTextWidget)self)->linkText.scrollTimer=0;
		}

	((LinkTextWidget)self)->linkText.selecting=False;
	if (XtOwnSelection(self, XA_PRIMARY, event->xbutton.time, 
		convert_proc, lose_ownership_proc, convert_done_proc) == False) {
		XtWarning("LinkText: failed to become selection owner\n");
		return;
		}
	((LinkTextWidget)self)->linkText.selected=True;
	}

static void _resolve_inheritance(class)
WidgetClass class;
{
  LinkTextWidgetClass c = (LinkTextWidgetClass) class;
  LinkTextWidgetClass super;
  static CompositeClassExtensionRec extension_rec = {
    NULL, NULLQUARK, XtCompositeExtensionVersion,
    sizeof(CompositeClassExtensionRec), True};
  CompositeClassExtensionRec *ext;
  ext = (XtPointer)XtMalloc(sizeof(*ext));
  *ext = extension_rec;
  ext->next_extension = c->composite_class.extension;
  c->composite_class.extension = ext;
  if (class == linkTextWidgetClass) return;
  super = (LinkTextWidgetClass)class->core_class.superclass;
}
#line 1427 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1427 "LinkText.w"
static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
#else
#line 1427 "LinkText.w"
static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
#endif
#line 1428 "LinkText.w"
{
	Pixmap shape, shapemask;
	XColor fore, back;

	((LinkTextWidget)self)->linkText.busy=False;
	((LinkTextWidget)self)->linkText.selecting=False;
	((LinkTextWidget)self)->linkText.selected=False;
	((LinkTextWidget)self)->linkText.selectStart.chunknum=-1;  /* nothing selected */
	((LinkTextWidget)self)->linkText.lastend.chunknum=-1; 
	((LinkTextWidget)self)->linkText.head=NULL;
	((LinkTextWidget)self)->linkText.tail=NULL;
	((LinkTextWidget)self)->linkText.lastFindChunk=NULL;
	((LinkTextWidget)self)->linkText.lastFindPos=0;
	((LinkTextWidget)self)->linkText.asciitext=NULL;
	((LinkTextWidget)self)->linkText.pages[0].start = NULL;
	((LinkTextWidget)self)->linkText.currentPage = 0;
	((LinkTextWidget)self)->linkText.numPages = 0;
	(void) XmuInternAtom(XtDisplay(self), XmuMakeAtom("NULL"));

    if (((LinkTextWidget)self)->linkText.hypertext) {
		((LinkTextWidget)self)->linkText.hypertext = XtNewString(((LinkTextWidget)self)->linkText.hypertext);
		hyperchunkit(self);
		}

	((LinkTextWidget)self)->linkText.scrollTimer=0;

	((LinkTextWidget)self)->linkText.ngc=NULL;
	make_gc(self);
	((LinkTextWidget)self)->linkText.graygc=NULL;
	make_graygc(self);

	/* make the grabCursor */
	shape=XCreatePixmapFromBitmapData(XtDisplay(self), 
		RootWindowOfScreen(XtScreen(self)),
		hand_bits, hand_width, hand_height, 1, 0, 1);
	shapemask=XCreatePixmapFromBitmapData(XtDisplay(self), 
		RootWindowOfScreen(XtScreen(self)),
		handmask_bits, handmask_width, handmask_height, 1, 0, 1);

	XParseColor(XtDisplay(self), ((LinkTextWidget)self)->core.colormap, "black", &fore);
	XParseColor(XtDisplay(self), ((LinkTextWidget)self)->core.colormap, "white", &back);
	((LinkTextWidget)self)->linkText.grabCursor=XCreatePixmapCursor(XtDisplay(self), shape, shapemask, 
		&fore, &back, 0, 0);

	}
#line 1475 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1475 "LinkText.w"
static void realize(Widget self,XtValueMask * mask,XSetWindowAttributes * attributes)
#else
#line 1475 "LinkText.w"
static void realize(self,mask,attributes)Widget self;XtValueMask * mask;XSetWindowAttributes * attributes;
#endif
#line 1476 "LinkText.w"
{
    compositeClassRec.core_class.realize(self, mask, attributes);
    ((LinkTextWidget)self)->linkText.pageBitmap = XCreateBitmapFromData(XtDisplay(self), XtWindow(self),
        trav_bits, trav_width, trav_height);
	}
#line 1485 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1485 "LinkText.w"
static void destroy(Widget self)
#else
#line 1485 "LinkText.w"
static void destroy(self)Widget self;
#endif
#line 1486 "LinkText.w"
{
	XtReleaseGC(self, ((LinkTextWidget)self)->linkText.ngc);
	EraseLinkText(((LinkTextWidget)self)->linkText.head);
	((LinkTextWidget)self)->linkText.head=((LinkTextWidget)self)->linkText.tail=NULL;
}
#line 1495 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1495 "LinkText.w"
static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
#else
#line 1495 "LinkText.w"
static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
#endif
#line 1496 "LinkText.w"
{
	Boolean do_size = False;
	Boolean do_redisplay = False;
	Dimension preferred_width = 500;

	/* printf("Set Values:\n"); */

	XtVaGetValues(XtParent(self), XtNwidth, &preferred_width, NULL);
	preferred_width -= 16;    /* KLUDGE - adjust for scrollbar */

	if (((LinkTextWidget)self)->core.background_pixel != ((LinkTextWidget)old)->core.background_pixel)
		make_graygc(self);

    if (((LinkTextWidget)self)->linkText.hypertext != ((LinkTextWidget)old)->linkText.hypertext) {
        XtFree(((LinkTextWidget)old)->linkText.hypertext);
        ((LinkTextWidget)self)->linkText.hypertext = XtNewString(((LinkTextWidget)self)->linkText.hypertext);
		hyperchunkit(self);
		do_size = True;
		((LinkTextWidget)self)->linkText.selected=False;
		((LinkTextWidget)self)->linkText.selectStart.chunknum=-1;
		}

	if ((((LinkTextWidget)old)->linkText.internalOffset != ((LinkTextWidget)self)->linkText.internalOffset) ||
		(((LinkTextWidget)old)->core.width != ((LinkTextWidget)self)->core.width)) {
		do_size = True;
		((LinkTextWidget)self)->linkText.selected=False;
		preferred_width=((LinkTextWidget)self)->core.width;
		}

	if ((((LinkTextWidget)old)->linkText.font1 != ((LinkTextWidget)self)->linkText.font1) ||
		(((LinkTextWidget)old)->linkText.font2 != ((LinkTextWidget)self)->linkText.font2) ||
		(((LinkTextWidget)old)->linkText.font3 != ((LinkTextWidget)self)->linkText.font3) ||
		(((LinkTextWidget)old)->linkText.font4 != ((LinkTextWidget)self)->linkText.font4) ||
		(((LinkTextWidget)old)->linkText.font5 != ((LinkTextWidget)self)->linkText.font5))
		do_size = True;

	if ((((LinkTextWidget)old)->linkText.color1 != ((LinkTextWidget)self)->linkText.color1) ||
		(((LinkTextWidget)old)->linkText.color2 != ((LinkTextWidget)self)->linkText.color2) ||
		(((LinkTextWidget)old)->linkText.color3 != ((LinkTextWidget)self)->linkText.color3) ||
		(((LinkTextWidget)old)->linkText.color4 != ((LinkTextWidget)self)->linkText.color4) ||
		(((LinkTextWidget)old)->linkText.color5 != ((LinkTextWidget)self)->linkText.color5) ||
		(((LinkTextWidget)old)->linkText.color6 != ((LinkTextWidget)self)->linkText.color6) ||
		(((LinkTextWidget)old)->linkText.color7 != ((LinkTextWidget)self)->linkText.color7) ||
		(((LinkTextWidget)old)->linkText.color8 != ((LinkTextWidget)self)->linkText.color8) ||
		(((LinkTextWidget)old)->linkText.linkColor != ((LinkTextWidget)self)->linkText.linkColor))
		do_redisplay = True;
	
	if (((LinkTextWidget)self)->linkText.selected)
		if ((((LinkTextWidget)old)->linkText.selectBackground != ((LinkTextWidget)self)->linkText.selectBackground) ||
			(((LinkTextWidget)old)->linkText.selectForeground != ((LinkTextWidget)self)->linkText.selectForeground))
			do_redisplay = True;

	if (((LinkTextWidget)old)->linkText.underlineLinks != ((LinkTextWidget)self)->linkText.underlineLinks)
		do_redisplay=True;
		
	if (do_size) {
		compute_positions(self, preferred_width);
		do_redisplay=True;
		}

	return do_redisplay;
	}
#line 1563 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1563 "LinkText.w"
static XtGeometryResult  query_geometry(Widget self,XtWidgetGeometry * request,XtWidgetGeometry * reply)
#else
#line 1563 "LinkText.w"
static XtGeometryResult  query_geometry(self,request,reply)Widget self;XtWidgetGeometry * request;XtWidgetGeometry * reply;
#endif
#line 1564 "LinkText.w"
{
	/* say no to any requested size change */
	reply->request_mode = CWWidth |CWHeight;
	reply->width = ((LinkTextWidget)self)->linkText.preferred_width;
	reply->height = ((LinkTextWidget)self)->linkText.preferred_height;
	return XtGeometryAlmost;
	}
#line 1574 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 1574 "LinkText.w"
static void expose(Widget self,XEvent * event,Region  region)
#else
#line 1574 "LinkText.w"
static void expose(self,event,region)Widget self;XEvent * event;Region  region;
#endif
#line 1575 "LinkText.w"
{
	TextChunk *chunk;
	int x, y, height, depth, width;
	int x1, cw;
	XFontStruct *f;
	char *s;
	char dots[256];
	int ndots, dotwidth, i, slen;
	int exp_y1, exp_y2;
	SelectionMarker top, bottom;
	Boolean reverse;
	int last_height=((LinkTextWidget)self)->linkText.font1->ascent;
	int last_depth=((LinkTextWidget)self)->linkText.font1->descent;

		
	if(! XtIsRealized(self))
		return ;

	if (event == NULL) {
		exp_y1=0;
		exp_y2=((LinkTextWidget)self)->core.height;
		}
	else {
		exp_y1=event->xexpose.y;
		exp_y2= exp_y1+event->xexpose.height;
		}

	/* don't try to draw to portions of the window that are off screen */
	if (-((LinkTextWidget)self)->core.y > exp_y1)
		exp_y1 = -((LinkTextWidget)self)->core.y;

	if (exp_y2 > exp_y1 +1500)
		exp_y2 = exp_y1 + 1500;

	/* printf("expose %d to %d, y=%d\n", exp_y1, exp_y2, $y); */

	/* skip past any chunks that are 'above' the region to be
			redisplayed */

	for(chunk=((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].start ; chunk ; chunk=chunk->next) {
		if (chunk->y + chunk->depth > exp_y1)
			break;
		switch(chunk->font)	{
			case 2:		f=((LinkTextWidget)self)->linkText.font2;	break;
			case 3:		f=((LinkTextWidget)self)->linkText.font3;	break;
			case 4:		f=((LinkTextWidget)self)->linkText.font4;	break;
			case 5:		f=((LinkTextWidget)self)->linkText.font5;	break;
			default:	f=((LinkTextWidget)self)->linkText.font1;	break;
			}
		if (chunk->type == CT_LINEBREAK)
			if (chunk->next != NULL)
				last_height = chunk->next->y - chunk->y - f->descent;
		}
		
	/* compute the top and bottom point of the text selection */
	top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
	bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);

	for( ; chunk; chunk=chunk->next) 	{
/* printf("type %d at (%d, %d)\n", chunk->type, chunk->x, chunk->y);*/
		switch(chunk->font)	{
			case 2:		f=((LinkTextWidget)self)->linkText.font2;	break;
			case 3:		f=((LinkTextWidget)self)->linkText.font3;	break;
			case 4:		f=((LinkTextWidget)self)->linkText.font4;	break;
			case 5:		f=((LinkTextWidget)self)->linkText.font5;	break;
			default:	f=((LinkTextWidget)self)->linkText.font1;	break;
			}

		x=chunk->x;
		y=chunk->y;
		height=chunk->height;
		depth=chunk->depth;
		width=chunk->width;

		/* see if remaining text is below the exposed area */
		if (y - ((LinkTextWidget)self)->linkText.maxheight > (exp_y2))
			break;

		/* see if we've reached the end of the page */
		if (chunk->type == CT_TRAVERSER)
			if (chunk->pagenum != ((LinkTextWidget)self)->linkText.currentPage)
				break;
		switch (chunk->type) {
			case CT_LINK:
			case CT_TEXT:
				s=chunk->text;
				x1=x;
				slen = strlen(s);
				if (newline(s))
					slen--;
				cw=XTextWidth(f,s,slen);
				draw_chunktext(self, f, chunk, s, slen, x1, y);
				last_height=f->ascent;
				last_depth=f->descent;
				break;


			case CT_DOTTAB:		
				if (chunk->indent > 0) {
					dotwidth = XTextWidth(f,".",1);
					ndots = (chunk->indent -x)/dotwidth;
					for (i=0; i<ndots; i++)
						dots[i]='.';
					 draw_chunktext(self, f, chunk, dots, ndots, x, y);
					}
				break;

			case CT_BULLET:
				reverse=((LinkTextWidget)self)->linkText.selected &&
						(chunk->chunknum >= top.chunknum) &&
						(chunk->chunknum <= bottom.chunknum);
				if (reverse) {
					XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectBackground);
					XSetBackground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectForeground);
					XFillRectangle(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.ngc, 
						chunk->x, chunk->y-chunk->height, 
						chunk->width, chunk->height+chunk->depth);
					}
				else
					XClearArea(XtDisplay(self), XtWindow(self), 
						chunk->x, chunk->y-chunk->height, 
						chunk->width, chunk->height+chunk->depth, False);
				set_color(self, chunk->color, reverse);
				XFillArc(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.ngc, 
					chunk->x + ((LinkTextWidget)self)->linkText.bulletDiameter, chunk->y - ((LinkTextWidget)self)->linkText.bulletDiameter,
					((LinkTextWidget)self)->linkText.bulletDiameter, ((LinkTextWidget)self)->linkText.bulletDiameter, 0, 360*64);
				break;

			case CT_LINEBREAK:
				reverse=((LinkTextWidget)self)->linkText.selected &&
						(chunk->chunknum >= top.chunknum) &&
						(chunk->chunknum <= bottom.chunknum);
				if (reverse) {
					XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectBackground);
					XSetBackground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectForeground);
					}
				else {
					XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->core.background_pixel);
					XSetBackground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.selectBackground);
					}
				XFillRectangle(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.ngc, 
						chunk->x, chunk->y-last_height, 
						10, last_height+last_depth);
				if (chunk->next != NULL)
					last_height = chunk->next->y - chunk->y - f->descent;
				break;

			case CT_TRAVERSER:
				/* printf("Drawing traverser at (%d, %d)\n", chunk->x, chunk->y); */
				XSetForeground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->linkText.linkColor);
				XSetBackground(XtDisplay(self), ((LinkTextWidget)self)->linkText.ngc, ((LinkTextWidget)self)->core.background_pixel);
				XCopyPlane(XtDisplay(self), ((LinkTextWidget)self)->linkText.pageBitmap, XtWindow(self), ((LinkTextWidget)self)->linkText.ngc,
					0, 0, trav_width, trav_height, chunk->x, chunk->y-trav_height, 1);

				/* grey out inoperative buttons */
				if (chunk->pagenum == 0) {
					XFillRectangle(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.graygc, 
						chunk->x+2, chunk->y-trav_height+2, trav_width/2-4, trav_height-4);
					}
				else if (chunk->pagenum == ((LinkTextWidget)self)->linkText.numPages-1)
					XFillRectangle(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.graygc, 
						chunk->x+trav_width/2+2, chunk->y-trav_height+2, 
						trav_width/2-4, trav_height-4);
				break;

			default:
				XtAppWarning(XtWidgetToApplicationContext(self), 
					"expose() - unknown type!");
			}
		
		}
	}
#line 170 "LinkText.w"
#line 175 "LinkText.w"
#line 2620 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2620 "LinkText.w"
int  LinkTextFind(Widget self,char * str,Boolean  fromTop)
#else
#line 2620 "LinkText.w"
int  LinkTextFind(self,str,fromTop)Widget self;char * str;Boolean  fromTop;
#endif
#line 2621 "LinkText.w"
{
	TextChunk *chunk;
	int offset;
	char *cp;
	int pos, textlen;
	char buf[256];
	int begun;

	begun = fromTop ? 1 : 0;
	if (((LinkTextWidget)self)->linkText.head == NULL)
		return -1;
	if (fromTop || (((LinkTextWidget)self)->linkText.lastFindChunk == NULL)) {
		((LinkTextWidget)self)->linkText.lastFindChunk = ((LinkTextWidget)self)->linkText.head;
		offset = 0;
		}
	else
		offset = ((LinkTextWidget)self)->linkText.lastFindPos;

	chunk=((LinkTextWidget)self)->linkText.lastFindChunk;
	textlen = strlen(str);
	ConvertToLowerCase(str);
	while (1) {
		if (IsTextual(chunk)) {
			FetchLowerCase(buf, 256, chunk, textlen);
			cp = strstr(buf + offset, str);
			if (cp != NULL) {
				pos = cp - buf;
				/* check if the matched text begins in the next chunk */
				if (pos < strlen(chunk->text)) 
					break;
				}
			}
		offset=0;
		chunk=chunk->next;
		if (chunk == NULL) {
			chunk = ((LinkTextWidget)self)->linkText.head;
			begun++;
			}

		/* if we're back where we started then the text doesn't exist */
		if (begun > 1)
			return -1;
		}


	/* If we get to here then we found the text */
	TextOffset(self, chunk, pos, textlen, &(((LinkTextWidget)self)->linkText.lastFindChunk), &(((LinkTextWidget)self)->linkText.lastFindPos));
	clear_selection(self);
	((LinkTextWidget)self)->linkText.selectStart.chunk = chunk;
	((LinkTextWidget)self)->linkText.selectStart.chunknum = chunk->chunknum;
	((LinkTextWidget)self)->linkText.selectStart.pos = pos;
	((LinkTextWidget)self)->linkText.selectEnd.chunk = ((LinkTextWidget)self)->linkText.lastFindChunk;
	((LinkTextWidget)self)->linkText.selectEnd.chunknum = ((LinkTextWidget)self)->linkText.lastFindChunk->chunknum;
	((LinkTextWidget)self)->linkText.selectEnd.pos = ((LinkTextWidget)self)->linkText.lastFindPos;
	((LinkTextWidget)self)->linkText.selected = True;

	return chunk->y;
	}
#line 2679 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2679 "LinkText.w"
void  LinkTextRefreshSelection(Widget self)
#else
#line 2679 "LinkText.w"
void  LinkTextRefreshSelection(self)Widget self;
#endif
#line 2680 "LinkText.w"
{
	XExposeEvent ev;
	SelectionMarker top, bottom;

	top=minimum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);
	bottom=maximum_marker(((LinkTextWidget)self)->linkText.selectStart, ((LinkTextWidget)self)->linkText.selectEnd);

		/* construct an exposure bounding box */
		ev.x=0;
		ev.width=((LinkTextWidget)self)->core.width;
		ev.y=top.chunk->y - top.chunk->height-5;
		if (bottom.chunk==NULL)
			ev.height=((LinkTextWidget)self)->core.height - ev.y;
		else
			ev.height=bottom.chunk->y + bottom.chunk->depth - ev.y;
		expose(self, (XEvent*) &ev, NULL);
	}
#line 2701 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2701 "LinkText.w"
char * HypertextToText(Widget self)
#else
#line 2701 "LinkText.w"
char * HypertextToText(self)Widget self;
#endif
#line 2702 "LinkText.w"
{
	get_text(self, True);
	return ((LinkTextWidget)self)->linkText.asciitext->buf;
	}
#line 2711 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2711 "LinkText.w"
void SetBusy(Widget self,Boolean  v)
#else
#line 2711 "LinkText.w"
void SetBusy(self,v)Widget self;Boolean  v;
#endif
#line 2712 "LinkText.w"
{
	((LinkTextWidget)self)->linkText.busy=v;

	if (((LinkTextWidget)self)->linkText.busy)
	    XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.busyCursor);
	else
	    XDefineCursor(XtDisplay(self), XtWindow(self), ((LinkTextWidget)self)->linkText.normalCursor);
	}
#line 2727 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2727 "LinkText.w"
Dimension  GetBaselineskip(Widget self)
#else
#line 2727 "LinkText.w"
Dimension  GetBaselineskip(self)Widget self;
#endif
#line 2728 "LinkText.w"
{
	return (((LinkTextWidget)self)->linkText.font1->ascent + ((LinkTextWidget)self)->linkText.font1->descent);
	}
#line 2735 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2735 "LinkText.w"
void LinkTextFirstPage(Widget self,Boolean  reset_to_top)
#else
#line 2735 "LinkText.w"
void LinkTextFirstPage(self,reset_to_top)Widget self;Boolean  reset_to_top;
#endif
#line 2736 "LinkText.w"
{
	LinkTextSetPage(self, 0, reset_to_top);
	}
#line 2742 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2742 "LinkText.w"
void LinkTextLastPage(Widget self,Boolean  reset_to_top)
#else
#line 2742 "LinkText.w"
void LinkTextLastPage(self,reset_to_top)Widget self;Boolean  reset_to_top;
#endif
#line 2743 "LinkText.w"
{
	LinkTextSetPage(self, ((LinkTextWidget)self)->linkText.numPages-1, reset_to_top);
	}
#line 2749 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2749 "LinkText.w"
void LinkTextNextPage(Widget self,Boolean  reset_to_top)
#else
#line 2749 "LinkText.w"
void LinkTextNextPage(self,reset_to_top)Widget self;Boolean  reset_to_top;
#endif
#line 2750 "LinkText.w"
{
	LinkTextSetPage(self, ((LinkTextWidget)self)->linkText.currentPage + 1, reset_to_top);
	}
#line 2758 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2758 "LinkText.w"
void LinkTextPrevPage(Widget self,Boolean  reset_to_top)
#else
#line 2758 "LinkText.w"
void LinkTextPrevPage(self,reset_to_top)Widget self;Boolean  reset_to_top;
#endif
#line 2759 "LinkText.w"
{
	LinkTextSetPage(self, ((LinkTextWidget)self)->linkText.currentPage - 1, reset_to_top);
	}
#line 2767 "LinkText.w"
/*ARGSUSED*/
#if NeedFunctionPrototypes
#line 2767 "LinkText.w"
void LinkTextSetPage(Widget self,int  p,Boolean  reset_to_top)
#else
#line 2767 "LinkText.w"
void LinkTextSetPage(self,p,reset_to_top)Widget self;int  p;Boolean  reset_to_top;
#endif
#line 2768 "LinkText.w"
{
	Dimension parent_width, parent_height, width;
	static PageRecord pr;

	if ((p<0) || (p>=((LinkTextWidget)self)->linkText.numPages))
		return;
	((LinkTextWidget)self)->linkText.currentPage = p;

	/* resize the widget - but don't make it narrower than the parent */
	width = ((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].width;
	XtVaGetValues(XtParent(self), XtNwidth, &parent_width, 
		XtNheight, &parent_height, NULL);
	if (width < parent_width)
		width=parent_width;
	XtResizeWidget(self, width, ((LinkTextWidget)self)->linkText.pages[((LinkTextWidget)self)->linkText.currentPage].height, 0);
	LinkViewSetCoordinates(XtParent(self), 0, 0);
	if (!reset_to_top) 
		XtCallActionProc(XtParent(self), "pageBottom", NULL, NULL, 0);

	XClearArea(XtDisplay(self), XtWindow(self), 0, -((LinkTextWidget)self)->core.y, ((LinkTextWidget)self)->core.width, parent_height, True);

 	pr.current=((LinkTextWidget)self)->linkText.currentPage;
	pr.total=((LinkTextWidget)self)->linkText.numPages;
	XtCallCallbackList(self, ((LinkTextWidget)self)->linkText.newpage, &pr);
	}
