Article View: comp.soft-sys.andrew
Article #1289Re: problems with textview_FindLineNumber...
From: Tom Neuendorffer
Date: Thu, 13 Dec 1990 16:47
Date: Thu, 13 Dec 1990 16:47
33 lines
1813 bytes
1813 bytes
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
Technical Details
Message-ID:
<QbNv2Oe00Vt1Q8ilgz@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!ANDREW.CMU.EDU!tpn+References:
<wbNpeyA_8000Q9cmVV@libby>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!ANDREW.CMU.EDU!tpn+ From: tpn+@ANDREW.CMU.EDU (Tom Neuendorffer) Newsgroups: comp.soft-sys.andrew Subject: Re: problems with textview_FindLineNumber... Message-ID: <QbNv2Oe00Vt1Q8ilgz@andrew.cmu.edu> Date: 13 Dec 90 16:47:22 GMT References: <wbNpeyA_8000Q9cmVV@libby> Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 33