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

[REBOL] word wrap

From: hijim::pronet::net at: 29-Jul-2001 16:50

I'd like to have a function that will fill and wrap long and short lines for the printer. I'll set it for 70 characters so as to have a 5 character indent on both sides. I found this script in the Rebol library. I've made it work on the screen and the printer. The problem is this: it condenses spaces and line feeds to a single space. All text is run together, and paragraphs are lost. I want to load a normal text file (entered in a text area with wrap on) and be able to print it correctly on the printer. This routine works to break the text into proper length lines. How do I get it to leave line breaks intact? I'd also like to leave initial spaces intact (spaces used to indent). Does anyone have any ideas? Thanks, Jim REBOL [Title: "Test of Wrap"] wrap-text: func [para /margin size /local count][ count: 1 if not margin [size: 30] ; default size trim/lines para forall para [ if all [count >= size find/match para " "][ insert para " " ; I added this to indent printing change para newline count: 0 ] count: count + 1 ] head para ] ; my-file: read %htme.r ;change this to a file on your computer view layout [ backdrop silver * 1.2 button red "Quit" [quit] button "Print File" [print wrap-text my-file] button "Print" [ print wrap-text { This is a paragraph that we want to fill and wrap using the default margin which is set to 20. *Why doesn't the first line indent?* *Add another paragraph to see if indent works here. Why are blank lines lost?* } ] ]