home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume3 / xprompt / part01 / README < prev    next >
Encoding:
Text File  |  1989-03-10  |  2.4 KB  |  77 lines

  1.  
  2. Xprompt provides a means by which programs can ask the user
  3. for one or more responses.  I have found it especially useful for
  4. reducing the size of my twm menus.
  5. Instead of hardwiring alternatives into a menu, a single script is used
  6. to call xprompt and then invoke the appropriate thing.
  7.  
  8. For example, I have a twm menu item:
  9.  
  10.     "RLOGIN"    !"xprompt.rlogin &"
  11.  
  12. that invokes a shell script called xprompt.rlogin:
  13.  
  14. #! /bin/sh
  15.  
  16. defaulthost=${HOME}/.xprompt.rlogin
  17. reply=
  18.  
  19. if [ -r $defaulthost ]
  20. then
  21.     reply=`cat $defaulthost`
  22. fi
  23.  
  24. reply=`xprompt -p "Hostname" -r "$reply"`
  25. if [ $? = 1 ]
  26. then
  27.     exit 0
  28. fi
  29. echo "$reply" > $defaulthost
  30.  
  31. xhost "$reply" > /dev/null 2>&1
  32. xterm -T "rlogin $reply" -e rlogin "$reply" &
  33.  
  34. exit 0
  35.  
  36. Xprompt relies on the user to set its geometry to something reasonable.
  37. I set the following resources in my .xresources:
  38.     XPrompt*cursor: left_ptr
  39.     XPrompt*Geometry: 800x30+300+2
  40.     XPrompt*Rlen: 70
  41.     XPrompt*borderWidth: 2
  42.     XPrompt*Grab: off
  43.     XPrompt*Warp: on
  44.     XPrompt*returnExit: on
  45.     XPrompt*textTranslations: #override \n\
  46.                          Ctrl<Key>W:  erase-word() \n\
  47.                          <Btn1Up>: select-start() \n\
  48.                          <Btn2Up>: insert-selection(PRIMARY,CUT_BUFFER0) \n\
  49.                          <Btn3Up>: next-prompt-or-finish()
  50.  
  51. This is my first X program and there's a good chance I've made a few major
  52. X faux pas.  Suggestions on how to clean it up will be gratefully received.
  53. There are a few minor problems, perhaps my fault, perhaps the fault
  54. of the text widget.  Horizontal scrolling, for example, doesn't seem
  55. to work correctly.  Still, I've found the program useful and perhaps others
  56. will as well.
  57.  
  58. The program has been tested with the server running on a monochrome Sun 3/50
  59. (SunOS 4.0) and has been compiled with gcc 1.32 and greater.
  60. The program has executed on all manner of Sun 3 and a Sun 4/260.
  61. It has been written for X11R3.  I can't vouch for the Imakefile.  The
  62. enclosed Makefile was not made by imake.
  63.  
  64. I have a man page for trcomp() should anyone think it's a useful library
  65. function.  Ask and I'll mail it.
  66.  
  67. Please report bugs, enhancements, suggestions, etc. to me rather than
  68. posting to the net.
  69.  
  70. -----
  71. Barry Brachman           | UUCP:    {alberta,uw-beaver,uunet}!
  72. Dept. of Computer Science|           ubc-vision!ubc-csgrads!brachman
  73. Univ. of British Columbia| Internet: brachman@cs.ubc.ca
  74. Vancouver, B.C. V6T 1W5  |           brachman%ubc.csnet@csnet-relay.arpa
  75. (604) 228-4327           | brachman@ubc.csnet
  76.  
  77.