[comp.sys.hp] HP TextEdit Bug?

rosenbl@cis.ohio-state.edu (Robert Rosenblum) (07/29/89)

Hi.  I think I've found a bug in the HP TextEdit widget.  It occurs
when I try to modify the text displayed in a leaveVerification
callback.  The program below is supposed to increment a counter
displayed in the text widget every time the cursor leaves the window.
It does this, but it often causes the cursor to lose pixels.  The
bigger problem is that it also tends to insert a NULL character (^@)
into the text when I try to type some new characters, and it gets
confused about where the cursor actually is.

Am I doing something wrong in my code?  Any help that can be given
will be greatly appreciated.

I'm running X11 on and HP 9000/370.


Thanks.


		Rob Rosenblum
		Dept. of Computer and Information Science
		The Ohio State University






#include <stdio.h>
#include <string.h>

#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <Xw/Xw.h>

#include <Xw/TextEdit.h>


Widget top;					  /* toplevel widget */
Widget txtedit;					  /* text edit widget */


int num=1;					  /* number to display in */
						  /* text editor */



txtedit_leave(w, client, data)			  /* callback when leave */
Widget w;
caddr_t client, data;
{
  char outstr[100];


  XwTextUpdate(w, FALSE);			  /* shut off updating */

  num++;					  /* increment number */
  sprintf(outstr, "%d", num);			  /* convert to string */


  XwTextClearBuffer(w);				  /* clear editor */

  XwTextInsert(w, outstr);			  /* put new string in edit */

  XwTextUpdate(w, TRUE);			  /* turn on updating */
}




main(argc, argv)				  /* main routine */
int argc;
char *argv[];
{
  Arg arglist[10];
  Cardinal i=0;

  top = XtInitialize("toplevel", "TOplevel", NULL, NULL, &argc, argv);



  i = 0;
  XtSetArg(arglist[i], XtNstring, (XtArgVal) "1"); i++;

  txtedit = XtCreateManagedWidget("txtedit", XwtexteditWidgetClass,
				 top, arglist, i);

  XtAddCallback(txtedit, XtNleaveVerification, txtedit_leave, NULL);
						  /* add leave callback */

  XtRealizeWidget(top);				  /* start 'er up */
  XtMainLoop();
}