:> credz to myr for coming up with the idea to do a color paster.

fe ($pattern(cpaste.% $getarrays())) aa {@delarray($aa)}

^on #-window 44 * {
  if (!cpasting) {
    @ numitems(cpaste.$0) == winsize() ? delitem(cpaste.$0 0) :
    @ setitem(cpaste.$0 $numitems(cpaste.$0) $1-)}}

alias paste {
  @ p.sw = winnum()
  @cpasting=1
  ^local blahblah 0
  @holdline=0
  for (@xx=numitems(cpaste.$p.sw)-1,xx >=0, @xx--) {
    @blahblah+=numlines($stripansicodes($getitem(cpaste.$p.sw $xx)))
    if (blahblah==winsize()) {
      @holdline=xx + 1
      ^break}}
  for (@p.c=0, p.c<numitems(cpaste.$p.sw), @p.c++) {
    if (p.c==holdline) {^set hold_mode on}
    echo $(c.hk)[$(c.lc)$[2]p.c$(c.hk)]$(cl) $getitem(cpaste.$p.sw $p.c)}
  input "enter line to paste (or startline stopline): " if (0 < [$0] <= numitems(cpaste.$p.sw)) {
    if (numwords($0-)>1) {
      for (@xx=[$0], xx <=[$1], @xx++) {
        say $getitem(cpaste.$p.sw $xx)}} else {
      say $getitem(cpaste.$p.sw $0)}
    ^set hold_mode off
    @cpasting=0}}
    
    
