Hi Gavin,

On Wed, 8 Jan 2003 00:25:25 +1100
Gavin Sinclair <[EMAIL PROTECTED]> wrote:

> (Left|Right|Center|Full)-justification has little to do with spaces
> and everything to do with newlines.

No, of course this is wrong.

See this line
and this
and this line too

No imagine <Alt>+L would be applied to these three line and it would
only care about '\n'. What's the result?

See this lineand thisand this line too

Bad ... really bad.
The re-justification has to take care of spaces, because it has to
insert one for every '\n'. But now take these lines:

This line is a shorter one.
While this will be a very long, long line that's not wrapped correctly at e.g. 72 
characters counted from beginning of line.
And another shorter line.

No imagine re-justification only replacing every '\n' with ' ':

This line is a shorter one. While this will be a very long, long line that's not 
wrapped correctly at e.g. 72 characters counted from beginning of line. And another 
shorter line.

Result: one long line. So this could only be an intermediate step to the
final result.
What's next? Simple:  The Bat! has to wrap each line at XX (e.g. 72)
characters. But it shouldn't wrap in the middle of a word, but only
between them AND not after XX characters.
So The Bat! has to spplit up these one very long line into single words,
take the first one and check for "length() <= 72". If this is true it
adds the next word and checks again ... until this conditio is false.
No the last appended word is stripped off and the result is written down
a "one line". The just stripped word is taken as starting point for the
next line and the following words are appended until the line length
would grow to much ... and so on.
But "what is a word?" Words distinguished by "non-word boundaries". This
non-word boundaries are defined as "everything but [a-zA-Z0-9_]".
Therefore the space is a simple boundary.
Now in the final "line building" the words are "glued" together by
spaces. As all spaces are "stripped" while splitting the one long line
into words the double spaces are lost.
There's an exception for word-glueing: punctation characters. If the
next word is a punctation character it's appended without trailing
space, to avoid them beeing singled out on a line like this
:

Of course, the whole process could be arbitrary more complex, but that
(or something very similar) is the basic method.
If one now wan't to introduce a "double space between sentences keeper"
he'd have to write a far more complex algorithm.

And this might have two disadvantages:
1. it migth slow down thing sensible
2. One (the coder) might have to implement a completely "self written"
   function to achieve wrapping. The one given in The Bat! might be one
   the component used as editor brings with it, so it's optimized for
   speed and usuability. Implementing an own opens the gate for
   introducing new bugs and significant slow down.

All in all I don't see the down side of The Bat! stripping the double
spaces to single ones. This is still e-mail and not a typewriting
competition and it seems we're all able to read texts even if sentences
are isolated by single spaces.
-- 
Regards
Pit

________________________________________________
Current version is 1.62 | "Using TBUDL" information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to