[comp.sys.next] Question about Text methods

BSD@PSUVM.BITNET (Scott Dickson) (05/02/89)

I am having trouble using my own filters with a Text object.
I am starting with Lab3 from the developers course as a basis.
What I want to do is to be able to read in data from a file,
put it into a TextView, but be able to filter it as it is
read in.  I want to be able to basically find and filter out
markers from a plain text file.

So, I started into the newText: method of TextView.m in Lab3.
I made the following changes to the code:

-newText: (NXRect *) tF
{
   int fd;
   NXStream *stream;

  /* set up text same as before */

[text setTextFilter: (NXTextFunc) myTextFilter];
  fd = open("Makefile",O_RDONLY,0);
  stream = NXOpenFile(fd,NX_READONLY);

  /* do rest of initialization, including setting character filter */

  [text readText: stream];

  return text;
}

Now, the manual says that the text filter is used for input
from the keyboard, the pasteboard, or a file.  But, it doesn't get
called until I start doing keyboard input.  The textView is created
just fine, complete with text from the file, but the filter is never
called.  All the filter does is echo its input to stdout.  Once the
view is initialized with the text, the text filter is called for each
timer interval, I suppose.  It's not quite each keystroke, since sometimes
I can type fast enough to get two.  That makes me somewhat suspect
about the text filter in general.

So, how can I get text that I am reading in from a file into a
Text object to pass through its textfilter?

--SCott Dickson