/* ----------------------------------------------------------------- Execution of this macro requires a license for uni-XEDIT Extended for each concurrent user of the macro. ----------------------------------------------------------------- bclr.xedit adapted and generalized, by: The Workstation Group based on bmove.xedit, supplied to TWG by: H. F. Veldman - IST original author: A. B. Doremus, University of Oregon description: This XEDIT macro may be used to clear (set to blanks) any arbitrary rectangular block of text in a file being edited. The macro name should be assigned to a PF key. To use: position cursor over any corner of block to be cleared and press assignd PF key. Then position cursor to diagonally opposite corner of block and again enter Pf key. dependencies: Only works on display terminals. The program stack must be empty on entry (XEDIT READ doesn't work, otherwise). =======================================================================*/ trace o TRUE = 1 FALSE = 0 macname = 'BCLR' call get_src_corners 'extract /line' /* store current line position */ /* blank out source block */ ':'start_line 'cl:'start_col blanks = left('', length, ' ') /* get string of blanks */ do lines 'creplace' blanks /* replace existing string with blanks */ 'down' /* position for next line */ end /* position to old current line and first column */ ':'line.1 'cfirst' exit /*=====================================================================*/ /**************/ get_src_corners: /**************/ if queued() > 0 then do /* XEDIT READ won't work unls pgm stk empty*/ 'msg' macname': program stack must be empty' signal exit16 end /* extract cursor position, validate, and save */ /* also get number of alterations */ 'extract /cursor/alt' /* compare current to original position */ if cursor.3 ~= cursor.7 | cursor.4 ~= cursor.8 then do 'msg' macname': file was changed by prefix operation, aborting' signal exit16 end if cursor.3 = -1 | cursor.4 = -1 then do /* cursor within file? */ 'msg' macname': cursor is not within file, aborting' signal exit16 end c1_line = cursor.3 /* line number in file for first corner */ c1_col = cursor.4 /* column num in file for first corner */ entryalt.1 = alt.1 /* save alteration values on entry */ entryalt.2 = alt.2 done = FALSE do while ~done thismac = FALSE 'msg' macname': move cursor to diagonally opposite corner', 'and enter pf key' 'read cmdline tag' /* see what user hath wrought */ /* (stacked LIFO) */ queued = queued() parse pull tag pfnum pfstring if queued = 2 then do /* => something on cmd line */ parse pull cmdtag cmdstring dot = pos('.xedit',cmdstring) if dot >0 then macstring = substr(cmdstring,1,dot-1) else macstring = cmdstring if wordpos(macname,upper(macstring))=0 then cmdstring else thismac = TRUE end select when tag = 'PFK' | tag = 'PAK' then do dot = pos('.xedit',pfstring) if dot >0 then macstring = substr(pfstring,1,dot-1) else macstring = pfstring if wordpos(macname,upper(macstring))=0 then pfstring else thismac = TRUE end when tag = 'CMD' | tag = 'ETK' then do dot = pos('.xedit',pfnum) if dot >0 then macstring = substr(pfnum,1,dot-1) else macstring = pfnum if wordpos(macname,upper(macstring))=0 then pfnum pfstring else thismac = TRUE end otherwise nop end if thismac then done = TRUE /* If we've somehow quit from last file in ring, get out of here */ 'extract /ring' if rc=6 then exit end /* extract cursor position, validate, and save */ 'extract /cursor/alt' /* compare current to original position */ if cursor.3 ~= cursor.7 | cursor.4 ~= cursor.8 then do 'msg' macname': file was changed by prefix operation, aborting' signal exit16 end if cursor.3 = -1 | cursor.4 = -1 then do /* cursor within file? */ 'msg' macname': cursor is not within file, aborting' signal exit16 end if entryalt.1 ~= alt.1 | entryalt.2 ~= alt.2 then do 'msg' macname': file has been changed, aborting' signal exit16 end c2_line = cursor.3 /* line number in file for second corner */ c2_col = cursor.4 /* column num in file for second corner */ /* calculate number of lines, number of columns */ start_col = min(c1_col, c2_col) length = abs(c1_col - c2_col) + 1 start_line = min(c1_line, c2_line) lines = abs(c1_line - c2_line) + 1 return /*=====================================================================*/ exit16: /* error return */ exit(16)