JUSTIFY macros for XEDIT (written in REXX)

lab at and.cs.liv.ac.uk lab at and.cs.liv.ac.uk
Tue Nov 6 06:48:46 AEST 1990


Here is a collection of CMS XEDIT macros (written in REXX by Eric Thomas
ERIC at SEARN.BITNET - note the change of net address from the macro 
headers).

In submitting this, I've tried to keep to the rules for comp.sources.misc
and hence the shar format (CMS users I'm sure can manage :-)).
Please note that some lines are longer than 80 characters. This is just
to warn those whose mailers may chop at column 81.....

Alan Thew
qq11 at liverpool.ac.uk
mcsun!ukc!liv!qq11

Submitted-by: qq11 at liv.ac.uk
Archive-name: justify/part01

---- Cut Here and feed the following to sh ----
#!/bin/sh
# This is justify, a shell archive (produced by shar 3.49)
# To extract the files from this archive, save it to a file, remove
# everything above the "!/bin/sh" line above, and type "sh file_name".
#
# made 10/30/1990 23:42 UTC by qq11 at liv.ac.uk
# Source directory /users/u5/qcl/qq11/work
#
# existing files will NOT be overwritten unless -c is specified
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#    126 -rw------- MANIFEST
#  13319 -rw------- jf.xedit
#  10354 -rw------- jm.xedit
#  12986 -rw------- justify.memo
#   5894 -rw------- prefixb.xedit
#   5979 -rw------- prefixj.xedit
#   7424 -rw------- prefixtf.xedit
#
# ============= MANIFEST ==============
if test -f 'MANIFEST' -a X"$1" != X"-c"; then
	echo 'x - skipping MANIFEST (File already exists)'
else
echo 'x - extracting MANIFEST (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'MANIFEST' &&
XJF       XEDIT    C1
XJM       XEDIT    C1
XJUSTIFY  MEMO     C1
XPREFIXB  XEDIT    C1
XPREFIXJ  XEDIT    C1
XPREFIXTF XEDIT    C1
SHAR_EOF
chmod 0600 MANIFEST ||
echo 'restore of MANIFEST failed'
Wc_c="`wc -c < 'MANIFEST'`"
test 126 -eq "$Wc_c" ||
	echo 'MANIFEST: original size 126, current size' "$Wc_c"
fi
# ============= jf.xedit ==============
if test -f 'jf.xedit' -a X"$1" != X"-c"; then
	echo 'x - skipping jf.xedit (File already exists)'
else
echo 'x - extracting jf.xedit (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'jf.xedit' &&
X/***********************************************************************
X *                                                                     *
X * JF -- Justify and Flow XEDIT macro, release 2                       *
X *                                                                     *
X *       (c) Eric Thomas 1987          (ERIC at FRECP11)               *
X *                                                                     *
X * This file was last updated on Saturday, January the 9th of 1988     *
X *                                                                     *
X * This XEDIT macro was originally written to justify MAILER-format or *
X * IBM NOTE-format files  and was intended to be issued  from the MAIL *
X * or NOTE exec just before pressing the  PF5 key to send the note. It *
X * performs as the PREFIXTF (qqv) macro,  except that all lines in the *
X * body of the mail item are  formatted and that any line extending up *
X * to column 79  is concatenated with the following line  to allow you *
X * to enter text as a "continuous  stream" without having to resort to *
X * POWER INPUT mode.                                                   *
X *                                                                     *
X * Please refer  to PREFIXTF  XEDIT and  JUSTIFY MEMO  (available from *
X * Netserv) for more information in the formatting process.            *
X *                                                                     *
X * Syntax: JF  <nn | ? | <L<nn>> <R<nn>>> <QUIET> <RAgged>             *
X *             <PLpl<,tm<,bm>>> <PN<T|B>>                              *
X *                                                                     *
X * - JF alone will justify the whole file. For NOTE or MAIL files, the *
X *   header is left unchanged. Otherwise the whole file is justified.  *
X *                                                                     *
X * - JF nn indicates that output text should be formatted with a right *
X *   margin of  'nn'. The default  is to  format output text  with the *
X *   same right  margin as input. For  example, if the person  you are *
X *   mailing  to  has  a  40-columns  terminal  (such  as  the  french *
X *   MINITEL), you  can use JF  40 to make sure  that he will  have no *
X *   problem  reading your  mail.  Using  JF 70  makes  sure that  the *
X *   mailfile  can be  read without  problem under  XEDIT or  the ISPF *
X *   editor  with prefixes  on,  even if  the  note gets  subsequently *
X *   quoted by a "REPLY TEXT" or suchlike.                             *
X *                                                                     *
X * - JF ? queries the status of the left and right margins.            *
X *                                                                     *
X * - L<nn> redefines  the Left margin. If  you omit 'nn', you  will be *
X *   asked to move the cursor to the desired column and press ENTER.   *
X *                                                                     *
X * - R<nn> similarly redefines the Right margin.                       *
X *                                                                     *
X * - The QUIET option suppresses the information message which is dis- *
X *   played when  margins are  changed. This is  very useful  when you *
X *   call  JF from  your  PROFILE XEDIT  to  select different  default *
X *   options.                                                          *
X *                                                                     *
X|* - The RAgged  option causes  the text to  be formatted  with ragged *
X|*   right.                                                            *
X|*                                                                     *
X|* - The PL option allows you to  define a page length, top margin and *
X|*   bottom margin.  The default  top and bottom  margins are  2 lines *
X|*   each, and  the default  page length  is OFF  (continuous output). *
X|*   These options are particularly useful  when running JF on a piece *
X|*   of  INCOMING  mail  with  the  intent  of  neatening  it  up  and *
X|*   subsequently printing it  on a line printer  without running over *
X|*   the page perforations.                                            *
X|*                                                                     *
X|* - The PN option is meaningful  only when specified together with PL *
X|*   and orders JF to number  the output pages. The optional parameter *
X|*   indicates whether pages  must be numbered on the Top  lines or on *
X|*   the Bottom  lines (the default is  Top). The page number  will be *
X|*   printed on the  first (or last) line if  the corresponding margin *
X|*   is set to 1 or 2, or after a blank line if the margin is set to 3 *
X|*   or more. I will of course not  be printed if the margin is set to *
X|*   0.                                                                *
X *                                                                     *
X *                                                                     *
X * The default values are L1; R73 if PREFIX ON is in effect, R78 other *
X * wise.                                                               *
X *                                                                     *
X * 08 Mar 1987: Change right margin after a  'JF nn' call if nn is not *
X *              the current  right margin. Allow  'JF nn' where  nn is *
X *              larger than the present right margin.                  *
X *                                                                     *
X * 08 Mar 1987: Some fixes that can't be explained in 4-5 lines...     *
X *                                                                     *
X * 09 Mar 1987: Fix for right margin = 80.                             *
X *                                                                     *
X * 29 May 1987: Allow use of JF on incoming mail.                      *
X *              New options: RAgged, PLpl<,tm<,bm>> and PN<T|B>        *
X *                                                                     *
X * 09 Jan 1988: Change MAIL identification algorithm and processing    *
X *              to solve problems with RICE mail.                      *
X *                                                                     *
X ***********************************************************************/
X 
X Arg options
X 
X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Trunc'
X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
X Parse pull xfn xft xfm lmarg rmarg minl .
X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
X  Do
X    lmarg = 1
X    If prefix.1 ^= 'OFF'
X     Then Do
X            rmarg = 73
X            minl = 62
X          End
X     Else Do
X            rmarg = 78
X            minl = 66
X          End
X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1 ftype.1 fmode.1 lmarg rmarg minl
X  End
X 
X JMopt = ''
X orgline = line.1
X newrmarg = rmarg
X pl = 0
X tm = 2
X bm = 2
X pn = 'O'
X format = 1
X ragged = 0
X Do Words(options)
X    Parse var options opt options
X    Select
X      When Datatype(opt,'W') & opt > 0 Then newrmarg = opt
X      When opt == '?' Then
X       Do
X         'COMMAND MSG Left margin:' lmarg', Right margin:' rmarg'.'
X          format = 0
X       End
X      When Abbrev('OFF',opt,1) Then Call Error 'Text Flow operation cannot be undone'
X      When Left(opt,2) == 'PL' Then
X       Do
X         Parse var opt 'PL'pl','tm','bm
X         If pl = '' Then Signal Missarg
X         If tm = '' Then tm = 2
X         If bm = '' Then bm = 2
X         If ^Datatype(pl||tm||bm,'W') | pl ^> 0 | tm < 0 | bm < 0
X            Then Signal Invarg
X         If tm+bm ^< pl Then Call Error 'Top and bottom margins exceed page length'
X       End
X      When Left(opt,2) == 'PN' Then
X       Do
X         Parse var opt 'PN'pn
X         If pn = '' Then pn = 'T'
X         If pn ^= 'T' & pn ^= 'B' Then Call Error 'Invalid page numbering option -- "'opt'"'
X       End
X      When Abbrev('RAGGED',opt,3) Then ragged = 1
X      Otherwise JMopt = JMopt opt
X    End
X End
X 
X If newrmarg < lmarg+2 | newrmarg > trunc.1 Then Call Error 'New right margin exceeds allowable boundaries'
X 
X If JMopt ^= '' Then
X  Do
X    'STATE JM XEDIT'
X     If rc ^== 0 Then Call Error 'File "JM XEDIT" not found',28
X    'MACRO JM' JMopt
X     Exit rc
X  End
X If ^format Then Exit 0
X 
X'COMMAND PRESERVE'
X'COMMAND SET LINEND OFF'
X'COMMAND SET IMAGE OFF'
X'COMMAND SET SCOPE ALL'
X'COMMAND SET AUTOSAVE OFF'
X accents = '@{}:?]XDKa*J-\X 
X/* You may wish not to consider accentuated characters as alphabetical
X    ones,  especially since  some of  them are  regular characters  on
X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
X    character). In  that case, remove  the "||accents" portion  of the
X    following statement.   */
X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||,
X            '0123456789()"'':;'||accents
X 
X If ftype.1 = 'NOTE'
X  Then 'COMMAND :6 COMMAND FIND _______'
X  Else If Not_Mail() Then 'COMMAND TOP'
X 
X'COMMAND EXTRACT /Line'
X hdrline = line.1
X 
X t. = ''
X r. = ''
X n. = 1
X index = 1
X il = 1
X previndent = -2
X ll = rmarg-lmarg+1
X maxmarg = Max(80,rmarg+1)
X 
X Do forever
X   'COMMAND NEXT'
X    If rc ^== 0 Then Leave
X   'COMMAND EXTRACT /Curline'
X    line = Substr(curline.3,lmarg,ll)
X    If Right(t.index,1) == ' '
X     Then indent = Verify(line'A',alphabet,'M')
X     Else indent = 1
X    l.index.il = Left(curline.3,lmarg-1)Left(line,indent-1)
X    previl = il
X    If Length(l.index.il) > newrmarg Then Call Spill_L
X    If rmarg = 78 & Substr(curline.3,79,1) ^== ' '
X     Then line = Substr(curline.3,lmarg,ll+1)
X     Else r.index.il = Substr(curline.3,rmarg+1)
X    line = Substr(line,indent,maxmarg-indent)
X    If line = '' Then
X     Do
X       Call Close_Par
X       previndent = 0
X       Iterate
X     End
X    Select
X      When previndent = indent Then nop
X      When previndent = -2 Then previndent = -1
X      When previndent = -1 Then previndent = indent
X      Otherwise
X        Call Close_Par
X        il = il-1
X        previndent = -1
X    End
X    t.index = t.index||line
X    il = il+1
X End
X 
X n.index = il-1
X If n.index = 0 Then index = index-1
X 
X lc = 1
X pg = 1
X Select
X   When pn == 'O' Then nop
X   When pn == 'B' Then
X    If bm > 2 Then po = 'COMMAND -1'
X              Else po = ''
X   When pn == 'T' Then
X    Do
X      If tm > 2 Then po = 2-tm
X                Else po = 1-tm
X      If po = 0 Then po = ''
X                Else po = 'COMMAND' po
X    End
X End
X pe = pl-bm+1
X 
X toldspill = 0
X'COMMAND :'hdrline
X Do i = 1 to index
X    If n.i = 0 Then Iterate
X    If t.i = '' Then
X     Do
X       Call Input Left(l.i.1,newrmarg)r.i.1
X       Iterate
X     End
X    il = 1
X    t = Space(t.i)
X    Do until t = ''
X       xl = newrmarg-Length(l.i.il)+1
X       j = Lastpos(' ',t' ',xl)
X       If j == 0 Then Call Spill
X       line = Left(t,j-1)
X       t = Strip(Substr(t,j))
X       If ^ragged & t ^== '' Then line = Justify(line,xl-1)
X       Call Input Left(l.i.il||line,newrmarg)r.i.il
X       If il ^= n.i Then il = il+1
X    End
X End
X If pn = 'B' Then
X  Do
X    'COMMAND ADD' pe-lc+bm
X    'COMMAND NEXT' pe-lc+bm
X     Call Page
X  End
X 
X'COMMAND SET MSGMODE OFF'
X'COMMAND +1 COMMAND DELETE *'
X'COMMAND :'orgline 'COMMAND RESTORE'
X If newrmarg = rmarg Then Exit
X minl = Format(minl*(newrmarg-lmarg+1)/(rmarg-lmarg+1),,0)
X Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1 ftype.1 fmode.1 lmarg newrmarg minl
X'COMMAND MSG Note: right margin has been adjusted to' newrmarg'.'
X Exit
X 
XInput:
X Select
X   When pl == 0 Then nop
X   When lc == 1 Then Call Top_Margin
X   When lc == pe Then Call Bottom_Margin
X   Otherwise lc = lc+1
X End
X'COMMAND INPUT' Arg(1)
X Return
X 
XTop_Margin:
X lc = tm+2
X If tm == 0 Then Return
X'COMMAND ADD' tm
X'COMMAND NEXT' tm
X If pn == 'T' Then Call Page
X Return
X 
XBottom_Margin:
X If bm ^== 0 Then
X  Do
X    'COMMAND ADD' bm
X    'COMMAND NEXT' bm
X     If pn == 'B' Then Call Page
X  End
X Call Top_Margin
X Return
X 
XPage:
X po 'COMMAND REPLACE' Left('',newrmarg-9) 'Page' Right(pg,3)
X pg = pg+1
X If po = '' Then Return
X Translate(po,'+','-')
X Return
X 
XClose_Par:
X n.index = previl-1
X i = index
X index = index+1
X Do j = 1 for il-previl+1
X    l.index.j = l.i.previl
X    r.index.j = r.i.previl
X    previl = previl+1
X End
X il = j
X Return
X 
XSpill:
X xl = Max(xl,2)
X j = xl
X If toldspill Then Return
X toldspill = 1
X'COMMAND EMSG Text flow operation caused words to be spilled.'
X Return
X 
XSpill_L:
X If l.index.il = '' Then
X  Do
X    l.index.il = ' ' /* Purposefully leave one 1 blank */
X    Return
X  End
X Do while Length(l.index.il) > newrmarg
X    xline = Substr(l.index.il,newrmarg+1)
X    l.index.il = Left(l.index.il,newrmarg)
X    il = il+1
X    l.index.il = xline
X End
X Return
X 
XMissarg:
X Call Error 'Missing argument'
X 
XInvarg:
X Call Error 'Invalid argument'
X 
XError:
X Parse arg msg,retcode
X If retcode == '' Then retcode = 24
X'COMMAND EMSG' msg'.'
X Exit retcode
X 
XNot_Mail:
X'COMMAND TOP'
X'COMMAND +1 COMMAND EXTRACT /Curline'
X If Pos(':',curline.3) == 0 Then Return 1
X Parse upper var curline.3 tag ':'
X If Words(tag) ^== 1 Then Return 1
X If Find('RECEIVED DATE RESENT-DATE',tag) == 0 Then Return 1
X banner = Copies('=',70)
X Do forever
X   'COMMAND NEXT'
X    If rc ^== 0 Then Return 1
X   'COMMAND EXTRACT /Curline'
X    If curline.3 = '' | Left(curline.3,70) = banner Then Return 0
X End
SHAR_EOF
chmod 0600 jf.xedit ||
echo 'restore of jf.xedit failed'
Wc_c="`wc -c < 'jf.xedit'`"
test 13319 -eq "$Wc_c" ||
	echo 'jf.xedit: original size 13319, current size' "$Wc_c"
fi
# ============= jm.xedit ==============
if test -f 'jm.xedit' -a X"$1" != X"-c"; then
	echo 'x - skipping jm.xedit (File already exists)'
else
echo 'x - extracting jm.xedit (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'jm.xedit' &&
X/***********************************************************************
X *                                                                     *
X * JM -- Justify Mail XEDIT macro, release 2                           *
X *                                                                     *
X *       (c) Eric Thomas 1986          (ERIC at FRECP11)               *
X *                                                                     *
X * This file was last updated on Friday, February the 27th of 1987     *
X *                                                                     *
X * This XEDIT macro was originally written to justify MAILER-format or *
X * IBM NOTE-format files  and was intended to be issued  from the MAIL *
X * or NOTE exec just before pressing the  PF5 key to send the note. It *
X * respects  indentation, starting  its justification  process at  the *
X * first alphabetical  character encountered within  the justification *
X * margins. The justification  margins, as well as  the minimum number *
X * of characters that are required for  a line to be justified, can be *
X * altered and will remain active for the current file.                *
X *                                                                     *
X * Please see also the JF (Justify  and Flow) macro. It is recommended *
X * that JF be used instead of  JM whenever possible, that is, when the *
X * mailfile contains only  pure text (no drawings, no  boxes, etc). JF *
X * usually gives much  better results than JM, and also  allows you to *
X * choose the number of columns of the resulting output.               *
X *                                                                     *
X *                                                                     *
X * Syntax: JM  <Off | ? | <L<nn>> <R<nn>> <nn | nn%>>> <QUIET>         *
X *                                                                     *
X * - JM alone will justify the whole file. For NOTE or MAIL files, the *
X *   header is left unchanged. Otherwise the whole file is justified.  *
X *                                                                     *
X * - JM Off will undo the justification process, if needed.            *
X *                                                                     *
X * - JM  ? queries  the status  of  the margins  and minimum  required *
X *   length for justification.                                         *
X *                                                                     *
X * - L<nn> redefines  the Left margin. If  you omit 'nn', you  will be *
X *   asked to move the cursor to the desired column and press ENTER.   *
X *                                                                     *
X * - R<nn> similarly redefines the Right margin.                       *
X *                                                                     *
X * - nn redefines the minimum number of characters that the portion of *
X *   the line that is between the justification margins should have in *
X *   order to get justified. If one  of the margins is changed without *
X *   a new 'nn' being justified, the value will be automatically adjus *
X *   ted in the  same proportions as the previous  value. For example, *
X *   if JM L1 R73 66 is in effect, entering JM L10 will cause the mini *
X *   mum required length to be automatically adjusted to 58.           *
X *                                                                     *
X * - nn% redefines the minimum required  length as a percentage of the *
X *   total  available space  between  justification margins.  Example: *
X *   JM L10 R50 90% and JM L10 R50 37 lead to the same result.         *
X *                                                                     *
X * - The QUIET option suppresses the information message which is dis- *
X *   played when  margins are  changed. This is  very useful  when you *
X *   call  JM from  your  PROFILE XEDIT  to  select different  default *
X *   options.                                                          *
X *                                                                     *
X * The default values are L1; R73 if PREFIX ON is in effect, R78 other *
X * wise; 85% minimum required size.                                    *
X *                                                                     *
X *  3 Feb 1986: changed default right margin  from 79 to 78 for compa- *
X *              tibility with the JF macro.                            *
X *                                                                     *
X * 20 Feb 1986: JM failed to recognize the header of resent mail.      *
X *                                                                     *
X * 22 Feb 1986: minimum required  length  redefined to 85%  for better *
X *              results.                                               *
X *                                                                     *
X * 27 Feb 1986: incorrect  results  when  first TAB  not in  column 1. *
X *              AUTOSAVE  may  get   triggered  several  times  during *
X *              execution of the macro.                                *
X *                                                                     *
X ***********************************************************************/
X 
X Arg options
X If Abbrev('OFF',options,1) Then Do
X                                   options = ''
X                                   off = 1
X                                 End
X                            Else off = 0
X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM'
X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
X Pull xfn xft xfm lmarg rmarg minl .
X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
X  Do
X    lmarg = 1
X    If prefix.1 ^= 'OFF' Then Do
X                                rmarg = 73
X                                minl = 62
X                              End
X                         Else Do
X                                rmarg = 78
X                                minl = 66
X                              End
X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
X     ftype.1 fmode.1 lmarg rmarg minl
X  End
X If options ^= '' Then Signal Setup
X 
X'COMMAND PRESERVE'
X'COMMAND SET LINEND OFF'
X'COMMAND SET IMAGE OFF'
X'COMMAND SET AUTOSAVE OFF'
X accents = '@{}:?]XDKa*J-\X 
X/* You may wish not to consider accentuated characters as alphabetical
X    ones,  especially since  some of  them are  regular characters  on
X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
X    character). In  that case, remove  the "||accents" portion  of the
X    following statement.   */
X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||accents
X 
X If ftype.1 = 'NOTE'
X  Then 'COMMAND :6 COMMAND FIND _______'
X  Else Do /* Check for MAIL files */
X         'COMMAND TOP'
X         'COMMAND +1 COMMAND EXTRACT /Curline'
X          Parse upper var curline.3 tag ':'
X          If Words(tag) = 1 & Find('DATE RESENT-DATE',tag) ^= 0
X           Then 'COMMAND LOCATE /=============='
X           Else 'COMMAND TOP'
X       End
X 
X maxl = minl+lmarg-1
X jc = rmarg + 1
X If ^off
X  Then /* Separate Do...End for better speed */
X   Do forever
X     'COMMAND NEXT'
X      If rc ^= 0 Then Leave
X     'COMMAND EXTRACT /Curline'
X      start = Verify(curline.3,alphabet,'MATCH',lmarg)
X      If start = 0 | start >= rmarg Then Iterate
X      If Length(Strip(Left(curline.3,rmarg),'T')) < maxl Then Iterate
X     'COMMAND REPLACE' Left(curline.3,start-1)Justify(Substr(curline.3,start,jc-start),jc-start)Substr(curline.3,jc)
X   End
X  Else
X   Do forever
X     'COMMAND NEXT'
X      If rc ^= 0 Then Leave
X     'COMMAND EXTRACT /Curline'
X      start = Verify(curline.3,alphabet,'MATCH',lmarg)
X      If start = 0 | start > rmarg Then Iterate
X     'COMMAND REPLACE' Left(curline.3,start-1)Left(Space(Substr(curline.3,start,jc-start)),jc-start)Substr(curline.3,jc)
X  End
X 
X'COMMAND :'line.1 'COMMAND RESTORE'
X Exit
X 
XSetup:
X'EXTRACT /LRECL'
X pct = 0
X newmin = 0
X didlist = 0
X quiet = 0
X prev = rmarg-lmarg+1
X Do Words(options)
X    Parse var options opt options
X    Select
X      When Left(opt,1) = 'L' Then Call Nalieva
X      When Left(opt,1) = 'R' Then Call Naprava
X      When Right(opt,1) = '%' Then Call Percent
X      When opt = 'QUIET' Then quiet = 1
X      When opt = '?' Then Call List
X      Otherwise
X        minl = Decparm(1)
X        newmin = 1
X    End
X End
X 
X If rmarg ^> lmarg Then
X  Do
X    'COMMAND EMSG Left margin cannot exceed right margin.'
X     Exit
X  End
X 
X If pct Then minl = Format(minl*(rmarg-lmarg+1)/100,,0)
X If newmin & minl > rmarg-lmarg+1 Then
X  Do
X    'COMMAND EMSG Minimum required length exceeds total length.'
X     Exit
X  End
X 
X If ^newmin Then
X  Do
X    oldml = minl
X    minl = Format((rmarg-lmarg+1)*(minl/prev),,0)
X    If ^quiet & oldml ^= minl Then
X     'COMMAND MSG Minimum required length has been adjusted according',
X       'to previous proportions.'
X  End
X 
X Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1 ftype.1,
X  fmode.1 lmarg rmarg minl
X Call List
X Exit
X 
XList:
X  If didlist | quiet Then Return
X  didlist = 1
X 'COMMAND MSG Left margin:' lmarg', Right margin:' rmarg||,
X   ', Minimum length:' minl '('Format(100*minl/(rmarg-lmarg+1),,0)'%)'
X  Return
X 
XPercent:
X  pct = 1
X  newmin = 1
X  Parse var opt opt'%'
X  minl = Decparm(1,'')
X  If minl > 100 Then
X   Do
X     'COMMAND EMSG Invalid percentage value.'
X      Exit
X   End
X  Return
X 
XNalieva:
X  lmarg = Decparm(2,'Left margin',lmarg)
X  If lmarg > lrecl.1 Then
X   Do
X     'COMMAND EMSG Left margin should not exceed LRECL.'
X      Exit
X   End
X  Return
X 
XNaprava:
X  rmarg = Decparm(2,'Right margin',rmarg)
X  If rmarg > lrecl.1 Then
X   Do
X     'COMMAND EMSG Right margin should not exceed LRECL.'
X      Exit
X   End
X  Return
X 
X 
XDecparm:
X  Parse arg x,title,y
X  arg = Substr(opt,x)
X  If arg = '' Then
X   Do 1
X      If title = '' Then Leave
X     'COMMAND MSG Position cursor on the' title 'and press ENTER.'
X      If y > lrecl.1 Then y = lrecl.1
X     'COMMAND CURSOR FILE' line.1 y
X      Address COMMAND 'MAKEBUF'
X     'COMMAND READ'
X      Address COMMAND 'DROPBUF'
X     'COMMAND EXTRACT /Cursor'
X     'COMMAND CURSOR CMDLINE'
X      If cursor.4 > 0 Then Return cursor.4
X     'COMMAND EMSG Invalid cursor location.'
X      Exit
X   End
X  If Datatype(arg,'W') & arg > 0 Then Return arg
X 'COMMAND EMSG Invalid argument -- "'opt'".'
X  Exit
SHAR_EOF
chmod 0600 jm.xedit ||
echo 'restore of jm.xedit failed'
Wc_c="`wc -c < 'jm.xedit'`"
test 10354 -eq "$Wc_c" ||
	echo 'jm.xedit: original size 10354, current size' "$Wc_c"
fi
# ============= justify.memo ==============
if test -f 'justify.memo' -a X"$1" != X"-c"; then
	echo 'x - skipping justify.memo (File already exists)'
else
echo 'x - extracting justify.memo (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'justify.memo' &&
X  Installation and programming logic information for the JUSTIFY package
X   --------------------------------------------------------------------
X                    Revision date: 8 March 1987
X 
X 
XHistory of changes: moved to the comments area in the affected macros.
X 
X*-----------------------------------------------------------------------*
X|
X|  There are two distinct sub-packages in the JUSTIFY package:
X|
X|   - The PREFIXJ -  PREFIXB - JM package which  performs text justifica-
X|     tion on a line per line basis.
X|
X|   - The PREFIXTF - JF package which performs "text flow" and justifica-
X|     tion on a paragraph per paragraph basis.
X|
X|   The installation procedure is identical for the two sub-packages, and
X| has not been  revised. A detailed description of  the programming logic
X| involved in the Text Flow package can be found at the end of this memo.
X|
X|   The following lines are the original description of the package which
X| I have not had time to rewrite:
X|
X| Part I -- The Justification sub-package
X|
X    This  package  consists  in  three   XEDIT  macros:  two  new  prefix
X  subcommands  (J/Jnnn/JJ...JJ and  B/Bnnn/BB...BB) to  justify/unjustify
X  text, and one  command-line macro, JM, to justify a  whole file at once
X  from  the command-  line. JM  originally stood  for "Justify  Mail" and
X  supported only  MAIL files from  the MAIL/MAILBOOK environment.  It was
X  later upgraded  to support IBM  NOTEs as  well, and finally  suffered a
X  major rewrite before  being made available on Netserv in  an attempt to
X  raise it  to the same level  of quality as the  other Netserv programs.
X  This is  the reason  why there  are special cases  for the  handling of
X  NOTEs and MAIL files in the code.
X 
X 
X    Before  starting to  use the  prefix  commands you  must modify  your
X  PROFILE XEDIT  file to include  synonym definitions for the  new prefix
X  subcommands since they are not provided in the standard IBM set:
X 
X    SET PREFIX SYNONYM J  PREFIXJ
X    SET PREFIX SYNONYM JJ PREFIXJ
X    SET PREFIX SYNONYM B  PREFIXB
X    SET PREFIX SYNONYM BB PREFIXB
X|   SET PREFIX SYNONYM TF PREFIXTF
X 
X    These lines can be added nearly anywhere, preferrably before or after
X  the regular synonym definitions, if any.
X 
X 
X    The justification  process performed  by the  three macros  will take
X  place  between  user-modifiable  "justification margins".  The  default
X  values for  these margins are column  1 for the left  margin and either
X| column 73 or 78 for the right margin, depending on whether you run with
X  PREFIX ON or OFF. These default  values correspond to the proper values
X  for  justifying IBM  NOTE and  RFC822 MAIL  files, respectively.  It is
X  important  to note  that anything  that  might appear  after the  right
X  margin  (or before  the  left margin)  will be  left  unchanged; it  is
X  therefore  necessary to  make sure  that the  right margin  is expanded
X  whenever lines  longer than 73  characters are to be  justified (unless
X  PREFIX  OFF  was  in  effect  and   the  lines  were  smaller  than  80
X  characters).
X 
X    These "justification parameters" are local  to each file in the XEDIT
X  ring and  will remain valid for  the XEDIT session, ie  until you QUIT;
X  however, if you immediately recall the  file you have just QUITted, the
X  previous justification  parameters will  be recalled  and you  will not
X  have  to provide  them  again. This  does  not occur  if  you recall  a
X  different file, of course.
X 
X 
X    Additionally,  the actual  justification  process will  start at  the
X  first  alphabetical  character  encountered  within  the  justification
X  margins. This allows for indentation and sub-paragraphs to be respected
X  by the justification process:
X 
X     - This line has been justified with margins of 1 and 73, and yet the
X       leading blanks and dash were not "squeezed" in the process.
X 
X    If  the portion  of the  line  between the  justification margins  is
X  smaller than a  certain amount of characters, it will  not be expanded.
X  This                                                             avoids
X  justifying               lines               like               that...
X  This "minimum  required number of  characters" can be redefined  by the
X  user in one of two ways:
X 
X  1) An absolute value
X  2) A percentage  of the size  of the "justification area".  The default
X|    value is precisely expressed as 85% of the justification area.
X 
X 
X    Furthermore, if one or both  of the justification margins are changed
X  without the "minimum  required number of characters"  being altered, JM
X  will  automatically  expand or  reduce  it  according to  the  previous
X| proportions. For  example, if you  change from the default  settings of
X| margins 1 and 73 and minimum length 62 (ie 85% of 73) to margins 10 and
X| 50, the minimum length will be  automatically changed to 35 (85% of 41)
X  to stay in proportions with the previous value.
X 
X 
X    The  justification parameters  can  be  changed by  means  of the  JM
X  command, and  will affect both  JM and PREFIXJ/PREFIXB  operations. The
X  syntax is:
X 
X               JM  <L<nn>> <R<nn>> <nn | nn%>
X 
X  - Lnn  and  Rnn indicate  the  left  and right  justification  margins,
X    respectively. If 'nn' is omitted you will be required to position the
X    cursor on the  desired column and press ENTER.  The original position
X    of the cursor will be the last value of the corresponding margin.
X 
X  - nn  and nn%  indicate a  new value  for the  minimum required  length
X    parameter, either as an absolute  number or expressed as a percentage
X    of the size of the justification area.
X 
X  Examples:
X 
X    JM L1 R 80% -- left margin  = 1
X                   right margin to be modified using the cursor keys
X                   new minimum is 80% of justification area
X 
X    JM R70      -- left margin  = unchanged
X                   right margin = 70
X                   minimum will be adjusted according to the previous
X                   proportions
X 
X 
X    You can query the status of the justification parameters by issuing a
X  'JM ?' command. Please refer to  the block comments at the beginning of
X  the various macros for a more detailed description of their syntax.
X 
X|
X| Part II -- The Text Flow sub-package
X|
X|   There are only  two macros in the Text Flow  sub-package, JF (similar
X| to JM)  and PREFIXTF which implements  the TF block prefix  command. As
X| Text Flow cannot  be undone, there is no equivalent  to the B/BB prefix
X| command.
X|
X|   The algorithms  used by JF and  TF are slightly different  because JF
X| was designed  to be invoked  from the  MAIL environment mainly.  It can
X| also be called  from the NOTE environment but it  is NOT recommended to
X| blindly use  JF on  a non-mail  file as this  might lead  to unexpected
X| results. The differences  between the two algorithms  will be explained
X| later.
X|
X|   JF and TF are similar to JM  and JJ in that they will operate between
X| a left  margin and a right  margin, and will preserve  anything outside
X| those margins.  JF/TF and JM/JJ  use the  same GLOBALV storage  to keep
X| those margins  which are therefore shared  between JM and JF:  a JM L10
X| command has exactly the same effect  as JF L10. However, JF/TF will not
X| use the "minimum required length" parameter at all as they will justify
X| ALL the lines in each paragraph, except the last one.
X|
X|   Another important  difference between JF/TF  and JM/JJ is  that JF/TF
X| can reformat text using a different output right margin, ie a different
X| number of columns for output. This  "output right margin" is called the
X| "reformatting margin". The default is of  course to use the input right
X| margin as reformatting margin.
X|
X|   A short description of the Text Flow algorithm used by both JF and TF
X| follows.  Please refer  to the  macros for  more details  on the  exact
X| implementation.
X|
X|
X| Step 1: Process the input lines and split them in paragraph units.
X|
X|   The input text  is read in, analyzed and stored  in an internal array
X|   of "paragraph units". A "break" between two paragraph units is caused
X|   by one of the following:
X|
X|    - A blank line: a blank line causes a break and is preserved.
X|
X|    - A change in  indention, except between the two first  lines of the
X|      paragraph  unit.  That is,  the  first  and  second line  of  each
X|      paragraph can  have different indentions without  causing a break.
X|      Those indentions  will be  respected in the  output text.  A break
X|      caused by a change in indention  does NOT generate any blank line.
X|
X|   For each paragraph  unit, JF/TF maintains an internal  array of "left
X|   keep" and "right keep", one "keep" of  each type for each line in the
X|   input paragraph.
X|
X|     - The "right  keep" is the data  in the input line  after the right
X|       margin (possibly null string).
X|
X|     - The "left  keep" is the  data in the  input line before  the left
X|       margin, concatenated  with any "non-alphanumeric" bytes  that may
X|       have been found  at the beginning of the actual  "data line". The
X|       definition of "non-alphanumeric"  can be found in  the macros and
X|       it differs from that of JM/JJ. Note that blanks are considered as
X|       non-alphanumeric characters.
X|
X|     - Whenever the left keep  length exceeds the "reformatting margin",
X|       null input lines are generated and  the left keep is split across
X|       those  new lines,  with  each  new left  keep  generated in  this
X|       fashion  not exceeding  the reformatting  margin. That  is, JF/TF
X|       acts as  if the large left  keep had been found  on several input
X|       lines, each of  them having a left keep smaller  than or equal to
X|       the reformatting margin and being  otherwise empty. This does not
X|       apply when the left keep contains  only blanks: in that case, the
X|       left  keep is  forced  to a  single  blank and  no  null line  is
X|       generated  as those  null lines  would only  result in  pointless
X|       blank lines in the output text.
X|
X|   Finally, the concatenated contents of  each paragraph unit is kept in
X|   an internal array.
X|
X| Step 2: Produce output lines according to the reformatting margin.
X|
X|   Each paragraph unit will then be  reformatted and produce one or more
X|   output lines.  The indention of  all the  lines in a  given paragraph
X|   will be  the same, except  that the first  line might be  undented or
X|   outdented. The data  portions of all the lines in  the paragraph unit
X|   except the last  one will be unconditionally justified.  The left and
X|   right "keeps" will not be justified of course.
X|
X|   It is  however possible  for the  output paragraph  to be  smaller or
X|   longer than  the input one. In  this case a special  handling must be
X|   performed on the "keeps":
X|
X|    - If the  output paragraph is smaller  than the input one,  the last
X|      (unused) keeps will be discarded. Another solution would have been
X|      to  generate null  lines  to  make sure  that  all  the keeps  are
X|      preserved,  but  this would  have  been  very impractical  in  the
X|      majority of case.
X|
X|    - If the  output paragraph is  longer, the  last keep is  re-used as
X|      many times as  required to make sure that all  the extra lines are
X|      properly indented. This may not necessarily be what you wanted but
X|      it seems to be the best solution.
X|
X|   Note  that if  the reformatting  margin is  different from  the input
X|   right  margin, the  right  keep  may end  up  at  a different  column
X|   position than it originally was. This is perfectly normal.
X|
X| Step 3: Delete the original input lines.
X|
X|
X|
X| JF  is  slightly different  from  TF  and  will perform  the  following
X| additional steps:
X|
X|  - When the input  right margin is set  to 78, lines which  have a non-
X|    blank character in column 79 will be pasted with the next line. This
X|    allows  MAIL users  to  enter  text without  having  to worry  about
X|    physical  line size,  and to  reformat it  later. This  is also  the
X|    reason why the default right margin was changed to 78: running JF on
X|    a piece of  text formatted with the R79 option  would be most likely
X|    to cause disastrous results...
X|
X|  - When you specify  a reformatting margin different  from the original
X|    right margin, the  right margin will be changed  to the reformatting
X|    margin you specified upon completion  of the reformatting process in
X|    order to avoid problems if you subsequently call JF on the mail file
X|    again. Try  the following  sequence on  a dummy  mailfile originally
X|    containing text in columns 1-50 only:
X|
X|      o JF  70  (reformats text  for  70  columns).  A  JF R70  is  then
X|        automatically issued.
X|
X|      o JF R50 to cancel the previous internal JF R70.
X|
X|      o JF 50  to format the text  back in 50 columns mode.  As you will
X|        see the result is not precisely what you would have expected...
X|
SHAR_EOF
chmod 0600 justify.memo ||
echo 'restore of justify.memo failed'
Wc_c="`wc -c < 'justify.memo'`"
test 12986 -eq "$Wc_c" ||
	echo 'justify.memo: original size 12986, current size' "$Wc_c"
