[comp.windows.x] Need help with XtTextReplace and other stuff

rgcote@mit-vax.LCS.MIT.EDU (Rob Cote) (09/10/88)

I am fairly new to X11 hacking and am running into a few problems with
things not working the way I expected. I have included my use of 
XtTextReplace below, along with the rest of the code for init'ing 
the text widget. Can someone tell me what I am doing wrong?

I know it is asking a lot, but would someone out there be willing
to correspond with me via email on an occassional basis to answer
questions? I don't want to take up news bandwidth with novice
questions. Please send email if you would be willing to help.

The following code was intended to be a status line in a program. I
would like to use a text widget to print out messages when I need
to tell the user that something is happening. What am I doing wrong?

					-Rob

		---------------------------------------------


#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Form.h>
#include <X11/AsciiText.h>
#include "widgets.h"
#include "extern.h"

typedef struct {
    int  firstPos;
    int  length;
    char *ptr;
    Atom format;
    } XtTextBlock, *XtTextBlockPtr;

#define STATUSLEN 150
char status_text[STATUSLEN];
static XtTextBlock textblock;

/*****************************************************************************/

SetupStatusLine()

{
  argn = 0;
  XtSetArg(arg[argn], XtNfromVert, QueryWindowText); ++argn;
  XtSetArg(arg[argn], XtNvertDistance, 5); ++argn;
  XtSetArg(arg[argn], XtNwidth, 500); ++argn;
  XtSetArg(arg[argn], XtNeditType, XttextRead); ++argn;
  XtSetArg(arg[argn], XtNstring, status_text); ++argn;
  XtSetArg(arg[argn], XtNlength, STATUSLEN); ++argn;
  StatusWindow = XtCreateManagedWidget("StatusWindow", asciiStringWidgetClass,
				       XWalterForm, arg, argn);
  XtSetMappedWhenManaged(StatusWindow, FALSE);
}

/*****************************************************************************/

UpdateStatusLine(newmsg)

     char *newmsg;

{
  textblock.firstPos = 0;
  textblock.length = strlen(newmsg);
  textblock.ptr = newmsg;

  XtTextReplace(StatusWindow, 0, STATUSLEN, &textblock);
  XtMapWidget(StatusWindow); /* I have tried this code with and without
				this explicit map. */
}

-- 
and none of this of course will stand when I stand before the man on that great
day of the great divide when all the kings and queens will have their closets
emptied and the bones them bones them dry bones will not fail dead men will 
tell tales and you can laugh I can laugh we can laugh but its not funny -the 77s