

class VirtualText

  def initialize(canvas,nblines)

    @canvas=canvas
    @nblines=nblines

    @props=TkDefaults::GUI['VirtualText.text']
    @text_line=0
    @h_line=16
    @margin=5
    @lines=[@nblines]
    @timer=TkAfter.new(Defaults::DEFS['VirtualText.clear']* 1000,-1,proc {shift_lines})
  end 

  def putline(line)

    shift_lines if @text_line == @nblines

    opts= @props.update('text'=>line)
    @lines[@text_line]= TkcText.new(@canvas,@margin,@text_line*@h_line,opts)
    @text_line+= 1
    @timer.restart
  end

  def shift_lines
    return if @text_line== 0


    @lines.shift.delete
    @text_line-=1

    for i in 0...@text_line
      @lines[i].coords(@margin,i*@h_line)
    end
  end
  @timer.stop if @text_line == 0

end

