mai@qt.ipa.fhg.de (Christoph Mai) (12/13/90)
I got the following problem:
After having inserted a certain amount of characters in a textobject I
want to know from the
corresponding textview how many additional lines had to be brought up
therefore. Here's
in short what I'm doing:
tView is the textview and t the associated textobject, buf is a
char-pointer to the inserted string,
insertPos the insert position and length the strlen(buf):
{
...
oldlines = textview_FindLineNumber(tView,insertPos);
text_AlwaysInsertCharacters(t,insertPos,buf,length);
newlines = textview_FindLineNumber(tView,insertPos+length);
numberOfNewLines = (newlines - oldlines);
...
}
But this doesn't work as textview_FindLineNumber returns (as for my
part!) strange values.
Has anybody got an idea how to get along or perhaps can tell me what
this method really returns?
Thanks in advance,
Christoph
____________________________________________________________
Christoph Mai (chm@qt.IPA.FhG.de)
Fraunhofer-Institut f. Produktionstechnik u. Automatisierung
Eierstrasse 46,D-7000 Stuttgart 1
tpn+@ANDREW.CMU.EDU (Tom Neuendorffer) (12/14/90)
Excerpts from mail: 13-Dec-90 problems with textview_Find.. Christoph Mai@qt.IPA.FhG (1030+0) > After having inserted a certain amount of characters in a textobject I > want to know from the > corresponding textview how many additional lines had to be brought up > therefore. Here's > in short what I'm doing: > ... > oldlines = textview_FindLineNumber(tView,insertPos); > text_AlwaysInsertCharacters(t,insertPos,buf,length); > newlines = textview_FindLineNumber(tView,insertPos+length); > ... > But this doesn't work as textview_FindLineNumber returns (as for my > part!) strange values. textview_FindLineNumber is a mainly internal routine that, given a text position, will return -1 if that text is not currently displayed on the screen, or a number indicating which line of text on the screen contains the character at that position. Assuming this is what you are looking for, the problem with the above code is that textview hasn't had time to update itself before you ask where the new line number is. You need something more like oldlines = textview_FindLineNumber(tView,insertPos); text_AlwaysInsertCharacters(t,insertPos,buf,length); text_NotifyObservers(t,0); im_ForceUpdate(); if((newlines = textview_FindLineNumber(tView,insertPos+length)) == -1){ /* text has scrolled off the screen */ } Tom