home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / FPC35_5.ZIP / FPCSRC.ZIP / SEDCOPY.SEQ < prev    next >
Encoding:
Text File  |  1989-06-08  |  6.0 KB  |  143 lines

  1. \ SEDCOPY.SEQ           Editor Cut Copy & Paste         by Tom Zimmer
  2.  
  3. : insertaline   ( a1 --- )
  4.                 ?showfull ?exit
  5.                 linebuf over c@ 1+ 2- cmove
  6.                 linebuf c@ dup =: linelen =: screenchar
  7.                 ch/l linebuf c!
  8.                 modified
  9.                 nodisp-nln ;
  10.  
  11. create cut/copy_file ," TEMP.SEQ"
  12.  
  13. : imp/exp.init  ( --- )
  14.                 cut/copy_file ed2hndl $>handle ;
  15.  
  16. : getinpfile    ( --- f1 )
  17.                 imp/exp.init
  18.                 ?shiftkey dup
  19.                 if      drop
  20.                         ['] femit  is emit
  21.                         ['] noop save!> doLF
  22.                         getfile 0=  showstat            \ get a filename
  23.                         restore> doLF
  24.                         ['] (emit) is emit
  25.                         dup 0=
  26.                         if      swap ed2hndl $>handle
  27.                         then
  28.                 then    ;
  29.  
  30. 0 value export$
  31.  
  32. : ?getexpfile   ( --- f1 )      \ get a filename, and test to see if it
  33.                                 \ already exists before overwriting it.
  34.                 imp/exp.init
  35.                 ?shiftkey dup
  36.                 if      drop
  37.                         8 6 73 12 box&fill
  38.                         space >rev export$ count type >norm
  39.                         ."    Enter=accept  ESC=cancel"
  40.                         " TEMP.SEQ" ">$ pad over c@ 1+ cmove
  41.                         on> autoclear
  42.                         >attrib1
  43.                         10 9 pad 59 lineeditor       ( --- f1 )
  44.                         >norm
  45.                         pad c@ 0<> and
  46.                         if      pad ed2hndl $>handle ed2hndl pathset
  47.                                 " Can't read drive path" ?terror
  48.                                 already_exists?         \ prompt for replace
  49.                                                         \ if already exists.
  50.                                 10 11 at
  51.                         else    true scrshow
  52.                         then
  53.                 else    10 6 70 8 box&fill space
  54.                 then    ;
  55.  
  56. : export        ( --- )
  57.                 marking 0=
  58.                 if      .nomark exit
  59.                 then    "  Copy marked text to filename: " ">$ =: export$
  60.                 ?getexpfile ?exit
  61.                 ." Copying text to " ed2hndl count type ." ..."
  62.                 ed2hndl hcreate 0=
  63.                 if      0.0 ed2hndl movepointer
  64.                         off> wblen
  65.                         markend 1+ markstrt
  66.                         ?do     i linewrite ?leave
  67.                         loop    flushwrite      ( --- f1 )
  68.                         if      true " \4 Failed, Disk FULL " ?softerror
  69.                         else    ." ..Done " ?doingmac 0=
  70.                                 if      7 tenths then
  71.                         then    ed2hndl hclose
  72.                         " \4 Error Closing File " ?softerror
  73.                         mark-clear
  74.                 else    true " \4 Failed, Couldn't CREATE file " ?softerror
  75.                 then    scrshow ;
  76.  
  77. ' export is exportx     \ patch into smaller editor
  78.  
  79. : excut         ( --- )         \ Cut out marked text
  80.                 ?browse ?exit
  81.                 marking 0=
  82.                 if      .nomark exit
  83.                 then    "  Cut marked text to filename: " ">$ =: export$
  84.                 ?getexpfile ?exit
  85.                 ." Cutting text to " ed2hndl count type ."  ..."
  86.                 ed2hndl hcreate 0=
  87.                 if      0.0 ed2hndl movepointer
  88.                         off> wblen
  89.                         markend 1+ markstrt
  90.                         do      i linewrite ?leave
  91.                         loop    flushwrite 0=
  92.                         if      ed2hndl hclose drop
  93.                                 curline markstrt >
  94.                                 if      markstrt backto.line
  95.                                 else    markstrt to.line
  96.                                 then    markend markstrt - #deletelines
  97.                                 linedelete      \ in case we're on last line
  98.                                 ." ..Done " ?doingmac 0=
  99.                                 if      7 tenths then
  100.                                 clipdown
  101.                         else    true " \4 Failed, Disk FULL " ?softerror
  102.                         then    mark-clear
  103.                 else    true " \4 Failed, Couldn't CREATE file " ?softerror
  104.                 then    scrshow ;
  105.  
  106. ' excut is excutx       \ patch into smaller editor
  107.  
  108. : import        ( --- )
  109.                 ?browse ?exit
  110.                 ?showfull ?exit
  111.                 getinpfile ?exit
  112.                 true save!> imode
  113.                 ed2hndl hopen 0=
  114.                 if      0.0 ed2hndl movepointer
  115.                         off> loadline
  116.                         ibreset
  117.                         shoml nln suln
  118.                         10 09 70 12 box&fill
  119.                         ed2hndl save!> seqhandle
  120.                         ."  Importing from " seqhandle count type bcr
  121.                         ."  Inserting lines...     Press \r ESC \0 to Abort"
  122.                         57 11 at .time
  123.                         cursor-off
  124.                         ?doingmac 0=
  125.                         if      5 tenths then
  126.                         begin   lineread  dup c@ 0<> ?full 0= and
  127.                                 key? if key 27 <> and then
  128.                         while   loadline @ 7 and 0=
  129.                                 if      30 11 at >rev
  130.                                         loadline @ 4 .r >norm
  131.                                         loadline @ 31 and 0=
  132.                                         if      57 11 at .time
  133.                                         then
  134.                                 then    insertaline
  135.                         repeat  drop    <ldel>
  136.                         restore> seqhandle
  137.                         ed2hndl hclose drop
  138.                 then    scrshow cursor-on ?cursor
  139.                 restore> imode emptykbd ?showfull drop ;
  140.  
  141. ' import is importx     \ patch into smaller editor
  142.  
  143.