west@turing.toronto.edu (Tom West) (06/29/90)
Perhaps a few people knowing about TextEdit could help here. I have a few questions about the lineStarts and nLines fields. (1) When you first initialize a TextEdit field? what are the values of these three fields? I assume nLines is zero and lineStarts is completely uninitialized. (2) If I then enter an X into TE through TEKey, what are the values of the two fields? I assume lineStarts[0] = 0. What would nLines and lineStarts[1] would be? (3) I then enter a \r, so the record contains X\r. Now I get lost. Is nLines 1 or 2? lineStarts[0] = 0. Does lineStarts[1] = 1 or 2? Are all other values of lineStarts uninitialized? (4) If I then enter a Y, so the record contains X\rY, what is the value of nLines? lineStarts[0] = 0. What is lineStarts[1]? Is lineStarts[2] defined? In another unrelated question. I have found out that TextEdit displays actual CRs at the end of each line when it is displaying a record. I wish to use a character set where very character is printable. Is there any way to have TE do the proper line ends, without actually putting a CR on the screen? (I would display Chr(13)'s using another routine that wouldn't use TE when the user wanted that character printed) Thanks for all the help. If you wish to e-mail rather than post, I can be reached at either: tomwest@gpu.utcs.utoronto.ca or west@turing.toronto.edu
minow@mountn.dec.com (Martin Minow) (06/29/90)
In article <1990Jun28.174941.3176@jarvis.csri.toronto.edu> west@turing.toronto.edu (Tom West) writes: > > Perhaps a few people knowing about TextEdit could help here. I have a few >questions about the lineStarts and nLines fields. The best way to figure this out is to write a small program and use the ThinkC debugger to watch the TERec as you single-step through the program. These answers are from memory and probably incorrect. (1) I believe nLines is zero and lineStarts is empty when the TERecord is first initialized. Also teLength, selStart and selEnd are zeroed. (2) After entering one character, nLines is one and lineStarts[1] is one -- it's one past the index of the last character. (3) After entering \r, we all get lost. I *think* the first line is "X\r" so lineStarts[1] = 2 and nLines is still one: better look at the TERec: the case where there's a \r at the end of the TERec is what we professional programmers call a real mess. (4) After entering V (X\rV), nLines would be two, lineStarts[1] -> 'V', lineStarts[2] is the index to the character after 'V' (== teLength) When you poke around in the TERec, watch the interaction of the cursor and the presence/abscence of a \r at the end of a record. If you want to see code that more-or-less duplicates TextEdit, look at my articles in the Feb/March MacTutor (Note: it is *NOT* Apple code.) >In another unrelated question. I have found out that TextEdit displays >actual CRs at the end of each line when it is displaying a record. I wish >to use a character set where very character is printable. Is there any way >to have TE do the proper line ends, without actually putting a CR on the >screen? (I would display Chr(13)'s using another routine that wouldn't >use TE when the user wanted that character printed) I think you're out of luck, unless you decide to attack the display "bottleneck" functions. I think you'd be better off writing something that suits your specific needs, though. Martin Minow minow@bolt.enet.dec.com
tph@cs.utexas.edu (Pow-Hwee Tan) (07/03/90)
I have a few questions about TextEdit: 1. TERec has two hooks for the programmer to put in his/her own text highlight routine. I suppose the same routine will be called to unhighlight text as well. Am I correct? 2. How do I get TextEdit to overwrite the character at the cursor position when I call TEKey, instead of inserting before the character? My current solution is to use TESetSelect to select the character at the cursor (actually the character in front of the cursor) so that when I call TEKey the character is replaced. This produce the undesired effect of highlighting the character, which I circumvent by putting in a highlight routine that does nothing in TERec. This seems clumsy, is there a better way to do it? Actually, I am writing a terminal emulation program; will I be better off not using TextEdit? Are there alternative TextEdit-type packages that will help solve my problem? Many thanks in advance. --p.h. tan, UT Austin CS Dept, tph@cs.utexas.edu