home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x
- Path: sparky!uunet!spool.mu.edu!darwin.sura.net!wupost!ukma!netnews.louisville.edu!starbase.spd.louisville.edu!rmbult01
- From: rmbult01@starbase.spd.louisville.edu (Robert M. Bultman)
- Subject: Re: Reading text from Athena (Xaw) asciiTextWidgets ?
- Sender: news@netnews.louisville.edu (Netnews)
- Message-ID: <rmbult01.716307823@starbase.spd.louisville.edu>
- Date: Sat, 12 Sep 1992 14:23:43 GMT
- Distribution: usa
- References: <9SEP199213355388@portal.lasc.lockheed.com>
- Nntp-Posting-Host: starbase.spd.louisville.edu
- Organization: University of Louisville
- Keywords: Athena widgets
- Lines: 63
-
- In <9SEP199213355388@portal.lasc.lockheed.com> le01156@portal.lasc.lockheed.com (Jeff Sheffel @ x2016) writes:
-
- >I have unsuccessfully tried to read (retrieve) the user
- >modified text from an Athena asciiTextWidget. I looked
- >at other example programs (xless and xdbx) to see how it
- >was done. Here is a section of (pseudo) code:
-
- >Widget textSrcWidget, asciiTextWidget1;
- >XawTextBlock buffer;
- >char *userInput;
-
- > textSrcWidget = XawTextGetSource( asciiTextWidget1 );
- > XawTextSourceRead( textSrcWidget, start, &buffer, length );
- > xtrncpy( userInput, buffer.ptr, buffer.length );
-
- >When I tried this, buffer.ptr = '\0' and buffer.length
- >was zero. The standard X documentation is weak in the area
- >Athena widget usage and particularly in the explanation of
- >"text sources and sinks" which appear to be used in the
- >above example.
-
- >How is text read from the Athena asciiTextWidget?
-
- >Jeff Sheffel le01156@portal.lasc.lockheed.com
-
- I did the following. (I am not sure if this is "legal", so use with
- caution.) This is for "small" strings, not files.
-
- char theString[THESTRINGLENGTH];
- Widget theTextWidget;
-
- XtVaCreateManagedWidget(
- ...
- XtNstring, theString,
- XtNlength, THESTRINGLENGTH,
- XtNusrStringInPlace, True,
- ...
- );
-
- Then just access the string as any other string. According to the
- O'Reilly reference, XtNlength is the length of the buffer, not the
- string itself. The useStringInPlace resource tells the source to
- edit the string in place rather than in chunks. Note that you should
- only use this method to read the string, and probably only after some
- event (like closing a popup or something where the the widget
- appeared). If you want to set the string to something, use
- XtVaSetValues.
-
- (I made a similar inquiry earlier, and got 1 or two replies. I do
- not consider myself to be a crack X programmer, and would appreciate
- someone who is really in the know to verify what I have done. It
- seems to work, and I am using it now. Thanks.)
-
- I hope this helps. If you have further questions, e-mail me.
-
-
- -rob
-
- --
- Robert M. Bultman |
- Speed Scientific School |
- University of Louisville |
- Internet: rmbult01@starbase.spd.louisville.edu |
-