Path: 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: Date: 13 Dec 90 16:47:22 GMT References: Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 33 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