Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: wrap - wrap-text

From: hijim::pronet::net at: 31-Jul-2001 21:14

Hi Anton, Thanks for the new word wrap function. It didn't want to put a 5 space margin on the first line. I think that was because that paragraph was not preceded by newlines. So I added two newlines at the beginning and removed them at the end of the function's formatting. That made it work perfectly. I probably could have used better code than remove para "^/^/" "^/^/" ; remove two newlines at top remove para "^/^/" "^/^/" ; remove two more newlines at top but that does the work. I posted the revised editor at http://www.geocities.com/~jimclatfelter/eddy.txt I set the wrap length to 76. That way all lines get a maximum of 70 characters plus the 5 spaces at the beginning of the line. Thanks again! Jim wrap-text: func [ para /margin size /local count ][ insert para "^/^/" "^/^/" ; add two newlines at top count: 1 if not margin [size: 72] ; default size replace/all para "^/^/" "^/^/ " ; two newlines and some spaces count: 5 remove para "^/^/" "^/^/" ; remove two newlines at top remove para "^/^/" "^/^/" ; remove two more newlines at top forall para [ if (first para) = newline [count: 0] if all [ count >= size find/reverse para " " ][ para: find/reverse para " " change para newline para: insert next para " " count: 5 ] count: count + 1 ] head para ] Anton wrote: