jkh@meepmeep.UUCP (Jordan K. Hubbard) (03/04/89)
I've got an application that simply wants to display some text in an asciiStringWidget, scrolling if necessary. First, I was surprised that there didn't seem to be any way to just append something to an asciiTextWidget and have it do the buffer management (unless I've missed something), but that didn't seem to be any great hardship since I could just do it myself. What's really getting me, however, is the fact that *every* time I modify the asciiTextWidget's buffer, everything is redrawn. Here's what I'm doing: /* * Append string "src" to "view". view->output is the asciiTextWidget, * view->maxlen is the size of the buffer. */ void appendTextToView(view, src, srclen) View *view; char *src; int srclen; { int len; /* * How much text is in the buffer? We assume that the insertion point * will always be at the end (it should be). */ i = 0; XtSetArg(args[i], XtNinsertPosition, (XtArgVal)&len); i++; XtGetValues(view->output, args, i); /* * Do we need to make room? Try to free up whole lines, if possible. */ if (len + srclen > view->maxlen) { int rolloff = (len + srclen) - view->maxlen; for (i = 0; i < len; i++) { if (view->buffer[i] == '\n' && i >= rolloff) rolloff = i + 1; } len -= rolloff; memcpy(view->buffer, view->buffer + rolloff, len); } memcpy(view->buffer + len, src, srclen); XtTextSetLastPos(view->output, len + srclen); XtTextSetInsertionPoint(view->output, len + srclen + 1); } Now I did some reading about this stuff and came across the XtTextInvalidate() call, which I tried to use. About the best I could get out of it was an instant core dump (and I've tried all sorts of ranges of "from" and "to", all of which were in the range of 1 and "len"). Is there any other way of dealing with this? It seems the proper mechanism would be to disable redisplay, add (or adjust) the text, invalidate what's been added/rolled, and call XtTextDisplay(), but I just can't get it to work. The arguments to XtTextInvalidate() are integer indices into the buffer, right? What am I doing wrong? Why does merely adding one character to the buffer cause everything (visible) in the widget to get redrawn? help, Mr. Wizard.... Jordan pyramid!pcsbst!jkh (awaiting bounces...)