- width - (term->core.parent->core.border_width * 2);
- width - (SHELL_OF(term)->core.border_width * 2);
static void TekRealize (    Widget gw,    XtValueMask *valuemaskp,    XSetWindowAttributes *values){    TekWidget tw = (TekWidget) gw;    register TScreen *screen = &term->screen;    register int i;    register TekLink *tek;    register double d;    register int border = 2 * screen->border;    int pr;    XGCValues gcv;    int winX, winY, width, height;    XSizeHints sizehints;    char Tdefault[32];#ifndef NO_ACTIVE_ICON    term->screen.whichTwin = &term->screen.fullTwin;#endif /* NO_ACTIVE_ICON */    tw->core.border_pixel = term->core.border_pixel;    for (i = 0; i < TEKNUMFONTS; i++) {	if (!tw->tek.Tfont[i]) 	  tw->tek.Tfont[i] = XQueryFont (screen->display, DefaultGCID);	tw->tek.tobaseline[i] = tw->tek.Tfont[i]->ascent;    }    if((Tbuffer = (Char *)malloc(BUF_SIZE)) == NULL ||       (Tpushb = (Char *)malloc(10)) == NULL ||       (Tline = (XSegment *)malloc(MAX_VTX * sizeof(XSegment))) == NULL) {	fprintf (stderr, "%s: Not enough core for Tek mode\n", xterm_name);	if(Tpushb) free((char *)Tpushb);	if(Tbuffer) free((char *)Tbuffer);	Tfailed = TRUE;	return;    }    screen->xorplane = 1;    screen->Tbackground = term->core.background_pixel;    screen->Tforeground = screen->foreground;    screen->Tcursorcolor = screen->cursorcolor;    if (term->misc.T_geometry == NULL) {	int defwidth, defheight;	if (term->misc.tekSmall) {	    defwidth = TEKMINWIDTH;	    defheight = TEKMINHEIGHT;	} else {	    defwidth = TEKDEFWIDTH;	    defheight = TEKDEFHEIGHT;	}	sprintf (Tdefault, "=%dx%d", defwidth + border, defheight + border);	term->misc.T_geometry = Tdefault;    }    winX = 1;    winY = 1;    width = TEKDEFWIDTH + border;    height = TEKDEFHEIGHT + border;    pr = XParseGeometry(term->misc.T_geometry, &winX, &winY, (unsigned int *)&width, (unsigned int *)&height);    if ((pr & XValue) && (pr & XNegative))      winX += DisplayWidth(screen->display, DefaultScreen(screen->display))                        - width - (term->core.parent->core.border_width * 2);    if ((pr & YValue) && (pr & YNegative))      winY += DisplayHeight(screen->display, DefaultScreen(screen->display))	- height - (term->core.parent->core.border_width * 2);      /* set up size hints */    sizehints.min_width = TEKMINWIDTH + border;    sizehints.min_height = TEKMINHEIGHT + border;    sizehints.width_inc = 1;    sizehints.height_inc = 1;    sizehints.flags = PMinSize|PResizeInc;    sizehints.x = winX;    sizehints.y = winY;    if ((XValue&pr) || (YValue&pr)) {	sizehints.flags |= USSize|USPosition;	sizehints.flags |= PWinGravity;	switch (pr & (XNegative | YNegative)) {	  case 0:	    sizehints.win_gravity = NorthWestGravity;	    break;	  case XNegative:	    sizehints.win_gravity = NorthEastGravity;	    break;	  case YNegative:	    sizehints.win_gravity = SouthWestGravity;	    break;	  default:	    sizehints.win_gravity = SouthEastGravity;	    break;	}    } else {	sizehints.flags |= PSize;    }    sizehints.width = width;    sizehints.height = height;    if ((WidthValue&pr) || (HeightValue&pr))      sizehints.flags |= USSize;    else sizehints.flags |= PSize;    (void) XtMakeResizeRequest ((Widget) tw, width, height,				&tw->core.width, &tw->core.height);    /* XXX This is bogus.  We are parsing geometries too late.  This     * is information that the shell widget ought to have before we get     * realized, so that it can do the right thing.     */    if (sizehints.flags & USPosition)      XMoveWindow (XtDisplay(tw), tw->core.parent->core.window,		   sizehints.x, sizehints.y);    XSetWMNormalHints (XtDisplay(tw), tw->core.parent->core.window,		       &sizehints);    XFlush (XtDisplay(tw));	/* get it out to window manager */    values->win_gravity = NorthWestGravity;    values->background_pixel = screen->Tbackground;    tw->core.window = TWindow(screen) = 	XCreateWindow (screen->display,		       tw->core.parent->core.window,		       tw->core.x, tw->core.y,		       tw->core.width, tw->core.height, tw->core.border_width,		       (int) tw->core.depth,		       InputOutput, CopyFromParent,		       ((*valuemaskp)|CWBackPixel|CWWinGravity),		       values);    TFullWidth(screen) = width;    TFullHeight(screen) = height;    TWidth(screen) = width - border;    THeight(screen) = height - border;    TekScale(screen) = (double)TWidth(screen) / TEKWIDTH;    if((d = (double)THeight(screen) / (TEKHEIGHT + TEKTOPPAD +				       TEKBOTTOMPAD)) < TekScale(screen))      TekScale(screen) = d;        screen->cur.fontsize = TEK_FONT_LARGE;    if (tw->tek.initial_font) {	char *s = tw->tek.initial_font;	if (XmuCompareISOLatin1 (s, "large") == 0)	  screen->cur.fontsize = TEK_FONT_LARGE;	else if (XmuCompareISOLatin1 (s, "2") == 0 || 		 XmuCompareISOLatin1 (s, "two") == 0)	  screen->cur.fontsize = TEK_FONT_2;	else if (XmuCompareISOLatin1 (s, "3") == 0 || 		 XmuCompareISOLatin1 (s, "three") == 0)	  screen->cur.fontsize = TEK_FONT_3;	else if (XmuCompareISOLatin1 (s, "small") == 0)	  screen->cur.fontsize = TEK_FONT_SMALL;    }    if(XmuCompareISOLatin1(tw->tek.gin_terminator_str, GIN_TERM_NONE_STR) == 0)	screen->gin_terminator = GIN_TERM_NONE;    else if(XmuCompareISOLatin1(tw->tek.gin_terminator_str, GIN_TERM_CR_STR) == 0)	screen->gin_terminator = GIN_TERM_CR;    else if(XmuCompareISOLatin1(tw->tek.gin_terminator_str, GIN_TERM_EOT_STR) == 0)	screen->gin_terminator = GIN_TERM_EOT;    else	fprintf(stderr, "%s: illegal GIN terminator setting \"%s\"\n",		xterm_name, tw->tek.gin_terminator_str);    gcv.graphics_exposures = TRUE;	/* default */    gcv.font = tw->tek.Tfont[screen->cur.fontsize]->fid;    gcv.foreground = screen->Tforeground;    gcv.background = screen->Tbackground;        /* if font wasn't successfully opened, then gcv.font will contain       the Default GC's ID, meaning that we must use the server default font.      */    TEKgcFontMask = (gcv.font == DefaultGCID) ? 0 : GCFont;    screen->TnormalGC = XCreateGC (screen->display, TWindow(screen), 				   (TEKgcFontMask|GCGraphicsExposures|				    GCForeground|GCBackground), &gcv);    gcv.function = GXinvert;    gcv.plane_mask = screen->xorplane = (screen->Tbackground ^					 screen->Tcursorcolor);    gcv.join_style = JoinMiter;	/* default */    gcv.line_width = 1;    screen->TcursorGC = XCreateGC (screen->display, TWindow(screen), 				   (GCFunction|GCPlaneMask), &gcv);    gcv.foreground = screen->Tforeground;    gcv.line_style = LineOnOffDash;    gcv.line_width = 0;    for(i = 0 ; i < TEKNUMLINES ; i++) {	screen->linepat[i] = XCreateGC (screen->display, TWindow(screen),					(GCForeground|GCLineStyle), &gcv); 	XSetDashes (screen->display, screen->linepat[i], 0,		    (char *) dashes[i], dash_length[i]);    }    TekBackground(screen);    screen->margin = MARGIN1;		/* Margin 1		*/    screen->TekGIN = FALSE;			/* GIN off		*/    XDefineCursor(screen->display, TShellWindow, screen->pointer_cursor);    {	/* there's gotta be a better way... */	static Arg args[] = {	    {XtNtitle, (XtArgVal)NULL},	    {XtNiconName, (XtArgVal)NULL},	};	char *icon_name, *title, *tek_icon_name, *tek_title;	args[0].value = (XtArgVal)&icon_name;	args[1].value = (XtArgVal)&title;	XtGetValues (tw->core.parent, args, 2);	tek_icon_name = XtMalloc(strlen(icon_name)+7);	strcpy(tek_icon_name, icon_name);	strcat(tek_icon_name, "(Tek)");	tek_title = XtMalloc(strlen(title)+7);	strcpy(tek_title, title);	strcat(tek_title, "(Tek)");	args[0].value = (XtArgVal)tek_icon_name;	args[1].value = (XtArgVal)tek_title;	XtSetValues (tw->core.parent, args, 2);	XtFree( tek_icon_name );	XtFree( tek_title );    }    tek = TekRecord = &Tek0;    tek->next = (TekLink *)0;    tek->fontsize = screen->cur.fontsize;    tek->count = 0;    tek->ptr = tek->data;    Tpushback = Tpushb;    Tbptr = Tbuffer;    screen->cur_X = 0;    screen->cur_Y = TEKHOME;    line_pt = Tline;    Ttoggled = TRUE;    screen->page = screen->cur;    return;}