cursor fixes

This commit is contained in:
chombier 2001-05-17 10:16:11 +00:00
parent 3ce0dd2da8
commit ba46aba06a
3 changed files with 142 additions and 112 deletions

View File

@ -179,7 +179,7 @@ void RSselect( short w, Point pt, EventRecord theEvent)
} }
} }
} while (StillDown() && (EqualPt(curr, RSlocal[w].last) || EqualPt(pt, temp))); } while (StillDown() && (EqualPt(curr, RSlocal[w].last) || EqualPt(pt, temp)));
if ( !EqualPt(pt, temp) ) { if ( !EqualPt(pt, temp) || RSlocal[w].selected ) {
// toggle highlight state of text between current and last mouse positions // toggle highlight state of text between current and last mouse positions
RSinvText(w, curr, RSlocal[w].last, &noConst); RSinvText(w, curr, RSlocal[w].last, &noConst);
RSlocal[w].last = curr; RSlocal[w].last = curr;
@ -649,7 +649,7 @@ void RSsendstring
WindRecPtr tw; WindRecPtr tw;
sn = findbyVS(w); sn = findbyVS(w);
if (sn) if ( sn < 0 )
return; return;
tw = &screens[sn]; tw = &screens[sn];
netpush(tw->port); /* BYU 2.4.18 - for Diab systems? */ netpush(tw->port); /* BYU 2.4.18 - for Diab systems? */
@ -689,9 +689,7 @@ short RSnewwindow
WindowPtr behind; WindowPtr behind;
/* create the virtual screen */ /* create the virtual screen */
w = VSnewscreen(vtemulation, scrollback, (scrollback != 0), /* NCSA 2.5 */ w = VSnewscreen(vtemulation, scrollback, (scrollback != 0), lines, width, flags);
lines, width, flags & RSWforcesave, flags & RSWignoreBeeps,
flags & RSWsavelines, flags & RSWjumpscroll, flags & RSWrealBlink);
if (w < 0) { /* problems opening the virtual screen -- tell us about it */ if (w < 0) { /* problems opening the virtual screen -- tell us about it */
return(-1); return(-1);
} }
@ -736,7 +734,7 @@ short RSnewwindow
/* create the window */ /* create the window */
if (!TelInfo->haveColorQuickDraw) { if (!TelInfo->haveColorQuickDraw) {
RScurrent->window = NewWindow(0L, wDims, name, flags & RSWshowit, 8,behind, flags & RSWgoaway, (long)w); RScurrent->window = NewWindow(0L, wDims, name, (flags & RSWshowit) != 0, 8,behind, (flags & RSWgoaway) != 0, (long)w);
RScurrent->pal = NULL; RScurrent->pal = NULL;
if (RScurrent->window == NULL) { if (RScurrent->window == NULL) {
VSdestroy(w); VSdestroy(w);
@ -748,7 +746,7 @@ short RSnewwindow
return(-2); return(-2);
} }
RScurrent->window = NewCWindow(0L, wDims, name, flags & RSWshowit, 8,behind, flags & RSWgoaway, (long)w); RScurrent->window = NewCWindow(0L, wDims, name, (flags & RSWshowit) != 0, 8,behind, (flags & RSWgoaway) != 0, (long)w);
if (RScurrent->window == NULL) { if (RScurrent->window == NULL) {
VSdestroy(w); VSdestroy(w);
return(-2); return(-2);
@ -991,6 +989,7 @@ RgnHandle RSGetTextSelRgn(short w)
} }
RSsetwind(w); RSsetwind(w);
RSsetConst(w);
curr = RSlocal[w].anchor; curr = RSlocal[w].anchor;
last = RSlocal[w].last; last = RSlocal[w].last;
@ -1261,11 +1260,14 @@ void RScprompt(short w)
/* puts up the dialog that lets the user examine and change the color /* puts up the dialog that lets the user examine and change the color
settings for the specified window. */ settings for the specified window. */
{ {
short scratchshort, ditem; short scratchshort, ditem;
Point ColorBoxPoint; Point ColorBoxPoint;
DialogPtr dptr; DialogPtr dptr;
Boolean UserLikesNewColor; Boolean UserLikesNewColor;
RGBColor scratchRGBcolor; RGBColor scratchRGBcolor;
short itemType;
Handle itemHandle;
Rect itemRect;
SetUpMovableModalMenus(); SetUpMovableModalMenus();
dptr = GetNewMySmallDialog(ColorDLOG, NULL, kInFront, (void *)ThirdCenterDialog); dptr = GetNewMySmallDialog(ColorDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
@ -1304,6 +1306,9 @@ void RScprompt(short w)
&BoxColorData[ditem-ColorNF], &scratchRGBcolor); &BoxColorData[ditem-ColorNF], &scratchRGBcolor);
if (UserLikesNewColor) if (UserLikesNewColor)
BoxColorData[ditem-ColorNF] = scratchRGBcolor; BoxColorData[ditem-ColorNF] = scratchRGBcolor;
// force refresh
GetDialogItem(dptr, ditem, &itemType, &itemHandle, &itemRect);
InvalRect(&itemRect);
} }
break; break;
@ -1480,35 +1485,64 @@ static void HandleDoubleClick(short w, short modifiers)
{ {
Point leftLoc, rightLoc, curr, oldcurr; Point leftLoc, rightLoc, curr, oldcurr;
long mySize; long mySize;
char theChar[5]; char theChar;
short mode = -1, newmode, foundEnd=0; short mode = -1, newmode, foundEnd=0;
Point pt; Point pt;
Point temp; Point temp;
VSAttrib attrib; VSAttrib attrib;
short mw;
VSlinePtr ypt;
RSsetConst(w); // get window dims RSsetConst(w); // get window dims
leftLoc = RSlocal[w].anchor; // these two should be the same leftLoc = RSlocal[w].anchor; // these two should be the same
rightLoc = RSlocal[w].last; rightLoc = RSlocal[w].last;
while(!foundEnd) // scan to the right first mw = VSgetcols(w);
{
mySize = VSgettext(w,rightLoc.h, rightLoc.v, rightLoc.h+1, rightLoc.v,
theChar, (long)1, "\015", 0, 0);
if(mySize ==0 || isspace(*theChar)) // stop if not a letter
foundEnd =1;
else rightLoc.h++;
}
foundEnd =0; ypt = VSIGetLineStart(w, rightLoc.v);
while(!foundEnd) // ...and then scan to the left while ( !foundEnd ) {
{ // scan to the right first
mySize = VSgettext(w,leftLoc.h-1, leftLoc.v, leftLoc.h, leftLoc.v, mySize = VSgettext(w, rightLoc.h, rightLoc.v, rightLoc.h+1, rightLoc.v,
theChar, (long)1, "\015", 0, 0); &theChar, (long)1, "\015", 0, 0);
if(mySize ==0 || isspace(*theChar)) // STOP! if ( mySize == 0 || isspace(theChar) ) { // stop if not a letter
foundEnd =1; foundEnd = 1;
else leftLoc.h--; } else if ( ++rightLoc.h > mw - 1 ) {
if ( rightLoc.v == 0 ) {
ypt = VSIGetLineStart(w, rightLoc.v);
}
if ( ypt && VSiswrap(ypt->lattr) ) {
ypt = ypt->next;
rightLoc.h = -1;
++rightLoc.v;
} else {
foundEnd = 1;
}
} }
}
if ( leftLoc.h < 0 )
leftLoc.h = 0;
ypt = VSIGetLineStart(w, leftLoc.v);
foundEnd = 0;
while( !foundEnd ) {
// ...and then scan to the left
mySize = VSgettext(w, leftLoc.h-1, leftLoc.v, leftLoc.h, leftLoc.v,
&theChar, (long)1, "\015", 0, 0);
if ( mySize == 0 || isspace(theChar) ) { // STOP!
foundEnd = 1;
} else if ( --leftLoc.h < 0 ) {
if ( leftLoc.v == -1 ) {
ypt = VSIGetLineStart(w, leftLoc.v);
}
if ( ypt && VSiswrap(ypt->prev->lattr) ) {
ypt = ypt->prev;
leftLoc.h = mw;
--leftLoc.v;
} else {
foundEnd = 1;
}
}
}
if (leftLoc.h != rightLoc.h) { // we selected something if (leftLoc.h != rightLoc.h) { // we selected something
@ -1536,7 +1570,7 @@ static void HandleDoubleClick(short w, short modifiers)
} }
} while (StillDown() && (EqualPt(curr, oldcurr) || EqualPt(pt, temp))); } while (StillDown() && (EqualPt(curr, oldcurr) || EqualPt(pt, temp)));
if ( !EqualPt(pt, temp) ) { if ( !EqualPt(pt, temp) /*|| RSlocal[w].selected*/ ) {
pt = temp; pt = temp;
if ((curr.v < leftLoc.v) || ((curr.v == leftLoc.v) && (curr.h < leftLoc.h))) { if ((curr.v < leftLoc.v) || ((curr.v == leftLoc.v) && (curr.h < leftLoc.h))) {
@ -1639,30 +1673,34 @@ void RSchangefont(short w, short fnum,long fsiz)
WStateData *wstate; WStateData *wstate;
WindowPeek wpeek; WindowPeek wpeek;
short resizeWidth, resizeHeight; /* NCSA: SB */ short resizeWidth, resizeHeight; /* NCSA: SB */
int cursOff;
RSsetwind(w); RSsetwind(w);
cursOff = 0;
if ( VSIcursorenabled() && RScursison(w) ) {
cursOff = 1;
VSIcuroff(w); // temporarily hide cursor
}
srw = RScurrent->rwidth; srw = RScurrent->rwidth;
srh = RScurrent->rheight; srh = RScurrent->rheight;
if (fnum != -1) if (fnum != -1) {
{
RSTextFont(fnum,fsiz,0); /* BYU */ RSTextFont(fnum,fsiz,0); /* BYU */
RScurrent->fnum = fnum; RScurrent->fnum = fnum;
} /* if */ }
if ( !fsiz ) {
fsiz = RScurrent->fsiz;
}
if (fsiz) TextSize(fsiz);
{ RScurrent->fsiz = fsiz;
TextSize(fsiz); /* adjust bold size too */
RScurrent->fsiz = fsiz; RScurrent->bfsiz = fsiz;
/* NONO */
/* adjust bold size too */
RScurrent->bfsiz = fsiz;
/* NONO */
} /* if */
RSfontmetrics(); RSfontmetrics();
width = VSmaxwidth(w) + 1; width = VSmaxwidth(w) + 1;
lines = VSgetlines(w); lines = VSgetlines(w);
@ -1679,9 +1717,8 @@ void RSchangefont(short w, short fnum,long fsiz)
if (RScurrent->rheight > RMAXWINDOWHEIGHT - 16) if (RScurrent->rheight > RMAXWINDOWHEIGHT - 16)
RScurrent->rheight = RMAXWINDOWHEIGHT - 16; RScurrent->rheight = RMAXWINDOWHEIGHT - 16;
RScheckmaxwind(&RScurrent->window->portRect,RScurrent->rwidth +16, /* NCSA: SB */ RScheckmaxwind(&RScurrent->window->portRect,RScurrent->rwidth +16,
RScurrent->rheight + 16, &resizeWidth, &resizeHeight); /* NCSA: SB */ RScurrent->rheight + 16, &resizeWidth, &resizeHeight);
SizeWindow SizeWindow
( (
@ -1707,8 +1744,14 @@ void RSchangefont(short w, short fnum,long fsiz)
VSsetrgn(w, x1, y1, VSsetrgn(w, x1, y1,
(short) (x1 + (RScurrent->rwidth ) / RScurrent->fwidth - 1), (short) (x1 + (RScurrent->rwidth ) / RScurrent->fwidth - 1),
(short) (y1 + (RScurrent->rheight) / RScurrent->fheight - 1)); (short) (y1 + (RScurrent->rheight) / RScurrent->fheight - 1));
VSgetrgn(w, &x1, &y1, &x2, &y2); /* Get new region */ VSgetrgn(w, &x1, &y1, &x2, &y2); // Get new region
if ( cursOff ) {
VSIcurson(w, VSIw->x, VSIw->y, 0); /* restore cursor at original position */
} else {
// just calcutate the new coordinates
VScursset(w, VSIw->x, VSIw->y);
}
/* /*
DrawGrowIcon(RScurrent->window); DrawGrowIcon(RScurrent->window);
RSdrawlocker(w, RScurrent->window->visRgn); RSdrawlocker(w, RScurrent->window->visRgn);
@ -1718,7 +1761,8 @@ void RSchangefont(short w, short fnum,long fsiz)
*/ */
InvalRect(&RScurrent->window->portRect); InvalRect(&RScurrent->window->portRect);
} /* RSchangefont */ } /* RSchangefont */
void RSchangebold void RSchangebold
( (
@ -1741,6 +1785,7 @@ void RSchangebold
InvalRect(&RScurrent->window->portRect); InvalRect(&RScurrent->window->portRect);
} }
short RSgetfont short RSgetfont
( (
short w, /* which window */ short w, /* which window */

View File

@ -198,8 +198,8 @@ short RSsetwind
{ {
if ((w < 0) || (w > MaxRS)) if ((w < 0) || (w > MaxRS))
return(-3); return(-3);
if (RSw != w) /* if last window used is different */ if (RSw != w) {
{ /* last window used is different */
if (RSlocal[w].window == 0L) if (RSlocal[w].window == 0L)
return(-4); return(-4);
RScurrent = RSlocal + w; RScurrent = RSlocal + w;
@ -208,10 +208,10 @@ short RSsetwind
RSla = 0; RSla = 0;
SetPort(RScurrent->window); SetPort(RScurrent->window);
return(1); return(1);
} }
SetPort(RScurrent->window); SetPort(RScurrent->window);
return(0); return(0);
} /* RSsetwind */ } /* RSsetwind */
/* /*
* RScursoff * RScursoff
@ -221,8 +221,7 @@ short RSsetwind
void RSbell( short w ) void RSbell( short w )
{ {
/* #@%! bell ! I'm not deaf, It's my autokey buffer... */
/* NONO : #@%! bell ! I'm not deaf, It's my autokey buffer... */
static unsigned long sLastBellTicks = 0; static unsigned long sLastBellTicks = 0;
static short sConsecutiveBeeps = 0; static short sConsecutiveBeeps = 0;
if ((LMGetTicks() - sLastBellTicks) < 15) { if ((LMGetTicks() - sLastBellTicks) < 15) {
@ -233,18 +232,15 @@ void RSbell( short w )
sLastBellTicks = LMGetTicks(); sLastBellTicks = LMGetTicks();
if ( sConsecutiveBeeps >= 5 ) if ( sConsecutiveBeeps >= 5 )
return; return;
/* NONO */
RSsetwind(w); RSsetwind(w);
if (FrontWindow() != RScurrent->window) if (FrontWindow() != RScurrent->window) {
{
/* beep and temporarily invert the window contents, so /* beep and temporarily invert the window contents, so
the user sees which window is beeping */ the user sees which window is beeping */
InvertRect(&RScurrent->window->portRect); InvertRect(&RScurrent->window->portRect);
SysBeep(8); SysBeep(8);
InvertRect(&RScurrent->window->portRect); InvertRect(&RScurrent->window->portRect);
} } else
else
/* window is frontmost--just beep */ /* window is frontmost--just beep */
SysBeep(8); SysBeep(8);
NotifyUser(); NotifyUser();
@ -283,21 +279,17 @@ void RScursoff( short w )
} /* RScursoff */ } /* RScursoff */
void RScursset( short w, short la, short x, short y )
/* /*
* RScurson * RScursset
* *
* displays the text cursor for the specified window, at the * displays the text cursor for the specified window, at the
* specifified position. Assumes it isn't currently being off. * specifified position. Assumes it isn't currently being off.
*/ */
void RScurson( short w, short la, short x, short y )
{ {
short xw; short xw;
VSAttrib attrib; VSAttrib attrib;
if ( RSlocal[w].skip || RSlocal[w].cursorstate )
return;
RSsetwind(w); RSsetwind(w);
xw = RScurrent->fwidth; xw = RScurrent->fwidth;
@ -357,6 +349,16 @@ void RScurson( short w, short la, short x, short y )
RScurrent->cursor.bottom = RScurrent->cursor.top + RScurrent->fheight; RScurrent->cursor.bottom = RScurrent->cursor.top + RScurrent->fheight;
break; break;
} }
}
void RScurson( short w, short la, short x, short y )
{
if ( RSlocal[w].skip || RSlocal[w].cursorstate )
return;
RScursset( w, la, x, y );
if ( VSIcursorvisible() ) { if ( VSIcursorvisible() ) {
if ( !gApplicationPrefs->BlinkCursor ) { if ( !gApplicationPrefs->BlinkCursor ) {
InvertRect(&RScurrent->cursor); InvertRect(&RScurrent->cursor);
@ -386,12 +388,13 @@ void RSsetattr(short la, VSAttrib a)
RSa = a; RSa = a;
size = (VSisdecdwh(la)) ? RScurrent->fsiz * 2 : RScurrent->fsiz; size = (VSisdecdwh(la)) ? RScurrent->fsiz * 2 : RScurrent->fsiz;
if ( VSisgrph(a) ) { if ( VSisgrph(a) ) {
TextFont( gNCSAFontID ); TextFont( gNCSAFontID );
TextSize( size );
} else { } else {
RSTextFont( RScurrent->fnum, size, VSisbold(a) && RScurrent->allowBold ); RSTextFont( RScurrent->fnum, size, VSisbold(a) && RScurrent->allowBold );
} }
TextSize(size);
face = VSisundl(a) ? underline : 0; face = VSisundl(a) ? underline : 0;
if ( VSisbold(a) && RScurrent->allowBold && RScurrent->realbold ) { if ( VSisbold(a) && RScurrent->allowBold && RScurrent->realbold ) {
@ -469,24 +472,15 @@ void RSsetattr(short la, VSAttrib a)
} }
} /* RSTextFont */ } /* RSTextFont */
void RSTextFont(short myfnum, short myfsiz, short myface) /* BYU */ void RSTextFont(short myfnum, short myfsiz, short myface)
{ /* BYU */ {
short tempFontID; // RAB BetterTelnet 1.0fc4 if ((myface & bold)) {
TextFont(RScurrent->bfnum);
// RAB BetterTelnet 1.0fc4: For one thing, we use font *names* now. Also, we use NCSA VT Bold } else {
// when the user wants, not when it's Monaco 9. TextFont(myfnum);
}
if (// (myfnum == monaco) && /* BYU - If Monaco, size 9, and bold, then */ TextSize(myfsiz);
// (myfsiz == 9) && /* BYU */ }
(myface & bold)) { /* BYU */
// GetFNum("\p%NCSA VT Bold", &tempFontID);
// TextFont(tempFontID); /* BYU - use NCSA's Monaco. (75) */
TextFont(RScurrent->bfnum); // RAB BetterTelnet 1.0fc9
} else { /* BYU */
TextFont(myfnum); /* BYU */
} /* BYU */
} /* BYU */
#ifdef NO_UNIVERSAL #ifdef NO_UNIVERSAL
@ -665,10 +659,6 @@ void RSdraw
if (rect.left <= 0) if (rect.left <= 0)
rect.left = 0; rect.left = 0;
if (rect.right >= RScurrent->width)
rect.right = RScurrent->width;
if (rect.bottom >= RScurrent->height)
rect.bottom = RScurrent->height;
if (VSisdecdhlt(la)) { if (VSisdecdhlt(la)) {
// Upper part // Upper part
@ -799,7 +789,6 @@ void RSdelchars
return; return;
RSsetwind(w); RSsetwind(w);
// RSsetattr(VSIw->lattrib, VSIw->attrib & ~kVSblnk);
RSsetattr(0, 0); RSsetattr(0, 0);
xw = RScurrent->fwidth; xw = RScurrent->fwidth;
@ -872,7 +861,6 @@ void RSdellines
RSsetwind(w); RSsetwind(w);
RSsetConst(w); RSsetConst(w);
// RSsetattr(VSIw->lattrib, VSIw->attrib & ~kVSblnk);
RSsetattr(0, 0); RSsetattr(0, 0);
if (scrolled) if (scrolled)
@ -935,7 +923,7 @@ void RSerase
if (rect.left <= 0) /* little buffer strip on left */ if (rect.left <= 0) /* little buffer strip on left */
rect.left = CHO; rect.left = CHO;
if (rect.right >= RScurrent->width - 1) if (rect.right >= RScurrent->width - 1)
rect.right = RScurrent->rwidth - 1; /* clear to edge of window, including edge strip */ rect.right = RScurrent->rwidth - 1;
if (rect.bottom >= RScurrent->height - 1) if (rect.bottom >= RScurrent->height - 1)
rect.bottom = RScurrent->rheight + 1; /* clear to bottom edge also */ rect.bottom = RScurrent->rheight + 1; /* clear to bottom edge also */
EraseRect(&rect); EraseRect(&rect);
@ -965,7 +953,6 @@ void RSinslines
RSsetwind(w); RSsetwind(w);
RSsetConst(w); RSsetConst(w);
// RSsetattr(VSIw->lattrib, VSIw->attrib & ~kVSblnk);
RSsetattr(0, 0); RSsetattr(0, 0);
if (RScurrent->selected && (scrolled < 0)) if (RScurrent->selected && (scrolled < 0))
@ -1058,7 +1045,7 @@ void RSinsstring
rect, rect,
x * xw, x * xw,
ys, ys,
RScurrent->width, RScurrent->rwidth - 1,
(y + 1) * RScurrent->fheight (y + 1) * RScurrent->fheight
); );
@ -1278,9 +1265,6 @@ void RSsetsize( short w, short v, short h, short screenIndex)
/* saves the new size settings for a window, and repositions /* saves the new size settings for a window, and repositions
the scroll bars accordingly. */ the scroll bars accordingly. */
{ {
if ( VSIcursorvisible() )
RScursoff( w );
RSlocal[w].height = ((v - 16 + CVO) / FHeight) * FHeight; RSlocal[w].height = ((v - 16 + CVO) / FHeight) * FHeight;
RSlocal[w].width = ((h - 16 + CHO) / FWidth) * FWidth; RSlocal[w].width = ((h - 16 + CHO) / FWidth) * FWidth;
RSlocal[w].rheight = v - 16; RSlocal[w].rheight = v - 16;
@ -1303,7 +1287,7 @@ void RSsetsize( short w, short v, short h, short screenIndex)
SizeControl(RSlocal[w].scroll, 16, (v - 13)); SizeControl(RSlocal[w].scroll, 16, (v - 13));
MoveControl(RSlocal[w].scroll, (h - 15) + CHO, -1 + CVO); MoveControl(RSlocal[w].scroll, (h - 15) + CHO, -1 + CVO);
ShowControl(RSlocal[w].scroll); ShowControl(RSlocal[w].scroll);
} }
if ( RSlocal[w].left != NULL ) { if ( RSlocal[w].left != NULL ) {
short i; short i;
if (screenIndex < 0) if (screenIndex < 0)

View File

@ -8,6 +8,7 @@ void RSsetConst(short w);
short RSsetwind(short w); short RSsetwind(short w);
void RSbell(short w); void RSbell(short w);
Boolean RScursison( short w ); Boolean RScursison( short w );
void RScursset( short w, short la, short x, short y );
void RScursoff(short w); void RScursoff(short w);
void RScurson(short w, short la, short x, short y); void RScurson(short w, short la, short x, short y);
void RSsetattr(short la, VSAttrib a); void RSsetattr(short la, VSAttrib a);