Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Archive » net.micro.mac » Bug in TESetSelect (first text operation only)
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Bug in TESetSelect (first text operation only) [message #112509] Mon, 16 September 2013 13:46 Go to next message
ee163ahe is currently offline  ee163ahe
Messages: 10
Registered: September 2013
Karma: 0
Junior Member
Message-ID: <168@sdcc13.UUCP>
Date: Mon, 4-Mar-85 21:24:18 EST
Article-I.D.: sdcc13.168
Posted: Mon Mar  4 21:24:18 1985
Date-Received: Sun, 10-Mar-85 07:28:28 EST
Organization: U.C. San Diego, Academic Computer Center
Lines: 23




	There is an interesting bug in TESetSelect.  If it is called before
	TEClick is ever called, the selection region is set to the proper
	value, but the caret appears at the end of the previous line if
	it was intended to appear at the beginning of a line.  Of course
	this causes strange things to happen when something is inserted
	(an in TEKey).  There is an interesting kludge which I added to
	solve this problem: (using MegaMax C)

		if	((*hte)->clickstuff == 0)
			(*hte)->clickstuff = -1;
		tesetselect	(start, end, hte);
	
	I discovered this is because clickstuff always has a value of
	-1, -255, -256, 255, and 256, but 0 before any text operations
	have been performed.  I arbitrarily chose to assign the value
	of -1, since this is the most common.  Question:  can this
	have any harmful side effects?  Also, what does this field
	mean, anyway?

			Victor Romano
Re: Bug in TESetSelect (first text operation only) [message #112513 is a reply to message #112509] Mon, 16 September 2013 13:46 Go to previous message
lsr is currently offline  lsr
Messages: 55
Registered: June 2013
Karma: 0
Member
Message-ID: <30097@apple.UUCP>
Date: Fri, 8-Mar-85 22:14:46 EST
Article-I.D.: apple.30097
Posted: Fri Mar  8 22:14:46 1985
Date-Received: Mon, 11-Mar-85 04:49:16 EST
References: 
Reply-To: lsr@apple.UUCP (Larry Rosenstein)
Organization: Macintosh Division, Apple Computer
Lines: 50
Summary: 

In article  ee163ahe@sdcc13.UUCP (VICTOR ROMANO) writes:
 > 
 > 
 > 
 > 	There is an interesting bug in TESetSelect.  If it is called before
 > 	TEClick is ever called, the selection region is set to the proper
 > 	value, but the caret appears at the end of the previous line if
 > 	it was intended to appear at the beginning of a line.

TextEdit represents its selections by the character positions; if the start
and end character positions are the same then you have an insertion point.
If the character after the insertion point is at the start of the line, it
is ambiguous whether the caret should be displayed at the start of the line
or the END of the PREVIOUS line.  (Either is plausible in certain
situations.)

That is where the clikStuff comes in.  The INTEGER is really used as 2
booleans; the first could be called TELeftClick and the second TELeftCaret.

TEClick uses a utility routine to determine what character the mouse was
clicked on.  That utility returns a character position, but the mouse could
have been to the left or right of the center of the character, and it makes
a difference as to where the insertion point goes.  So the utility sets
TELeftClick to indicate if the click was on the left side of the character.
TEClick copies TELeftClick into TELeftCaret.

When it comes time to draw the caret we have the ambiguity mentioned above
if the insertion point is before a character at the start of a line.
The value of TELeftCaret resolves the ambiguity.

I wouldn't call this a bug, only a lack of documentation.  The same problem
can arise even after TEClick was called once, if the last click was on the
right side of a character.  Also, the fix that was given before forces the
caret to be at the start of the line, rather than the end of the previous
line, which might not be what you want.

The moral of the story is that before you use TESetSelect to set an
insertion point, and you suspect that the insertion point will be at the
start of a line/end of a line, then you should set the clikStuff field to
-1 if you want the caret at the start of the line and 0 if you want it at
the end of the previous line.

(Unlike what was implied in the original message, there should be no
problem with other TE routines if you choose one or the other.)

-- 
Larry Rosenstein

UUCP:  {nsc, dual, voder, ios}!apple!lsr
CSNET: lsr@Apple.CSNET
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: (*hte)->clickloop or HTE^^.ClickLoop
Next Topic: multiple postings
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Mar 28 19:13:37 EDT 2024

Total time taken to generate the page: 0.03964 seconds