Code Coverage
 
Lines
Covered
100.00% covered (success)
100.00%
24 / 24
1
module TheFox
1
module TermKit
##
# Basic Text View class. View sub-class.
#
# Provides functionalities to draw text.
1
class TextView < View
1
def initialize(text = nil, name = nil)
166
name = "TextView_#{object_id}" if name.nil?
166
super(name)
#puts 'TextView->initialize'
166
if !text.nil?
163
draw_text(text)
end
end
1
def text=(text)
3
if !text.is_a?(String)
1
raise ArgumentError, "Argument is not a String -- #{text.class} given"
end
2
draw_text(text)
end
1
def draw_text(text)
166
changes = 0
166
y_pos = 0
166
text.split("\n").each do |line|
175
x_pos = 0
# puts "line '#{line}'"
175
line.split('').each do |char|
# puts "c '#{char}'"
951
content = draw_point(Point.new(x_pos, y_pos), char)
951
if !content.nil?
951
changes += 1
end
# puts " c '#{char}' #{changes}"
951
x_pos += 1
end
# puts "line '#{line}', changes #{changes}"
175
y_pos += 1
end
166
changes
end
end
end
end