[comp.windows.x] Xaw text widget -- any improvements?

scott@ontek.UUCP (Scott Dickson) (03/01/89)

I'm attempting to build a front-end for a cutsom database using
X11R3. The text widget in Xaw works fine for one-line responses, 
but is too slow to use for anything longer (xedit suffers from
this problem). I'm working on a Sun 4/110, running sys 4.0.1.

Does anyone have an alternative text widget/utility that could
used? Anyone have a good idea toward optimizing the existing
widget?

gringort@decwrl.dec.com (Joel Gringorten) (03/04/89)

In article <286@ontek.UUCP> scott@ontek.UUCP (Scott Dickson) writes:
>I'm attempting to build a front-end for a cutsom database using
>X11R3. The text widget in Xaw works fine for one-line responses, 
>but is too slow to use for anything longer 

What is too slow?  Display of the text or are you complaining about
character response time?

I've never been bothered by the speed of the Xaw Text widget itself
for display of text.

I cannot detect a degradation in performance do to the size of the 
text window. However, the one place where you can run into trouble 
is using it to edit a large buffer.  The AsciiText widget uses the 
StringSource text source for the character buffer, which is just a 
big array of characters.  To insert a character into the buffer, all
the subsequent characters are slid over to make room.  In other words,
entering text at the beginning of a large file is a big lose.

>(xedit suffers from
>this problem). I'm working on a Sun 4/110, running sys 4.0.1.
>

Actually, xedit doesn't suffer from the large buffer problem described
above.  This is because xedit supplies its own text source to the 
text widget.  This custom source is know as the PieceSource because
it maintains a list of pieces of text.  When a character is inserted
at some arbitrary place in the buffer, a new piece is created and
entered on the list.  Subsequent characters are added to that current
piece until either a delete is hit or the location of the insertion
point is moved by the user.  Therefore, the performance of the PieceSource
doesn't vary with buffer size.  Unfortunately, its performance does
degrade with the number of edits.  This degradation can be felt two
ways.  Assuming that the piece source is highly fragmented (lots of
pieces): 

	1) if the text window is positioned over the fragmented area
	of text, the refresh rate of that area will be slower.

	2) if the user moves the insertion point and begins to type,
	a delay might be felt as the piece source locates the correct
	place to enter the new piece.  

However in practice, neither of the these two effects seems particularly
noticable to me.

I'd encourage you to experiment more with xedit and text widgets. 
If you find that xedit is acceptable in handling large files, you
can use the PieceSource from it in your own Text application.  
(Oh, it supports multiple level undo/redo as well.)  Conversely, you
might be inspired to generate your own text source that's a real 
speed demon :)
-- 
                          -joel