Method: TerminalLayout::RenderObject#render
- Defined in:
- lib/terminal_layout.rb
#render ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/terminal_layout.rb', line 97 def render # Rather than worry about a 2-dimensional space we're going to cheat # and convert everything to a single point. result = height.times.map { |n| (" " * width) }.join result = ANSIString.new(result) if content && content.length > 0 result[0...content.length] = content.dup.to_s end children.each do |child| rendered_content = child.render # Find the single point where this child's content should be placed. # (child.y * width): make sure we take into account the row we're on # plus (child.y): make sure take into account the number of newlines x = child.x + (child.y * width) result[x...(x+rendered_content.length)] = rendered_content end result end |