home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac.zip / BOX.E < prev    next >
Text File  |  1994-06-21  |  5KB  |  128 lines

  1. ;  For linking version, BOX can be an external command.
  2. ;  Script style suggested by Larry Salomon, Jr.
  3.  
  4. compile if not defined(SMALL)
  5.  define INCLUDING_FILE = 'BOX.E'
  6. tryinclude 'MYCNF.E'
  7.  compile if not defined(SITE_CONFIG)
  8.     const SITE_CONFIG = 'SITECNF.E'
  9.  compile endif
  10.  compile if SITE_CONFIG
  11.     tryinclude SITE_CONFIG
  12.  compile endif
  13.  compile if not defined(NLS_LANGUAGE)
  14.   const NLS_LANGUAGE = 'ENGLISH'
  15.  compile endif
  16. include NLS_LANGUAGE'.e'
  17.  compile if EVERSION >= 6
  18.    EA_comment 'This defines the BOX command; it can be linked or executed directly.'
  19.  compile endif
  20. compile endif
  21.  
  22. defmain     -- External modules always start execution at DEFMAIN.
  23.    'box' arg(1)
  24.  
  25. defc box=  /* give height width style */
  26.    universal tempofid
  27.  
  28.    uparg=upcase(arg(1))
  29.    msg =  BOX_ARGS__MSG
  30.    if not length(uparg) then
  31.       sayerror msg
  32. compile if EVERSION < 5        -- If not EPM
  33.       cursor_command; begin_line;erase_end_line;keyin 'Box '
  34. compile endif
  35.       stop
  36.    endif
  37.    if marktype()<>'BLOCK' then
  38.       sayerror -288  -- 'Block mark required'
  39.       stop
  40.    endif
  41.    flg=0
  42.    for ptr = 1 to length(uparg)
  43.       if flg then
  44.          style=substr(arg(1),ptr,1)
  45.       else
  46.          style=substr(uparg,ptr,1)
  47.       endif
  48.       if style='/' then
  49.          flg=1; iterate
  50.       endif
  51.       if not flg and verify(uparg,"123456BCPAERS") then
  52.          sayerror msg
  53. compile if EVERSION < 5        -- If not EPM
  54.          cursor_command; begin_line;erase_end_line;keyin 'Box '
  55. compile endif
  56.          stop
  57.       endif
  58.       call psave_pos(save_pos)
  59.       getmark firstline,lastline,firstcol,lastcol,fileid
  60.       if style='E' then
  61.          getline tline,firstline,fileid
  62.          getline bline,lastline,fileid
  63.          msg=BOX_MARK_BAD__MSG
  64.          if firstcol=1 or firstline=1 or lastline=fileid.last then
  65.             sayerror msg
  66.             stop
  67.          endif
  68.  
  69.          brc=substr(bline,lastcol+1,1)
  70.          lside=substr(tline,firstcol-1,1)
  71.          if lside='║' or lside='│' or lside=';' or lside='|' or lside='█'  then
  72.             sl=1
  73.          elseif lside='*' and firstcol>2 and  -- MAX prevents error if firstcol <= 2
  74.                               pos(substr(tline,max(firstcol-2,1),1),'{/.') then
  75.                sl=2
  76.          elseif brc=lside then
  77.             sl=1
  78.          else
  79.             sayerror msg
  80.             stop
  81.          endif
  82.          for i=firstline to lastline
  83.             getline line,i,fileid
  84.             replaceline substr(line,1,firstcol-sl-1)||substr(line,firstcol,lastcol+1-firstcol)||substr(line,lastcol+sl+1),i,fileid
  85.          endfor
  86.          deleteline lastline+1,fileid
  87.          deleteline firstline-1,fileid
  88.          call prestore_pos(save_pos)
  89.          call pset_mark( firstline-1,lastline-1,firstcol-sl,lastcol-sl,marktype(),fileid)
  90.       elseif style='R' then
  91.          if not pblock_reflow(0,spc,tempofid) then
  92.             call pblock_reflow(1,spc,tempofid)
  93.          endif
  94.          call prestore_pos(save_pos)
  95.       else
  96.          if flg then
  97.             lside=style;rside=style;tside=style;tlc=style;trc=style;blc=style;brc=style
  98.          else
  99.             if style='P' then lside='{*';rside='*}';tside='*';tlc='{*';trc='*}';blc='{*';brc='*}'
  100.             elseif style='A' then lside=';';rside=' ';tside='*';tlc=';';trc=' ';blc=';';brc=' '
  101.             elseif style='C' then lside='/*';rside='*/';tside='*';tlc='/*';trc='*/';blc='/*';brc='*/'
  102.             elseif style=1 then lside='│';rside='│';tside='─';tlc='┌';trc='┐';blc='└';brc='┘'
  103.             elseif style=2 then lside='║';rside='║';tside='═';tlc='╔';trc='╗';blc='╚';brc='╝'
  104.             elseif style=3 then lside='|';rside='|';tside='-';tlc='+';trc='+';blc='+';brc='+'
  105.             elseif style=4 then lside='█';rside='█';tside='▀';tlc='█';trc='█';blc='▀';brc='▀'
  106.             elseif style=5 then lside='│';rside='│';tside='═';tlc='╒';trc='╕';blc='╘';brc='╛'
  107.             elseif style=6 then lside='║';rside='║';tside='─';tlc='╓';trc='╖';blc='╙';brc='╜'
  108.             elseif style='S' then lside='.*';rside='**';tside='*';tlc='.*';trc='**';blc='.*';brc='**'
  109.             else   style='B';lside=' ';rside=' ';tside=' ';tlc=' ';trc=' ';blc=' ';brc=' '
  110.             endif
  111.          endif
  112.          sl=length(lside)
  113.          width=1+lastcol-firstcol   /* width of inside of box */
  114.          side=substr('',1,width,tside)
  115.          line = substr('',1,firstcol-1)||blc||side||brc
  116.          insertline line,lastline+1,fileid
  117.          insertline substr('',1,firstcol-1)||tlc||side||trc,firstline,fileid
  118.          for i=firstline+1 to lastline+1
  119.             getline line,i,fileid
  120.             replaceline substr(line,1,firstcol-1)||lside||substr(line,firstcol,width)||rside||substr(line,lastcol+1),i,fileid
  121.          endfor
  122.          call prestore_pos(save_pos)
  123.          call pset_mark(firstline+1,lastline+1,firstcol+sl,lastcol+sl,marktype(),fileid)
  124.       endif
  125.       flg=0
  126.    endfor
  127.  
  128.