Board index » delphi » WORD WRAP / LINE EDITOR!

WORD WRAP / LINE EDITOR!

I am writing a small bbs door program that sends a comment to sysop..

The bit I am stuck on is Word Wrap in the edtirof..

The editor will be a simple line editor ie:

1>
2>
3>
4>
5>
6>
7>
8>
9>
10>

I need a word wrap function that will work for this type of thing..
the input is character by character.. (appeneded to a string)

I am sue someone must have a function to do ithis..

any help much appreciated

email to jhod...@netspace.net.au

Jason Hodges

 

Re:WORD WRAP / LINE EDITOR!


Quote
Jason Hodges (jhod...@netspace.net.au) wrote:
> I am writing a small bbs door program that sends a comment to sysop..
> The bit I am stuck on is Word Wrap in the edtirof..
> I am sue someone must have a function to do ithis..

Sure! Use your mind !

When scanning your "string" (hope you don't really use TPascal Strings since
they are limited to 255 chars) :

a:=CurrentPositionInSt; b:=a;
While (b<Length(St)) and (St[b+1]<>' ') do Inc(b);

This extracts a word. Now see if (b-a+1) + the size of the beginning of the
line exceeds or not your WordWrap limit. If it does, previous line is full,
start a new one and place this word.

Repeat the process until all the paragraph has been scanned.

If your editor is smart, it will remove unwanted heading/tailing spaces.

Good luck !
--
Jean-Christophe Boggio                          c...@gestalt.freenix.fr
Pascal and Linux {*word*60}, Dos and Windows independant programmer.

Re:WORD WRAP / LINE EDITOR!


Quote
jhod...@netspace.net.au (Jason Hodges) wrote:
>I am writing a small bbs door program that sends a comment to sysop..
>I need a word wrap function that will work for this type of thing..
>the input is character by character.. (appeneded to a string)

This should not be difficult. When the string reaches a certain length,
say 79, simply scan the string backwards from the end for the first
space. Copy the rest of the line (not including the space!) to a temp
string, delete it from the first string, and append it to the beginning
of the next line. This method will work for a full-screen editor
as well as the line editor you are writing.

Alan

--
My opinions, not ASM's.

Re:WORD WRAP / LINE EDITOR!


Quote
c...@gestalt.freenix.fr (Jean-Christophe Boggio) wrote:
>When scanning your "string" (hope you don't really use TPascal Strings since
>they are limited to 255 chars) :

Seen any 255 column screens lately? I think 255 is plenty
for an editor.

Alan

Alan Hohn -- AMH...@po.ASM-Intl.org
ASM International
Materials Park, OH  44073
My opinions, not ASM's.

Re:WORD WRAP / LINE EDITOR!


Quote
@po.ASM-Intl.org (Alan Hohn) writes:
> c...@gestalt.freenix.fr (Jean-Christophe Boggio) wrote:
> >When scanning your "string" (hope you don't really use TPascal Strings since
> >they are limited to 255 chars) :

> Seen any 255 column screens lately? I think 255 is plenty
> for an editor.

> Alan

The point is can it handle long lines from the files you are editing?  There
are users out there that cannot live with that limitation, and thus would not
get such an editor.

Regards,
Don.

Re:WORD WRAP / LINE EDITOR!


Quote
dbeu...@us.oracle.com (Don Beusee) wrote:
>AMH...@po.ASM-Intl.org (Alan Hohn) writes:
>> Seen any 255 column screens lately? I think 255 is plenty
>> for an editor.
>The point is can it handle long lines from the files you are editing?  There
>are users out there that cannot live with that limitation, and thus would not
>get such an editor.

I agree wholeheartedly. The original application was for a "Comment to
the SysOp" door on a BBS, so there would be no original file to edit.
In most cases, though, length would be a concern, and you'd have to
go to some kind of BigString type.

Alan

Alan Hohn -- AMH...@po.ASM-Intl.org
ASM International
Materials Park, OH  44073
My opinions, not ASM's.

Re:WORD WRAP / LINE EDITOR!


Quote
Alan Hohn (@po.ASM-Intl.org) wrote:
> c...@gestalt.freenix.fr (Jean-Christophe Boggio) wrote:
> >When scanning your "string" (hope you don't really use TPascal Strings
> >since they are limited to 255 chars) :
> Seen any 255 column screens lately? I think 255 is plenty
> for an editor.

I was (obviously) talking about the to-be-wrapped string. Not the final
string.

--
Jean-Christophe Boggio                          c...@gestalt.freenix.fr
Pascal and Linux {*word*60}, Dos and Windows independent programmer.

Other Threads