Sha256: b767e145b4c45f5f52fef097ccf851fc7c48208ece2f0a163033900cbb44800e

Contents?: true

Size: 734 Bytes

Versions: 1

Compression:

Stored size: 734 Bytes

Contents

require 'patchmaster/curses/pm_window'

module PM
class ListWindow < PmWindow

  attr_reader :list

  # +curr_item_method_sym+ is a method symbol that is sent to
  # PM::PatchMaster to obtain the current item so we can highlight it.
  def set_contents(title, list, curr_item_method_sym)
    @title, @list, @curr_item_method_sym = title, list, curr_item_method_sym
    draw
  end

  def draw
    super
    return unless @list

    curr_item = PM::PatchMaster.instance.send(@curr_item_method_sym)
    @list.each_with_index do |thing, i|
      @win.setpos(i+1, 1)
      @win.attron(A_REVERSE) if thing == curr_item
      @win.addstr(make_fit(" #{thing.name} "))
      @win.attroff(A_REVERSE) if thing == curr_item
    end
  end

end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
patchmaster-1.0.0 lib/patchmaster/curses/list_window.rb