home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2029 < prev    next >
Internet Message Format  |  1990-12-28  |  62KB

  1. From: lab@and.cs.liv.ac.uk
  2. Newsgroups: alt.sources
  3. Subject: JUSTIFY macros for XEDIT (written in REXX)
  4. Message-ID: <1990Nov5.204846.4363@and.cs.liv.ac.uk>
  5. Date: 5 Nov 90 19:48:46 GMT
  6.  
  7. Here is a collection of CMS XEDIT macros (written in REXX by Eric Thomas
  8. ERIC@SEARN.BITNET - note the change of net address from the macro 
  9. headers).
  10.  
  11. In submitting this, I've tried to keep to the rules for comp.sources.misc
  12. and hence the shar format (CMS users I'm sure can manage :-)).
  13. Please note that some lines are longer than 80 characters. This is just
  14. to warn those whose mailers may chop at column 81.....
  15.  
  16. Alan Thew
  17. qq11@liverpool.ac.uk
  18. mcsun!ukc!liv!qq11
  19.  
  20. Submitted-by: qq11@liv.ac.uk
  21. Archive-name: justify/part01
  22.  
  23. ---- Cut Here and feed the following to sh ----
  24. #!/bin/sh
  25. # This is justify, a shell archive (produced by shar 3.49)
  26. # To extract the files from this archive, save it to a file, remove
  27. # everything above the "!/bin/sh" line above, and type "sh file_name".
  28. #
  29. # made 10/30/1990 23:42 UTC by qq11@liv.ac.uk
  30. # Source directory /users/u5/qcl/qq11/work
  31. #
  32. # existing files will NOT be overwritten unless -c is specified
  33. #
  34. # This shar contains:
  35. # length  mode       name
  36. # ------ ---------- ------------------------------------------
  37. #    126 -rw------- MANIFEST
  38. #  13319 -rw------- jf.xedit
  39. #  10354 -rw------- jm.xedit
  40. #  12986 -rw------- justify.memo
  41. #   5894 -rw------- prefixb.xedit
  42. #   5979 -rw------- prefixj.xedit
  43. #   7424 -rw------- prefixtf.xedit
  44. #
  45. # ============= MANIFEST ==============
  46. if test -f 'MANIFEST' -a X"$1" != X"-c"; then
  47.     echo 'x - skipping MANIFEST (File already exists)'
  48. else
  49. echo 'x - extracting MANIFEST (Text)'
  50. sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST' &&
  51. XJF       XEDIT    C1
  52. XJM       XEDIT    C1
  53. XJUSTIFY  MEMO     C1
  54. XPREFIXB  XEDIT    C1
  55. XPREFIXJ  XEDIT    C1
  56. XPREFIXTF XEDIT    C1
  57. SHAR_EOF
  58. chmod 0600 MANIFEST ||
  59. echo 'restore of MANIFEST failed'
  60. Wc_c="`wc -c < 'MANIFEST'`"
  61. test 126 -eq "$Wc_c" ||
  62.     echo 'MANIFEST: original size 126, current size' "$Wc_c"
  63. fi
  64. # ============= jf.xedit ==============
  65. if test -f 'jf.xedit' -a X"$1" != X"-c"; then
  66.     echo 'x - skipping jf.xedit (File already exists)'
  67. else
  68. echo 'x - extracting jf.xedit (Text)'
  69. sed 's/^X//' << 'SHAR_EOF' > 'jf.xedit' &&
  70. X/***********************************************************************
  71. X *                                                                     *
  72. X * JF -- Justify and Flow XEDIT macro, release 2                       *
  73. X *                                                                     *
  74. X *       (c) Eric Thomas 1987          (ERIC at FRECP11)               *
  75. X *                                                                     *
  76. X * This file was last updated on Saturday, January the 9th of 1988     *
  77. X *                                                                     *
  78. X * This XEDIT macro was originally written to justify MAILER-format or *
  79. X * IBM NOTE-format files  and was intended to be issued  from the MAIL *
  80. X * or NOTE exec just before pressing the  PF5 key to send the note. It *
  81. X * performs as the PREFIXTF (qqv) macro,  except that all lines in the *
  82. X * body of the mail item are  formatted and that any line extending up *
  83. X * to column 79  is concatenated with the following line  to allow you *
  84. X * to enter text as a "continuous  stream" without having to resort to *
  85. X * POWER INPUT mode.                                                   *
  86. X *                                                                     *
  87. X * Please refer  to PREFIXTF  XEDIT and  JUSTIFY MEMO  (available from *
  88. X * Netserv) for more information in the formatting process.            *
  89. X *                                                                     *
  90. X * Syntax: JF  <nn | ? | <L<nn>> <R<nn>>> <QUIET> <RAgged>             *
  91. X *             <PLpl<,tm<,bm>>> <PN<T|B>>                              *
  92. X *                                                                     *
  93. X * - JF alone will justify the whole file. For NOTE or MAIL files, the *
  94. X *   header is left unchanged. Otherwise the whole file is justified.  *
  95. X *                                                                     *
  96. X * - JF nn indicates that output text should be formatted with a right *
  97. X *   margin of  'nn'. The default  is to  format output text  with the *
  98. X *   same right  margin as input. For  example, if the person  you are *
  99. X *   mailing  to  has  a  40-columns  terminal  (such  as  the  french *
  100. X *   MINITEL), you  can use JF  40 to make sure  that he will  have no *
  101. X *   problem  reading your  mail.  Using  JF 70  makes  sure that  the *
  102. X *   mailfile  can be  read without  problem under  XEDIT or  the ISPF *
  103. X *   editor  with prefixes  on,  even if  the  note gets  subsequently *
  104. X *   quoted by a "REPLY TEXT" or suchlike.                             *
  105. X *                                                                     *
  106. X * - JF ? queries the status of the left and right margins.            *
  107. X *                                                                     *
  108. X * - L<nn> redefines  the Left margin. If  you omit 'nn', you  will be *
  109. X *   asked to move the cursor to the desired column and press ENTER.   *
  110. X *                                                                     *
  111. X * - R<nn> similarly redefines the Right margin.                       *
  112. X *                                                                     *
  113. X * - The QUIET option suppresses the information message which is dis- *
  114. X *   played when  margins are  changed. This is  very useful  when you *
  115. X *   call  JF from  your  PROFILE XEDIT  to  select different  default *
  116. X *   options.                                                          *
  117. X *                                                                     *
  118. X|* - The RAgged  option causes  the text to  be formatted  with ragged *
  119. X|*   right.                                                            *
  120. X|*                                                                     *
  121. X|* - The PL option allows you to  define a page length, top margin and *
  122. X|*   bottom margin.  The default  top and bottom  margins are  2 lines *
  123. X|*   each, and  the default  page length  is OFF  (continuous output). *
  124. X|*   These options are particularly useful  when running JF on a piece *
  125. X|*   of  INCOMING  mail  with  the  intent  of  neatening  it  up  and *
  126. X|*   subsequently printing it  on a line printer  without running over *
  127. X|*   the page perforations.                                            *
  128. X|*                                                                     *
  129. X|* - The PN option is meaningful  only when specified together with PL *
  130. X|*   and orders JF to number  the output pages. The optional parameter *
  131. X|*   indicates whether pages  must be numbered on the Top  lines or on *
  132. X|*   the Bottom  lines (the default is  Top). The page number  will be *
  133. X|*   printed on the  first (or last) line if  the corresponding margin *
  134. X|*   is set to 1 or 2, or after a blank line if the margin is set to 3 *
  135. X|*   or more. I will of course not  be printed if the margin is set to *
  136. X|*   0.                                                                *
  137. X *                                                                     *
  138. X *                                                                     *
  139. X * The default values are L1; R73 if PREFIX ON is in effect, R78 other *
  140. X * wise.                                                               *
  141. X *                                                                     *
  142. X * 08 Mar 1987: Change right margin after a  'JF nn' call if nn is not *
  143. X *              the current  right margin. Allow  'JF nn' where  nn is *
  144. X *              larger than the present right margin.                  *
  145. X *                                                                     *
  146. X * 08 Mar 1987: Some fixes that can't be explained in 4-5 lines...     *
  147. X *                                                                     *
  148. X * 09 Mar 1987: Fix for right margin = 80.                             *
  149. X *                                                                     *
  150. X * 29 May 1987: Allow use of JF on incoming mail.                      *
  151. X *              New options: RAgged, PLpl<,tm<,bm>> and PN<T|B>        *
  152. X *                                                                     *
  153. X * 09 Jan 1988: Change MAIL identification algorithm and processing    *
  154. X *              to solve problems with RICE mail.                      *
  155. X *                                                                     *
  156. X ***********************************************************************/
  157. X Arg options
  158. X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Trunc'
  159. X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
  160. X Parse pull xfn xft xfm lmarg rmarg minl .
  161. X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
  162. X  Do
  163. X    lmarg = 1
  164. X    If prefix.1 ^= 'OFF'
  165. X     Then Do
  166. X            rmarg = 73
  167. X            minl = 62
  168. X          End
  169. X     Else Do
  170. X            rmarg = 78
  171. X            minl = 66
  172. X          End
  173. X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1 ftype.1 fmode.1 lmarg rmarg minl
  174. X  End
  175. X JMopt = ''
  176. X orgline = line.1
  177. X newrmarg = rmarg
  178. X pl = 0
  179. X tm = 2
  180. X bm = 2
  181. X pn = 'O'
  182. X format = 1
  183. X ragged = 0
  184. X Do Words(options)
  185. X    Parse var options opt options
  186. X    Select
  187. X      When Datatype(opt,'W') & opt > 0 Then newrmarg = opt
  188. X      When opt == '?' Then
  189. X       Do
  190. X         'COMMAND MSG Left margin:' lmarg', Right margin:' rmarg'.'
  191. X          format = 0
  192. X       End
  193. X      When Abbrev('OFF',opt,1) Then Call Error 'Text Flow operation cannot be undone'
  194. X      When Left(opt,2) == 'PL' Then
  195. X       Do
  196. X         Parse var opt 'PL'pl','tm','bm
  197. X         If pl = '' Then Signal Missarg
  198. X         If tm = '' Then tm = 2
  199. X         If bm = '' Then bm = 2
  200. X         If ^Datatype(pl||tm||bm,'W') | pl ^> 0 | tm < 0 | bm < 0
  201. X            Then Signal Invarg
  202. X         If tm+bm ^< pl Then Call Error 'Top and bottom margins exceed page length'
  203. X       End
  204. X      When Left(opt,2) == 'PN' Then
  205. X       Do
  206. X         Parse var opt 'PN'pn
  207. X         If pn = '' Then pn = 'T'
  208. X         If pn ^= 'T' & pn ^= 'B' Then Call Error 'Invalid page numbering option -- "'opt'"'
  209. X       End
  210. X      When Abbrev('RAGGED',opt,3) Then ragged = 1
  211. X      Otherwise JMopt = JMopt opt
  212. X    End
  213. X End
  214. X If newrmarg < lmarg+2 | newrmarg > trunc.1 Then Call Error 'New right margin exceeds allowable boundaries'
  215. X If JMopt ^= '' Then
  216. X  Do
  217. X    'STATE JM XEDIT'
  218. X     If rc ^== 0 Then Call Error 'File "JM XEDIT" not found',28
  219. X    'MACRO JM' JMopt
  220. X     Exit rc
  221. X  End
  222. X If ^format Then Exit 0
  223. X'COMMAND PRESERVE'
  224. X'COMMAND SET LINEND OFF'
  225. X'COMMAND SET IMAGE OFF'
  226. X'COMMAND SET SCOPE ALL'
  227. X'COMMAND SET AUTOSAVE OFF'
  228. X accents = '@{}:?]XDKa*J-\X 
  229. X/* You may wish not to consider accentuated characters as alphabetical
  230. X    ones,  especially since  some of  them are  regular characters  on
  231. X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
  232. X    character). In  that case, remove  the "||accents" portion  of the
  233. X    following statement.   */
  234. X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||,
  235. X            '0123456789()"'':;'||accents
  236. X If ftype.1 = 'NOTE'
  237. X  Then 'COMMAND :6 COMMAND FIND _______'
  238. X  Else If Not_Mail() Then 'COMMAND TOP'
  239. X'COMMAND EXTRACT /Line'
  240. X hdrline = line.1
  241. X t. = ''
  242. X r. = ''
  243. X n. = 1
  244. X index = 1
  245. X il = 1
  246. X previndent = -2
  247. X ll = rmarg-lmarg+1
  248. X maxmarg = Max(80,rmarg+1)
  249. X Do forever
  250. X   'COMMAND NEXT'
  251. X    If rc ^== 0 Then Leave
  252. X   'COMMAND EXTRACT /Curline'
  253. X    line = Substr(curline.3,lmarg,ll)
  254. X    If Right(t.index,1) == ' '
  255. X     Then indent = Verify(line'A',alphabet,'M')
  256. X     Else indent = 1
  257. X    l.index.il = Left(curline.3,lmarg-1)Left(line,indent-1)
  258. X    previl = il
  259. X    If Length(l.index.il) > newrmarg Then Call Spill_L
  260. X    If rmarg = 78 & Substr(curline.3,79,1) ^== ' '
  261. X     Then line = Substr(curline.3,lmarg,ll+1)
  262. X     Else r.index.il = Substr(curline.3,rmarg+1)
  263. X    line = Substr(line,indent,maxmarg-indent)
  264. X    If line = '' Then
  265. X     Do
  266. X       Call Close_Par
  267. X       previndent = 0
  268. X       Iterate
  269. X     End
  270. X    Select
  271. X      When previndent = indent Then nop
  272. X      When previndent = -2 Then previndent = -1
  273. X      When previndent = -1 Then previndent = indent
  274. X      Otherwise
  275. X        Call Close_Par
  276. X        il = il-1
  277. X        previndent = -1
  278. X    End
  279. X    t.index = t.index||line
  280. X    il = il+1
  281. X End
  282. X n.index = il-1
  283. X If n.index = 0 Then index = index-1
  284. X lc = 1
  285. X pg = 1
  286. X Select
  287. X   When pn == 'O' Then nop
  288. X   When pn == 'B' Then
  289. X    If bm > 2 Then po = 'COMMAND -1'
  290. X              Else po = ''
  291. X   When pn == 'T' Then
  292. X    Do
  293. X      If tm > 2 Then po = 2-tm
  294. X                Else po = 1-tm
  295. X      If po = 0 Then po = ''
  296. X                Else po = 'COMMAND' po
  297. X    End
  298. X End
  299. X pe = pl-bm+1
  300. X toldspill = 0
  301. X'COMMAND :'hdrline
  302. X Do i = 1 to index
  303. X    If n.i = 0 Then Iterate
  304. X    If t.i = '' Then
  305. X     Do
  306. X       Call Input Left(l.i.1,newrmarg)r.i.1
  307. X       Iterate
  308. X     End
  309. X    il = 1
  310. X    t = Space(t.i)
  311. X    Do until t = ''
  312. X       xl = newrmarg-Length(l.i.il)+1
  313. X       j = Lastpos(' ',t' ',xl)
  314. X       If j == 0 Then Call Spill
  315. X       line = Left(t,j-1)
  316. X       t = Strip(Substr(t,j))
  317. X       If ^ragged & t ^== '' Then line = Justify(line,xl-1)
  318. X       Call Input Left(l.i.il||line,newrmarg)r.i.il
  319. X       If il ^= n.i Then il = il+1
  320. X    End
  321. X End
  322. X If pn = 'B' Then
  323. X  Do
  324. X    'COMMAND ADD' pe-lc+bm
  325. X    'COMMAND NEXT' pe-lc+bm
  326. X     Call Page
  327. X  End
  328. X'COMMAND SET MSGMODE OFF'
  329. X'COMMAND +1 COMMAND DELETE *'
  330. X'COMMAND :'orgline 'COMMAND RESTORE'
  331. X If newrmarg = rmarg Then Exit
  332. X minl = Format(minl*(newrmarg-lmarg+1)/(rmarg-lmarg+1),,0)
  333. X Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1 ftype.1 fmode.1 lmarg newrmarg minl
  334. X'COMMAND MSG Note: right margin has been adjusted to' newrmarg'.'
  335. X Exit
  336. XInput:
  337. X Select
  338. X   When pl == 0 Then nop
  339. X   When lc == 1 Then Call Top_Margin
  340. X   When lc == pe Then Call Bottom_Margin
  341. X   Otherwise lc = lc+1
  342. X End
  343. X'COMMAND INPUT' Arg(1)
  344. X Return
  345. XTop_Margin:
  346. X lc = tm+2
  347. X If tm == 0 Then Return
  348. X'COMMAND ADD' tm
  349. X'COMMAND NEXT' tm
  350. X If pn == 'T' Then Call Page
  351. X Return
  352. XBottom_Margin:
  353. X If bm ^== 0 Then
  354. X  Do
  355. X    'COMMAND ADD' bm
  356. X    'COMMAND NEXT' bm
  357. X     If pn == 'B' Then Call Page
  358. X  End
  359. X Call Top_Margin
  360. X Return
  361. XPage:
  362. X po 'COMMAND REPLACE' Left('',newrmarg-9) 'Page' Right(pg,3)
  363. X pg = pg+1
  364. X If po = '' Then Return
  365. X Translate(po,'+','-')
  366. X Return
  367. XClose_Par:
  368. X n.index = previl-1
  369. X i = index
  370. X index = index+1
  371. X Do j = 1 for il-previl+1
  372. X    l.index.j = l.i.previl
  373. X    r.index.j = r.i.previl
  374. X    previl = previl+1
  375. X End
  376. X il = j
  377. X Return
  378. XSpill:
  379. X xl = Max(xl,2)
  380. X j = xl
  381. X If toldspill Then Return
  382. X toldspill = 1
  383. X'COMMAND EMSG Text flow operation caused words to be spilled.'
  384. X Return
  385. XSpill_L:
  386. X If l.index.il = '' Then
  387. X  Do
  388. X    l.index.il = ' ' /* Purposefully leave one 1 blank */
  389. X    Return
  390. X  End
  391. X Do while Length(l.index.il) > newrmarg
  392. X    xline = Substr(l.index.il,newrmarg+1)
  393. X    l.index.il = Left(l.index.il,newrmarg)
  394. X    il = il+1
  395. X    l.index.il = xline
  396. X End
  397. X Return
  398. XMissarg:
  399. X Call Error 'Missing argument'
  400. XInvarg:
  401. X Call Error 'Invalid argument'
  402. XError:
  403. X Parse arg msg,retcode
  404. X If retcode == '' Then retcode = 24
  405. X'COMMAND EMSG' msg'.'
  406. X Exit retcode
  407. XNot_Mail:
  408. X'COMMAND TOP'
  409. X'COMMAND +1 COMMAND EXTRACT /Curline'
  410. X If Pos(':',curline.3) == 0 Then Return 1
  411. X Parse upper var curline.3 tag ':'
  412. X If Words(tag) ^== 1 Then Return 1
  413. X If Find('RECEIVED DATE RESENT-DATE',tag) == 0 Then Return 1
  414. X banner = Copies('=',70)
  415. X Do forever
  416. X   'COMMAND NEXT'
  417. X    If rc ^== 0 Then Return 1
  418. X   'COMMAND EXTRACT /Curline'
  419. X    If curline.3 = '' | Left(curline.3,70) = banner Then Return 0
  420. X End
  421. SHAR_EOF
  422. chmod 0600 jf.xedit ||
  423. echo 'restore of jf.xedit failed'
  424. Wc_c="`wc -c < 'jf.xedit'`"
  425. test 13319 -eq "$Wc_c" ||
  426.     echo 'jf.xedit: original size 13319, current size' "$Wc_c"
  427. fi
  428. # ============= jm.xedit ==============
  429. if test -f 'jm.xedit' -a X"$1" != X"-c"; then
  430.     echo 'x - skipping jm.xedit (File already exists)'
  431. else
  432. echo 'x - extracting jm.xedit (Text)'
  433. sed 's/^X//' << 'SHAR_EOF' > 'jm.xedit' &&
  434. X/***********************************************************************
  435. X *                                                                     *
  436. X * JM -- Justify Mail XEDIT macro, release 2                           *
  437. X *                                                                     *
  438. X *       (c) Eric Thomas 1986          (ERIC at FRECP11)               *
  439. X *                                                                     *
  440. X * This file was last updated on Friday, February the 27th of 1987     *
  441. X *                                                                     *
  442. X * This XEDIT macro was originally written to justify MAILER-format or *
  443. X * IBM NOTE-format files  and was intended to be issued  from the MAIL *
  444. X * or NOTE exec just before pressing the  PF5 key to send the note. It *
  445. X * respects  indentation, starting  its justification  process at  the *
  446. X * first alphabetical  character encountered within  the justification *
  447. X * margins. The justification  margins, as well as  the minimum number *
  448. X * of characters that are required for  a line to be justified, can be *
  449. X * altered and will remain active for the current file.                *
  450. X *                                                                     *
  451. X * Please see also the JF (Justify  and Flow) macro. It is recommended *
  452. X * that JF be used instead of  JM whenever possible, that is, when the *
  453. X * mailfile contains only  pure text (no drawings, no  boxes, etc). JF *
  454. X * usually gives much  better results than JM, and also  allows you to *
  455. X * choose the number of columns of the resulting output.               *
  456. X *                                                                     *
  457. X *                                                                     *
  458. X * Syntax: JM  <Off | ? | <L<nn>> <R<nn>> <nn | nn%>>> <QUIET>         *
  459. X *                                                                     *
  460. X * - JM alone will justify the whole file. For NOTE or MAIL files, the *
  461. X *   header is left unchanged. Otherwise the whole file is justified.  *
  462. X *                                                                     *
  463. X * - JM Off will undo the justification process, if needed.            *
  464. X *                                                                     *
  465. X * - JM  ? queries  the status  of  the margins  and minimum  required *
  466. X *   length for justification.                                         *
  467. X *                                                                     *
  468. X * - L<nn> redefines  the Left margin. If  you omit 'nn', you  will be *
  469. X *   asked to move the cursor to the desired column and press ENTER.   *
  470. X *                                                                     *
  471. X * - R<nn> similarly redefines the Right margin.                       *
  472. X *                                                                     *
  473. X * - nn redefines the minimum number of characters that the portion of *
  474. X *   the line that is between the justification margins should have in *
  475. X *   order to get justified. If one  of the margins is changed without *
  476. X *   a new 'nn' being justified, the value will be automatically adjus *
  477. X *   ted in the  same proportions as the previous  value. For example, *
  478. X *   if JM L1 R73 66 is in effect, entering JM L10 will cause the mini *
  479. X *   mum required length to be automatically adjusted to 58.           *
  480. X *                                                                     *
  481. X * - nn% redefines the minimum required  length as a percentage of the *
  482. X *   total  available space  between  justification margins.  Example: *
  483. X *   JM L10 R50 90% and JM L10 R50 37 lead to the same result.         *
  484. X *                                                                     *
  485. X * - The QUIET option suppresses the information message which is dis- *
  486. X *   played when  margins are  changed. This is  very useful  when you *
  487. X *   call  JM from  your  PROFILE XEDIT  to  select different  default *
  488. X *   options.                                                          *
  489. X *                                                                     *
  490. X * The default values are L1; R73 if PREFIX ON is in effect, R78 other *
  491. X * wise; 85% minimum required size.                                    *
  492. X *                                                                     *
  493. X *  3 Feb 1986: changed default right margin  from 79 to 78 for compa- *
  494. X *              tibility with the JF macro.                            *
  495. X *                                                                     *
  496. X * 20 Feb 1986: JM failed to recognize the header of resent mail.      *
  497. X *                                                                     *
  498. X * 22 Feb 1986: minimum required  length  redefined to 85%  for better *
  499. X *              results.                                               *
  500. X *                                                                     *
  501. X * 27 Feb 1986: incorrect  results  when  first TAB  not in  column 1. *
  502. X *              AUTOSAVE  may  get   triggered  several  times  during *
  503. X *              execution of the macro.                                *
  504. X *                                                                     *
  505. X ***********************************************************************/
  506. X Arg options
  507. X If Abbrev('OFF',options,1) Then Do
  508. X                                   options = ''
  509. X                                   off = 1
  510. X                                 End
  511. X                            Else off = 0
  512. X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM'
  513. X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
  514. X Pull xfn xft xfm lmarg rmarg minl .
  515. X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
  516. X  Do
  517. X    lmarg = 1
  518. X    If prefix.1 ^= 'OFF' Then Do
  519. X                                rmarg = 73
  520. X                                minl = 62
  521. X                              End
  522. X                         Else Do
  523. X                                rmarg = 78
  524. X                                minl = 66
  525. X                              End
  526. X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
  527. X     ftype.1 fmode.1 lmarg rmarg minl
  528. X  End
  529. X If options ^= '' Then Signal Setup
  530. X'COMMAND PRESERVE'
  531. X'COMMAND SET LINEND OFF'
  532. X'COMMAND SET IMAGE OFF'
  533. X'COMMAND SET AUTOSAVE OFF'
  534. X accents = '@{}:?]XDKa*J-\X 
  535. X/* You may wish not to consider accentuated characters as alphabetical
  536. X    ones,  especially since  some of  them are  regular characters  on
  537. X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
  538. X    character). In  that case, remove  the "||accents" portion  of the
  539. X    following statement.   */
  540. X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||accents
  541. X If ftype.1 = 'NOTE'
  542. X  Then 'COMMAND :6 COMMAND FIND _______'
  543. X  Else Do /* Check for MAIL files */
  544. X         'COMMAND TOP'
  545. X         'COMMAND +1 COMMAND EXTRACT /Curline'
  546. X          Parse upper var curline.3 tag ':'
  547. X          If Words(tag) = 1 & Find('DATE RESENT-DATE',tag) ^= 0
  548. X           Then 'COMMAND LOCATE /=============='
  549. X           Else 'COMMAND TOP'
  550. X       End
  551. X maxl = minl+lmarg-1
  552. X jc = rmarg + 1
  553. X If ^off
  554. X  Then /* Separate Do...End for better speed */
  555. X   Do forever
  556. X     'COMMAND NEXT'
  557. X      If rc ^= 0 Then Leave
  558. X     'COMMAND EXTRACT /Curline'
  559. X      start = Verify(curline.3,alphabet,'MATCH',lmarg)
  560. X      If start = 0 | start >= rmarg Then Iterate
  561. X      If Length(Strip(Left(curline.3,rmarg),'T')) < maxl Then Iterate
  562. X     'COMMAND REPLACE' Left(curline.3,start-1)Justify(Substr(curline.3,start,jc-start),jc-start)Substr(curline.3,jc)
  563. X   End
  564. X  Else
  565. X   Do forever
  566. X     'COMMAND NEXT'
  567. X      If rc ^= 0 Then Leave
  568. X     'COMMAND EXTRACT /Curline'
  569. X      start = Verify(curline.3,alphabet,'MATCH',lmarg)
  570. X      If start = 0 | start > rmarg Then Iterate
  571. X     'COMMAND REPLACE' Left(curline.3,start-1)Left(Space(Substr(curline.3,start,jc-start)),jc-start)Substr(curline.3,jc)
  572. X  End
  573. X'COMMAND :'line.1 'COMMAND RESTORE'
  574. X Exit
  575. XSetup:
  576. X'EXTRACT /LRECL'
  577. X pct = 0
  578. X newmin = 0
  579. X didlist = 0
  580. X quiet = 0
  581. X prev = rmarg-lmarg+1
  582. X Do Words(options)
  583. X    Parse var options opt options
  584. X    Select
  585. X      When Left(opt,1) = 'L' Then Call Nalieva
  586. X      When Left(opt,1) = 'R' Then Call Naprava
  587. X      When Right(opt,1) = '%' Then Call Percent
  588. X      When opt = 'QUIET' Then quiet = 1
  589. X      When opt = '?' Then Call List
  590. X      Otherwise
  591. X        minl = Decparm(1)
  592. X        newmin = 1
  593. X    End
  594. X End
  595. X If rmarg ^> lmarg Then
  596. X  Do
  597. X    'COMMAND EMSG Left margin cannot exceed right margin.'
  598. X     Exit
  599. X  End
  600. X If pct Then minl = Format(minl*(rmarg-lmarg+1)/100,,0)
  601. X If newmin & minl > rmarg-lmarg+1 Then
  602. X  Do
  603. X    'COMMAND EMSG Minimum required length exceeds total length.'
  604. X     Exit
  605. X  End
  606. X If ^newmin Then
  607. X  Do
  608. X    oldml = minl
  609. X    minl = Format((rmarg-lmarg+1)*(minl/prev),,0)
  610. X    If ^quiet & oldml ^= minl Then
  611. X     'COMMAND MSG Minimum required length has been adjusted according',
  612. X       'to previous proportions.'
  613. X  End
  614. X Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1 ftype.1,
  615. X  fmode.1 lmarg rmarg minl
  616. X Call List
  617. X Exit
  618. XList:
  619. X  If didlist | quiet Then Return
  620. X  didlist = 1
  621. X 'COMMAND MSG Left margin:' lmarg', Right margin:' rmarg||,
  622. X   ', Minimum length:' minl '('Format(100*minl/(rmarg-lmarg+1),,0)'%)'
  623. X  Return
  624. XPercent:
  625. X  pct = 1
  626. X  newmin = 1
  627. X  Parse var opt opt'%'
  628. X  minl = Decparm(1,'')
  629. X  If minl > 100 Then
  630. X   Do
  631. X     'COMMAND EMSG Invalid percentage value.'
  632. X      Exit
  633. X   End
  634. X  Return
  635. XNalieva:
  636. X  lmarg = Decparm(2,'Left margin',lmarg)
  637. X  If lmarg > lrecl.1 Then
  638. X   Do
  639. X     'COMMAND EMSG Left margin should not exceed LRECL.'
  640. X      Exit
  641. X   End
  642. X  Return
  643. XNaprava:
  644. X  rmarg = Decparm(2,'Right margin',rmarg)
  645. X  If rmarg > lrecl.1 Then
  646. X   Do
  647. X     'COMMAND EMSG Right margin should not exceed LRECL.'
  648. X      Exit
  649. X   End
  650. X  Return
  651. XDecparm:
  652. X  Parse arg x,title,y
  653. X  arg = Substr(opt,x)
  654. X  If arg = '' Then
  655. X   Do 1
  656. X      If title = '' Then Leave
  657. X     'COMMAND MSG Position cursor on the' title 'and press ENTER.'
  658. X      If y > lrecl.1 Then y = lrecl.1
  659. X     'COMMAND CURSOR FILE' line.1 y
  660. X      Address COMMAND 'MAKEBUF'
  661. X     'COMMAND READ'
  662. X      Address COMMAND 'DROPBUF'
  663. X     'COMMAND EXTRACT /Cursor'
  664. X     'COMMAND CURSOR CMDLINE'
  665. X      If cursor.4 > 0 Then Return cursor.4
  666. X     'COMMAND EMSG Invalid cursor location.'
  667. X      Exit
  668. X   End
  669. X  If Datatype(arg,'W') & arg > 0 Then Return arg
  670. X 'COMMAND EMSG Invalid argument -- "'opt'".'
  671. X  Exit
  672. SHAR_EOF
  673. chmod 0600 jm.xedit ||
  674. echo 'restore of jm.xedit failed'
  675. Wc_c="`wc -c < 'jm.xedit'`"
  676. test 10354 -eq "$Wc_c" ||
  677.     echo 'jm.xedit: original size 10354, current size' "$Wc_c"
  678. fi
  679. # ============= justify.memo ==============
  680. if test -f 'justify.memo' -a X"$1" != X"-c"; then
  681.     echo 'x - skipping justify.memo (File already exists)'
  682. else
  683. echo 'x - extracting justify.memo (Text)'
  684. sed 's/^X//' << 'SHAR_EOF' > 'justify.memo' &&
  685. X  Installation and programming logic information for the JUSTIFY package
  686. X   --------------------------------------------------------------------
  687. X                    Revision date: 8 March 1987
  688. XHistory of changes: moved to the comments area in the affected macros.
  689. X*-----------------------------------------------------------------------*
  690. X|
  691. X|  There are two distinct sub-packages in the JUSTIFY package:
  692. X|
  693. X|   - The PREFIXJ -  PREFIXB - JM package which  performs text justifica-
  694. X|     tion on a line per line basis.
  695. X|
  696. X|   - The PREFIXTF - JF package which performs "text flow" and justifica-
  697. X|     tion on a paragraph per paragraph basis.
  698. X|
  699. X|   The installation procedure is identical for the two sub-packages, and
  700. X| has not been  revised. A detailed description of  the programming logic
  701. X| involved in the Text Flow package can be found at the end of this memo.
  702. X|
  703. X|   The following lines are the original description of the package which
  704. X| I have not had time to rewrite:
  705. X|
  706. X| Part I -- The Justification sub-package
  707. X|
  708. X    This  package  consists  in  three   XEDIT  macros:  two  new  prefix
  709. X  subcommands  (J/Jnnn/JJ...JJ and  B/Bnnn/BB...BB) to  justify/unjustify
  710. X  text, and one  command-line macro, JM, to justify a  whole file at once
  711. X  from  the command-  line. JM  originally stood  for "Justify  Mail" and
  712. X  supported only  MAIL files from  the MAIL/MAILBOOK environment.  It was
  713. X  later upgraded  to support IBM  NOTEs as  well, and finally  suffered a
  714. X  major rewrite before  being made available on Netserv in  an attempt to
  715. X  raise it  to the same level  of quality as the  other Netserv programs.
  716. X  This is  the reason  why there  are special cases  for the  handling of
  717. X  NOTEs and MAIL files in the code.
  718. X    Before  starting to  use the  prefix  commands you  must modify  your
  719. X  PROFILE XEDIT  file to include  synonym definitions for the  new prefix
  720. X  subcommands since they are not provided in the standard IBM set:
  721. X    SET PREFIX SYNONYM J  PREFIXJ
  722. X    SET PREFIX SYNONYM JJ PREFIXJ
  723. X    SET PREFIX SYNONYM B  PREFIXB
  724. X    SET PREFIX SYNONYM BB PREFIXB
  725. X|   SET PREFIX SYNONYM TF PREFIXTF
  726. X    These lines can be added nearly anywhere, preferrably before or after
  727. X  the regular synonym definitions, if any.
  728. X    The justification  process performed  by the  three macros  will take
  729. X  place  between  user-modifiable  "justification margins".  The  default
  730. X  values for  these margins are column  1 for the left  margin and either
  731. X| column 73 or 78 for the right margin, depending on whether you run with
  732. X  PREFIX ON or OFF. These default  values correspond to the proper values
  733. X  for  justifying IBM  NOTE and  RFC822 MAIL  files, respectively.  It is
  734. X  important  to note  that anything  that  might appear  after the  right
  735. X  margin  (or before  the  left margin)  will be  left  unchanged; it  is
  736. X  therefore  necessary to  make sure  that the  right margin  is expanded
  737. X  whenever lines  longer than 73  characters are to be  justified (unless
  738. X  PREFIX  OFF  was  in  effect  and   the  lines  were  smaller  than  80
  739. X  characters).
  740. X    These "justification parameters" are local  to each file in the XEDIT
  741. X  ring and  will remain valid for  the XEDIT session, ie  until you QUIT;
  742. X  however, if you immediately recall the  file you have just QUITted, the
  743. X  previous justification  parameters will  be recalled  and you  will not
  744. X  have  to provide  them  again. This  does  not occur  if  you recall  a
  745. X  different file, of course.
  746. X    Additionally,  the actual  justification  process will  start at  the
  747. X  first  alphabetical  character  encountered  within  the  justification
  748. X  margins. This allows for indentation and sub-paragraphs to be respected
  749. X  by the justification process:
  750. X     - This line has been justified with margins of 1 and 73, and yet the
  751. X       leading blanks and dash were not "squeezed" in the process.
  752. X    If  the portion  of the  line  between the  justification margins  is
  753. X  smaller than a  certain amount of characters, it will  not be expanded.
  754. X  This                                                             avoids
  755. X  justifying               lines               like               that...
  756. X  This "minimum  required number of  characters" can be redefined  by the
  757. X  user in one of two ways:
  758. X  1) An absolute value
  759. X  2) A percentage  of the size  of the "justification area".  The default
  760. X|    value is precisely expressed as 85% of the justification area.
  761. X    Furthermore, if one or both  of the justification margins are changed
  762. X  without the "minimum  required number of characters"  being altered, JM
  763. X  will  automatically  expand or  reduce  it  according to  the  previous
  764. X| proportions. For  example, if you  change from the default  settings of
  765. X| margins 1 and 73 and minimum length 62 (ie 85% of 73) to margins 10 and
  766. X| 50, the minimum length will be  automatically changed to 35 (85% of 41)
  767. X  to stay in proportions with the previous value.
  768. X    The  justification parameters  can  be  changed by  means  of the  JM
  769. X  command, and  will affect both  JM and PREFIXJ/PREFIXB  operations. The
  770. X  syntax is:
  771. X               JM  <L<nn>> <R<nn>> <nn | nn%>
  772. X  - Lnn  and  Rnn indicate  the  left  and right  justification  margins,
  773. X    respectively. If 'nn' is omitted you will be required to position the
  774. X    cursor on the  desired column and press ENTER.  The original position
  775. X    of the cursor will be the last value of the corresponding margin.
  776. X  - nn  and nn%  indicate a  new value  for the  minimum required  length
  777. X    parameter, either as an absolute  number or expressed as a percentage
  778. X    of the size of the justification area.
  779. X  Examples:
  780. X    JM L1 R 80% -- left margin  = 1
  781. X                   right margin to be modified using the cursor keys
  782. X                   new minimum is 80% of justification area
  783. X    JM R70      -- left margin  = unchanged
  784. X                   right margin = 70
  785. X                   minimum will be adjusted according to the previous
  786. X                   proportions
  787. X    You can query the status of the justification parameters by issuing a
  788. X  'JM ?' command. Please refer to  the block comments at the beginning of
  789. X  the various macros for a more detailed description of their syntax.
  790. X|
  791. X| Part II -- The Text Flow sub-package
  792. X|
  793. X|   There are only  two macros in the Text Flow  sub-package, JF (similar
  794. X| to JM)  and PREFIXTF which implements  the TF block prefix  command. As
  795. X| Text Flow cannot  be undone, there is no equivalent  to the B/BB prefix
  796. X| command.
  797. X|
  798. X|   The algorithms  used by JF and  TF are slightly different  because JF
  799. X| was designed  to be invoked  from the  MAIL environment mainly.  It can
  800. X| also be called  from the NOTE environment but it  is NOT recommended to
  801. X| blindly use  JF on  a non-mail  file as this  might lead  to unexpected
  802. X| results. The differences  between the two algorithms  will be explained
  803. X| later.
  804. X|
  805. X|   JF and TF are similar to JM  and JJ in that they will operate between
  806. X| a left  margin and a right  margin, and will preserve  anything outside
  807. X| those margins.  JF/TF and JM/JJ  use the  same GLOBALV storage  to keep
  808. X| those margins  which are therefore shared  between JM and JF:  a JM L10
  809. X| command has exactly the same effect  as JF L10. However, JF/TF will not
  810. X| use the "minimum required length" parameter at all as they will justify
  811. X| ALL the lines in each paragraph, except the last one.
  812. X|
  813. X|   Another important  difference between JF/TF  and JM/JJ is  that JF/TF
  814. X| can reformat text using a different output right margin, ie a different
  815. X| number of columns for output. This  "output right margin" is called the
  816. X| "reformatting margin". The default is of  course to use the input right
  817. X| margin as reformatting margin.
  818. X|
  819. X|   A short description of the Text Flow algorithm used by both JF and TF
  820. X| follows.  Please refer  to the  macros for  more details  on the  exact
  821. X| implementation.
  822. X|
  823. X|
  824. X| Step 1: Process the input lines and split them in paragraph units.
  825. X|
  826. X|   The input text  is read in, analyzed and stored  in an internal array
  827. X|   of "paragraph units". A "break" between two paragraph units is caused
  828. X|   by one of the following:
  829. X|
  830. X|    - A blank line: a blank line causes a break and is preserved.
  831. X|
  832. X|    - A change in  indention, except between the two first  lines of the
  833. X|      paragraph  unit.  That is,  the  first  and  second line  of  each
  834. X|      paragraph can  have different indentions without  causing a break.
  835. X|      Those indentions  will be  respected in the  output text.  A break
  836. X|      caused by a change in indention  does NOT generate any blank line.
  837. X|
  838. X|   For each paragraph  unit, JF/TF maintains an internal  array of "left
  839. X|   keep" and "right keep", one "keep" of  each type for each line in the
  840. X|   input paragraph.
  841. X|
  842. X|     - The "right  keep" is the data  in the input line  after the right
  843. X|       margin (possibly null string).
  844. X|
  845. X|     - The "left  keep" is the  data in the  input line before  the left
  846. X|       margin, concatenated  with any "non-alphanumeric" bytes  that may
  847. X|       have been found  at the beginning of the actual  "data line". The
  848. X|       definition of "non-alphanumeric"  can be found in  the macros and
  849. X|       it differs from that of JM/JJ. Note that blanks are considered as
  850. X|       non-alphanumeric characters.
  851. X|
  852. X|     - Whenever the left keep  length exceeds the "reformatting margin",
  853. X|       null input lines are generated and  the left keep is split across
  854. X|       those  new lines,  with  each  new left  keep  generated in  this
  855. X|       fashion  not exceeding  the reformatting  margin. That  is, JF/TF
  856. X|       acts as  if the large left  keep had been found  on several input
  857. X|       lines, each of  them having a left keep smaller  than or equal to
  858. X|       the reformatting margin and being  otherwise empty. This does not
  859. X|       apply when the left keep contains  only blanks: in that case, the
  860. X|       left  keep is  forced  to a  single  blank and  no  null line  is
  861. X|       generated  as those  null lines  would only  result in  pointless
  862. X|       blank lines in the output text.
  863. X|
  864. X|   Finally, the concatenated contents of  each paragraph unit is kept in
  865. X|   an internal array.
  866. X|
  867. X| Step 2: Produce output lines according to the reformatting margin.
  868. X|
  869. X|   Each paragraph unit will then be  reformatted and produce one or more
  870. X|   output lines.  The indention of  all the  lines in a  given paragraph
  871. X|   will be  the same, except  that the first  line might be  undented or
  872. X|   outdented. The data  portions of all the lines in  the paragraph unit
  873. X|   except the last  one will be unconditionally justified.  The left and
  874. X|   right "keeps" will not be justified of course.
  875. X|
  876. X|   It is  however possible  for the  output paragraph  to be  smaller or
  877. X|   longer than  the input one. In  this case a special  handling must be
  878. X|   performed on the "keeps":
  879. X|
  880. X|    - If the  output paragraph is smaller  than the input one,  the last
  881. X|      (unused) keeps will be discarded. Another solution would have been
  882. X|      to  generate null  lines  to  make sure  that  all  the keeps  are
  883. X|      preserved,  but  this would  have  been  very impractical  in  the
  884. X|      majority of case.
  885. X|
  886. X|    - If the  output paragraph is  longer, the  last keep is  re-used as
  887. X|      many times as  required to make sure that all  the extra lines are
  888. X|      properly indented. This may not necessarily be what you wanted but
  889. X|      it seems to be the best solution.
  890. X|
  891. X|   Note  that if  the reformatting  margin is  different from  the input
  892. X|   right  margin, the  right  keep  may end  up  at  a different  column
  893. X|   position than it originally was. This is perfectly normal.
  894. X|
  895. X| Step 3: Delete the original input lines.
  896. X|
  897. X|
  898. X|
  899. X| JF  is  slightly different  from  TF  and  will perform  the  following
  900. X| additional steps:
  901. X|
  902. X|  - When the input  right margin is set  to 78, lines which  have a non-
  903. X|    blank character in column 79 will be pasted with the next line. This
  904. X|    allows  MAIL users  to  enter  text without  having  to worry  about
  905. X|    physical  line size,  and to  reformat it  later. This  is also  the
  906. X|    reason why the default right margin was changed to 78: running JF on
  907. X|    a piece of  text formatted with the R79 option  would be most likely
  908. X|    to cause disastrous results...
  909. X|
  910. X|  - When you specify  a reformatting margin different  from the original
  911. X|    right margin, the  right margin will be changed  to the reformatting
  912. X|    margin you specified upon completion  of the reformatting process in
  913. X|    order to avoid problems if you subsequently call JF on the mail file
  914. X|    again. Try  the following  sequence on  a dummy  mailfile originally
  915. X|    containing text in columns 1-50 only:
  916. X|
  917. X|      o JF  70  (reformats text  for  70  columns).  A  JF R70  is  then
  918. X|        automatically issued.
  919. X|
  920. X|      o JF R50 to cancel the previous internal JF R70.
  921. X|
  922. X|      o JF 50  to format the text  back in 50 columns mode.  As you will
  923. X|        see the result is not precisely what you would have expected...
  924. X|
  925. SHAR_EOF
  926. chmod 0600 justify.memo ||
  927. echo 'restore of justify.memo failed'
  928. Wc_c="`wc -c < 'justify.memo'`"
  929. test 12986 -eq "$Wc_c" ||
  930.     echo 'justify.memo: original size 12986, current size' "$Wc_c"
  931. fi
  932. # ============= prefixb.xedit ==============
  933. if test -f 'prefixb.xedit' -a X"$1" != X"-c"; then
  934.     echo 'x - skipping prefixb.xedit (File already exists)'
  935. else
  936. echo 'x - extracting prefixb.xedit (Text)'
  937. sed 's/^X//' << 'SHAR_EOF' > 'prefixb.xedit' &&
  938. X/***********************************************************************
  939. X *                                                                     *
  940. X * PREFIXB -- Justification XEDIT prefix macro, release 2              *
  941. X *                                                                     *
  942. X *       (c) Eric Thomas 1986          (ERIC at FRECP11)               *
  943. X *                                                                     *
  944. X * This file was last updated on Friday, February the 27th of 1987     *
  945. X *                                                                     *
  946. X * This macro is the counterpart of PREFIXJ and defines an un-justifi- *
  947. X * cation prefix: B, Bnnnn, BB...BB. All lines subjected to the B pre- *
  948. X * fix  will be  unjustified with  all multiple  blanks being  removed *
  949. X * between  the justification  margins.  See "JM  XEDIT" and  "JUSTIFY *
  950. X * MEMO" (available from Netserv) for more information.                *
  951. X *                                                                     *
  952. X * Your PROFILE XEDIT must be modified in order to define the name you *
  953. X * want to give the justify synonym. The following two lines should be *
  954. X * added to  PROFILE XEDIT,  for example  immediately after  all other *
  955. X * synonym definitions:                                                *
  956. X *                                                                     *
  957. X *   SET PREFIX SYNONYM B  PREFIXB                                     *
  958. X *   SET PREFIX SYNONYM BB PREFIXB                                     *
  959. X *                                                                     *
  960. X * You may substitute  any other name for  B or BB if  those names are *
  961. X * already in use.                                                     *
  962. X *                                                                     *
  963. X *  3 Feb 1986: changed default right margin  from 79 to 78 for compa- *
  964. X *              tibility with the JF macro.                            *
  965. X *                                                                     *
  966. X * 22 Feb 1986: minimum required  length  redefined to 85%  for better *
  967. X *              results.                                               *
  968. X *                                                                     *
  969. X * 27 Feb 1986: incorrect  results  when  first TAB  not in  column 1. *
  970. X *              AUTOSAVE  may  get   triggered  several  times  during *
  971. X *              execution of the macro.                                *
  972. X *                                                                     *
  973. X ***********************************************************************/
  974. X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Size/Cursor'
  975. X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
  976. X Pull xfn xft xfm lmarg rmarg minl .
  977. X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
  978. X  Do
  979. X    lmarg = 1
  980. X    If prefix.1 ^= 'OFF' Then Do
  981. X                                rmarg = 73
  982. X                                minl = 62
  983. X                              End
  984. X                         Else Do
  985. X                                rmarg = 78
  986. X                                minl = 66
  987. X                              End
  988. X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
  989. X     ftype.1 fmode.1 lmarg rmarg minl
  990. X  End
  991. X jc = rmarg + 1
  992. X maxl = minl+lmarg-1
  993. X Arg prefix operand pline op rest
  994. X Parse Source . . . . . name .
  995. X prf=name||Space(op rest)
  996. X If prefix ^= 'PREFIX' Then
  997. X  Call Error1 "8 646E 'PREFIXB' must be invoked from the prefix area."
  998. X If operand = 'CLEAR' Then Exit
  999. X'COMMAND PRESERVE'
  1000. X'COMMAND SET LINEND OFF'
  1001. X'COMMAND SET IMAGE OFF'
  1002. X'COMMAND SET AUTOSAVE OFF'
  1003. X accents = '@{}:?]XDKa*J-\X 
  1004. X/* You may wish not to consider accentuated characters as alphabetical
  1005. X    ones,  especially since  some of  them are  regular characters  on
  1006. X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
  1007. X    character). In  that case, remove  the "||accents" portion  of the
  1008. X    following statement.   */
  1009. X alphabet = xrange('a','z')||xrange('A','Z')||accents
  1010. X Select
  1011. X   When Length(name) = 1 Then
  1012. X    Do
  1013. X      If rest ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
  1014. X      If op = '' Then op = 1
  1015. X      If op = '*' Then op = size.1
  1016. X      If Datatype(op,'W') & op > 0
  1017. X       Then
  1018. X        Do
  1019. X         'COMMAND :'pline
  1020. X          Do Format(op,,0)
  1021. X             Call Justifyline
  1022. X            'COMMAND NEXT'
  1023. X             pline = pline + 1
  1024. X             If pline > size.1 Then Leave
  1025. X          End
  1026. X          Signal Closeup
  1027. X        End
  1028. X      Else Call Error "0 659E Invalid prefix subcommand:" prf
  1029. X    End
  1030. X   When Length(name) = 2 Then
  1031. X    Do
  1032. X      If op ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
  1033. X     'COMMAND EXTRACT /PENDING BLOCK' name ':0 :'pline '/'
  1034. X      If pending.0 ^= 0
  1035. X       Then
  1036. X        Do
  1037. X          'COMMAND :'pending.1 'COMMAND SET PENDING OFF'
  1038. X           Do pline-pending.1+1
  1039. X              Call Justifyline
  1040. X             'COMMAND NEXT'
  1041. X              pending.1 = pending.1 + 1
  1042. X              If pending.1 > size.1 Then Leave
  1043. X           End
  1044. X           Signal Closeup
  1045. X        End
  1046. X       Else 'COMMAND :'pline 'COMMAND SET PENDING BLOCK' Left(prf,5)
  1047. X    End
  1048. X   Otherwise Call Error "0 686E Synonym '"name"' not recognized by prefix macro 'PREFIXB'."
  1049. X End
  1050. X'COMMAND RESTORE'
  1051. X Exit
  1052. XCloseup:
  1053. X  'COMMAND :'line.1 'COMMAND RESTORE'
  1054. X  'COMMAND CURSOR SCREEN' cursor.5 cursor.6 'PRIORITY 40'
  1055. X   Exit
  1056. XError:
  1057. X  'COMMAND :'pline 'COMMAND SET PENDING ERROR' Left(prf,5)
  1058. X  'COMMAND RESTORE'
  1059. XError1:
  1060. X  Parse arg err msg
  1061. X  If msg ^= '' Then 'COMMAND EMSG PXJ'Strip(msg)
  1062. X  Exit err
  1063. XJustifyline:
  1064. X 'COMMAND EXTRACT /Curline'
  1065. X  start = Verify(curline.3,alphabet,'MATCH',lmarg)
  1066. X  If start = 0 | start > rmarg Then Return
  1067. X 'COMMAND REPLACE' Left(curline.3,start-1)Left(Space(Substr(curline.3,start,jc-start)),jc-start)Substr(curline.3,jc)
  1068. X  Return
  1069. SHAR_EOF
  1070. chmod 0600 prefixb.xedit ||
  1071. echo 'restore of prefixb.xedit failed'
  1072. Wc_c="`wc -c < 'prefixb.xedit'`"
  1073. test 5894 -eq "$Wc_c" ||
  1074.     echo 'prefixb.xedit: original size 5894, current size' "$Wc_c"
  1075. fi
  1076. # ============= prefixj.xedit ==============
  1077. if test -f 'prefixj.xedit' -a X"$1" != X"-c"; then
  1078.     echo 'x - skipping prefixj.xedit (File already exists)'
  1079. else
  1080. echo 'x - extracting prefixj.xedit (Text)'
  1081. sed 's/^X//' << 'SHAR_EOF' > 'prefixj.xedit' &&
  1082. X/***********************************************************************
  1083. X *                                                                     *
  1084. X * PREFIXJ -- Justification XEDIT prefix macro, release 2              *
  1085. X *                                                                     *
  1086. X *       (c) Eric Thomas 1986          (ERIC at FRECP11)               *
  1087. X *                                                                     *
  1088. X * This file was last updated on Friday, February the 27th of 1987     *
  1089. X *                                                                     *
  1090. X * This macro can  be used to define a justification  prefix to XEDIT: *
  1091. X * J, Jnnnn, JJ...JJ.  The selected lines will be  justified using the *
  1092. X * same algorithm and parameters as the  JM macro, to which you should *
  1093. X * refer for  more details  on the  justification process  itself. See *
  1094. X * also file "JUSTIFY MEMO" from Netserv.                              *
  1095. X *                                                                     *
  1096. X * Your PROFILE XEDIT must be modified in order to define the name you *
  1097. X * want to give the justify synonym. The following two lines should be *
  1098. X * added to  PROFILE XEDIT,  for example  immediately after  all other *
  1099. X * synonym definitions:                                                *
  1100. X *                                                                     *
  1101. X *   SET PREFIX SYNONYM J  PREFIXJ                                     *
  1102. X *   SET PREFIX SYNONYM JJ PREFIXJ                                     *
  1103. X *                                                                     *
  1104. X * You may substitute  any other name for  J or JJ if  those names are *
  1105. X * already in use.                                                     *
  1106. X *                                                                     *
  1107. X *  3 Feb 1986: changed default right margin  from 79 to 78 for compa- *
  1108. X *              tibility with the JF macro.                            *
  1109. X *                                                                     *
  1110. X * 22 Feb 1986: minimum required  length  redefined to 85%  for better *
  1111. X *              results.                                               *
  1112. X *                                                                     *
  1113. X * 27 Feb 1986: incorrect  results  when  first TAB  not in  column 1. *
  1114. X *              AUTOSAVE  may  get   triggered  several  times  during *
  1115. X *              execution of the macro.                                *
  1116. X *                                                                     *
  1117. X ***********************************************************************/
  1118. X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Size/Cursor'
  1119. X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
  1120. X Pull xfn xft xfm lmarg rmarg minl .
  1121. X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
  1122. X  Do
  1123. X    lmarg = 1
  1124. X    If prefix.1 ^= 'OFF' Then Do
  1125. X                                rmarg = 73
  1126. X                                minl = 62
  1127. X                              End
  1128. X                         Else Do
  1129. X                                rmarg = 78
  1130. X                                minl = 66
  1131. X                              End
  1132. X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
  1133. X     ftype.1 fmode.1 lmarg rmarg minl
  1134. X  End
  1135. X jc = rmarg + 1
  1136. X maxl = minl+lmarg-1
  1137. X Arg prefix operand pline op rest
  1138. X Parse Source . . . . . name .
  1139. X prf=name||Space(op rest)
  1140. X If prefix ^= 'PREFIX' Then
  1141. X  Call Error1 "8 646E 'PREFIXJ' must be invoked from the prefix area."
  1142. X If operand = 'CLEAR' Then Exit
  1143. X'COMMAND PRESERVE'
  1144. X'COMMAND SET LINEND OFF'
  1145. X'COMMAND SET IMAGE OFF'
  1146. X'COMMAND SET AUTOSAVE OFF'
  1147. X accents = '@{}:?]XDKa*J-\X 
  1148. X/* You may wish not to consider accentuated characters as alphabetical
  1149. X    ones,  especially since  some of  them are  regular characters  on
  1150. X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
  1151. X    character). In  that case, remove  the "||accents" portion  of the
  1152. X    following statement.   */
  1153. X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||accents
  1154. X Select
  1155. X   When Length(name) = 1 Then
  1156. X    Do
  1157. X      If rest ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
  1158. X      If op = '' Then op = 1
  1159. X      If op = '*' Then op = size.1
  1160. X      If Datatype(op,'W') & op > 0
  1161. X       Then
  1162. X        Do
  1163. X         'COMMAND :'pline
  1164. X          Do Format(op,,0)
  1165. X             Call Justifyline
  1166. X            'COMMAND NEXT'
  1167. X             pline = pline + 1
  1168. X             If pline > size.1 Then Leave
  1169. X          End
  1170. X          Signal Closeup
  1171. X        End
  1172. X      Else Call Error "0 659E Invalid prefix subcommand:" prf
  1173. X    End
  1174. X   When Length(name) = 2 Then
  1175. X    Do
  1176. X      If op ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
  1177. X     'COMMAND EXTRACT /PENDING BLOCK' name ':0 :'pline '/'
  1178. X      If pending.0 ^= 0
  1179. X       Then
  1180. X        Do
  1181. X          'COMMAND :'pending.1 'COMMAND SET PENDING OFF'
  1182. X           Do pline-pending.1+1
  1183. X              Call Justifyline
  1184. X             'COMMAND NEXT'
  1185. X              pending.1 = pending.1 + 1
  1186. X              If pending.1 > size.1 Then Leave
  1187. X           End
  1188. X           Signal Closeup
  1189. X        End
  1190. X       Else 'COMMAND :'pline 'COMMAND SET PENDING BLOCK' Left(prf,5)
  1191. X    End
  1192. X   Otherwise Call Error "0 686E Synonym '"name"' not recognized by prefix macro 'PREFIXJ'."
  1193. X End
  1194. X'COMMAND RESTORE'
  1195. X Exit
  1196. XCloseup:
  1197. X  'COMMAND :'line.1 'COMMAND RESTORE'
  1198. X  'COMMAND CURSOR SCREEN' cursor.5 cursor.6 'PRIORITY 40'
  1199. X   Exit
  1200. XError:
  1201. X  'COMMAND :'pline 'COMMAND SET PENDING ERROR' Left(prf,5)
  1202. X  'COMMAND RESTORE'
  1203. XError1:
  1204. X  Parse arg err msg
  1205. X  If msg ^= '' Then 'COMMAND EMSG PXJ'Strip(msg)
  1206. X  Exit err
  1207. XJustifyline:
  1208. X 'COMMAND EXTRACT /Curline'
  1209. X  start = Verify(curline.3,alphabet,'MATCH',lmarg)
  1210. X  If start = 0 | start >= rmarg Then Return
  1211. X  If Length(Strip(Left(curline.3,rmarg),'T')) < maxl Then Return
  1212. X 'COMMAND REPLACE' Left(curline.3,start-1)Justify(Substr(curline.3,start,jc-start),jc-start)Substr(curline.3,jc)
  1213. X  Return
  1214. SHAR_EOF
  1215. chmod 0600 prefixj.xedit ||
  1216. echo 'restore of prefixj.xedit failed'
  1217. Wc_c="`wc -c < 'prefixj.xedit'`"
  1218. test 5979 -eq "$Wc_c" ||
  1219.     echo 'prefixj.xedit: original size 5979, current size' "$Wc_c"
  1220. fi
  1221. # ============= prefixtf.xedit ==============
  1222. if test -f 'prefixtf.xedit' -a X"$1" != X"-c"; then
  1223.     echo 'x - skipping prefixtf.xedit (File already exists)'
  1224. else
  1225. echo 'x - extracting prefixtf.xedit (Text)'
  1226. sed 's/^X//' << 'SHAR_EOF' > 'prefixtf.xedit' &&
  1227. X/***********************************************************************
  1228. X *                                                                     *
  1229. X * PREFIXTF -- Text Flow XEDIT prefix macro, release 2                 *
  1230. X *                                                                     *
  1231. X *       (c) Eric Thomas 1987          (ERIC at FRECP11)               *
  1232. X *                                                                     *
  1233. X * This file was last updated on Sunday, March the 8th of 1987         *
  1234. X *                                                                     *
  1235. X * This macro  can be used  to define a  "Text Flow" prefix  to XEDIT: *
  1236. X * TF<adj>...TF. Text from the selected lines  will be flown in or out *
  1237. X * to produce evenly balanced lines, and will eventually be justified. *
  1238. X * The "input" margins can be defined  by means of the JM macro (qqv), *
  1239. X * while 'adj' defines  the "output" right margin. It  defaults to the *
  1240. X * input right margin and must be  either an absolute column number or *
  1241. X * an offset (+nn or -nn) relative to the input right margin.          *
  1242. X *                                                                     *
  1243. X * Please refer  to file "JUSTIFY  MEMO" (available from  Netserv) for *
  1244. X * more details.                                                       *
  1245. X *                                                                     *
  1246. X * Your PROFILE XEDIT must be modified in order to define the name you *
  1247. X * want to give to the Text  Flow prefix. The following line should be *
  1248. X * added to  PROFILE XEDIT,  for example  immediately after  all other *
  1249. X * synonym definitions:                                                *
  1250. X *                                                                     *
  1251. X *   SET PREFIX SYNONYM TF PREFIXTF                                    *
  1252. X *                                                                     *
  1253. X * You may substitute any other name for TF if this name is already in *
  1254. X * use.                                                                *
  1255. X *                                                                     *
  1256. X * 08 Mar 1987: Some fixes that can't be explained in 4-5 lines...     *
  1257. X *                                                                     *
  1258. X ***********************************************************************/
  1259. X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Size/Cursor/Trunc'
  1260. X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
  1261. X Pull xfn xft xfm lmarg rmarg minl .
  1262. X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
  1263. X  Do
  1264. X    lmarg = 1
  1265. X    If prefix.1 ^= 'OFF' Then Do
  1266. X                                rmarg = 73
  1267. X                                minl = 62
  1268. X                              End
  1269. X                         Else Do
  1270. X                                rmarg = 78
  1271. X                                minl = 66
  1272. X                              End
  1273. X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
  1274. X     ftype.1 fmode.1 lmarg rmarg minl
  1275. X  End
  1276. X Arg prefix function pline op
  1277. X If prefix ^= 'PREFIX' Then
  1278. X  Do
  1279. X    "COMMAND EMSG 'PREFIXTF' must be invoked from the prefix area."
  1280. X     Exit 8
  1281. X  End
  1282. X If function = 'CLEAR' Then Exit 0
  1283. X Parse Source . . . . . name .
  1284. X op = Space(op,0)
  1285. X prefix = name||op
  1286. X'COMMAND PRESERVE'
  1287. X'COMMAND SET LINEND OFF'
  1288. X'COMMAND SET IMAGE OFF'
  1289. X'COMMAND SET AUTOSAVE OFF'
  1290. X accents = '@{}:?]XDKa*J-\X 
  1291. X/* You may wish not to consider accentuated characters as alphabetical
  1292. X    ones,  especially since  some of  them are  regular characters  on
  1293. X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
  1294. X    character). In  that case, remove  the "||accents" portion  of the
  1295. X    following statement.   */
  1296. X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||,
  1297. X            '0123456789()"'':;'||accents
  1298. X'COMMAND EXTRACT /PENDING BLOCK' name ':0 :'pline '/'
  1299. X If pending.0 = 0 Then
  1300. X  Do
  1301. X     If op ^= '' & ^Datatype(op,'W') Then
  1302. X      Call Error '8 Invalid argument -- "'op'".'
  1303. X    'COMMAND :'pline 'COMMAND SET PENDING BLOCK' Left(prefix,5)
  1304. X    'COMMAND RESTORE'
  1305. X     Exit
  1306. X  End
  1307. X If op ^= '' Then
  1308. X  Call Error '0 No argument is allowed on closing prefix ('prefix').'
  1309. X'COMMAND :'pending.1 'COMMAND SET PENDING OFF'
  1310. X If pending.1 = 0 Then pending.1 = 1
  1311. X If pending.5 = ''
  1312. X  Then newrmarg = rmarg
  1313. X  Else Do
  1314. X         op = pending.5
  1315. X         If ^Datatype(op,'W') Then
  1316. X          Call Error '0 Invalid argument -- "'op'".'
  1317. X         Select
  1318. X           When Left(op,1) = '-' Then newrmarg = rmarg - Substr(op,2)
  1319. X           When Left(op,1) = '+' Then newrmarg = rmarg + Substr(op,2)
  1320. X           Otherwise newrmarg = op
  1321. X         End
  1322. X         If newrmarg < lmarg+2 | newrmarg > trunc.1 Then
  1323. X          Call Error '0 New right margin exceeds allowable boundaries.'
  1324. X       End
  1325. X'COMMAND -1'
  1326. X t. = ''
  1327. X n. = 1
  1328. X index = 1
  1329. X il = 1
  1330. X previndent = -2
  1331. X ll = rmarg-lmarg+1
  1332. X Do pline-pending.1+1
  1333. X   'COMMAND NEXT'
  1334. X    If rc ^= 0 Then Leave
  1335. X   'COMMAND EXTRACT /Curline'
  1336. X    line = Substr(curline.3,lmarg,ll)
  1337. X    indent = Verify(line'A',alphabet,'M')
  1338. X    l.index.il = Left(curline.3,lmarg-1)Left(line,indent-1)
  1339. X    r.index.il = Substr(curline.3,rmarg+1)
  1340. X    previl = il
  1341. X    If Length(l.index.il) > newrmarg Then Call Spill_L
  1342. X    line = Substr(line,indent)
  1343. X    If line = '' Then
  1344. X     Do
  1345. X       Call Close_Par
  1346. X       previndent = 0
  1347. X       Iterate
  1348. X     End
  1349. X    Select
  1350. X      When previndent = indent Then nop
  1351. X      When previndent = -2 Then previndent = -1
  1352. X      When previndent = -1 Then previndent = indent
  1353. X      Otherwise
  1354. X        Call Close_Par
  1355. X        il = il - 1
  1356. X        previndent = -1
  1357. X    End
  1358. X    t.index = t.index line
  1359. X    il = il + 1
  1360. X End
  1361. X n.index = il - 1
  1362. X If n.index = 0 Then index = index - 1
  1363. X/*do i = 1 to index;
  1364. Xsay 'T.'i'='t.i;
  1365. Xsay '  n.'i'='n.i
  1366. Xdo j = 1 to 10; if l.i.j == 'L.'i'.'j then iterate
  1367. Xsay '  L.'i'.'j'= >>>'l.i.j'<<<'; end
  1368. Xend*/
  1369. X toldspill = 0
  1370. X'COMMAND :'pending.1 'COMMAND -1'
  1371. X Do i = 1 to index
  1372. X    If n.i = 0 Then Iterate
  1373. X    If t.i = '' Then
  1374. X     Do
  1375. X       'COMMAND INPUT' Left(l.i.1,newrmarg)r.i.1
  1376. X        Iterate
  1377. X     End
  1378. X    il = 1
  1379. X    t = Space(t.i)
  1380. X    Do until t = ''
  1381. X       xl = newrmarg-Length(l.i.il)+1
  1382. X       j = Lastpos(' ',t' ',xl)
  1383. X       If j = 0 Then Call Spill
  1384. X       line = Left(t,j-1)
  1385. X       t = Strip(Substr(t,j))
  1386. X       If t ^= '' Then line = Justify(line,xl-1)
  1387. X      'COMMAND INPUT' Left(l.i.il||line,newrmarg)r.i.il
  1388. X       If il ^= n.i Then il = il + 1
  1389. X    End
  1390. X End
  1391. X'COMMAND MSGMODE OFF'
  1392. X'COMMAND +1 COMMAND DELETE' pline-pending.1+1
  1393. X'COMMAND :'line.1 'COMMAND RESTORE'
  1394. X'COMMAND CURSOR SCREEN' cursor.5 cursor.6 'PRIORITY 40'
  1395. X Exit
  1396. XClose_Par:
  1397. X  n.index = previl - 1
  1398. X  i = index
  1399. X  index = index + 1
  1400. X  Do j = 1 for il-previl+1
  1401. X     l.index.j = l.i.previl
  1402. X     r.index.j = r.i.previl
  1403. X     previl = previl + 1
  1404. X  End
  1405. X  il = j
  1406. X  Return
  1407. XSpill:
  1408. X  xl = Max(xl,2)
  1409. X  j = xl
  1410. X  If toldspill Then Return
  1411. X  toldspill = 1
  1412. X 'COMMAND EMSG Text flow operation caused words to be spilled.'
  1413. X  Return
  1414. XSpill_L:
  1415. X  If l.index.il = '' Then
  1416. X   Do
  1417. X     l.index.il = ' ' /* Purposefully leave one 1 blank */
  1418. X     Return
  1419. X   End
  1420. X  Do while Length(l.index.il) > newrmarg
  1421. X     xline = Substr(l.index.il,newrmarg+1)
  1422. X     l.index.il = Left(l.index.il,newrmarg)
  1423. X     il = il + 1
  1424. X     l.index.il = xline
  1425. X  End
  1426. X  Return
  1427. XError:
  1428. X  Parse arg err msg
  1429. X 'COMMAND :'pline 'COMMAND SET PENDING ERROR' Left(prefix,5)
  1430. X 'COMMAND RESTORE'
  1431. X  If msg ^= '' Then 'COMMAND EMSG' Strip(msg)
  1432. X  Exit err
  1433. SHAR_EOF
  1434. chmod 0600 prefixtf.xedit ||
  1435. echo 'restore of prefixtf.xedit failed'
  1436. Wc_c="`wc -c < 'prefixtf.xedit'`"
  1437. test 7424 -eq "$Wc_c" ||
  1438.     echo 'prefixtf.xedit: original size 7424, current size' "$Wc_c"
  1439. fi
  1440. exit 0
  1441.