TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ERIC MCDERMOTT
from: TOM HALL
date: 1994-12-13 16:04:00
subject: ALT-B REFORMATTING MACRO

>Found an old backup that included the macro I was looking for. Thank God 
>for redundancy.... :-)
 EM> I'd like to see this one - Pretty please?   :)
Here 'tis... :-)
I call it WRAP.S, and have bound this to , which I define in TSE.UI 
:
                 ExecMacro('c:\tse2\mac\wrap')
If no block is marked, the default wrapping occurs; otherwise, using Column 
Blocks, the following gets called:
_ _ _ O_/_ _C_U_T_ _H_E_R_E_ _ _ _ _ _ _
      O \
Keydef pausekeys
             EndProcess()
        Left() Message ("goto desired Rt-Margin,  press Return")
       Right() Message ("goto desired Rt-Margin,  press Return") 
end
proc mWrapPara()
//-------------------------------
integer OrigBlockEndCol, newColRtMrgn                     //jn integer 
OrigBlockLines, newBlockLines, moreLinesInBlock   //jn 
//-------------------------------
    integer
        id,                         // work buffer id
        block_beg_col,
        save_leftmargin,
        save_rightmargin,
        save_autoindent,
        save_wrapend,
        curr_id = GetBufferId(),    // current file id
        blocktype = isCursorInBlock()
    if blocktype == 0
        WrapPara()
        Return()                                             //jn
    else
        Set(Marking, off)               // Stop marking
        if blocktype  _COLUMN_        // Wrap entire block if not column
            GotoBlockEnd()
            AddLine()
            GotoBlockBegin()
            repeat
            until (not WrapPara()) or (not isCursorInBlock())
            if CurrLineLen() == 0
                DelLine()
            endif
            Return()                                          //jn
        endif
    endif
    //  wrap whats in col
    gotoblockEnd()                                            //jn
    OrigBlockEndCol = CurrCol()                               //jn
    GotoBlockBegin()
    block_beg_col = CurrCol()
//-----------------------------------------------jn
  GotoColumn(OrigBlockEndCol)
  Enable(pausekeys, _EXCLUSIVE_)
  Message ("goto desired Rt-Margin,  press Return")
  Process()
  Disable(pausekeys)
  newColRtMrgn = CurrCol()
  GotoBlockBegin()
//-----------------------------------------------jn
    id = CreateTempBuffer()
    CopyBlock()                 // Copy block to temp buffer 
//___________________________________jn
     while lFind("  ", "")
          DelChar()
          endWhile
//___________________________________jn
    /**************************************************************
      The number of lines in the column may become less than what
      it was - so we must fill the old block with spaces.
     **************************************************************/
    PushBlock()                 // Save block settings
    GotoBufferId(curr_id)       // Back to original file
    CopyBlock(_OVERWRITE_)      // And get the block back
    FillBlock(' ')              // Wipe it out
    GotoBufferid(id)            // Back to where we were
    PopBlock()                  // And get our block marked again
    /**************************************************************
      Prepare to wrap - we need to set the left/right margins to
      1 and the width of the column.  We also need to preserve the
      old settings.
     **************************************************************/
    save_leftmargin = Set(LeftMargin, 1)
    GotoBlockEnd()
    save_rightmargin = Set(RightMargin, CurrCol())
    OrigBlockLines = CurrLine()                                //jn
    save_autoindent = Set(AutoIndent, Off)
    save_wrapend = Set(ParaEndStyle, 0)
    BegFile()
    Set(RightMargin, newColRtMrgn - block_beg_col +1)         //jn
    repeat
    until not WrapPara()
    UnmarkBlock()           // We need to re-mark the block
    NewBlockLines = CurrLine()                                  //jn
    BegFile()
    MarkColumn()
    EndFile()
    GotoColumn(newColRtMrgn - block_beg_col +1)                 //jn
    /*************************************************************
      And finally, go back to the original file, and copy the block
      in.
     *************************************************************/
    GotoBufferId(curr_id)
//------------------------------------------------------jn
    moreLinesInBlock = NewBlockLines - OrigBlockLines
    if moreLinesInBlock > 0
          down(OrigBlockLines)
          repeat
               addline()
               moreLinesInBlock = moreLinesInBlock - 1
               until moreLinesInBlock == 0
          up(NewBlockLines)
          endif
    if moreLinesInBlock < 0
          down(NewBlockLines )
          repeat
               delline()
               moreLinesInBlock = moreLinesInBlock +1
               until moreLinesInBlock == 0
          up(NewBlockLines )
          endif
//------------------------------------------------------jn
    CopyBlock(_OVERWRITE_)
    AbandonFile(id)
    GotoBlockBegin()                                       //jn
    GotoColumn(block_beg_col)
    // Restore saved settings
    Set(LeftMargin, save_leftmargin)
    Set(RightMargin, save_rightmargin)
    Set(AutoIndent, save_autoindent)
    Set(ParaEndStyle, save_wrapend)
end mWrapPara
//-----------------End Macro
Proc Main()
    mWrapPara()
end
--- Maximus 2.01wb
---------------
* Origin: Ten Forward (1:342/1)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.