home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / windows / x / 16591 < prev    next >
Encoding:
Text File  |  1992-09-12  |  2.8 KB  |  78 lines

  1. Newsgroups: comp.windows.x
  2. Path: sparky!uunet!spool.mu.edu!darwin.sura.net!wupost!ukma!netnews.louisville.edu!starbase.spd.louisville.edu!rmbult01
  3. From: rmbult01@starbase.spd.louisville.edu (Robert M. Bultman)
  4. Subject: Re: Reading text from Athena (Xaw) asciiTextWidgets ?
  5. Sender: news@netnews.louisville.edu (Netnews)
  6. Message-ID: <rmbult01.716307823@starbase.spd.louisville.edu>
  7. Date: Sat, 12 Sep 1992 14:23:43 GMT
  8. Distribution: usa
  9. References: <9SEP199213355388@portal.lasc.lockheed.com>
  10. Nntp-Posting-Host: starbase.spd.louisville.edu
  11. Organization: University of Louisville
  12. Keywords: Athena widgets
  13. Lines: 63
  14.  
  15. In <9SEP199213355388@portal.lasc.lockheed.com> le01156@portal.lasc.lockheed.com (Jeff Sheffel @ x2016) writes:
  16.  
  17. >I have unsuccessfully tried to read (retrieve) the user
  18. >modified text from an Athena asciiTextWidget.  I looked
  19. >at other example programs (xless and xdbx) to see how it
  20. >was done.  Here is a section of (pseudo) code:
  21.  
  22. >Widget    textSrcWidget, asciiTextWidget1;
  23. >XawTextBlock    buffer;
  24. >char    *userInput;
  25.  
  26. >    textSrcWidget = XawTextGetSource( asciiTextWidget1 );
  27. >    XawTextSourceRead( textSrcWidget, start, &buffer, length );
  28. >    xtrncpy( userInput, buffer.ptr, buffer.length );
  29.  
  30. >When I tried this, buffer.ptr = '\0' and buffer.length
  31. >was zero.  The standard X documentation is weak in the area
  32. >Athena widget usage and particularly in the explanation of
  33. >"text sources and sinks" which appear to be used in the
  34. >above example.
  35.  
  36. >How is text read from the Athena asciiTextWidget?
  37.  
  38. >Jeff Sheffel        le01156@portal.lasc.lockheed.com
  39.  
  40. I did the following.  (I am not sure if this is "legal", so use with
  41. caution.)  This is for "small" strings, not files.
  42.  
  43. char theString[THESTRINGLENGTH];
  44. Widget theTextWidget;
  45.  
  46. XtVaCreateManagedWidget(
  47.     ...
  48.     XtNstring, theString,
  49.     XtNlength, THESTRINGLENGTH,
  50.     XtNusrStringInPlace, True,
  51.     ...
  52.     );
  53.  
  54. Then just access the string as any other string.  According to the
  55. O'Reilly reference, XtNlength is the length of the buffer, not the
  56. string itself.  The useStringInPlace resource tells the source to
  57. edit the string in place rather than in chunks.  Note that you should
  58. only use this method to read the string, and probably only after some
  59. event (like closing a popup or something where the the widget
  60. appeared).  If you want to set the string to something, use
  61. XtVaSetValues.
  62.  
  63. (I made a similar inquiry earlier, and got 1 or two replies.  I do
  64. not consider myself to be a crack X programmer, and would appreciate
  65. someone who is really in the know to verify what I have done.  It 
  66. seems to work, and I am using it now.  Thanks.)
  67.  
  68. I hope this helps.  If you have further questions, e-mail me.
  69.  
  70.  
  71. -rob
  72.  
  73. -- 
  74. Robert M. Bultman                              |
  75. Speed Scientific School                        |
  76. University of Louisville                       |
  77. Internet: rmbult01@starbase.spd.louisville.edu |
  78.