def add_child(h={})
      c = nil

      if h.key?(:component)
        c = h[:component]

        h = {:rows => c.requested_rows + c.extra_padding,
             :cols => c.requested_cols + c.extra_padding}.merge(h)
      end

      raise ArgumentError, "must specify x/y" unless h.key?(:x) &&
                                                     h.key?(:y)

      raise ArgumentError, "must specify rows/cols" unless h.key?(:rows) &&
                                                           h.key?(:cols)

      h[:rows], h[:cols] = *Window.adjust_proportional(window, h[:rows], h[:cols])
      h[:x],    h[:y]    = *Window.align(window, h[:x], h[:y], h[:rows], h[:cols])
      h[:rows], h[:cols] = *Window.fill_parent(parent? ? parent.window : Terminal,
                                               h[:x], h[:y],
                                               h[:rows], h[:cols]) if h[:fill]

      if exceeds_bounds_with?(h)
        if expandable? # ... && can_expand_to?(h)
          expand(h)

        else
          raise ArgumentError, "child exceeds bounds"

        end
      end

      child = window.create_child(h)

      # TODO need to reverse expansion if operation fails at any
      # point on, or verify expandable before create_child but
      # do not expand until after

      if child.win.nil?
        raise ArgumentError, "could not create child window"
      end

      if exceeds_bounds?
        window.del_child(child) unless child.win.nil?
        raise ArgumentError, "child exceeds bounds"
      end

      child.component = c unless c.nil?

      update_reterm
      child
    end
def add_child(h={})
      c = nil

      if h.key?(:component)
        c = h[:component]

        h = {:rows => c.requested_rows + c.extra_padding,
             :cols => c.requested_cols + c.extra_padding}.merge(h)
      end

      raise ArgumentError, "must specify x/y" unless h.key?(:x) &&
                                                     h.key?(:y)

      raise ArgumentError, "must specify rows/cols" unless h.key?(:rows) &&
                                                           h.key?(:cols)

      h[:rows], h[:cols] = *Window.adjust_proportional(window, h[:rows], h[:cols])
      h[:x],    h[:y]    = *Window.align(window, h[:x], h[:y], h[:rows], h[:cols])
      h[:rows], h[:cols] = *Window.fill_parent(parent? ? parent.window : Terminal,
                                               h[:x], h[:y],
                                               h[:rows], h[:cols]) if h[:fill]

      if exceeds_bounds_with?(h)
        if expandable? # ... && can_expand_to?(h)
          expand(h)

        else
          raise ArgumentError, "child exceeds bounds"

        end
      end

      child = window.create_child(h)

      # TODO need to reverse expansion if operation fails at any
      # point on, or verify expandable before create_child but
      # do not expand until after

      if child.win.nil?
        raise ArgumentError, "could not create child window"
      end

      if exceeds_bounds?
        window.del_child(child) unless child.win.nil?
        raise ArgumentError, "child exceeds bounds"
      end

      child.component = c unless c.nil?

      update_reterm
      child
    end
Create new child window and add it to layout