[comp.windows.x] AsciiDiskWidget

jbentley@pcs.cnc.EDU.cnc.EDU (jon bentley) (10/01/90)

Howdy!

We are trying to compile XMTOOL, (With -DXAW_BC) but it says that
AsciiDiskWidget is undefined, and bombs.

The Athena documentation states that the AsciiText widget replaces it.

What is the declaration syntax for using the AsciiText widget?

Can anyone help me?


Please we need this ASAP.


Thanks in advance.

		jbentley

converse@EXPO.LCS.MIT.EDU (10/03/90)

> We are trying to compile XMTOOL, (With -DXAW_BC) but it says that
> AsciiDiskWidget is undefined, and bombs.
> 
> The Athena documentation states that the AsciiText widget replaces it.
> 
> What is the declaration syntax for using the AsciiText widget?


The declaration is the same as for any other Athena widget; you need to include
the public header file for that widget, and you need to know the widget
class name in order to create a widget.   This information, and the names
and definitions of widget resources, are given in the Athena widget set manual,
and there are examples in the source tree under the directory mit/examples/Xaw.  

#include <X11/Xaw/AsciiText.h>

Widget text;
text = XtCreateManagedWidget("text", asciiTextWidgetClass, parent, args, n);

gram@uctcs.uucp (Graham Wheeler) (10/04/90)

The AsciiText widget is fairly easy to use. Obviously you should
include AsciiText.h. If you want to cheat and access private data
(like I needed to do), you will want to use:

#define ASCII_DISK
#define ASCII_STRING
#include <X11/IntrinsicP.h>
#include <X11/Xaw/XawInit.h>
#include <X11/Xaw/AsciiSrcP.h>

Note that the reason I needed to do this is that the XawAsciiSourceChanged
routine returns the value of a flag which is cleared ONLY in calls to
XawAsciiSave (contrary to what the manual says).

The code I use to access this flag myself is:

void XawClearAsciiSrcChangedFlag(w)
Widget w;
{
	((AsciiSrcObject)w)->ascii_src.changes = False;
}

but I digress....

To invoke a function manually (for example, the Search popup), you can
use:

void PopupSearch()
{
	char *tmp="forward";
	XtCallActionProc(AsciiTxtW, "search", NULL, &tmp, 1);
}

and similarly for other action functions.

To load up a new file, whose name is in the string 'fname', use:

Arg arg;
XtSetArg(arg,"string",fname);
XtSetValues(AsciiTxtW, &arg, 1);

You may want to call the flag clearing routine I gave earlier as well.

If you want to read the source, you can use:

XawTextBlock TxtBlk;
char *TxtBlk;
int pos, Xtpos, avail;

int NextChar()
{
	if (avail==0)
		{
		pos = 0;
		avail = XawTextSourceRead(AsciiTxtW, XtPos, &TxtBlk, 80) - XtPos;
		TxtBuf = TxtBlk.ptr;
		XtPos += avail;
	}
	if (avail==0) return '\0'; /* End of file */
	else	{
		avail--;
		return TxtBuf[pos++];
	}
}

Finally, before you create the widget, you may want to set some of the
following arguments (this is by no means an exhaustive list):

"string"	The name of the file
"type"		XawAsciiFile for disk files
"editType"	if you want to be able to edit the text
"scrollHorizontal"
"scrollVertical" if you want scroll bars

Hope this information is of assistance.

Graham Wheeler		      |	"Don't bother me,
Data Network Architectures Lab|		I'm reading a `Crisis'!"
Dept. of Computer Science     | Internet: <gram.uctcs@f4.n494.z5.fidonet.org>
University of Cape Town       |     BANG: <...uunet!ddsw1!olsa99!uctcs!gram>