cleanup. fixed crash

This commit is contained in:
chombier 2001-05-17 10:16:57 +00:00
parent 72f42f1086
commit 84a61847f8
1 changed files with 41 additions and 20 deletions
macssh/source/tek

View File

@ -50,6 +50,8 @@ static RGLINK RG[TEK_DEVICE_MAX] = {
extern WindRec *screens; extern WindRec *screens;
Boolean gTekCopying = FALSE;
static fontnum(short vw, short n); static fontnum(short vw, short n);
static storexy(short vw, short x, short y); static storexy(short vw, short x, short y);
static joinup(short hi, short lo, short e); static joinup(short hi, short lo, short e);
@ -385,16 +387,14 @@ static short VGcheck(short dnum)
short VGnewwin short VGnewwin
( (
short device, /* number of RG device to use */ short device, /* number of RG device to use */
short theVS short theVS,
short tek4105,
short tekclear
) )
{ {
short vw = 0; short vw = 0;
short theScrn; short theScrn;
theScrn = findbyVS(theVS);
if (theScrn < 0)
return(-1);
while ((vw < MAXVG) && (VGwin[vw] != nil)) vw++; while ((vw < MAXVG) && (VGwin[vw] != nil)) vw++;
if (vw == MAXVG) if (vw == MAXVG)
return(-1); return(-1);
@ -415,7 +415,8 @@ short VGnewwin
VGwin[vw]->RGdevice = device; VGwin[vw]->RGdevice = device;
VGwin[vw]->RGnum = (*RG[device].newwin)(); VGwin[vw]->RGnum = (*RG[device].newwin)();
VGwin[vw]->TEKtype = screens[theScrn].tektype; // 0 = 4014, 1 = 4105 VGwin[vw]->TEKtype = (tek4105 != 0); // 0 = 4014, 1 = 4105
VGwin[vw]->tekclear = tekclear;
if (VGwin[vw]->RGnum < 0) if (VGwin[vw]->RGnum < 0)
{ {
@ -458,6 +459,25 @@ void VGclose(short vw)
VGwin[vw] = nil; VGwin[vw] = nil;
} }
/* return this window's tek emulation type */
short VGgettektype(short vw)
{
if (VGcheck(vw)) {
return -1;
}
return VGwin[vw]->TEKtype;
}
/* return this window's tek clear flag */
short VGgettekclear(short vw)
{
if (VGcheck(vw)) {
return -1;
}
return VGwin[vw]->tekclear;
}
/* Detach window from its current device and attach it to the /* Detach window from its current device and attach it to the
* specified device. Returns negative number if unable to do so. * specified device. Returns negative number if unable to do so.
* Sample application: switching an image from #9 to Hercules. * Sample application: switching an image from #9 to Hercules.
@ -529,7 +549,6 @@ void VGdumpstore(short vw, short (*func )(short))
*/ */
void VGdraw(short vw, char c) /* the latest input char */ void VGdraw(short vw, char c) /* the latest input char */
{ {
short sn;
char cmd; char cmd;
char value; char value;
char goagain; /* true means go thru the function a second time */ char goagain; /* true means go thru the function a second time */
@ -537,6 +556,7 @@ void VGdraw(short vw, char c) /* the latest input char */
RgnHandle PanelRgn; RgnHandle PanelRgn;
struct VGWINTYPE *vp; struct VGWINTYPE *vp;
pointlist temppoint; pointlist temppoint;
GrafPtr savePort;
if (VGcheck(vw)) { if (VGcheck(vw)) {
return; return;
@ -544,10 +564,6 @@ void VGdraw(short vw, char c) /* the latest input char */
vp = VGwin[vw]; /* BYU */ vp = VGwin[vw]; /* BYU */
sn = findbyVS(vp->theVS);
if (sn < 0)
return;
temp[0] = c; temp[0] = c;
temp[1] = (char) 0; temp[1] = (char) 0;
@ -824,7 +840,7 @@ void VGdraw(short vw, char c) /* the latest input char */
state[vw] = DONE; state[vw] = DONE;
break; break;
case 12: /* form feed = clrscr */ case 12: /* form feed = clrscr */
if (sn >= 0 && screens[sn].tekclear) { if (vp->tekclear) {
VGpage(vw); VGpage(vw);
VGclrstor(vw); VGclrstor(vw);
} }
@ -983,6 +999,7 @@ void VGdraw(short vw, char c) /* the latest input char */
{ {
if (vp->TEKPanel) if (vp->TEKPanel)
{ {
if ((vp->current->x != vp->savx) || if ((vp->current->x != vp->savx) ||
(vp->current->y != vp->savy)) (vp->current->y != vp->savy))
{ {
@ -1020,6 +1037,7 @@ void VGdraw(short vw, char c) /* the latest input char */
vp->TEKPanel = (pointlist) NULL; vp->TEKPanel = (pointlist) NULL;
vp->curx = vp->savx; vp->curx = vp->savx;
vp->cury = vp->savy; vp->cury = vp->savy;
} }
} }
state[vw] = DONE; state[vw] = DONE;
@ -1268,15 +1286,18 @@ void VGdraw(short vw, char c) /* the latest input char */
state[vw] = CMD0; state[vw] = CMD0;
break; break;
default: default:
if (vp->mode == ALPHA) if (vp->mode == ALPHA) {
{
state[vw] = DONE; state[vw] = DONE;
if (! vp->TEKtype) if (! vp->TEKtype) {
drawc(vw,(short) c); drawc(vw,(short) c);
else } else {
{ // not while copying a picture !!!
VSwrite(vp->theVS,&c,1); if (!gTekCopying) {
TEKunstore(VGstore[vw]); GetPort(&savePort);
VSwrite(vp->theVS, &c, 1);
SetPort(savePort);
TEKunstore(VGstore[vw]);
}
} }
return; return;
} }
@ -1431,7 +1452,7 @@ void VGredraw(short vw, short dest)
if (VGcheck(vw)) { if (VGcheck(vw)) {
return; return;
} }
topTEKstore(VGstore[vw]); topTEKstore(VGstore[vw]);
while ((data = nextTEKitem(VGstore[vw])) != -1) VGdraw(dest,data); while ((data = nextTEKitem(VGstore[vw])) != -1) VGdraw(dest,data);