home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / lout2.lzh / LOUT2 / DOC / TR.LOUT / ch1.01 < prev    next >
Text File  |  1994-01-25  |  7KB  |  169 lines

  1. @Section
  2.   @Title { Objects }
  3.   @Tag { objects }
  4. @Begin
  5. @PP
  6. Since our aim is to produce neatly formatted documents, we should begin by
  7. looking at a typical example of such a document:
  8. @ID {
  9. nohyphen @Break @LittleDocument
  10. //
  11. @LittleText {
  12. @DP
  13. |0.5rt {@B PURCELL}{ 0.8f @Font 1 ^//0.2v}
  14. @LittleFootNote
  15. { { 0.8f @Font 1 ^//0.2v}Blom, Eric.  @I {Some Great Composers.}  Oxford, 1944.
  16. }
  17. @DP
  18. In the world of music England is supposed to be a mere province.  If she
  19. produces an indifferent composer or performer, that is regarded
  20. elsewhere as perfectly normal and natural; but if foreign students of
  21. musical history have to acknowledge a British musical genius, he is
  22. considered a freak.
  23. @PP
  24. Such a freak is Henry Purcell.  Yet if we make a choice of fifteen of
  25. the world's musical classics, as here, we find that we cannot omit this
  26. English master.
  27. }
  28. //
  29. @LittleEndRun
  30. }
  31. It is a large rectangle made from three smaller rectangles -- its
  32. pages.  Each page is made of lines; each line is made of words,
  33. although it makes sense for any rectangle (even a complete document) to
  34. be part of a line, provided it is not too large.
  35. @PP
  36. Lout deals with something a little more complicated than rectangles:
  37. @I objects.  An object
  38. objec @Index { Object }
  39. is a rectangle with at least one @I {column mark}
  40. column.mark @Index { Column mark }
  41. mark.alignment @Index { Mark alignment }
  42. alignment @RawIndex { Alignment @I see mark alignment }
  43. protruding above and below it, and at least one @I {row mark}
  44. row.mark @Index { Row mark }
  45. protruding to the left and right.  The simplest objects contain words like
  46. metempsychosis, and have one mark of each type:
  47. @ID {
  48. @ShowMarks metempsychosis
  49. }
  50. The rectangle exactly encloses the word; its column mark is at the left
  51. edge, and its row mark passes through the middle of the lower-case
  52. letters.  The rectangle and marks do not appear on the printed page, but
  53. to understand what Lout is doing you have to imagine them.
  54. @PP
  55. To place two objects side by side, we separate them by the
  56. symbol @Code "|", which denotes the act of @I {horizontal
  57. concatenation}.  So, if we write
  58. @ID {
  59. @Code "USA  |  Australia"
  60. }
  61. the result will be the object
  62. @ID {
  63. @ShowMarks USA | @ShowMarks Australia
  64. }
  65. Notice that this object has two column marks, but still only one row mark,
  66. because @Code "|" merges the two row marks
  67. together.  This merging of row marks fixes the vertical
  68. position of each object with respect to the other, but it does not
  69. determine how far apart they are.  This distance, or {@I gap},
  70. may be given just after the symbol, as in @Code "|0.5i" for example,
  71. which specifies horizontal concatenation with a gap of half an inch.  If
  72. no gap is given, it is assumed to be {@Code "0i"}.
  73. @PP
  74. @I {Vertical concatenation} & , denoted by the symbol {@Code "/"},
  75. is the same apart from the change of direction:
  76. @ID {
  77. @Code "Australia  /0.1i  USA"
  78. }
  79. has result
  80. @ID {
  81. @ShowMarks Australia /0.1i
  82. @ShowMarks USA
  83. }
  84. The usual merging of marks occurs, and now the gap determines the
  85. vertical separation.  Horizontal and vertical can be combined:
  86. @ID  @Code {
  87.              |1m  USA         |1m  "|0.2i" |1m   Australia
  88. /1vx "/0.1i" |    Washington  |    "|"     |     Canberra
  89. }
  90. has result
  91. @ID {
  92.       @ShowMarks USA &
  93.       { 0 ymark moveto xsize 10 pt add ymark lineto [ 3 pt ] 0 setdash stroke }
  94.       @Graphic {1c @Wide }
  95.       |0.2i @ShowMarks Australia
  96. /0.1i @ShowMarks Washington  |     @ShowMarks Canberra
  97. }
  98. tables @Index { Tables }
  99. There are several things to note carefully here.  White space (including
  100. tabs and newlines) adjacent to a concatenation symbol is ignored, so
  101. it may be used freely to lay out the expression clearly.  The symbol
  102. @Code "|" takes precedence over {@Code "/"}, which means that the rows
  103. are formed first, then vertically concatenated.  The symbol @Code "/" will
  104. merge two or more column marks, creating multiple
  105. columns (and @Code "|" will merge two or more row marks).  This
  106. implies that the gap @Code "0.2i" used above is between
  107. columns, not individual items in columns; a gap in the second row
  108. would therefore be redundant, and so is omitted.
  109. @PP
  110. A variant of @Code "/" called @Code "//" left-justifies
  111. two objects instead of merging their marks.
  112. @PP
  113. By enclosing an object in braces, it is possible to override the
  114. braces @Index { Braces }
  115. set precedences.  Here is another expression for the table
  116. above, in which the columns are formed first:
  117. @ID  @Code {
  118.              |1m "{ USA"       |1m "/0.1i" |1m "Washington }"
  119. /1vx "|0.2i" |   "{ Australia" |   "/"     |   "Canberra }"
  120. }
  121. Braces have no effect other than to alter the grouping.
  122. @PP
  123. @I {Paragraph breaking} occurs when an object is too wide to fit
  124. paragraph.breaking @Index { Paragraph breaking }
  125. into the space available to it; by breaking its paragraphs into lines,
  126. its width is reduced to an acceptable amount.  The available
  127. space is determined by the @@Wide symbol, whose form is
  128. @ID  {
  129. @I length  @@Wide  @I object
  130. }
  131. and whose result is the given object modified to have exactly the given
  132. length.  For example, the expression
  133. @ID  @Code {
  134. "5i @Wide {"
  135. "Macbeth was very ambitious.  This led him to wish to become"
  136. "king of Scotland.  The witches told him that this wish of"
  137. "his would come true.  The king of Scotland at this time was"
  138. "Duncan.  Encouraged by his wife, Macbeth murdered Duncan.  He"
  139. "was thus enabled to succeed Duncan as king.  (51 words)"
  140. "|0.5i"
  141. "Encouraged by his wife, Macbeth achieved his ambition and"
  142. "realized the prediction of the witches by murdering Duncan"
  143. "and becoming king of Scotland in his place.  (26 words)"
  144. "}"
  145. }
  146. has for its result the following five inch wide object [{@Ref strunk79}]:
  147. @ID {
  148. 5i @Wide {
  149. Macbeth was very ambitious.  This led him to wish to become king
  150. of Scotland.  The witches told him that this wish of his would
  151. come true.  The king of Scotland at this time was Duncan.  Encouraged
  152. by his wife, Macbeth murdered Duncan.  He was thus enabled to succeed
  153. Duncan as king.  (51 words)
  154. |0.5i
  155. Encouraged by his wife, Macbeth achieved his ambition and realized
  156. the prediction of the witches by murdering Duncan and becoming king of
  157. Scotland in his place.  (26 words)
  158. }
  159. }
  160. A paragraph of text can be included anywhere, and it will be broken
  161. automatically if necessary to fit the available space.  The spaces
  162. between words are converted by Lout into concatenation symbols.
  163. @PP
  164. These are the most significant of Lout's object-building symbols.  There
  165. are others, for changing fonts, controlling paragraph breaking, printing
  166. graphical objects like boxes and circles, and so on, but
  167. they do not add anything new in principle.
  168. @End @Section
  169.