* * FLOWBOXX.KEX * * KEXX macro to format text within a box block. The text is flowed between the * left or right edges of the block with any text to the right of the block * included. This works well for comments like this: * * // Text... * // * // * // * * Works with: * * KEDIT for Windows 1.5 * KEDIT 5.0 for DOS * KEDIT 5.0 for OS/2 * if block.1() \= "BOX" then do "emsg FLOWBOXX Error 1: You need to mark a box block" exit 1 end if block.6() \= fileid.1() then do "emsg FLOWBOXX Error 2: The box block is not in the current file" exit 2 end CurrentFile = fileid.1() TempFile = ".\flowboxx.tmp" ResetBlock = 0 if version.1() = "KEDIT/WINDOWS" then do if block.7() = "SELECTION" then do * Make the selection temporarily persistent "mark persistent" ResetBlock = 1 end end call SavePosition * Remember the original block dimensions TopOfBlock = block.2() BottomOfBlock = block.4() LeftBlockCol = block.3() RightBlockCol = block.5() BlockWidth = block.5() - block.3() + 1 BlockHeight = block.4() - block.2() + 1 * Remark the block so that it extends out to the WIDTH setting so we grab any * text beyond the right edge of the original block "reset block" ":"TopOfBlock "clocate :"LeftBlockCol "mark box" ":"BottomOfBlock "clocate :"width.1() "mark box" * Copy the block into a temporary file "kedit" TempFile "(new noprof" if rc \= 0 then exit rc "add" BlockHeight "copy block" * Setup and flow the copy of the block "set margins" 1 BlockWidth "+0" "reset block" "flow all" * Add any necessary lines to the bottom diff = BlockHeight - size.1() if diff > 0 then do "bottom" "add" diff end * Mark the block in the temporary file ":1" "clocate :1" "mark box" "bottom" n = width.1() - LeftBlockCol "clocate :"n "mark box" NewBlockHeight = size.1() * Overlay the block in the original file "kedit" CurrentFile * We may need to add some lines to amke room for the formatted text if NewBlockHeight > BlockHeight then do ":"BottomOfBlock n = NewBlockHeight - BlockHeight "add" n end ":"TopOfBlock "clocate :"LeftBlockCol "overlaybox" * Quit out of the temporary file and return to the original file "kedit" TempFile "qquit" "kedit" CurrentFile "reset block" if \ResetBlock then do ":"TopOfBlock "clocate :"LeftBlockCol "mark box" ":"BottomOfBlock "clocate :"RightBlockCol "mark box" end call RestorePosition exit 0 * Save the current line and cursor position SavePosition: "sos save" OnCmdline = command() StartLine = line.1() if \OnCmdline then do "cursor cmdline" n = StartLine StartLine = line.1() ":"n return end return * Restore the current line and cursor position RestorePosition: ":"StartLine if \OnCmdline then "sos current" "sos restore" return