home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2583 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  57.4 KB

  1. Path: sparky!uunet!stanford.edu!morrow.stanford.edu!sep!steve
  2. From: steve@sep.Stanford.EDU (Steve Cole)
  3. Newsgroups: alt.sources
  4. Subject: xtpanel 2.0 - interactive program builder - part 07/10
  5. Followup-To: alt.sources.d
  6. Date: 21 Nov 1992 00:33:28 GMT
  7. Organization: Stanford Exploration Project
  8. Lines: 1623
  9. Distribution: world
  10. Message-ID: <1ek04oINN194@morrow.stanford.edu>
  11. NNTP-Posting-Host: taal.stanford.edu
  12.  
  13.  
  14. Submitted-by: steve@sep.Stanford.EDU
  15. Archive-name: xtpanel/part07
  16.  
  17. #!/bin/sh
  18. # This is part 07 of a multipart archive
  19. # ============= xtpanel/xtpanel.man.sed ==============
  20. if test ! -d 'xtpanel'; then
  21.     echo 'x - creating directory xtpanel'
  22.     mkdir 'xtpanel'
  23. fi
  24. if test -f 'xtpanel/xtpanel.man.sed' -a X"$1" != X"-c"; then
  25.     echo 'x - skipping xtpanel/xtpanel.man.sed (File already exists)'
  26. else
  27. echo 'x - extracting xtpanel/xtpanel.man.sed (Text)'
  28. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/xtpanel.man.sed' &&
  29. .TH XTPANEL l "19 November 1992"
  30. .SH NAME
  31. xtpanel \- build an interactive program, from the command line
  32. or using a simple scripting language
  33. .SH SYNOPSIS
  34. \fBxtpanel\fP [-help] [-tty] [-cpp] [cpp_args] [-file script_file] 
  35. [-message] [-text] [-dialog] [-button] [-toggle] [-slider] [-scrollbar] 
  36. [-choice] [-list] [-menubutton] [-graph] [-var] [-quit] < script_file
  37. X
  38. .SH DESCRIPTION
  39. X
  40. \fIxtpanel\fP provides a quick and easy way of producing a panel
  41. containing interactive objects such as buttons, sliders, and text
  42. fields, either from the command line or from an xtpanel script file.
  43. Each panel object maintains a string representation of its value. When
  44. the object is modified it updates its value and it can also perform one
  45. or more actions such as printing its value or calling a system command. 
  46. Objects can make use of the values of other objects in constructing their
  47. actions and they can set the values of other objects as the result of
  48. an action. The result is an interactive X windows program, without the
  49. need for conventional programming.
  50. X
  51. .PP
  52. X
  53. Three utilities are provided with xtpanel. The first is a script
  54. generator. This is a collection af xtpanel scripts that can be used to
  55. generate, examine and test xtpanel script files. It is invoked using
  56. the command \fIxtpanel-generator\fP.  The second utility is a
  57. collection of example scripts and a master script that can be use to
  58. view and run the examples. It is invoked using the command
  59. \fIxtpanel-examples\fP.  A particularly powerful demo is the "lister"
  60. script example, which is a tool for maneuvering through a Unix
  61. filesystem and viewing files at any level. The third is a set of
  62. xtpanel scripts that present information about xtpanel, mostly taken
  63. from this manual page, in an interactive, menu-driven form. This
  64. is invoked by doing \fIxtpanel -help\fP.
  65. X
  66. .SH OBJECT TYPES
  67. xtpanel supports the following objects: 
  68. .IP message 10
  69. Displays a single line of text.
  70. X
  71. .IP text 10
  72. Displays multiple lines of text in a scrollable area. Can be read-write
  73. or read-only.
  74. X
  75. .IP dialog 10
  76. Provides an editable text field, with a label and an OK button.
  77. X
  78. .IP button 10
  79. A single button.
  80. X
  81. .IP toggle 10
  82. A button that can be toggled between two states.
  83. X
  84. .IP slider 10
  85. Allows the user to choose a value from a range of integer
  86. or floating point values. 
  87. X
  88. .IP scrollbar 10
  89. Similar to a slider, but simpler in appearance.
  90. X
  91. .IP choice 10
  92. A group of buttons, only one of which may be selected at a time.
  93. X
  94. .IP menubutton 10
  95. A button with a menu attached.
  96. X
  97. .IP list 10
  98. A list of character strings, only one of which may be selected at a time.
  99. X
  100. .IP graph 10
  101. An object containing a number of scrollbars, each of which controls
  102. the value for one sample of a list of numbers. 
  103. X
  104. .IP var 10
  105. A variable that has no screen representation but stores a value.
  106. X
  107. .PP
  108. In addition there are several objects that group
  109. other objects together in boxes. Grouping objects in this
  110. way allows greater control of the panel layout. See
  111. the section below on BOXES.
  112. X
  113. .SH CONTROLLING XTPANEL
  114. The rest of this manual page describes
  115. how to write xtpanel script files or run xtpanel from the command
  116. line. If you just want to use it, and don't want to write script
  117. files or learn the command line syntax, then run the automatic
  118. script generator described above. The generator is also a good
  119. way to learn about the script language, since it allows you to
  120. view, edit, and test a script file as it is being built.
  121. X
  122. .SH SCRIPT VS. COMMAND LINE
  123. The typical xtpanel script contains lines of the form:
  124. X
  125. .br
  126. object_type={ parameter1=value1 parameter2=value2 ... }
  127. X
  128. .br
  129. This format is very flexible; the parameters can be supplied in 
  130. any order, or omitted and defaults will be provided. Line breaks can 
  131. occur anywhere.
  132. .PP
  133. XFrom the command line, all objects and all their parameters must
  134. be specified on the same line in a precise order:
  135. X
  136. .br
  137. -object_type value1 value2 value3... -object_type value1 ...
  138. X
  139. .PP
  140. Some parameters can be omitted; the "-" on the beginning
  141. of the next object tells xtpanel to stop reading parameters
  142. for one object and begin the next. However, in order to 
  143. specify a particular parameter, all those up to it in the
  144. sequence must be specified. (For instance, in the case above,
  145. to specify value3 for the first object, one must also specify
  146. value1 and value2, while in a script they could be omitted and left to
  147. default.)
  148. .PP
  149. For these reasons, and because the command line format
  150. (where the entire panel is specified on a single line)
  151. is more difficult to read, it is recommended that a script file be
  152. used for all but the smallest examples. The following section
  153. describes the objects in greater detail, along with the
  154. script language syntax. If you wish instead to use the
  155. command line interface, see the COMMAND LINE SYNTAX
  156. section below.
  157. .PP
  158. Note that scripts and the command line interface can be mixed, and multiple
  159. script files can be read using the "-file" option (see GENERAL COMMAND 
  160. LINE OPTIONS, below.) So the following is a valid xtpanel command:
  161. .br
  162. xtpanel <script1 -file script2 -quit.
  163. .SH DESCRIPTION OF OBJECTS AND SCRIPT SYNTAX
  164. Here is a more detailed description of the objects,
  165. the parameters relevant to each, and the syntax for
  166. building these objects in a script file.
  167. X
  168. The general format for specifying an object in a script file is:
  169. X
  170. .br
  171. object_type={ parameter=value ... }
  172. X
  173. Note that no spaces are allowed between
  174. the object_type and the "{".
  175. X
  176. Each "value" can take one of four forms:
  177. A single word, a string enclosed in single quotes, string enclosed in
  178. double quotes, a system command enclosed in backquotes. See the section
  179. "SCRIPT SYNTAX DETAILS" for more information on the syntax. 
  180. X
  181. .PP
  182. There are four parameters that many objects have in common, these are:
  183. name, label, action and value.
  184. X
  185. \fIname\fP is the name of the object. 
  186. The name serves two purposes, it can be referred to by other objects who wish
  187. to obtain the or modify the string representation of the object. 
  188. X
  189. The name can also be used in modifying the appearance of an object using 
  190. the X-toolkit resource mechanism. 
  191. X
  192. When names are referred to by other objects they start with a dollar sign and
  193. optionally an opening brace. They are assumed to end at
  194. the next space or closing brace. Therefore a name may not contain spaces,
  195. braces or dollar signs.
  196. X
  197. \fIlabel\fP is the label that appears on the object. By default it
  198. is the set to the name. It will appear in an "appropriate" place
  199. which depends on the object type. Some objects do not have labels, the
  200. label parameter is ignored for these objects.
  201. X
  202. \fIvalue\fP is the initial string value associate with the object.
  203. If the object is modified this string value will change. It defaults to
  204. be the same as label.
  205. X
  206. \fIaction\fP is an action that occurs when the button is pressed.
  207. Defaults to "NONE", which means that the button simply maintains a
  208. string, containing its value, for use by other objects.  Other actions
  209. are PRINT (print string to standard output), SYSTEM (execute a
  210. command), STRING (reformat the internal representation of the object's
  211. value, where the string can contain more than just the object's value)
  212. , ASSIGN (set another object's value to a given string), SET (set an
  213. attribute of an object; e.g. color ) and QUIT (quit xtpanel). 
  214. See the section below on ACTIONS for more
  215. details. If more than one action is present the actions will be performed 
  216. in the order that they are specified.
  217. X
  218. .IP \fImessage\fP 3
  219. A message displays a single line of text on a panel.
  220. Messages are used to give short instructions or bits of
  221. information to the user. The script syntax for a message is:
  222. X
  223. .br
  224. message={  value=.... name=.... }
  225. X
  226. The most important variable in a message object is the \fIvalue\fP. 
  227. The value is the text that is displayed on the screen. 
  228. The \fIname\fP is relevant for tailoring the appearance of
  229. this message object using resources or assigning new values to the
  230. message. If a new value is assigned to the message the text will change
  231. to reflect the new value.
  232. X
  233. .br
  234. example:
  235. .br
  236. message={ value=" hello world, I am a message object " }
  237. X
  238. Assigning a new value to a message object (using an ASSIGN
  239. action) will change the text that is displayed.
  240. X
  241. .IP \fItext\fP 3
  242. A text object displays any number of lines of text in
  243. a multi-line scrollable region.
  244. X
  245. .br
  246. text={ action=... name=.... value=... editType=... }
  247. X
  248. The \fIvalue\fP is the text to be displayed on the screen.
  249. Newlines in the value will cause the text to start a new line.
  250. The \fIname\fP is relevant for tailoring the appearance of
  251. this text object using resources  or assigning new values to the
  252. message. If a new value is assigned to the text the text will change
  253. to reflect the new value.
  254. \fIeditType\fP is used to select whether editing of the text
  255. is allowed. Choices are read (read-only), append (can add to text
  256. but not modify existing text), edit (read-write).
  257. X
  258. Assigning a new value to a text object will change the text
  259. that is displayed.
  260. X
  261. .br
  262. examples:
  263. .br
  264. text={ value="I am a multiline \\n text object \\n with three lines" }
  265. .br
  266. text={ value=`cat README` }
  267. X
  268. .IP \fIdialog\fP 3
  269. A dialog displays an editable line of text. Syntax:
  270. X
  271. .br
  272. dialog={ label=... value=... name=... action=... }
  273. X
  274. \fIname\fP  defaults to "dialog1", "dialog2" etc.
  275. \fIlabel\fP appears above the text field.
  276. \fIvalue\fP is the text that initially appears in the text field.
  277. A value of "" means that the text field will initially be blank.
  278. \fIaction\fP: An "ok" button is added to the
  279. panel, and the dialog object is activated when this button is
  280. pressed.
  281. X
  282. Assigning a new value to a dialog changes the displayed string 
  283. to the new value.
  284. X
  285. .br
  286. example:
  287. .br
  288. dialog={ label="Filename to edit" value="" action="xterm -e vi $val" }
  289. X
  290. .IP \fIbutton\fP 3
  291. Button is the first of the interactive objects. Pressing
  292. the button will cause a specified action to take place.
  293. X
  294. .br
  295. button={ label=... value=... name=... action=... }
  296. X
  297. \fIname\fP defaults to "button1", "button2" etc.
  298. \fIlabel\fP is the text  that appears on the button. 
  299. \fIvalue\fP is the string value associated with the button.
  300. \fIaction\fP is an action that occurs when the button is pressed. 
  301. X
  302. Assigning a new value to a button does not change the appearance of the
  303. button but it will change the value used in an action.
  304. X
  305. .br
  306. example:
  307. .br
  308. button={ label="Press me" action="PRINT Aargh! I was pressed" }
  309. X
  310. .IP \fItoggle\fP 3
  311. A toggle object is similar to a button except that it
  312. can be toggled between its on (highlighted) and off states,
  313. while a button returns to its off state immediately. The
  314. value of a toggle object is blank when the toggle is in
  315. its off state.
  316. X
  317. .IP \fIslider\fP 3
  318. A slider lets the user choose a value from a range of integer
  319. or floating point values. Syntax:
  320. X
  321. .br
  322. slider={ label=... value=... name=... action=... min=... max=... \
  323. format=... width=... height=... }
  324. X
  325. A slider object has a label, a slider and a text field that
  326. displays the current slider value, and
  327. an "OK" button to allow the user to trigger the slider's
  328. action. 
  329. X
  330. \fIname\fP defaults to "slider1", "slider2" etc. 
  331. \fIlabel\fP appears above the slider.
  332. \fIvalue\fP is the starting value for the slider; defaults to the minimum.
  333. \fIaction\fP: For action types SYSTEM and PRINT the action occurs when 
  334. the "ok" button is pressed. For action type STRING the action occurs when 
  335. the slider position changes.
  336. X
  337. Assigning a new value to a slider changes the slider position to match the
  338. new value. If the new value string is not a number (as intepreted by the
  339. routine atof() ) the slider will be set to zero.
  340. X
  341. \fImin\fP is the minimum value for the slider; defaults to 0. 
  342. \fImax\fP is the maximum value for the slider; defaults to 1. 
  343. X
  344. \fIformat\fP is the format with which the slider label and its internal 
  345. string 
  346. will be printed. The slider value is stored internally as a floating point
  347. number; the default value for format is %f, which prints the value
  348. with five decimal places. You can specify a different format, according
  349. to the format specification for the C programming language. To obtain
  350. in integer-only slider, use a format of %.0f (the 0 indicates no digits
  351. after the decimal point).
  352. X
  353. \fIwidth\fP and \fIheight\fP are the lengths of the major and minor
  354. axes of the slider. By default, sliders are oriented horizontally.
  355. This can be changed by using the orientation parameter described
  356. below in the MISCELLANEOUS PARAMETERS section.
  357. X
  358. .br
  359. example
  360. .br
  361. slider={ label=Velocity min=1000 max=4000 value=2000 format=%4.0f }
  362. X
  363. .IP \fIscrollbar\fP 3
  364. A scrollbar object is similar to a slider, except that it has
  365. no label or ok button. A scrollbar's actions are performed
  366. whenever the scrollbar is changed.
  367. X
  368. .IP \fIchoice\fP 3
  369. A choice object is a set of toggle buttons. Each button may
  370. be set on or off, but only one button may be active at a time. Syntax:
  371. X
  372. .br
  373. choice={ label=... value=... name=... action=... item=... itemlist=... }
  374. X
  375. The choice object consists of a text label and a set of buttons.
  376. The value of the object on output is set to the value associated with 
  377. the active button.
  378. X
  379. \fIname\fP  defaults to "choice1", "choice2" etc.
  380. \fIlabel\fP  appears adjacent to the buttons.
  381. \fIvalue\fP is the initial value associated with the 
  382. choice. It must match the value of one of the buttons, or by default
  383. it is set to the value of the first button.
  384. \fIaction\fP is an action that occurs when a button is pressed. 
  385. X
  386. Assigning a new value to a choice changes the choice to match the new
  387. value. If the new value does not match any item's value the choice will be
  388. unchanged.
  389. X
  390. \fIitem\fP and \fIitemlist\fP are used to describe the buttons
  391. contained in a choice. You can either specify buttons one at a
  392. time with item, or in groups with itemlist. See the detailed
  393. descriptions of item and itemlist below. There is no limit on
  394. the number of items or itemlists used in a choice object.
  395. X
  396. .br
  397. example:
  398. .nf
  399. choice={ label="english colors" action="PRINT use $val " 
  400. X        item={ label=red } item={ label=green } item={ label=blue }
  401. X            }
  402. .fi
  403. X
  404. .IP \fImenubutton\fP 3
  405. A button with a pulldown menu. Syntax:
  406. X
  407. menubutton={ label=... value=... name=... action=... item=... itemlist=... }
  408. X
  409. \fIname\fP  defaults to "menubutton1", "menubutton2" etc.  
  410. \fIlabel\fP  appears on the button.
  411. \fIvalue\fP is the initial value associated with the menu. 
  412. It must match the value of one of the menu items, or it
  413. defaults to be the same as the value of the first menu item. 
  414. \fIaction\fP  occurs when a menu item is selected. 
  415. X
  416. \fIitem\fP and \fIitemlist\fP are used to describe the options
  417. contained in a menu. You can either specify buttons one at a
  418. time with item, or in groups with itemlist. See the detailed
  419. descriptions of item and itemlist below. There is no limit on
  420. the number of items or itemlists used in a menubutton object.
  421. X
  422. Assigning a new value to a menubutton changes the menubutton to match 
  423. the new value. If the new value does not match any item's value the 
  424. menubutton will be unchanged.
  425. X
  426. .br
  427. example
  428. .nf
  429. menubutton={ label="french color" action="PRINT utilisez $val " 
  430. X    item={ label=red value=rouge } 
  431. X        item={ label=green value=vert } 
  432. X        item={ label=blue value=bleu }
  433. X            }
  434. .fi
  435. X
  436. .IP \fIlist\fP 3
  437. A list of items; the user clicks on one of the items to select it.
  438. Syntax:
  439. X
  440. .br
  441. list={ label=... value=... name=... action=... item=... itemlist=... }
  442. X
  443. The list object has a text label and a list of items.
  444. X
  445. \fIname\fP  defaults to "list1", "list2" etc.
  446. \fIlabel\fP appears adjacent to the list.
  447. \fIvalue\fP is the initial value associated with the list. It must
  448. match the value of one of the list items, or it defaults to be
  449. the same as the value of the first list item.
  450. \fIaction\fP occurs when an item is selected. 
  451. X
  452. \fIitem\fP and \fIitemlist\fP are used to describe the items
  453. contained in a list. You can either specify items one at a
  454. time with item, or in groups with itemlist. See the detailed
  455. descriptions of item and itemlist below. There is no limit on
  456. the number of items or itemlists used in a list object.
  457. X
  458. Assigning a new value to a list changes the list value to match the new
  459. value. If the new value does not match any item's value the list will be
  460. unchanged.
  461. X
  462. .br
  463. example:
  464. .nf
  465. list={ label="german color" action="PRINT benutze $val " 
  466. X    item={ label=red value=rot } 
  467. X        item={ label=green value=gruen } 
  468. X        item={ label=blue value=blau }
  469. X            }
  470. .fi
  471. X
  472. X
  473. .IP \fIitem\fP 3
  474. Item is used to specify a single item for a choice, menu or list.
  475. Syntax:
  476. X
  477. .br
  478. item={ label=... value=... }
  479. X
  480. \fIlabel\fP is the label that appears on the screen,
  481. as the name of the button (for choice) or on the menu or list.
  482. Defaults to "item1", "item2" etc.
  483. \fIvalue\fP is the value that is set in the parent object when this
  484. item is selected. Defaults to be the same as label.
  485. Item is preferred over itemlist when the text displayed
  486. on the screen for an item and that used for its value differ.
  487. X
  488. .br
  489. example:
  490. .br
  491. item={ label=Two value=2 }
  492. X
  493. .IP \fIitemlist\fP 3
  494. Itemlist is used to specify several items for a choice, menu or list.
  495. Syntax:
  496. X
  497. .br
  498. itemlist={ list=... separator=... }
  499. X
  500. \fIlist\fP is a single string containing a list of items. The string 
  501. will be parsed to obtain the individual items. The label and value
  502. of each item will be the same, set to the string taken from the list.
  503. Thus itemlist is not appropriate when the text displayed on
  504. the screen for an item (the label) and that used for the value 
  505. are to differ.
  506. \fIseparator\fP is a string of characters that is used to separate different 
  507. items in the list string. Defaults to separator=" " (the blank character.)
  508. X
  509. .br
  510. examples:
  511. .nf
  512. itemlist={ list="red white blue" } 
  513. itemlist={ list=`ls -aF` separator=" \\n" }
  514. .fi
  515. X
  516. .IP \fIgraph\fP 3
  517. A graph is a composite object, made up of a number of scrollbars.
  518. Syntax:
  519. X
  520. .br
  521. graph={ nsamp=... label=... value=... name=... action=... min=... max=... \
  522. format=... width=... height=... }
  523. X
  524. A graph object has a label, and \fInsamp\fP scrollbars, each of
  525. which sets the value of one sample in the graph. The value of
  526. a graph is a string containing the sample values, separated by
  527. spaces.
  528. X
  529. \fInsamp\fP number of samples in the graph.
  530. \fIname\fP defaults to "graph1", "graph2" etc. 
  531. \fIlabel\fP appears above the graph.
  532. \fIvalue\fP is the starting value for the graph; defaults to the minimum.
  533. You can specify up to nsamp values in a blank-separated list. If
  534. you specify fewer than nsamp, the last value specified is re-used
  535. as needed. Thus you can use value=0 to set all samples to zero.
  536. \fIaction\fP: Graph objects cannot do PRINT or SYSTEM actions by
  537. themselves. You must supply another button that uses the graph's
  538. value to perform an action.
  539. X
  540. \fImin\fP, \fImax\fP, and \fIformat\fP are the same as for sliders.
  541. X
  542. \fIwidth\fP and \fIheight\fP are the lengths of the major and minor
  543. axes of the scrollbars in the graph. These are the dimensions of
  544. each scrollbar, not the graph as a whole.
  545. X
  546. By default, the scrollbars are oriented horizontally.
  547. This can be changed by using the orientation parameter; see the
  548. MISCELLANEOUS PARAMETERS section below.
  549. X
  550. Assigning a new value to a graph will change the value of 
  551. the samples. You can specify up to nsamp values in a blank-separated list. 
  552. If you specify fewer than nsamp, the last value specified is re-used
  553. as needed.
  554. X
  555. Holding down the meta key while the cursor is inside a graph object
  556. allows the user to "draw" the graph without having to press mouse
  557. buttons. This drawing can be slow for graphs with a large number
  558. of samples, because of the number of widgets involved.
  559. X
  560. .br
  561. example
  562. .br
  563. graph={ nsamp=100 label="A(t)"  min=-100 max=100 value=0 format=%4.0f }
  564. X
  565. .IP \fIvar\fP 3
  566. Var is an object that has a value and no screen representation.
  567. X
  568. Syntax:
  569. var={ name=... value=... }
  570. \fIname\fP  defaults to "var1", "var2" etc.  
  571. \fIvalue\fP is the value of the var. 
  572. X
  573. X
  574. Variables can be used for adding arbitrary arguments on the command line. 
  575. See the command line syntax below. The values of var objects may be used
  576. in the action of other objects so that an xtpanel's behaviour can be
  577. modified without changing the script file. Also the value of a var may be 
  578. changed by the ASSIGN action. Thus a var can be used to pass
  579. information from one object to another.
  580. X
  581. .SH MISCELLANEOUS PARAMETERS
  582. In addition to the parameters described above, there are a number
  583. of general parameters that apply to many objects that customize
  584. the appearance of the object. These are listed below, along with
  585. a list for each of the objects it can be applied to. These
  586. general parameters can also be modified by xtpanel using the SET
  587. action. See the section on ACTIONS.
  588. X
  589. .IP height 10
  590. height of object, in pixels.
  591. .IP width 10
  592. width in pixels. Height and width can be used for most objects.
  593. .IP foreground 10
  594. foreground color. Colors are appropriate for most object types.
  595. .IP background 10
  596. background color
  597. .IP borderColor 10
  598. border color. 
  599. .IP font 10
  600. text font. Appropriate for message objects only.
  601. .IP orientation 10
  602. for boxes, scrollbars, choice objects. Choices are horizontal and vertical.
  603. .IP bitmap 10
  604. for message, button, and toggle objects. Specify a file name.
  605. The bitmap will be displayed in place of the label.
  606. .IP editType 10
  607. for text objects only, to indicate whether they are read-only
  608. are not. Choices are read (read-only), append (can add to text
  609. but not modify existing text), edit (read-write).
  610. X
  611. These parameters are just some of the many resources defined
  612. for Athena widgets. In the future we hope xtpanel will provide
  613. a more general method that allows the user to access all
  614. resources, not just those on this list.
  615. X
  616. .SH SCRIPT SYNTAX DETAILS
  617. The general format for specifying an object in a script file is:
  618. X
  619. .br
  620. object_type={ parameter=value ... }
  621. X
  622. Note that no spaces are allowed between
  623. the object_type and the "{".
  624. X
  625. A line with an exclamation "!" in column one is treated as a comment line,
  626. the rest of the line will be ignored.
  627. X
  628. Each "value" can take one of four forms:
  629. X
  630. .IP 1) 3 
  631. A single word. 
  632. .br
  633. e.g. label=fred
  634. X
  635. .IP 2) 3 
  636. zero or more words enclosed in single quotes 
  637. .br
  638. e.g. label='fred in quotes'
  639. .br
  640. The quotes are stripped before the value is stored. Two consecutive
  641. single quotes within the quotes will produce a single quote in the
  642. stored value. Any other type of quotes pass through unchanged.
  643. .nf
  644. e.g. ' ''fred'' is happy' is stored as -> 'fred' is happy<-
  645. X       '"fred" is happy' is stored as ->"fred" is happy<-
  646. .fi
  647. X
  648. .IP 3) 3
  649. zero or more words enclosed in double quotes
  650. .br
  651. e.g. label="fred in quotes"
  652. .br
  653. The quotes are stripped before the value is stored. Two consecutive
  654. double quotes within the quotes will produce one double quote in the
  655. stored value. Any other type of quotes pass through unchanged.
  656. .nf
  657. e.g. " ""fred"" is happy" is stored as -> "fred" is happy<-
  658. X     " ""fred"" is 'happy'" is stored as -> "fred" is 'happy'<-
  659. .fi
  660. Within either single or double quotes the following transformations are
  661. applied to handle newlines:
  662. .br
  663. .nf
  664. X newline                ->              newline
  665. X backslash newline      ->              is removed 
  666. X \\n                     ->              newline
  667. .fi
  668. X
  669. .IP 4) 3
  670. zero or more words enclosed in backquotes.
  671. .br
  672. e.g. label=`echo my name is fred`
  673. .br
  674. The value stored is the output produced by running the command using
  675. the user's shell. Any trailing whitespace is stripped from the output.
  676. .br
  677. In this example the value stored is ->my name is fred<- 
  678. X
  679. Note the special case of a backquoted string within a quoted action.
  680. See actions below.
  681. X
  682. .SH ACTIONS
  683. An action is a command performed when a user interface object has changed
  684. its state. e.g. a button is pushed, a list item is chosen, a slider is
  685. moved. If more than one action is specified for an object then the separate
  686. actions are performed in the order in which they are specified in the script
  687. file.
  688. X
  689. There are seven basic types of action NONE, QUIT, SYSTEM, PRINT, STRING, 
  690. ASSIGN, and SET.
  691. X
  692. If no action is specified (or the action is specified as "NONE")
  693. the action type is NONE. In this case an object 
  694. will just maintain its string representation.  For dialogs, the string
  695. is the contents of the text field; for sliders, the slider value;
  696. for choice, menubutton and list objects, the value associated with
  697. the selected item. When an object with action=NONE is modified, 
  698. its string is kept up to date, but nothing else happens.
  699. X
  700. An action type of QUIT, specified as ACTION=QUIT, will cause the xtpanel
  701. program to quit when the object is interacted with. The simple quit button
  702. is written as: 
  703. .br
  704. button={ label=QUIT action=QUIT }
  705. X
  706. The next four action types (SYSTEM, PRINT, STRING and ASSIGN) are more 
  707. complicated.  Each uses the format specified in the action command to 
  708. generate a string.
  709. If the action is SYSTEM, then that string is executed. If the action type
  710. is PRINT then the string is printed to the standard output. If the action
  711. is STRING then the string is stored as the internal string representation
  712. of the object.
  713. X
  714. If the action type is ASSIGN the value of the other
  715. object is set to the string. Additionally the screen representation of the
  716. object is updated to reflect the new value (if it makes sense to do so).
  717. For example if the value of a dialog is updated the text field of the
  718. dialog will contain the updated string. If a slider is updated the
  719. slider thumb will be moved to the corresponding position.
  720. X
  721. The format specified can contain the names of objects preceded
  722. by a dollar "$" sign. The value of the string associated with the object
  723. is substitued in the generated string. The special symbol "$val" is used
  724. to refer to the string associated with the current object. An object name can
  725. be enclosed in brackets to avoid syntactic ambiguity. You can use "$(val)" or
  726. "$val", the first form is recommended. If you do not enclose the name in
  727. brackets it will be assumed to end at the next space, dollar sign or quote.
  728. You should give an object a name if you intend to use its string in the 
  729. action of another object.
  730. A double
  731. dollar sign "$$" is used to generate a single dollar in the generated
  732. string. 
  733. X
  734. If a format contains a command enclosed in backquotes then the output
  735. produced by running the command will be subsituted in the generated string.
  736. The command will be run when the action takes place. i.e. if a backquoted
  737. command is present in the action for a button then the command will be run
  738. each time the button is pressed. Note that the evaluation of the command 
  739. takes place after the substitution of object values, thus the backquoted 
  740. command evaluated at action time may contain an evaluated object value.
  741. X
  742. The ASSIGN action is special because the word immediately following 
  743. the word ASSIGN (separated by blanks) is the name of an object that 
  744. will have its value modified.
  745. The format is thus assumed to start at the second word after ASSIGN. 
  746. X
  747. The SET action is another special case. The set action allows you
  748. to modify not the value of an object, but one of its resources,
  749. such as foreground or background color, font, orientation, etc.
  750. The word immediately following the word SET is the name of the
  751. object; the next word is the resource you wish to set. Following
  752. that is the resource specification.
  753. See the section above on MISCELLANEOUS PARAMETERS to see which attributes
  754. can be changed with the SET action.
  755. X
  756. An action type of PRINT is used for any action command that begins with
  757. PRINT (It must be in upper case and start at the first character of the action
  758. string). An action type of STRING is used for any command that begins with
  759. STRING. An action type of ASSIGN is used for any command that begins with
  760. the word ASSIGN. An action type of SET is used for any command that
  761. begins with SET.
  762. An action type of SYSTEM is used for any command that doesn't
  763. begin with QUIT, STRING, PRINT, SET or ASSIGN or if it begins with SYSTEM.
  764. X
  765. X
  766. Following are two examples of using actions.
  767. X
  768. Here is a choice object that uses its value as a parameter
  769. for an imaginary system command, showcolor:
  770. X
  771. .nf
  772. choice={ label=colors value="255 0 0" action="showcolor -rgb $(val)"
  773. X         item={ label=red value="255 0 0" }
  774. X         item={ label=green value="0 255 0" }
  775. X         item={ label=blue value="0 0 255" }
  776. X       }
  777. .fi
  778. X
  779. In this next example, the list item has no action specified. Actions
  780. default to type NONE; the list will maintain a string containing
  781. the value of the selected list item, but will do nothing more.
  782. Here a separate button is used to do something with the list's
  783. output:
  784. X
  785. .nf
  786. message={ label="press button to find out which item is selected" }
  787. list={ label=numbers name=listout
  788. X         itemlist={ list="1 2 3"
  789. X       }
  790. button={ label="press for answer" 
  791. X         action="PRINT list selection is $(listout)" }
  792. .fi
  793. X
  794. In this example the assign action is used to reset the value of a dialog
  795. to a known string (fred). The reset button assigns the string to the dialog.
  796. The dialog itself has two actions, the first prints the value of the
  797. text field and the second action quits xtpanel.
  798. X
  799. .nf
  800. dialog={ label=dialog value="fred" 
  801. X         action="PRINT I am $(val)" 
  802. X         action=QUIT 
  803. X       }
  804. X
  805. button={ label=RESET action="ASSIGN dialog fred" }
  806. .fi
  807. X
  808. X
  809. In the final example the user can select a file from all the ".ps" files
  810. in the current directory. The file is then viewed with the ghostview program:
  811. X
  812. .nf
  813. button={ label=QUIT action=QUIT }
  814. list={ label="Choose a file" action="ghostview $(val)" 
  815. X         itemlist={ list=`echo *.ps`  }
  816. X       }
  817. .fi
  818. X
  819. .SH BOXES
  820. Several objects are provided to manage the appearance
  821. of the panel. These box objects group other objects
  822. into boxes that are oriented either vertically or
  823. horizontally. In a vertically oriented box, 
  824. the objects are arranged in a single column, and then
  825. a box is drawn around them. A vertically oriented box
  826. (vbox) is specified as follows:
  827. X
  828. .nf
  829. vbox={ name=
  830. object_type={ parameter=value ... }
  831. object_type={ parameter=value ... }
  832. }
  833. .fi
  834. X
  835. All of the objects bounded by the starting and ending braces
  836. of a box will be grouped together in the box. In addition
  837. to vbox, there is hbox, which is oriented horizontally,
  838. and vpane and hpane, where the objects within the box are
  839. separated by movable partitions (these use the Athena
  840. paned widget). There is also box and pane; these default
  841. to vbox and vpane, but could be overridden from a resource
  842. file.
  843. X
  844. Boxes can be nested. In this way, fairly precise control
  845. over a panel's layout is obtained.
  846. X
  847. Box objects have only a single parameter, \fIname\fB.
  848. Two special names are recognized by the resource
  849. file; boxes with name=\fInoborder\fB will have no
  850. border drawn around them. If you use boxes extensively
  851. to arrange objects on the panel, using noborder can help
  852. avoid the tunnel-like appearance of multiple nested boxes.
  853. Also, one of the examples makes use of a special
  854. box name \fIsqueezebox\fB.
  855. This name triggers definitions in
  856. the resource file that "squeeze out" the annotation
  857. of sliders, choices, and buttons that are grouped together
  858. in such a box. When a number of sliders are squeezed together
  859. in this way, the result is a seemingly new object that lets
  860. the user manipulate the data samples of a function. See the
  861. "sliderbox" examples in the panel brought up doing "run_demos"
  862. in the xtpanel source directory.
  863. X
  864. .SH COMMAND LINE INTERFACE
  865. On the command line, objects are specified in the following
  866. format:
  867. X
  868. xtpanel -object_type value value ... -object_type value...
  869. X
  870. The values must be specified in a prescribed order, as described
  871. below for each object type. You can specify as many of the
  872. values for a given object as you wish; the "-" on the object
  873. type is the signal to xtpanel to stop reading parameters for
  874. one object and begin the next. But in
  875. order to specify a value for one parameter, you MUST specify values all those
  876. that precede it, in exactly the order specified here.
  877. X
  878. The values for each object are described in the section
  879. above named DESCRIPTION OF OBJECTS AND SCRIPT SYNTAX.
  880. Here we simply list them in the order that they
  881. must be specified from the command line.
  882. X
  883. .nf
  884. \-message    [value]
  885. \-text       [action name value width height editType]
  886. \-dialog     [label action name value]
  887. \-button     [label action name value]
  888. \-toggle     [label action name value]
  889. \-slider     [label action name value min max format width height]
  890. \-scrollbar  [action name value min max format width height]
  891. \-choice     [label action name value numchoice label value ...]
  892. \-menubutton [label action name value numchoice label value ...]
  893. \-list       [label action name value numchoice label value ...]
  894. \-graph      [nsamp label action name value min max format width height]
  895. \-var        [name value]
  896. \-quit         
  897. .fi
  898. X
  899. For the multiple-choice objects (choice, menubutton, and list),
  900. you must specify a label (which gets displayed on the screen)
  901. and a value (used on output) for each item, and you must
  902. precede these by the number of items in the choice,
  903. menubutton, or list (which is not required in a script).
  904. There is no analog
  905. to the script "itemlist" object, which lets you specify only
  906. one string for each item instead of two.
  907. X
  908. Note that the box objects described above (see BOXES),
  909. used to group objects into horizontally or vertically
  910. oriented boxes, are not available from the command line.
  911. X
  912. .SH COMMAND LINE EXAMPLES
  913. The following examples illustrate the use of xtpanel from the
  914. command line:
  915. X
  916. This example contains a quit button and a message:
  917. X
  918. .nf
  919. xtpanel -quit -message "this is a message"
  920. .fi
  921. X
  922. This example contains a choice:
  923. X
  924. .nf
  925. xtpanel -choice "this is a choice" 'PRINT choice is $val' name 1 \
  926. 3 one 1 two 2 three 3  
  927. .fi
  928. X
  929. This example contains a slider and a button that outputs the slider's value:
  930. X
  931. .nf
  932. xtpanel -quit -slider "this is a slider" 'PRINT slider value is $val' 
  933. name 5 0 10 "%.0f" 100 20 -button "press me" 'PRINT slider value is $name'
  934. .fi
  935. X
  936. .SH GENERAL COMMAND LINE OPTIONS
  937. .TP
  938. .B \-file filename
  939. Read in the script file "filename". Xtpanel also looks for
  940. a script file on stdin. The filename specified in this way is searched
  941. for in a number of possible directories.
  942. If the environment variable "XTPANEL_PATH" is set it is assumed to be
  943. a colon separated list of directories to be searched. If the file is not found
  944. in these directories the program will search a directory called .xtpanel in
  945. the users home directory and then the system xtpanel directory.
  946. X
  947. If the environment variable is not
  948. set the program will search the current directory, followed by ~/.xtpanel
  949. followed by the system xtpanel directory.
  950. X
  951. The system directory is specified in the Makefile used to compile the
  952. xtpanel program. At compilation time on this system it was set to
  953. SYS_XTPANELDIR.
  954. X
  955. .TP
  956. .B \-cpp [cpp_args]
  957. If the -cpp flag is specified then all files read using the "-file" flag
  958. will be passed though the C-preprocessor before being parsed. The preprocessor
  959. will be invoked using any command line arguments that look like they might be
  960. C-preprocessor arguments. Currently this is interpreted as being any argument
  961. that starts with "-I" or "-D". Note the standard input is never passed through
  962. cpp. If you wish to to this you should pipe the output of cpp into xtpanel
  963. yourself.
  964. X
  965. This option can be very useful in designing system wide xtpanel scripts
  966. where a few key words may be changed at each invocation. These words may
  967. be redefined with "-Doldname=newname". The -cpp option can also be used to
  968. define macros for repeated parts of script files or even including prebuilt
  969. pieces of script files from elsewhere. The following example illustrates
  970. some of these possibilities.
  971. X
  972. .nf
  973. #ifndef NAME
  974. #define NAME "default name"
  975. #endif
  976. X
  977. #define mkslid(VAL) slider={ label="" min=0 max=100 value=VAL width=300 \
  978. height=25 format="%.0f" action="STRING $val" }
  979. X
  980. label={ value=NAME }
  981. X
  982. mkslid(0)
  983. mkslid(10)
  984. mkslid(20)
  985. .fi
  986. X
  987. .TP
  988. .B \-help
  989. Invokes a series of xtpanel scripts that present information
  990. about xtpanel, mostly taken from this manual page, in an
  991. interactive, menu-driven form.
  992. X
  993. .TP
  994. .B \-tty
  995. Read a script from the terminal. Generally not recommended;
  996. it is better to save the script in a file first. If this option
  997. is not set the program will not accept input from standard input if
  998. it is a terminal. You can redirect standard input and pipe data to
  999. xtpanel without setting this option.
  1000. X
  1001. .SH RESOURCES
  1002. All widgets are constructed using the "name" parameter of the object.
  1003. The X-toolkit resource mechanism can be used to control the appearance
  1004. of an object based on either its class or its name.
  1005. The xtpanel objects are constructed from Xaw widgets as follows:
  1006. X
  1007. .IP message 10 
  1008. is a Label widget
  1009. .IP button 10
  1010. is a Command widget
  1011. .IP toggle 10
  1012. is a Toggle widget
  1013. .IP dialog 10
  1014. is a Dialog widget
  1015. .IP text 10
  1016. is a Text widget
  1017. .IP scrollbar 10
  1018. is a Scrollbar widget.
  1019. .IP slider 10
  1020. is a Box containing two Labels and a Scrollbar.
  1021. .IP choice 10
  1022. is a Box containing a Label and a number of Toggles.
  1023. .IP menubutton 10
  1024. is a MenuButton. Attached to it is a SimpleMenu, with a
  1025. number of SmeBSB menu entries.
  1026. .IP list 10
  1027. is a Box containing a Label and a List.
  1028. .IP graph 10
  1029. is a Box containing a number of Scollbars, and several Label widgets.
  1030. X
  1031. If I have the following xtpanel script file:
  1032. X
  1033. button={ label=QUIT action=QUIT }
  1034. X
  1035. box={ name=bigfont
  1036. X      button={ label=fred action="PRINT fred" }
  1037. X      button={ label=joe name=curs action="PRINT joe" }
  1038. }
  1039. X
  1040. and the following resources:
  1041. X
  1042. XXTpanel*Command.Font: fixed
  1043. XXTpanel*bigfont*Command.Font: 8x16
  1044. XXTpanel*bigfont*curs.Font: cursor
  1045. X
  1046. Then the quit button will use the "fixed" font, fred will use "8x16" and
  1047. joe will use "cursor" (and thus be unreadable).
  1048. X
  1049. .SH COPYRIGHT
  1050. Although xtpanel is not in the public domain, its copyright is not
  1051. very restrictive. Here is the official xtpanel copyright notice (the one
  1052. that all the source files tell you about):
  1053. .PP
  1054. Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1055. University.  All Rights Reserved.  Permission is hereby given
  1056. to use, copy, modify, and distribute this software provided
  1057. that (1) copyright and proprietary notices are retained in
  1058. each copy, (2) any files which are modified are identified as such,
  1059. and (3) you do not copy or distribute the software for payment or
  1060. for commercial use without prior written consent from Stanford.
  1061. STANFORD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND
  1062. concerning this software or its use.
  1063. X
  1064. .SH BUGS
  1065. Probably many. Please send bug reports, suggestions,
  1066. interesting xtpanel scripts, code to support new widgets, etc.
  1067. to the authors.
  1068. X
  1069. X
  1070. .SH AUTHORS
  1071. Steve Cole (steve@sep.stanford.edu)
  1072. .br
  1073. Dave Nichols (dave@sep.stanford.edu)
  1074. .br
  1075. Stanford Exploration Project, Department of Geophysics
  1076. .br
  1077. Stanford University, Stanford, CA, 94305-2215
  1078. SHAR_EOF
  1079. chmod 0664 xtpanel/xtpanel.man.sed ||
  1080. echo 'restore of xtpanel/xtpanel.man.sed failed'
  1081. Wc_c="`wc -c < 'xtpanel/xtpanel.man.sed'`"
  1082. test 38445 -eq "$Wc_c" ||
  1083.     echo 'xtpanel/xtpanel.man.sed: original size 38445, current size' "$Wc_c"
  1084. fi
  1085. # ============= xtpanel/xtpanel-generator.script ==============
  1086. if test -f 'xtpanel/xtpanel-generator.script' -a X"$1" != X"-c"; then
  1087.     echo 'x - skipping xtpanel/xtpanel-generator.script (File already exists)'
  1088. else
  1089. echo 'x - extracting xtpanel/xtpanel-generator.script (Text)'
  1090. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/xtpanel-generator.script' &&
  1091. #!/bin/csh -f
  1092. X
  1093. xtpanel -name "xtpanel generator" -file generator/generator
  1094. SHAR_EOF
  1095. chmod 0664 xtpanel/xtpanel-generator.script ||
  1096. echo 'restore of xtpanel/xtpanel-generator.script failed'
  1097. Wc_c="`wc -c < 'xtpanel/xtpanel-generator.script'`"
  1098. test 75 -eq "$Wc_c" ||
  1099.     echo 'xtpanel/xtpanel-generator.script: original size 75, current size' "$Wc_c"
  1100. fi
  1101. # ============= xtpanel/NoImake ==============
  1102. if test -f 'xtpanel/NoImake' -a X"$1" != X"-c"; then
  1103.     echo 'x - skipping xtpanel/NoImake (File already exists)'
  1104. else
  1105. echo 'x - extracting xtpanel/NoImake (Text)'
  1106. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/NoImake' &&
  1107. #!/bin/csh
  1108. #The following files are used by NoImake:
  1109. #     NoImake.cpp contains variable definitions and machine specific flags
  1110. #     NoImake.m4  contains Imake-rules in form of m4 macro definitions
  1111. #
  1112. # Martin Karrenbach  8-25-92
  1113. X
  1114. echo "You are running an Imake substitute to create: Makefile"
  1115. if ( "$1" == "" ) then 
  1116. echo "You can give the optional argument: SUN4, RS6000, HP700 or DEC3100"
  1117. endif
  1118. echo "You may have to edit the file:"
  1119. echo "      NoImake.cpp"
  1120. echo "to set machine specific flags and rerun NoImake."
  1121. X
  1122. X
  1123. if ( "$1" == "" ) then 
  1124. cat NoImake.cpp Imakefile | /lib/cpp      > Makefile.tmp
  1125. else
  1126. cat NoImake.cpp Imakefile | /lib/cpp -D$1 > Makefile.tmp
  1127. endif
  1128. m4 NoImake.m4 Makefile.tmp > Makefile
  1129. rm -f Makefile.tmp
  1130. X
  1131. foreach dir ( generator help )
  1132. X  echo making  Makefile in $dir
  1133. X  cd $dir;
  1134. X  if ( "$1" == "" ) then
  1135. X    cat ../NoImake.cpp Imakefile | /lib/cpp      > Makefile.tmp
  1136. X  else
  1137. X    cat ../NoImake.cpp Imakefile | /lib/cpp -D$1 > Makefile.tmp
  1138. X  endif
  1139. X  m4 ../NoImake.m4 Makefile.tmp > Makefile
  1140. X  rm -f Makefile.tmp
  1141. X  cd ..
  1142. end
  1143. X
  1144. foreach dir ( examples )
  1145. X  echo making  Makefile in $dir
  1146. X  cd $dir;
  1147. X  if ( "$1" == "" ) then
  1148. X    cat ../NoImake.cpp Imakefile | /lib/cpp      > Makefile.tmp
  1149. X  else
  1150. X    cat ../NoImake.cpp Imakefile | /lib/cpp -D$1 > Makefile.tmp
  1151. X  endif
  1152. X  m4 ../NoImake.m4 Makefile.tmp > Makefile
  1153. X  rm -f Makefile.tmp
  1154. X
  1155. X  foreach subdir ( commandline script )
  1156. X  echo making  Makefile in $dir/$subdir
  1157. X  cd $subdir;
  1158. X  if ( "$1" == "" ) then
  1159. X    cat ../../NoImake.cpp Imakefile | /lib/cpp      > Makefile.tmp
  1160. X  else
  1161. X    cat ../../NoImake.cpp Imakefile | /lib/cpp -D$1 > Makefile.tmp
  1162. X  endif
  1163. X  m4 ../../NoImake.m4 Makefile.tmp > Makefile
  1164. X  rm -f Makefile.tmp
  1165. X  cd ..
  1166. X  end
  1167. X  cd ..
  1168. end
  1169. X
  1170. SHAR_EOF
  1171. chmod 0775 xtpanel/NoImake ||
  1172. echo 'restore of xtpanel/NoImake failed'
  1173. Wc_c="`wc -c < 'xtpanel/NoImake'`"
  1174. test 1708 -eq "$Wc_c" ||
  1175.     echo 'xtpanel/NoImake: original size 1708, current size' "$Wc_c"
  1176. fi
  1177. # ============= xtpanel/eval_command.h ==============
  1178. if test -f 'xtpanel/eval_command.h' -a X"$1" != X"-c"; then
  1179.     echo 'x - skipping xtpanel/eval_command.h (File already exists)'
  1180. else
  1181. echo 'x - extracting xtpanel/eval_command.h (Text)'
  1182. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/eval_command.h' &&
  1183. X
  1184. #ifndef EVAL_COMM_H
  1185. #define EVAL_COMM_H
  1186. X
  1187. #ifndef _NO_PROTO
  1188. extern char* eval_command( char*);
  1189. #else
  1190. extern char* eval_command();
  1191. #endif
  1192. X
  1193. #endif
  1194. SHAR_EOF
  1195. chmod 0664 xtpanel/eval_command.h ||
  1196. echo 'restore of xtpanel/eval_command.h failed'
  1197. Wc_c="`wc -c < 'xtpanel/eval_command.h'`"
  1198. test 145 -eq "$Wc_c" ||
  1199.     echo 'xtpanel/eval_command.h: original size 145, current size' "$Wc_c"
  1200. fi
  1201. # ============= xtpanel/eval_command.c ==============
  1202. if test -f 'xtpanel/eval_command.c' -a X"$1" != X"-c"; then
  1203.     echo 'x - skipping xtpanel/eval_command.c (File already exists)'
  1204. else
  1205. echo 'x - extracting xtpanel/eval_command.c (Text)'
  1206. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/eval_command.c' &&
  1207. /*
  1208. X * Copyright 1992 the Board of Trustees of the Leland Stanford Junior
  1209. X * University. Official permission to use this software is included in
  1210. X * the documentation. It authorizes you to use this file for any
  1211. X * non-commercial purpose, provided that this copyright notice is not
  1212. X * removed and that any modifications made to this file are commented
  1213. X * and dated in the style of the example below.
  1214. X */
  1215. X
  1216. /*
  1217. X *
  1218. X *  source file:   ./xtpanel/eval_command.c
  1219. X *
  1220. X * Steve Cole, Dave Nichols (SEP), September 9 1992
  1221. X *      Inserted this sample edit history entry.
  1222. X *      Please log any further modifications made to this file:
  1223. X * Steve Cole, Dave Nichols (SEP), November 20 1992 -  version 2.00
  1224. X * 1) added new objects: toggle, scrollbar, graph.
  1225. X * 2) added new actions: ASSIGN, SET.
  1226. X * 3) objects can have multiple actions.
  1227. X * 4) backquoted strings in actions get executed at action time.
  1228. X */
  1229. X
  1230. /* This routine should evaluate a command using an appropriate shell
  1231. X * and return the data from stdout in the a character buffer.
  1232. X *
  1233. X * This implementation uses popen() to do this. There may be faster ways on
  1234. X * some systems but this is reasonably portable.
  1235. X */
  1236. X
  1237. #include <stdio.h>
  1238. #include <string.h>
  1239. X
  1240. #if defined _POSIX_SOURCE
  1241. #include <unistd.h>
  1242. #endif
  1243. X
  1244. #if defined __STDC__ || defined __stdc__
  1245. #include <stdlib.h>
  1246. #else
  1247. #if defined AIXV3 || defined sun || defined ultrix
  1248. #include <stdlib.h>
  1249. #else
  1250. extern char* malloc();
  1251. #endif
  1252. #endif     
  1253. X
  1254. #include "eval_command.h"
  1255. #include "string_buf.h"
  1256. X
  1257. /* evaluate a back-quoted command */
  1258. #define CBUF_LEN 20000
  1259. static char comm_buf[CBUF_LEN];
  1260. X
  1261. char* eval_command( comm )
  1262. char* comm;
  1263. {
  1264. FILE* in;
  1265. int num,pos;
  1266. char *ret;
  1267. string_buf *buffer;
  1268. X
  1269. if( (in = popen( comm, "r" )) == (FILE*)0 ) {
  1270. X   perror("eval_command"); 
  1271. X   exit(-1);
  1272. }
  1273. X
  1274. buffer = buf_start();
  1275. X
  1276. while( (num = fread( comm_buf, 1, CBUF_LEN, in )) != 0 ){
  1277. X    buf_cat( buffer, comm_buf, num );   
  1278. };
  1279. pclose( in );
  1280. X
  1281. /* trim off trailing whitespace */
  1282. buf_trim( buffer, " \t\n" );
  1283. X
  1284. ret = buf_fetch( buffer );
  1285. X
  1286. buf_free( buffer );
  1287. X
  1288. return ret;
  1289. }
  1290. SHAR_EOF
  1291. chmod 0664 xtpanel/eval_command.c ||
  1292. echo 'restore of xtpanel/eval_command.c failed'
  1293. Wc_c="`wc -c < 'xtpanel/eval_command.c'`"
  1294. test 2031 -eq "$Wc_c" ||
  1295.     echo 'xtpanel/eval_command.c: original size 2031, current size' "$Wc_c"
  1296. fi
  1297. # ============= xtpanel/help/general ==============
  1298. if test ! -d 'xtpanel/help'; then
  1299.     echo 'x - creating directory xtpanel/help'
  1300.     mkdir 'xtpanel/help'
  1301. fi
  1302. if test -f 'xtpanel/help/general' -a X"$1" != X"-c"; then
  1303.     echo 'x - skipping xtpanel/help/general (File already exists)'
  1304. else
  1305. echo 'x - extracting xtpanel/help/general (Text)'
  1306. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/help/general' &&
  1307. X
  1308. DESCRIPTION
  1309. X     xtpanel provides a quick and easy way of producing  a  panel
  1310. X     containing interactive objects such as buttons, sliders, and
  1311. X     text fields, either from the command line or from an xtpanel
  1312. X     script file.  Each panel object maintains a string represen-
  1313. X     tation of its value. When the object is modified it  updates
  1314. X     its  value  and it can also perform one or more actions such
  1315. X     as printing its value or calling a system  command.  Objects
  1316. X     can  make use of the values of other objects in constructing
  1317. X     their actions and they can set the values of  other  objects
  1318. X     as  the  result of an action. The result is an interactive X
  1319. X     windows program, without the need for conventional  program-
  1320. X     ming.
  1321. X
  1322. X
  1323. X     Three utilities are provided with xtpanel. The  first  is  a
  1324. X     script  generator.  This  is a collection af xtpanel scripts
  1325. X     that can be used  to  generate,  examine  and  test  xtpanel
  1326. X     script  files.  It  is  invoked  using  the command xtpanel-
  1327. X     generator.  The second utility is a  collection  of  example
  1328. X     scripts  and a master script that can be use to view and run
  1329. X     the examples. It  is  invoked  using  the  command  xtpanel-
  1330. X     examples.   A  particularly  powerful  demo  is the "lister"
  1331. X     script example, which is a tool for  maneuvering  through  a
  1332. X     Unix filesystem and viewing files at any level. The third is
  1333. X     a set of xtpanel  scripts  that  present  information  about
  1334. X     xtpanel,  mostly taken from this manual page, in an interac-
  1335. X     tive, menu-driven form. This is  invoked  by  doing  xtpanel
  1336. X     -help.
  1337. X
  1338. X
  1339. OBJECT TYPES
  1340. X     xtpanel supports the following objects:
  1341. X
  1342. X
  1343. X     message   Displays a single line of text.
  1344. X
  1345. X
  1346. X     text      Displays multiple lines of text  in  a  scrollable
  1347. X               area. Can be read-write or read-only.
  1348. X
  1349. X
  1350. X     dialog    Provides an editable text field, with a label  and
  1351. X               an OK button.
  1352. X
  1353. X
  1354. X     button    A single button.
  1355. X
  1356. X
  1357. X     toggle    A button that can be toggled between two states.
  1358. X
  1359. X
  1360. X     slider    Allows the user to choose a value from a range  of
  1361. X               integer or floating point values.
  1362. X
  1363. X
  1364. X     scrollbar Similar to a slider, but simpler in appearance.
  1365. X
  1366. X
  1367. X     choice    A group of buttons,  only  one  of  which  may  be
  1368. X               selected at a time.
  1369. X
  1370. X
  1371. X     menubutton
  1372. X               A button with a menu attached.
  1373. X
  1374. X
  1375. X     list      A list of character strings, only one of which may
  1376. X               be selected at a time.
  1377. X
  1378. X
  1379. X     graph     An object containing a number of scrollbars,  each
  1380. X               of  which  controls  the value for one sample of a
  1381. X               list of numbers.
  1382. X
  1383. X
  1384. X     var       A variable that has no screen  representation  but
  1385. X               stores a value.
  1386. X
  1387. X
  1388. X     In addition there  are  several  objects  that  group  other
  1389. X     objects  together  in  boxes.  Grouping  objects in this way
  1390. X     allows greater control of the panel layout. See the  section
  1391. X     below on BOXES.
  1392. X
  1393. DESCRIPTION OF OBJECTS AND SCRIPT SYNTAX
  1394. X     Here is a more detailed  description  of  the  objects,  the
  1395. X     parameters  relevant  to  each,  and the syntax for building
  1396. X     these objects in a script file.
  1397. X
  1398. X     The general format for specifying an object in a script file
  1399. X     is:
  1400. X
  1401. X     objecttype={ parameter=value ... }
  1402. X
  1403. X     Note that no spaces are allowed between the objecttype  and
  1404. X     the "{".
  1405. X
  1406. X     Each "value" can take one of four forms: A  single  word,  a
  1407. X     string  enclosed in single quotes, string enclosed in double
  1408. X     quotes, a system command enclosed  in  backquotes.  See  the
  1409. X     section  "SCRIPT SYNTAX DETAILS" for more information on the
  1410. X     syntax.
  1411. X
  1412. X
  1413. X     There are four parameters that many objects have in  common,
  1414. X     these are: name, label, action and value.
  1415. X
  1416. X     name is the name of the object. The  name  serves  two  pur-
  1417. X     poses,  it  can  be referred to by other objects who wish to
  1418. X     obtain the  or  modify  the  string  representation  of  the
  1419. X     object.
  1420. X
  1421. X     The name can also be used in modifying the appearance of  an
  1422. X     object using the X-toolkit resource mechanism.
  1423. X
  1424. X     When names are referred to by other objects they start  with
  1425. X     a  dollar  sign  and  optionally  an opening brace. They are
  1426. X     assumed to end at the next space or closing brace. Therefore
  1427. X     a name may not contain spaces, braces or dollar signs.
  1428. X
  1429. X     label is the label that appears on the object. By default it
  1430. X     is  the  set to the name. It will appear in an "appropriate"
  1431. X     place which depends on the object type. Some objects do  not
  1432. X     have  labels,  the  label  parameter  is  ignored  for these
  1433. X     objects.
  1434. X
  1435. X     value is the initial string value associate with the object.
  1436. X     If  the object is modified this string value will change. It
  1437. X     defaults to be the same as label.
  1438. X
  1439. X     action is an action that occurs when the button is  pressed.
  1440. X     Defaults to "NONE", which means that the button simply main-
  1441. X     tains a string, containing  its  value,  for  use  by  other
  1442. X     objects.   Other actions are PRINT (print string to standard
  1443. X     output), SYSTEM (execute a command),  STRING  (reformat  the
  1444. X     internal  representation  of  the  object's value, where the
  1445. X     string can contain more than  just  the  object's  value)  ,
  1446. X     ASSIGN  (set  another object's value to a given string), SET
  1447. X     (set an attribute of an object; e.g. color ) and QUIT  (quit
  1448. X     xtpanel). See the section below on ACTIONS for more details.
  1449. X     If more than one action is present the actions will be  per-
  1450. X     formed in the order that they are specified.
  1451. SHAR_EOF
  1452. chmod 0664 xtpanel/help/general ||
  1453. echo 'restore of xtpanel/help/general failed'
  1454. Wc_c="`wc -c < 'xtpanel/help/general'`"
  1455. test 5609 -eq "$Wc_c" ||
  1456.     echo 'xtpanel/help/general: original size 5609, current size' "$Wc_c"
  1457. fi
  1458. # ============= xtpanel/help/message ==============
  1459. if test -f 'xtpanel/help/message' -a X"$1" != X"-c"; then
  1460.     echo 'x - skipping xtpanel/help/message (File already exists)'
  1461. else
  1462. echo 'x - extracting xtpanel/help/message (Text)'
  1463. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/help/message' &&
  1464. X
  1465. X     message
  1466. X        A message displays a single line  of  text  on  a  panel.
  1467. X        Messages  are  used to give short instructions or bits of
  1468. X        information to the user. The script syntax for a  message
  1469. X        is:
  1470. X
  1471. X        message={  value=.... name=.... }
  1472. X
  1473. X        The most important variable in a message  object  is  the
  1474. X        value.  The  value  is  the text that is displayed on the
  1475. X        screen. The name is relevant for tailoring the appearance
  1476. X        of  this  message object using resources or assigning new
  1477. X        values to the message. If a new value is assigned to  the
  1478. X        message the text will change to reflect the new value.
  1479. X
  1480. X        example:
  1481. X        message={ value=" hello world, I am a message object " }
  1482. X
  1483. X        Assigning a new value  to  a  message  object  (using  an
  1484. X        ASSIGN action) will change the text that is displayed.
  1485. SHAR_EOF
  1486. chmod 0664 xtpanel/help/message ||
  1487. echo 'restore of xtpanel/help/message failed'
  1488. Wc_c="`wc -c < 'xtpanel/help/message'`"
  1489. test 874 -eq "$Wc_c" ||
  1490.     echo 'xtpanel/help/message: original size 874, current size' "$Wc_c"
  1491. fi
  1492. # ============= xtpanel/help/objects ==============
  1493. if test -f 'xtpanel/help/objects' -a X"$1" != X"-c"; then
  1494.     echo 'x - skipping xtpanel/help/objects (File already exists)'
  1495. else
  1496. echo 'x - extracting xtpanel/help/objects (Text)'
  1497. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/help/objects' &&
  1498. X
  1499. OBJECT TYPES
  1500. X     xtpanel supports the following objects:
  1501. X
  1502. X
  1503. X     message   Displays a single line of text.
  1504. X
  1505. X
  1506. X     text      Displays multiple lines of text  in  a  scrollable
  1507. X               area. Can be read-write or read-only.
  1508. X
  1509. X
  1510. X     dialog    Provides an editable text field, with a label  and
  1511. X               an OK button.
  1512. X
  1513. X
  1514. X     button    A single button.
  1515. X
  1516. X
  1517. X     toggle    A button that can be toggled between two states.
  1518. X
  1519. X
  1520. X     slider    Allows the user to choose a value from a range  of
  1521. X               integer or floating point values.
  1522. X
  1523. X
  1524. X     scrollbar Similar to a slider, but simpler in appearance.
  1525. X
  1526. X
  1527. X     choice    A group of buttons,  only  one  of  which  may  be
  1528. X               selected at a time.
  1529. X
  1530. X
  1531. X     menubutton
  1532. X               A button with a menu attached.
  1533. X
  1534. X
  1535. X     list      A list of character strings, only one of which may
  1536. X               be selected at a time.
  1537. X
  1538. X
  1539. X     graph     An object containing a number of scrollbars,  each
  1540. X               of  which  controls  the value for one sample of a
  1541. X               list of numbers.
  1542. X
  1543. X
  1544. X     var       A variable that has no screen  representation  but
  1545. X               stores a value.
  1546. X
  1547. X
  1548. X     In addition there  are  several  objects  that  group  other
  1549. X     objects  together  in  boxes.  Grouping  objects in this way
  1550. X     allows greater control of the panel layout. See the  section
  1551. X     below on BOXES.
  1552. SHAR_EOF
  1553. chmod 0664 xtpanel/help/objects ||
  1554. echo 'restore of xtpanel/help/objects failed'
  1555. Wc_c="`wc -c < 'xtpanel/help/objects'`"
  1556. test 1367 -eq "$Wc_c" ||
  1557.     echo 'xtpanel/help/objects: original size 1367, current size' "$Wc_c"
  1558. fi
  1559. # ============= xtpanel/help/text ==============
  1560. if test -f 'xtpanel/help/text' -a X"$1" != X"-c"; then
  1561.     echo 'x - skipping xtpanel/help/text (File already exists)'
  1562. else
  1563. echo 'x - extracting xtpanel/help/text (Text)'
  1564. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/help/text' &&
  1565. X
  1566. X     text
  1567. X        A text object displays any number of lines of text  in  a
  1568. X        multi-line scrollable region.
  1569. X
  1570. X        text={ action=... name=.... value=... editType=... }
  1571. X
  1572. X        The value is the text to  be  displayed  on  the  screen.
  1573. X        Newlines  in the value will cause the text to start a new
  1574. X        line.  The name is relevant for tailoring the  appearance
  1575. X        of  this  text  object  using resources  or assigning new
  1576. X        values to the message. If a new value is assigned to  the
  1577. X        text  the  text  will  change  to  reflect the new value.
  1578. X        editType is used to select whether editing of the text is
  1579. X        allowed. Choices are read (read-only), append (can add to
  1580. X        text but not modify existing text), edit (read-write).
  1581. X
  1582. X        Assigning a new value to a text object  will  change  the
  1583. X        text that is displayed.
  1584. X
  1585. X        examples:
  1586. X        text={ value="I am a multiline \n  text  object  \n  with
  1587. X        three lines" }
  1588. X        text={ value=`cat README` }
  1589. SHAR_EOF
  1590. chmod 0664 xtpanel/help/text ||
  1591. echo 'restore of xtpanel/help/text failed'
  1592. Wc_c="`wc -c < 'xtpanel/help/text'`"
  1593. test 1012 -eq "$Wc_c" ||
  1594.     echo 'xtpanel/help/text: original size 1012, current size' "$Wc_c"
  1595. fi
  1596. # ============= xtpanel/help/dialog ==============
  1597. if test -f 'xtpanel/help/dialog' -a X"$1" != X"-c"; then
  1598.     echo 'x - skipping xtpanel/help/dialog (File already exists)'
  1599. else
  1600. echo 'x - extracting xtpanel/help/dialog (Text)'
  1601. sed 's/^X//' << 'SHAR_EOF' > 'xtpanel/help/dialog' &&
  1602. X
  1603. X     dialog
  1604. X        A dialog displays an editable line of text. Syntax:
  1605. X
  1606. X        dialog={ label=... value=... name=... action=... }
  1607. X
  1608. X        name   defaults  to  "dialog1",  "dialog2"  etc.    label
  1609. X        appears  above  the  text  field.  value is the text that
  1610. X        initially appears in the text field.  A value of "" means
  1611. X        that  the text field will initially be blank.  action: An
  1612. X        "ok" button is added to the panel, and the dialog  object
  1613. X        is activated when this button is pressed.
  1614. X
  1615. X        Assigning a new value to a dialog changes  the  displayed
  1616. X        string to the new value.
  1617. X
  1618. X        example:
  1619. X        dialog={ label="Filename to edit" value=""  action="xterm
  1620. X        -e vi $val" }
  1621. SHAR_EOF
  1622. chmod 0664 xtpanel/help/dialog ||
  1623. echo 'restore of xtpanel/help/dialog failed'
  1624. Wc_c="`wc -c < 'xtpanel/help/dialog'`"
  1625. test 720 -eq "$Wc_c" ||
  1626.     echo 'xtpanel/help/dialog: original size 720, current size' "$Wc_c"
  1627. fi
  1628. true || echo 'restore of xtpanel/help/button failed'
  1629. echo End of part 7, continue with part 8
  1630. exit 0
  1631. -----------------------------------------------------------------
  1632. Steve Cole  (steve@sep.stanford.edu, apple!sep!steve)
  1633. Department of Geophysics, Stanford University, Stanford, CA 94305
  1634.