fi
# ============= prefixb.xedit ==============
if test -f 'prefixb.xedit' -a X"$1" != X"-c"; then
	echo 'x - skipping prefixb.xedit (File already exists)'
else
echo 'x - extracting prefixb.xedit (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'prefixb.xedit' &&
X/***********************************************************************
X *                                                                     *
X * PREFIXB -- Justification XEDIT prefix macro, release 2              *
X *                                                                     *
X *       (c) Eric Thomas 1986          (ERIC at FRECP11)               *
X *                                                                     *
X * This file was last updated on Friday, February the 27th of 1987     *
X *                                                                     *
X * This macro is the counterpart of PREFIXJ and defines an un-justifi- *
X * cation prefix: B, Bnnnn, BB...BB. All lines subjected to the B pre- *
X * fix  will be  unjustified with  all multiple  blanks being  removed *
X * between  the justification  margins.  See "JM  XEDIT" and  "JUSTIFY *
X * MEMO" (available from Netserv) for more information.                *
X *                                                                     *
X * Your PROFILE XEDIT must be modified in order to define the name you *
X * want to give the justify synonym. The following two lines should be *
X * added to  PROFILE XEDIT,  for example  immediately after  all other *
X * synonym definitions:                                                *
X *                                                                     *
X *   SET PREFIX SYNONYM B  PREFIXB                                     *
X *   SET PREFIX SYNONYM BB PREFIXB                                     *
X *                                                                     *
X * You may substitute  any other name for  B or BB if  those names are *
X * already in use.                                                     *
X *                                                                     *
X *  3 Feb 1986: changed default right margin  from 79 to 78 for compa- *
X *              tibility with the JF macro.                            *
X *                                                                     *
X * 22 Feb 1986: minimum required  length  redefined to 85%  for better *
X *              results.                                               *
X *                                                                     *
X * 27 Feb 1986: incorrect  results  when  first TAB  not in  column 1. *
X *              AUTOSAVE  may  get   triggered  several  times  during *
X *              execution of the macro.                                *
X *                                                                     *
X ***********************************************************************/
X 
X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Size/Cursor'
X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
X Pull xfn xft xfm lmarg rmarg minl .
X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
X  Do
X    lmarg = 1
X    If prefix.1 ^= 'OFF' Then Do
X                                rmarg = 73
X                                minl = 62
X                              End
X                         Else Do
X                                rmarg = 78
X                                minl = 66
X                              End
X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
X     ftype.1 fmode.1 lmarg rmarg minl
X  End
X jc = rmarg + 1
X maxl = minl+lmarg-1
X 
X Arg prefix operand pline op rest
X Parse Source . . . . . name .
X prf=name||Space(op rest)
X 
X If prefix ^= 'PREFIX' Then
X  Call Error1 "8 646E 'PREFIXB' must be invoked from the prefix area."
X 
X If operand = 'CLEAR' Then Exit
X 
X'COMMAND PRESERVE'
X'COMMAND SET LINEND OFF'
X'COMMAND SET IMAGE OFF'
X'COMMAND SET AUTOSAVE OFF'
X 
X accents = '@{}:?]XDKa*J-\X 
X/* You may wish not to consider accentuated characters as alphabetical
X    ones,  especially since  some of  them are  regular characters  on
X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
X    character). In  that case, remove  the "||accents" portion  of the
X    following statement.   */
X alphabet = xrange('a','z')||xrange('A','Z')||accents
X 
X Select
X   When Length(name) = 1 Then
X    Do
X      If rest ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
X      If op = '' Then op = 1
X      If op = '*' Then op = size.1
X      If Datatype(op,'W') & op > 0
X       Then
X        Do
X         'COMMAND :'pline
X          Do Format(op,,0)
X             Call Justifyline
X            'COMMAND NEXT'
X             pline = pline + 1
X             If pline > size.1 Then Leave
X          End
X          Signal Closeup
X        End
X      Else Call Error "0 659E Invalid prefix subcommand:" prf
X    End
X 
X   When Length(name) = 2 Then
X    Do
X      If op ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
X     'COMMAND EXTRACT /PENDING BLOCK' name ':0 :'pline '/'
X      If pending.0 ^= 0
X       Then
X        Do
X          'COMMAND :'pending.1 'COMMAND SET PENDING OFF'
X           Do pline-pending.1+1
X              Call Justifyline
X             'COMMAND NEXT'
X              pending.1 = pending.1 + 1
X              If pending.1 > size.1 Then Leave
X           End
X           Signal Closeup
X        End
X       Else 'COMMAND :'pline 'COMMAND SET PENDING BLOCK' Left(prf,5)
X    End
X 
X   Otherwise Call Error "0 686E Synonym '"name"' not recognized by prefix macro 'PREFIXB'."
X End
X 
X'COMMAND RESTORE'
X Exit
X 
XCloseup:
X  'COMMAND :'line.1 'COMMAND RESTORE'
X  'COMMAND CURSOR SCREEN' cursor.5 cursor.6 'PRIORITY 40'
X   Exit
X 
XError:
X  'COMMAND :'pline 'COMMAND SET PENDING ERROR' Left(prf,5)
X  'COMMAND RESTORE'
X 
XError1:
X  Parse arg err msg
X  If msg ^= '' Then 'COMMAND EMSG PXJ'Strip(msg)
X  Exit err
X 
XJustifyline:
X 'COMMAND EXTRACT /Curline'
X  start = Verify(curline.3,alphabet,'MATCH',lmarg)
X  If start = 0 | start > rmarg Then Return
X 'COMMAND REPLACE' Left(curline.3,start-1)Left(Space(Substr(curline.3,start,jc-start)),jc-start)Substr(curline.3,jc)
X  Return
SHAR_EOF
chmod 0600 prefixb.xedit ||
echo 'restore of prefixb.xedit failed'
Wc_c="`wc -c < 'prefixb.xedit'`"
test 5894 -eq "$Wc_c" ||
	echo 'prefixb.xedit: original size 5894, current size' "$Wc_c"
