home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / editors / epm / e_macros / box.e < prev    next >
Encoding:
Text File  |  1992-12-18  |  4.7 KB  |  125 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 endif
  18.  
  19. defmain     -- External modules always start execution at DEFMAIN.
  20.    'box' arg(1)
  21.  
  22. defc box=  /* give height width style */
  23.    universal tempofid
  24.  
  25.    uparg=upcase(arg(1))
  26.    msg =  BOX_ARGS__MSG
  27.    if not length(uparg) then
  28.       sayerror msg
  29. compile if EVERSION < 5        -- If not EPM
  30.       cursor_command; begin_line;erase_end_line;keyin 'Box '
  31. compile endif
  32.       stop
  33.    endif
  34.    if marktype()<>'BLOCK' then
  35.       sayerror -288  -- 'Block mark required'
  36.       stop
  37.    endif
  38.    flg=0
  39.    for ptr = 1 to length(uparg)
  40.       if flg then
  41.          style=substr(arg(1),ptr,1)
  42.       else
  43.          style=substr(uparg,ptr,1)
  44.       endif
  45.       if style='/' then
  46.          flg=1; iterate
  47.       endif
  48.       if not flg and verify(uparg,"123456BCPAERS") then
  49.          sayerror msg
  50. compile if EVERSION < 5        -- If not EPM
  51.          cursor_command; begin_line;erase_end_line;keyin 'Box '
  52. compile endif
  53.          stop
  54.       endif
  55.       call psave_pos(save_pos)
  56.       getmark firstline,lastline,firstcol,lastcol,fileid
  57.       if style='E' then
  58.          getline tline,firstline,fileid
  59.          getline bline,lastline,fileid
  60.          msg=BOX_MARK_BAD__MSG
  61.          if firstcol=1 or firstline=1 or lastline=fileid.last then
  62.             sayerror msg
  63.             stop
  64.          endif
  65.  
  66.          brc=substr(bline,lastcol+1,1)
  67.          lside=substr(tline,firstcol-1,1)
  68.          if lside='║' or lside='│' or lside=';' or lside='|' or lside='█'  then
  69.             sl=1
  70.          elseif lside='*' and firstcol>2 and  -- MAX prevents error if firstcol <= 2
  71.                               pos(substr(tline,max(firstcol-2,1),1),'{/.') then
  72.                sl=2
  73.          elseif brc=lside then
  74.             sl=1
  75.          else
  76.             sayerror msg
  77.             stop
  78.          endif
  79.          for i=firstline to lastline
  80.             getline line,i,fileid
  81.             replaceline substr(line,1,firstcol-sl-1)||substr(line,firstcol,lastcol+1-firstcol)||substr(line,lastcol+sl+1),i,fileid
  82.          endfor
  83.          deleteline lastline+1,fileid
  84.          deleteline firstline-1,fileid
  85.          call prestore_pos(save_pos)
  86.          call pset_mark( firstline-1,lastline-1,firstcol-sl,lastcol-sl,marktype(),fileid)
  87.       elseif style='R' then
  88.          if not pblock_reflow(0,spc,tempofid) then
  89.             call pblock_reflow(1,spc,tempofid)
  90.          endif
  91.          call prestore_pos(save_pos)
  92.       else
  93.          if flg then
  94.             lside=style;rside=style;tside=style;tlc=style;trc=style;blc=style;brc=style
  95.          else
  96.             if style='P' then lside='{*';rside='*}';tside='*';tlc='{*';trc='*}';blc='{*';brc='*}'
  97.             elseif style='A' then lside=';';rside=' ';tside='*';tlc=';';trc=' ';blc=';';brc=' '
  98.             elseif style='C' then lside='/*';rside='*/';tside='*';tlc='/*';trc='*/';blc='/*';brc='*/'
  99.             elseif style=1 then lside='│';rside='│';tside='─';tlc='┌';trc='┐';blc='└';brc='┘'
  100.             elseif style=2 then lside='║';rside='║';tside='═';tlc='╔';trc='╗';blc='╚';brc='╝'
  101.             elseif style=3 then lside='|';rside='|';tside='-';tlc='+';trc='+';blc='+';brc='+'
  102.             elseif style=4 then lside='█';rside='█';tside='▀';tlc='█';trc='█';blc='▀';brc='▀'
  103.             elseif style=5 then lside='│';rside='│';tside='═';tlc='╒';trc='╕';blc='╘';brc='╛'
  104.             elseif style=6 then lside='║';rside='║';tside='─';tlc='╓';trc='╖';blc='╙';brc='╜'
  105.             elseif style='S' then lside='.*';rside='**';tside='*';tlc='.*';trc='**';blc='.*';brc='**'
  106.             else   style='B';lside=' ';rside=' ';tside=' ';tlc=' ';trc=' ';blc=' ';brc=' '
  107.             endif
  108.          endif
  109.          sl=length(lside)
  110.          width=1+lastcol-firstcol   /* width of inside of box */
  111.          side=substr('',1,width,tside)
  112.          line = substr('',1,firstcol-1)||blc||side||brc
  113.          insertline line,lastline+1,fileid
  114.          insertline substr('',1,firstcol-1)||tlc||side||trc,firstline,fileid
  115.          for i=firstline+1 to lastline+1
  116.             getline line,i,fileid
  117.             replaceline substr(line,1,firstcol-1)||lside||substr(line,firstcol,width)||rside||substr(line,lastcol+1),i,fileid
  118.          endfor
  119.          call prestore_pos(save_pos)
  120.          call pset_mark(firstline+1,lastline+1,firstcol+sl,lastcol+sl,marktype(),fileid)
  121.       endif
  122.       flg=0
  123.    endfor
  124.  
  125.