[comp.windows.x] ScrollOnOverflow in R4?

uejio@LLL-CRG.LLNL.GOV (Jeremy Y. Uejio) (02/02/90)

>> I've been converting my codes to R4 and cannot seem to find a
>> replacement for the ScrollOnOverflow option of the Text widget in
>> R3.  For those who don't know, ScrollOnOverflow automatically
>> scrolls the text up when new text is entered below the bottom
>> line.

> The Text widget will always scroll itself so that the insert point
> is visable, so when adding text you can make sure your new text is
> visable by careful placement of the insert point.

> I am not sure what you are trying to do, but by moving the insert
> point to be either before or after your newly inserted text you should
> be able to get whatever scrolling semantics that you desire.

What I'm trying to do is use the text widget as an interface to other
programs.  I.e. I have a psuedo tty connected to my program and
another UNIX program.  Whatever the user types in the text widget is
passed on to the UNIX program (after a CR) and whatever is output from
the UNIX program is displayed in my text widget.  Well, when a lot of
output from the UNIX program is displayed at the bottom of the text
widget, the widget scrolls very slowly.  In R3, I set the text options
to ScrollOnOverflow and that provided much faster smoother scrolling.

To insert the text into the text widget, I'm using XawtextReplace and
inserting 1K blocks of text.  After each block, I do an
XawtextSetInsertionPoint.  It seems that when I set the insertion
point past the bottom of the text, the text jumps too much instead of
scrolling nicely.

If I decrease the size of the blocks to about 50, then it doesn't
jump, but it pauses between blocks.  It looks like it's trying to
figure out whether or not it should jump scroll. :-)

I'm doing something like this:

		firstpos = XawTextGetInsertionPoint(w);
		length = strlen(msg);
		if (length>4096) {  /* if long msg then move to top first
				       before replacing text */
			n = 0;
			XTSETARG(XtNdisplayPosition,(XtArgVal)firstpos);
			XtSetValues(w,args,n);
		}
		maxlength = length;
		text.ptr = textbuffer;
		while (length>0) {
			newlength = MESSAGESIZE;
			if (newlength>length) newlength = length;
			strncpy(textbuffer,msg+maxlength-length,newlength);
			textbuffer[newlength]=NULL;
			text.length=newlength;
			XawTextReplace(w,firstpos,firstpos,&text);
			length = length - newlength;
			firstpos+=newlength;
		}
		XawTextSetInsertionPoint(w,firstpos);

msg is the output from the UNIX program.  MESSAGESIZE is the variable
that I'm varying.  I tried:

	10 -- output from the program is extremely slow,
	50 -- there is a pause between blocks,
	70 and up -- jump scrolls.

Did I explain my problem in great enough detail?  I can strip down the
code and send it to you, too.

BTW, I have a friend who I think works for Athena.  His name is Jimmy
Chen.  I'm actually an old friend of his wife.  (oh, oh...)  If you
know him, could you have him contact me at uejio@lll-crg.llnl.gov?


			Thanks a lot for you help,
			jeremy

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (03/02/90)

> Did I explain my problem in great enough detail?  I can strip down the
> code and send it to you, too.

Please do, I need to play with this a bit before I come to a decision.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213