fi
# ============= prefixj.xedit ==============
if test -f 'prefixj.xedit' -a X"$1" != X"-c"; then
	echo 'x - skipping prefixj.xedit (File already exists)'
else
echo 'x - extracting prefixj.xedit (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'prefixj.xedit' &&
X/***********************************************************************
X *                                                                     *
X * PREFIXJ -- Justification XEDIT prefix macro, release 2              *
X *                                                                     *
X *       (c) Eric Thomas 1986          (ERIC at FRECP11)               *
X *                                                                     *
X * This file was last updated on Friday, February the 27th of 1987     *
X *                                                                     *
X * This macro can  be used to define a justification  prefix to XEDIT: *
X * J, Jnnnn, JJ...JJ.  The selected lines will be  justified using the *
X * same algorithm and parameters as the  JM macro, to which you should *
X * refer for  more details  on the  justification process  itself. See *
X * also file "JUSTIFY MEMO" from Netserv.                              *
X *                                                                     *
X * Your PROFILE XEDIT must be modified in order to define the name you *
X * want to give the justify synonym. The following two lines should be *
X * added to  PROFILE XEDIT,  for example  immediately after  all other *
X * synonym definitions:                                                *
X *                                                                     *
X *   SET PREFIX SYNONYM J  PREFIXJ                                     *
X *   SET PREFIX SYNONYM JJ PREFIXJ                                     *
X *                                                                     *
X * You may substitute  any other name for  J or JJ if  those names are *
X * already in use.                                                     *
X *                                                                     *
X *  3 Feb 1986: changed default right margin  from 79 to 78 for compa- *
X *              tibility with the JF macro.                            *
X *                                                                     *
X * 22 Feb 1986: minimum required  length  redefined to 85%  for better *
X *              results.                                               *
X *                                                                     *
X * 27 Feb 1986: incorrect  results  when  first TAB  not in  column 1. *
X *              AUTOSAVE  may  get   triggered  several  times  during *
X *              execution of the macro.                                *
X *                                                                     *
X ***********************************************************************/
X 
X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Size/Cursor'
X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
X Pull xfn xft xfm lmarg rmarg minl .
X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
X  Do
X    lmarg = 1
X    If prefix.1 ^= 'OFF' Then Do
X                                rmarg = 73
X                                minl = 62
X                              End
X                         Else Do
X                                rmarg = 78
X                                minl = 66
X                              End
X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
X     ftype.1 fmode.1 lmarg rmarg minl
X  End
X jc = rmarg + 1
X maxl = minl+lmarg-1
X 
X Arg prefix operand pline op rest
X Parse Source . . . . . name .
X prf=name||Space(op rest)
X 
X If prefix ^= 'PREFIX' Then
X  Call Error1 "8 646E 'PREFIXJ' must be invoked from the prefix area."
X 
X If operand = 'CLEAR' Then Exit
X 
X'COMMAND PRESERVE'
X'COMMAND SET LINEND OFF'
X'COMMAND SET IMAGE OFF'
X'COMMAND SET AUTOSAVE OFF'
X 
X accents = '@{}:?]XDKa*J-\X 
X/* You may wish not to consider accentuated characters as alphabetical
X    ones,  especially since  some of  them are  regular characters  on
X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
X    character). In  that case, remove  the "||accents" portion  of the
X    following statement.   */
X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||accents
X 
X Select
X   When Length(name) = 1 Then
X    Do
X      If rest ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
X      If op = '' Then op = 1
X      If op = '*' Then op = size.1
X      If Datatype(op,'W') & op > 0
X       Then
X        Do
X         'COMMAND :'pline
X          Do Format(op,,0)
X             Call Justifyline
X            'COMMAND NEXT'
X             pline = pline + 1
X             If pline > size.1 Then Leave
X          End
X          Signal Closeup
X        End
X      Else Call Error "0 659E Invalid prefix subcommand:" prf
X    End
X 
X   When Length(name) = 2 Then
X    Do
X      If op ^= '' Then Call Error "0 659E Invalid prefix subcommand:" prf
X     'COMMAND EXTRACT /PENDING BLOCK' name ':0 :'pline '/'
X      If pending.0 ^= 0
X       Then
X        Do
X          'COMMAND :'pending.1 'COMMAND SET PENDING OFF'
X           Do pline-pending.1+1
X              Call Justifyline
X             'COMMAND NEXT'
X              pending.1 = pending.1 + 1
X              If pending.1 > size.1 Then Leave
X           End
X           Signal Closeup
X        End
X       Else 'COMMAND :'pline 'COMMAND SET PENDING BLOCK' Left(prf,5)
X    End
X 
X   Otherwise Call Error "0 686E Synonym '"name"' not recognized by prefix macro 'PREFIXJ'."
X End
X 
X'COMMAND RESTORE'
X Exit
X 
XCloseup:
X  'COMMAND :'line.1 'COMMAND RESTORE'
X  'COMMAND CURSOR SCREEN' cursor.5 cursor.6 'PRIORITY 40'
X   Exit
X 
XError:
X  'COMMAND :'pline 'COMMAND SET PENDING ERROR' Left(prf,5)
X  'COMMAND RESTORE'
X 
XError1:
X  Parse arg err msg
X  If msg ^= '' Then 'COMMAND EMSG PXJ'Strip(msg)
X  Exit err
X 
XJustifyline:
X 'COMMAND EXTRACT /Curline'
X  start = Verify(curline.3,alphabet,'MATCH',lmarg)
X  If start = 0 | start >= rmarg Then Return
X  If Length(Strip(Left(curline.3,rmarg),'T')) < maxl Then Return
X 'COMMAND REPLACE' Left(curline.3,start-1)Justify(Substr(curline.3,start,jc-start),jc-start)Substr(curline.3,jc)
X  Return
SHAR_EOF
chmod 0600 prefixj.xedit ||
echo 'restore of prefixj.xedit failed'
Wc_c="`wc -c < 'prefixj.xedit'`"
test 5979 -eq "$Wc_c" ||
	echo 'prefixj.xedit: original size 5979, current size' "$Wc_c"
