def pagination(title, options, collection, &block)
      start_line, options[:limit], options[:header] = pagination_limit(title, options)
      if collection.size > (options[:limit] - options[:header]) # minus pagination header
        key   = Device::IO.back_key
        pages = pagination_page(collection, options[:limit] - options[:header]) # minus pagination header
        page  = 1
        while(key == Device::IO.back_key || key == Device::IO.forward_key)
          Device::Display.clear
          pagination_header(title, page, pages.size, start_line, options[:default], options[:header])
          values = pages[page].to_a
          block.call(values, start_line + options[:header])
          key  = try_key(pagination_keys(values.size, true))
          page = pagination_key_page(page, key, pages.size)
        end
      else
        Device::Display.clear
        print_title(title, options[:default]) if title
        values = collection.to_a
        block.call(values, start_line)
        key = try_key(pagination_keys(collection.size, false))
      end
      result = values[key.to_i-1] if key.integer?
      if result.is_a? Array
        [key, result[1]]
      else
        [key, result]
      end
    end
def pagination(title, options, collection, &block)
      start_line, options[:limit], options[:header] = pagination_limit(title, options)
      if collection.size > (options[:limit] - options[:header]) # minus pagination header
        key   = Device::IO.back_key
        pages = pagination_page(collection, options[:limit] - options[:header]) # minus pagination header
        page  = 1
        while(key == Device::IO.back_key || key == Device::IO.forward_key)
          Device::Display.clear
          pagination_header(title, page, pages.size, start_line, options[:default], options[:header])
          values = pages[page].to_a
          block.call(values, start_line + options[:header])
          key  = try_key(pagination_keys(values.size, true))
          page = pagination_key_page(page, key, pages.size)
        end
      else
        Device::Display.clear
        print_title(title, options[:default]) if title
        values = collection.to_a
        block.call(values, start_line)
        key = try_key(pagination_keys(collection.size, false))
      end
      result = values[key.to_i-1] if key.integer?
      if result.is_a? Array
        [key, result[1]]
      else
        [key, result]
      end
    end
TODO Scalone: Refactor.