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Ã
Wrap
Text File
|
2000-06-30
|
9KB
|
154 lines
LINE JUSTIFICATION FOR VDE FILES
VDE 2.6x is a great compact text editor. It includes most of the useful
features of WORDSTAR and other editors, but it does lack line justification.
I have looked at several stand alone programs to handle this task; Irv Hoff's
(rip) JUST.COM comes the closest to doing what I want. It does a great job
of justifying the lines that it converts, and I have adapted some of his
ideas. What JUST fails to do is recognize which lines are to be justified.
It involves CODING the source document which can be a pain at times. VDE
2.6x via the SOFT RETURN approach can tell another program which lines
require justification. Enter VDEJUS.COM....
-Works with any size text file with a small transfer buffer
-Works only on lines which end with a soft return i.e. <space> <CR> <LF>
-Works on indented lines whether TABS or SPACES were used for formatting
-Adds extra spaces in the middle of all lines instead of using the ends
-Adds spaces to existing double spaces only after single spaces expanded
-Creates an output file with file type .JUS to leaving original intact
If you use JUS.COM to justify this .DOC file, the list above would have been
justified. VDEJUS on the other hand would not process these lines.
What if you want to justify a paragraph at a margin other
than the default. Take this one for example. I Normally set
my right margin to 77 and I want this one to be indented from
both the left and right side. I can cheat the program into
doing most of the work for me by setting my right margin to
61 (16 less than normal) and writing the paragraph as usual.
Once I am finished, I reset my margin to 77 (normal) and add
2 tabs before each line. VDEJUS will align the text to the
right margin and then all I need to do is remove one tab to
centre my paragraph.
To try this out, run VDEJUS on this .DOC file and have a look at the results.
This technique can be used with any indent value; just add the desired right
margin to the left margin prior to justification and remove the extra spaces
after. I find this technique more versatile and less cumbersome than CODING
individual lines.
INSTALLATION
VDEJUS uses no terminal specific information and will work on any CP/M system
with 16K of RAM. See the notes at the end of this file for changing the
default margin.
SYNTAX
The syntax is quite simple: VDEJUS [d:]ufn [margin]
where ufn is an unambiguous file name (no wild cards) and may be preceded by
a drive code (sorry no user). If a drive is specified, the output file will
be on the same drive. If no margin is specified, the default is used. To
override the default margin, you can supply a 2 digit number from 10 to 99
for a justification column. Note that this is the last column in which text
will appear; trailing spaces are not counted.
TECHNICAL STUFF
The full source code (except the MACLIB's) has been included. If you wish to
modify the code, you will require your own EQU's for the BDOS functions and a
few other constants. You will also require your own HEXDEC module which
saves all registers.
VDEJUS works on a file in the following fashion:
Read in one line up to a carriage return and place it in a buffer. Count
the physical number of characters in the line as it is read
Remove all but one trailing space from the end of the line. If spaces
are removed, adjust the length of line accordingly.
Check if the line ends in a soft return. This is defined as VDE 2.6x's
implementation of <SPACE><RETURN> to define a soft return. If there is
no soft return, then flush out the line as is.
Now the hard stuff begins. The first task is to check for leading tabs.
Rather than convert tabs and expand the line, 7 is added to the length
count for each leading tab. Once no more leading tabs are found, check
the rest of the line. If there are more tabs, let's presume you don't
want the line justified.
Now we add the physical line length and TAB FACTOR to get the printed
line length. If this is greater than the margin setting, flush the line.
If this is more than the threshold level (15 characters) from the right
margin, do not justify the line. This was the hardest decision to make.
I presume that if you have a 15-character word at the end of a line that
you would have hyphenated it rather than leave a large gap.
Then the line_length+tabs is subtracted from the margin setting to
determine the number of formatting spaces to add and we begin scanning
from the middle of the line, alternating left and right direction on each
successive line. This has the effect of spreading out the double spaces
in such a fashion that they are hardly noticeable. In this pass, we
ignore double spaces (like after some punctuation) and double up only on
single spaces. If the line is not fully formatted when one direction is
checked, we reverse and check the other way. During this process, care
is taken not to add a space in the LEADING SPACES (or leading tabs)
section, or in the soft return itself
The above routine will handle 90% or more of your formatting
requirements. In those cases where still more spaces are required, we
then proceed to add a third space after double spaces which existed in
the line. Then third spaces are added elsewhere in the line. This
approach will now handle 99% of the cases. Fourth and fifth spaces will
be added until the line length finally reaches the right margin. Note
that these unusual circumstances can present themselves in 2 situations:
they are illustrated in the following paragraphs.
If a paragraph is indented
extremely far to the right,
there may not be sufficient
spaces to allow proper
formatting. This is
particularly true when there
are several long words in
each line. Justify this DOC
file and check out the
results.
The other situation can occur in medium or
normal indents where there are simply too many
very long words. The first part of this
paragraph is acceptable but see what happens.
Absolutely consecutive iterations occurring
simultaneously on the same line will cause some
problems. Also, hyphenated words or linked
words like END_OF_FILE and REST_OF_STORY
will cause hardships to the program.
Justified lines can be indented by multiple spaces, or TABS followed by
spaces. If a tab follows a space, the line will not be justified. For that
matter, if a tab appears anywhere in the line after the first non-tab
character, the line will not be justified. You can therefore force indented
paragraphs to be UNJUSTIFIED by preceding them with SPACE-TAB.
PATCHING VDEJUS
The default right margin is 77 and the default threshold is 15. This means
that lines which end 15 or more from the right margin will not be justified.
In some cases, this may give undesirable results. You can override the right
margin setting on the command line. However, if you wish to set your own
defaults, use a disk/file editor or DDT to look at the first record of the
COM file. You will see the following DB's:
JUSTIFY TO COLUMN>?<THRESHOLD>?<
The 2 question marks indicate the default margin and threshold values.
Guy Cousineau
1059 Hindley Street
OTTAWA Canada
K2B 5L9
OTTAWA RCPM (613) 952-2289