[comp.windows.x.motif] Best way to handle large text

argv@Eng.Sun.COM (Dan Heller) (08/16/90)

I am trying to find the best way to load a file or read arbitrary
text into a text widget.  The problem: performance and resource
consumption.

Consider a routine that displays text to the user using the
text widget.  The routine may be called repeatedly in order to
add new text to the widget.  The problem is if the amount of
data sent to the routine is large enough, it doesn't perform
well enough to just "add" the text at the end all the time.
So, what I did was take all the text that comes in and save
it in a file.  when the text stops (function is called with a
flag indicating there is no more data to print), the function
then allocates N bytes (the size of the file), reads the file
in one read() call into the buffer, and then sets the text's
XmNvalue to that string.  The string is then freed.

When data gets to be around 400 lines, this process begins to
take way too long.  Using the append-text method described
earlier takes about 10 times longer.  There is no resource
available for setting the "source" for a text widget to be
a file.  If I had my druthers, I would provide two new resources:

    XmNfile		text widget reflects the contents of file
    XmNfileContents	The contents of the file is used, but the
			file is no longer accessed once read.

It would also be interesting to provide a "batch" type function
that implies the following: "I am going to make a bunch of changes
to this widget through repeated calls to XtVaSetValues(), convenience
routines or otherwise.  Don't update anything visually until I turn
batching off."  This feature would be useful for many widgets, not
just Text widgets.

Anyway, are there any changes in 1.1 that will facilitate this
type of problem?  Are there any recommendations for better 
performance or suggestions for alternate methods?

--dan