* * FLOWBOX.KEX * * KEXX macro to format text within a box block without affecting text to the * left or right of the block. Ideal for formatting text within comments * like this: * * /* Text... */ * /* */ * /* */ * /* */ * * Mark a box block around the text you want to format. The left and right block * columns will delimit the left and right edges of the resulting formatted text. * With SET IMPMACRO ON, issue this command from the KEDIT command line: * * flowbox * * 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 FLOWBOX Error 1: Box block not marked' exit 1 end CurrentFile = fileid.1() TempFile = '.\flowbox.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 * Copy the block into a temporary file old_row = block.2() old_col = block.3() 'kedit' TempFile '(new noprof' if rc \= 0 then exit rc if version.1() = "KEDIT/WINDOWS" then "add 1" 'copy block' * Setup and flow the copy of the block width = block.5() - block.3() + 1 height = size.1() 'set margins' 1 width '+0' 'flow all' * Add any necessary lines to top and bottom diff = height - size.1() if diff > 0 then do 'bottom' 'add' diff end * Mark the block in the temporary file ':1' if command() then 'sos current' 'clocate :1' 'mark box' 'bottom' 'clocate :'margins.2() 'mark box' * Overlay the block in the original file 'kedit' CurrentFile ':'old_row 'clocate :'old_col 'overlaybox' * Quit out of the temporary file and return to the original file 'kedit' TempFile 'qquit' 'kedit' CurrentFile call RestorePosition if ResetBlock then "reset block" 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