fi
# ============= prefixtf.xedit ==============
if test -f 'prefixtf.xedit' -a X"$1" != X"-c"; then
	echo 'x - skipping prefixtf.xedit (File already exists)'
else
echo 'x - extracting prefixtf.xedit (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'prefixtf.xedit' &&
X/***********************************************************************
X *                                                                     *
X * PREFIXTF -- Text Flow XEDIT prefix macro, release 2                 *
X *                                                                     *
X *       (c) Eric Thomas 1987          (ERIC at FRECP11)               *
X *                                                                     *
X * This file was last updated on Sunday, March the 8th of 1987         *
X *                                                                     *
X * This macro  can be used  to define a  "Text Flow" prefix  to XEDIT: *
X * TF<adj>...TF. Text from the selected lines  will be flown in or out *
X * to produce evenly balanced lines, and will eventually be justified. *
X * The "input" margins can be defined  by means of the JM macro (qqv), *
X * while 'adj' defines  the "output" right margin. It  defaults to the *
X * input right margin and must be  either an absolute column number or *
X * an offset (+nn or -nn) relative to the input right margin.          *
X *                                                                     *
X * Please refer  to file "JUSTIFY  MEMO" (available from  Netserv) for *
X * more details.                                                       *
X *                                                                     *
X * Your PROFILE XEDIT must be modified in order to define the name you *
X * want to give to the Text  Flow prefix. The following line should be *
X * added to  PROFILE XEDIT,  for example  immediately after  all other *
X * synonym definitions:                                                *
X *                                                                     *
X *   SET PREFIX SYNONYM TF PREFIXTF                                    *
X *                                                                     *
X * You may substitute any other name for TF if this name is already in *
X * use.                                                                *
X *                                                                     *
X * 08 Mar 1987: Some fixes that can't be explained in 4-5 lines...     *
X *                                                                     *
X ***********************************************************************/
X 
X'COMMAND EXTRACT /Line/Uniqueid/Prefix/FN/FT/FM/Size/Cursor/Trunc'
X Address COMMAND 'GLOBALV SELECT $JM$ STACK $'uniqueid.1
X Pull xfn xft xfm lmarg rmarg minl .
X If xfn xft xfm ^= Space(fname.1 ftype.1 fmode.1) Then
X  Do
X    lmarg = 1
X    If prefix.1 ^= 'OFF' Then Do
X                                rmarg = 73
X                                minl = 62
X                              End
X                         Else Do
X                                rmarg = 78
X                                minl = 66
X                              End
X    Address COMMAND 'GLOBALV SELECT $JM$ SETL $'uniqueid.1 fname.1,
X     ftype.1 fmode.1 lmarg rmarg minl
X  End
X 
X Arg prefix function pline op
X If prefix ^= 'PREFIX' Then
X  Do
X    "COMMAND EMSG 'PREFIXTF' must be invoked from the prefix area."
X     Exit 8
X  End
X If function = 'CLEAR' Then Exit 0
X 
X Parse Source . . . . . name .
X op = Space(op,0)
X prefix = name||op
X 
X'COMMAND PRESERVE'
X'COMMAND SET LINEND OFF'
X'COMMAND SET IMAGE OFF'
X'COMMAND SET AUTOSAVE OFF'
X 
X accents = '@{}:?]XDKa*J-\X 
X/* You may wish not to consider accentuated characters as alphabetical
X    ones,  especially since  some of  them are  regular characters  on
X    some displays  (eg '@'  -- 'at'  sign or  'a accent  grave' french
X    character). In  that case, remove  the "||accents" portion  of the
X    following statement.   */
X alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'||,
X            '0123456789()"'':;'||accents
X'COMMAND EXTRACT /PENDING BLOCK' name ':0 :'pline '/'
X If pending.0 = 0 Then
X  Do
X     If op ^= '' & ^Datatype(op,'W') Then
X      Call Error '8 Invalid argument -- "'op'".'
X    'COMMAND :'pline 'COMMAND SET PENDING BLOCK' Left(prefix,5)
X    'COMMAND RESTORE'
X     Exit
X  End
X If op ^= '' Then
X  Call Error '0 No argument is allowed on closing prefix ('prefix').'
X 
X'COMMAND :'pending.1 'COMMAND SET PENDING OFF'
X If pending.1 = 0 Then pending.1 = 1
X If pending.5 = ''
X  Then newrmarg = rmarg
X  Else Do
X         op = pending.5
X         If ^Datatype(op,'W') Then
X          Call Error '0 Invalid argument -- "'op'".'
X         Select
X           When Left(op,1) = '-' Then newrmarg = rmarg - Substr(op,2)
X           When Left(op,1) = '+' Then newrmarg = rmarg + Substr(op,2)
X           Otherwise newrmarg = op
X         End
X         If newrmarg < lmarg+2 | newrmarg > trunc.1 Then
X          Call Error '0 New right margin exceeds allowable boundaries.'
X       End
X 
X'COMMAND -1'
X t. = ''
X n. = 1
X index = 1
X il = 1
X previndent = -2
X ll = rmarg-lmarg+1
X 
X Do pline-pending.1+1
X   'COMMAND NEXT'
X    If rc ^= 0 Then Leave
X   'COMMAND EXTRACT /Curline'
X    line = Substr(curline.3,lmarg,ll)
X    indent = Verify(line'A',alphabet,'M')
X    l.index.il = Left(curline.3,lmarg-1)Left(line,indent-1)
X    r.index.il = Substr(curline.3,rmarg+1)
X    previl = il
X    If Length(l.index.il) > newrmarg Then Call Spill_L
X    line = Substr(line,indent)
X    If line = '' Then
X     Do
X       Call Close_Par
X       previndent = 0
X       Iterate
X     End
X    Select
X      When previndent = indent Then nop
X      When previndent = -2 Then previndent = -1
X      When previndent = -1 Then previndent = indent
X      Otherwise
X        Call Close_Par
X        il = il - 1
X        previndent = -1
X    End
X    t.index = t.index line
X    il = il + 1
X End
X 
X n.index = il - 1
X If n.index = 0 Then index = index - 1
X 
X/*do i = 1 to index;
Xsay 'T.'i'='t.i;
Xsay '  n.'i'='n.i
Xdo j = 1 to 10; if l.i.j == 'L.'i'.'j then iterate
Xsay '  L.'i'.'j'= >>>'l.i.j'<<<'; end
Xend*/
X 
X toldspill = 0
X'COMMAND :'pending.1 'COMMAND -1'
X Do i = 1 to index
X    If n.i = 0 Then Iterate
X    If t.i = '' Then
X     Do
X       'COMMAND INPUT' Left(l.i.1,newrmarg)r.i.1
X        Iterate
X     End
X    il = 1
X    t = Space(t.i)
X    Do until t = ''
X       xl = newrmarg-Length(l.i.il)+1
X       j = Lastpos(' ',t' ',xl)
X       If j = 0 Then Call Spill
X       line = Left(t,j-1)
X       t = Strip(Substr(t,j))
X       If t ^= '' Then line = Justify(line,xl-1)
X      'COMMAND INPUT' Left(l.i.il||line,newrmarg)r.i.il
X       If il ^= n.i Then il = il + 1
X    End
X End
X'COMMAND MSGMODE OFF'
X'COMMAND +1 COMMAND DELETE' pline-pending.1+1
X'COMMAND :'line.1 'COMMAND RESTORE'
X'COMMAND CURSOR SCREEN' cursor.5 cursor.6 'PRIORITY 40'
X Exit
X 
XClose_Par:
X  n.index = previl - 1
X  i = index
X  index = index + 1
X  Do j = 1 for il-previl+1
X     l.index.j = l.i.previl
X     r.index.j = r.i.previl
X     previl = previl + 1
X  End
X  il = j
X  Return
X 
XSpill:
X  xl = Max(xl,2)
X  j = xl
X  If toldspill Then Return
X  toldspill = 1
X 'COMMAND EMSG Text flow operation caused words to be spilled.'
X  Return
X 
XSpill_L:
X  If l.index.il = '' Then
X   Do
X     l.index.il = ' ' /* Purposefully leave one 1 blank */
X     Return
X   End
X  Do while Length(l.index.il) > newrmarg
X     xline = Substr(l.index.il,newrmarg+1)
X     l.index.il = Left(l.index.il,newrmarg)
X     il = il + 1
X     l.index.il = xline
X  End
X  Return
X 
XError:
X  Parse arg err msg
X 'COMMAND :'pline 'COMMAND SET PENDING ERROR' Left(prefix,5)
X 'COMMAND RESTORE'
X  If msg ^= '' Then 'COMMAND EMSG' Strip(msg)
X  Exit err
SHAR_EOF
chmod 0600 prefixtf.xedit ||
echo 'restore of prefixtf.xedit failed'
Wc_c="`wc -c < 'prefixtf.xedit'`"
test 7424 -eq "$Wc_c" ||
	echo 'prefixtf.xedit: original size 7424, current size' "$Wc_c"
fi
exit 0



More information about the Alt.sources mailing list