gregr@tekig4.TEK.COM (Greg Rogers) (03/29/88)
Can any Mac wizard shed some light on a programming problem I'm having? My edit record (TERec) seems to completely loose track of the number of lines of text as I'm adding characters to the text. In other words TERec.nLines jumps ahead by hundreds of lines as I add characters using TEInsert. The number of lines that nLines jumps by doesn't seem to follow any pattern. Line after line of text is inserted properly and then out of the blue, nLines jumps. This seems to occur after a carriage return ($0D) is inserted, but only infrequently. I also follow TEInsert with TEScroll after each ($0D) is inserted but this seems unrelated. Calling TECalText fixes the edit record with nLines returning to normal, and all characters intact. Is there some bug related to carriage returns and TEInsert or TEScroll in these toolbox routines? I would really appreciate any information as I can't find any explaination for this behavior. Thanks, Greg Rogers
willc@tekchips.TEK.COM (Will Clinger) (03/31/88)
In article <2653@tekig4.TEK.COM> gregr@tekig4.UUCP (Greg Rogers) writes: > >Can any Mac wizard shed some light on a programming problem I'm having? My >edit record (TERec) seems to completely loose track of the number of lines of >text as I'm adding characters to the text.... I'll bet you're using a Macintosh SE. On an SE, the lineStarts array will be calculated incorrectly (or sometimes the system will crash) when all of the following conditions hold: _TEInsert is called; the inserted text ends in a space; selEnd = teLength; after the text has been inserted, the (garbage) byte following the newly inserted text in RAM happens to contain a carriage return. Neither the Macintosh Plus nor the Macintosh II have this bug. The bug lies in the routine whose address is stored at $07fc. The ninth through eleventh instructions in that routine are: cmpi.b #$0d,0(a0,d0.w) bne.s ... addq.w #1,d0 If you change the add instruction to a no-op, your bug will disappear. (You may have created a different bug because this undoubtedly disables a minor feature of TextEdit, but the new bug seems much less serious than the old.) I hope this helps. The bug was reported to Apple on 10 February 1988. Peace, William Clinger Semantic Microsystems, Inc.