module BotConsole::Layout
Constants
- MIN_PANE_HEIGHT
- MIN_PANE_WIDTH
Public Instance Methods
Source
# File lib/bot_console/layout.rb, line 29 def horizontal_panes(count, width, height) base = height / count remainder = height % count y = 0 (0...count).map do |index| h = base + (index < remainder ? 1 : 0) h = MIN_PANE_HEIGHT if h < MIN_PANE_HEIGHT rect = { x: 0, y: y, w: width, h: h } y += h rect end end
Source
# File lib/bot_console/layout.rb, line 15 def panes(count:, width:, height:, mode: :horizontal, status_rows: 1) return [] if count <= 0 usable_height = [height - status_rows, MIN_PANE_HEIGHT].max usable_width = width case mode.to_sym when :vertical vertical_panes(count, usable_width, usable_height) else horizontal_panes(count, usable_width, usable_height) end end
Source
# File lib/bot_console/layout.rb, line 42 def vertical_panes(count, width, height) base = width / count remainder = width % count x = 0 (0...count).map do |index| w = base + (index < remainder ? 1 : 0) w = MIN_PANE_WIDTH if w < MIN_PANE_WIDTH rect = { x: x, y: 0, w: w, h: height } x += w rect end end