def handle_click button, modifiers, x, y
if button == :scrollup
@offset -= 1 if @offset > 0
@index = [@offset + fit_data[1] - 1, @index].min
elsif button == :scrolldown
@offset += 1 if @offset < (@data.size - fit_data_back(@data.size)[1])
@index = [@offset, @index].max
elsif button == :left
if Time.now - @lastclick < 0.5
button = :double
end
@lastclick = Time.now
previous = @index
row = y1
data[@offset, height].each_with_index do |line, index|
_height = line_height(line)
if _height + row > height
break
else
row += _height
end
if row > y
@index = index + @offset
break
end
end
handler.call self, @data[@index] if button == :double && previous == @index && handler
end
redraw
end