home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / VDEJUS12.LBR / VDEJUS.DZC / VDEJUS.DOÃ
Text File  |  2000-06-30  |  9KB  |  154 lines

  1.                       LINE JUSTIFICATION FOR VDE FILES
  2.  
  3. VDE 2.6x is a great compact text editor.  It includes most of the useful 
  4. features of WORDSTAR and other editors, but it does lack line justification.
  5.  
  6. I have looked at several stand alone programs to handle this task; Irv Hoff's 
  7. (rip) JUST.COM comes the closest to doing what I want.  It does a great job 
  8. of justifying the lines that it converts, and I have adapted some of his 
  9. ideas.  What JUST fails to do is recognize which lines are to be justified.  
  10. It involves CODING the source document which can be a pain at times.  VDE 
  11. 2.6x via the SOFT RETURN approach can tell another program which lines 
  12. require justification.  Enter VDEJUS.COM....
  13.  
  14.     -Works with any size text file with a small transfer buffer
  15.     -Works only on lines which end with a soft return i.e. <space> <CR> <LF>
  16.     -Works on indented lines whether TABS or SPACES were used for formatting
  17.     -Adds extra spaces in the middle of all lines instead of using the ends
  18.     -Adds spaces to existing double spaces only after single spaces expanded
  19.     -Creates an output file with file type .JUS to leaving original intact
  20.  
  21. If you use JUS.COM to justify this .DOC file, the list above would have been 
  22. justified.  VDEJUS on the other hand would not process these lines.
  23.  
  24.         What if you want to justify a paragraph at a margin other 
  25.         than the default.  Take this one for example.  I Normally set 
  26.         my right margin to 77 and I want this one to be indented from 
  27.         both the left and right side.  I can cheat the program into 
  28.         doing most of the work for me by setting my right margin to 
  29.         61 (16 less than normal) and writing the paragraph as usual.  
  30.         Once I am finished, I reset my margin to 77 (normal) and add 
  31.         2 tabs before each line.  VDEJUS will align the text to the 
  32.         right margin and then all I need to do is remove one tab to 
  33.         centre my paragraph.
  34.  
  35. To try this out, run VDEJUS on this .DOC file and have a look at the results.  
  36. This technique can be used with any indent value; just add the desired right 
  37. margin to the left margin prior to justification and remove the extra spaces 
  38. after.  I find this technique more versatile and less cumbersome than CODING 
  39. individual lines.
  40.  
  41.                                 INSTALLATION
  42.  
  43. VDEJUS uses no terminal specific information and will work on any CP/M system 
  44. with 16K of RAM.  See the notes at the end of this file for changing the 
  45. default margin.
  46.  
  47.                                    SYNTAX
  48.  
  49. The syntax is quite simple:    VDEJUS [d:]ufn [margin]
  50. where ufn is an unambiguous file name (no wild cards) and may be preceded by 
  51. a drive code (sorry no user).  If a drive is specified, the output file will 
  52. be on the same drive.  If no margin is specified, the default is used.  To 
  53. override the default margin, you can supply a 2 digit number from 10 to 99 
  54. for a justification column.  Note that this is the last column in which text 
  55. will appear; trailing spaces are not counted.
  56.  
  57.                                TECHNICAL STUFF
  58.  
  59. The full source code (except the MACLIB's) has been included.  If you wish to 
  60. modify the code, you will require your own EQU's for the BDOS functions and a 
  61. few other constants.  You will also require your own HEXDEC module which 
  62. saves all registers.
  63.  
  64. VDEJUS works on a file in the following fashion:
  65.  
  66.     Read in one line up to a carriage return and place it in a buffer.  Count 
  67.     the physical number of characters in the line as it is read
  68.  
  69.     Remove all but one trailing space from the end of the line.  If spaces 
  70.     are removed, adjust the length of line accordingly.
  71.  
  72.     Check if the line ends in a soft return.  This is defined as VDE 2.6x's 
  73.     implementation of <SPACE><RETURN> to define a soft return.  If there is 
  74.     no soft return, then flush out the line as is.
  75.  
  76.     Now the hard stuff begins.  The first task is to check for leading tabs.  
  77.     Rather than convert tabs and expand the line, 7 is added to the length 
  78.     count for each leading tab.  Once no more leading tabs are found, check 
  79.     the rest of the line.  If there are more tabs, let's presume you don't 
  80.     want the line justified.
  81.  
  82.     Now we add the physical line length and TAB FACTOR to get the printed 
  83.     line length.  If this is greater than the margin setting, flush the line.  
  84.     If this is more than the threshold level (15 characters) from the right 
  85.     margin, do not justify the line.  This was the hardest decision to make.  
  86.     I presume that if you have a 15-character word at the end of a line that 
  87.     you would have hyphenated it rather than leave a large gap.
  88.  
  89.     Then the line_length+tabs is subtracted from the margin setting to 
  90.     determine the number of formatting spaces to add and we begin scanning 
  91.     from the middle of the line, alternating left and right direction on each 
  92.     successive line.  This has the effect of spreading out the double spaces 
  93.     in such a fashion that they are hardly noticeable.  In this pass, we 
  94.     ignore double spaces (like after some punctuation) and double up only on 
  95.     single spaces.  If the line is not fully formatted when one direction is 
  96.     checked, we reverse and check the other way.  During this process, care 
  97.     is taken not to add a space in the LEADING SPACES (or leading tabs) 
  98.     section, or in the soft return itself
  99.  
  100.     The above routine will handle 90% or more of your formatting 
  101.     requirements.  In those cases where still more spaces are required, we 
  102.     then proceed to add a third space after double spaces which existed in 
  103.     the line.  Then third spaces are added elsewhere in the line.  This 
  104.     approach will now handle 99% of the cases.  Fourth and fifth spaces will 
  105.     be added until the line length finally reaches the right margin.  Note 
  106.     that these unusual circumstances can present themselves in 2 situations:  
  107.     they are illustrated in the following paragraphs.
  108.  
  109.                                                  If a paragraph is indented 
  110.                                                  extremely far to the right, 
  111.                                                  there may not be sufficient 
  112.                                                  spaces to allow proper 
  113.                                                  formatting.  This is 
  114.                                                  particularly true when there 
  115.                                                  are several long words in 
  116.                                                  each line.  Justify this DOC 
  117.                                                  file and check out the 
  118.                                                  results.
  119.  
  120.                         The other situation can occur in medium or 
  121.                         normal indents where there are simply too many 
  122.                         very long words.  The first part of this 
  123.                         paragraph is acceptable but see what happens. 
  124.                         Absolutely consecutive iterations occurring 
  125.                         simultaneously on the same line will cause some 
  126.                         problems.  Also, hyphenated words or linked 
  127.                         words like END_OF_FILE and REST_OF_STORY  
  128.                         will cause hardships to the program.
  129.  
  130. Justified lines can be indented by multiple spaces, or TABS followed by 
  131. spaces.  If a tab follows a space, the line will not be justified.  For that 
  132. matter, if a tab appears anywhere in the line after the first non-tab 
  133. character, the line will not be justified.  You can therefore force indented 
  134. paragraphs to be UNJUSTIFIED by preceding them with SPACE-TAB.
  135.  
  136.  
  137.                                PATCHING VDEJUS
  138.  
  139. The default right margin is 77 and the default threshold is 15.  This means 
  140. that lines which end 15 or more from the right margin will not be justified.  
  141. In some cases, this may give undesirable results.  You can override the right 
  142. margin setting on the command line.  However, if you wish to set your own 
  143. defaults, use a disk/file editor or DDT to look at the first record of the 
  144. COM file.  You will see the following DB's:
  145.  
  146.                       JUSTIFY TO COLUMN>?<THRESHOLD>?<
  147.  
  148. The 2 question marks indicate the default margin and threshold values.
  149.  
  150. Guy Cousineau
  151. 1059 Hindley Street
  152. OTTAWA Canada
  153. K2B 5L9
  154.     OTTAWA RCPM (613) 952-2289