class Chamomile::Widgets::HorizontalLayout
Horizontal layout — splits width among children.
Attributes
Public Class Methods
Public Instance Methods
Source
# File lib/chamomile/frame.rb, line 193 def panel(title = nil, border: :rounded, width: nil, &block) p = Panel.new(title: title, border: border, width: width) block.call(p) if block @children << p p end
Source
# File lib/chamomile/frame.rb, line 206 def render(width: 80, height: 24) return "" if @children.empty? child_width = width / @children.length parts = @children.map { |c| c.render(width: child_width, height: height) } # Join horizontally line-by-line all_lines = parts.map { |p| p.split("\n", -1) } max_lines = all_lines.map(&:length).max || 0 all_lines.each { |ls| ls << "" while ls.length < max_lines } (0...max_lines).map do |row| all_lines.map { |ls| ls[row] || "" }.join end.join("\n") end
Source
# File lib/chamomile/frame.rb, line 200 def text(content) t = Text.new(content: content.to_s) @children << t t end