Title: Re: Paragraph wrapping with 3 column view
On or near 7/1/04 5:46 AM, Peter C.S. Adams  
at [EMAIL PROTECTED] observed:



> Does Entourage 2004 still have this  
annoying limitation? I would have


> thought after the "text wrap" controversy  
here a couple of years ago they


> would have added the option of wrapping at  
other lengths.



The real answer to this is "format-flowed"  
mail, which wraps to the window width. For  
my taste, anyhow. And I believe that  
Microsoft MBU has this high on the list of  
desired features.



Wrapping at other lengths (with hard, rather  
than soft, wrapping) is okay, too.

I have a script that hard wraps text; I wrapped the above at 45, just to see if it still works (I have not run it for ages). It seems to double blank lines for some reason, and it does not wrap commented lines well, but it works. Sort of. To open the following in Script Editor, select it, then from the Entourage menu, select Services->Script Editor->Make New AppleScript. Switch to script editor and save the script, naming it "Hard Wrap" or whatever you choose, and saving it in the Entourage Script Menu Items folder. If you want to assign it a shortcut, use the suffix conventions described in Entourage Help under "Script Menu". If someone wants to fix the double-spacing problem, be my guest. I've no time.

property newlen : 72
on ProcessMsg(theMsg) --
    tell application "Microsoft Entourage" --
        if class of the front window is not in {message window, draft window} then
            error "You must have a message open for editing to use this script."
            return
        end if
        
        try
            -- set theText to the selection, or if none, to the entire message
            set theText to ""
            try
                set theText to the selection as text
                set partial to true
            end try
            if (theText = "") or (class of theText is not string) then
                set theText to the content of theMsg
                set partial to false
            end if
            
            set theText to my hardwrap(theText)
            if partial then
                set the selection to theText
            else
                if class of the front window is draft window then
                    beep
                    save the front window
                    set the content of the front window to theText
                else
                    set the content of theMsg to theText
                end if
            end if
        on error theErr number theNum
            display dialog theErr
            return
        end try
    end tell --
end ProcessMsg --
on hardwrap(texttowrap)
    set pfx to "" -- Reserved for later use
    set newTxt to ""
    set lineLen to newlen
    set texttowrap to every paragraph of texttowrap
    repeat with aLine in texttowrap
        set savedel to AppleScript's text item delimiters
        set AppleScript's text item delimiters to " "
        repeat while (count of aLine) > 0
            if ((count of aLine) is less than or equal to lineLen) then
                set l to aLine & return
                set aLine to ""
            else
                set l to text 1 thru lineLen of aLine
                set lineList to text items of l
                if (count of lineList) > 1 then -- More than single 'word'
                    set l to items 1 thru -2 of lineList & " "
                    set aLine to item -1 of lineList & text (lineLen + 1) thru -1 of aLine
                else -- no word breaks
                    set aLine to text (lineLen + 1) thru -1 of aLine
                end if
            end if
            set newTxt to newTxt & pfx & l & return
        end repeat
        set newTxt to newTxt & return
    end repeat
    set AppleScript's text item delimiters to savedel
    return newTxt
end hardwrap

on run
    repeat
        display dialog "DEBUG:Wrap message to what length? (5 to 72)" default answer "70"
        set newlen to text returned of result as number
        if newlen ≥ 5 and newlen ≤ 72 then
            exit repeat
        end if
    end repeat
    
    tell application "Microsoft Entourage"
        set currentMessages to the current messages --
        repeat with theMsg in the currentMessages --
            my ProcessMsg(theMsg) --
        end repeat --
    end tell --
end run


Reply via email to