gram@uctcs.uucp (Graham Wheeler) (09/25/90)
I have (yet another) problem with X. I am trying to write a simple program
to behave as a file browser/editor. I was very pleased when I read that the
AsciiText widget (Athena) supports editing. Unfortunately the only docs I
have are the MIT distribution docs, which are really references for those
who already know how to do these things. I also no longer have the source
code for the Athena widget examples.
My program is appended below. The aim is to display/edit the file specified
on the command line, or open a file "Noname.est" if none is specified. If
I run with no arguments, I get a "File or directory not found" error. Fair
enough. If I specify a file name of an existing file (with or without quotes)
I just get the file name displayed followed by a number of ^@'s. I cannot
edit this display. Although the search widget pops up when I hit Ctrl-S, I
cannot get the AsciiWidget to recognise the META key (which I presume is
ESC or Ctrl-X). Note that there are two problems described here: displaying
the file *contents*, and using META key sequences. I am running X11R4 on
a SPARCstation 1+. Any ideas, anyone? Please E-mail.
The program is:
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/AsciiText.h>
main(argc,argv)
int argc;
char *argv[];
{
Widget toplevel, EdWinWidget;
Arg wargs[10];
int n=0; /* arg count */
/* Initialise intrinsics and create top-level shell widget */
toplevel = XtInitialize(argv[0],"Xpew", NULL, 0, &argc, argv);
/* Specify the file to be displayed */
XtSetArg(wargs[n], "type", "XawAsciiFile"); n++;
if (argc==2) XtSetArg(wargs[n], "string", argv[1]);
else XtSetArg(wargs[n], "string", "Noname.est");
n++;
/* Create the widget */
EdWinWidget = XtCreateManagedWidget("Editor",asciiTextWidgetClass, toplevel, wargs, n);
/* Realise the widgets, and enter event loop */
XtRealizeWidget(toplevel);
XtMainLoop();
}
Graham Wheeler |
Dept. of Computer Science | Internet: <gram.uctcs@f4.n494.z5.fidonet.org>
University of Cape Town | BANG: <...uunet!ddsw1!olsa99!uctcs!gram>
gram@uctcs.uucp (Graham Wheeler) (09/26/90)
With reference to my previous posting, I have solved the problems I was having with the file browser/editor. Firstly, XawAsciiFile was in quotes, which was what prevented the program from loading up a file from the command line. Also the default edit mode for a text widget is read-only; the editType resource must be set to XawtextEdit for the Meta key edit sequences to be enabled. Oh, well, live and learn... Hopefully I still have lots of both of these ahead! Graham Wheeler | Dept. of Computer Science | Internet: <gram.uctcs@f4.n494.z5.fidonet.org> University of Cape Town | BANG: <...uunet!ddsw1!olsa99!uctcs!gram>
purtill@morley.rutgers.edu (Mark Purtill) (01/28/91)
Suppose I have an AsciiText (athena) Widget (passed to me by WCL, although that shouldn't make any difference, right?). I know its a file-type widget -- how to I get at the filename? The obvious tries like: XtSetArg( args[0], "string", buf) ; XtGetValues( text, args, 1) ; (where text is the widget, etc). return "" for the filename, which I know is wrong. Any help, or suggestions as to where to look for help would be appreciated (the Xaw documentation was not helpful). ^.-.^ Mark Purtill purtill@dimacs.rutgers.edu (908)932-4580 (O) ((")) DIMACS, P.O. Box 1179, Rutgers U., Piscataway, NJ 08855 (908)220-6905 (H) ********** Note new area code! We are now (908) rather than (201)! **********