Method: Lab#addstr

Defined in:
lib/lab.rb

#addstr(str) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/lab.rb', line 102

def addstr str
   return if $lab_disabled
   extend_buffer @x, @y, str
   extend_attr_buffer @x + 1, @y + 1
   if @x == @buffer[@y].length
      @buffer[@y] << str
   else
      line = @buffer[@y]
      line[@x, str.length] = str
   end
   # todo - fill in attr_buffer with nil's for runs of colour?
   @twt.invalidate_scan @y, @x, (@x + str.length)
   @attr_buffer[@y][@x] = @attr
   (@x+1).upto(@x + str.length) {
      |x| 
      @attr_buffer[@y][x] = nil
   } if str.length > 1
   @x += str.length
end