<commit_before>module PPCurses



  class MenuBar < Responder

    def initialize
      @menu_items = []
    end

    # Expects screen to be PPCurses::Screen object
    # Need to convert to work with a window or a view.
    def show(screen)

      screen.set_pos_by_point(ZERO_POINT)

      @menu_items.each do |menu_item|
        screen.print_with_attribute( "#{menu_item} ", A_REVERSE )
      end

      p = screen.cur_point

      screen.print_with_attribute( ' ' * (screen.width - p.x), A_REVERSE )
    end


    def add_menu_item(menu_item)
      @menu_items.push(menu_item)
    end


    def key_down( key )

      @menu_items.each do |menu_item|
        if key == menu_item.key
          menu_item.action.call
          return
        end
      end

      @next_responder.key_down(key) unless @next_responder.nil?

    end

  end

  # Based on Cocoa NSMenuItem
  #
  # Current link, which probably won't be valid in the future ...
  #
  # https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenuItem_Class/index.html#//apple_ref/occ/instm/NSMenuItem/action
  # ----------------------------------------------------------
  # MenuBarItems ...
  #
  # q:Quit d:Del u:Undel
  #
  class MenuBarItem

    attr_accessor :key
    attr_accessor :label

    attr_accessor :action


    def initialize( key, label )
      @key = key
      @label = label
    end

    def to_s
      "#{@key}:#{@label}"
    end

  end

end
<commit_msg>Grammarz<commit_after>module PPCurses



  class MenuBar < Responder

    def initialize
      @menu_items = []
    end

    # Expects screen to be a PPCurses::Screen object
    # Need to convert to work with a window or a view.
    def show(screen)

      screen.set_pos_by_point(ZERO_POINT)

      @menu_items.each do |menu_item|
        screen.print_with_attribute( "#{menu_item} ", A_REVERSE )
      end

      p = screen.cur_point

      screen.print_with_attribute( ' ' * (screen.width - p.x), A_REVERSE )
    end


    def add_menu_item(menu_item)
      @menu_items.push(menu_item)
    end


    def key_down( key )

      @menu_items.each do |menu_item|
        if key == menu_item.key
          menu_item.action.call
          return
        end
      end

      @next_responder.key_down(key) unless @next_responder.nil?

    end

  end

  # Based on Cocoa NSMenuItem
  #
  # Current link, which probably won't be valid in the future ...
  #
  # https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMenuItem_Class/index.html#//apple_ref/occ/instm/NSMenuItem/action
  # ----------------------------------------------------------
  # MenuBarItems ...
  #
  # q:Quit d:Del u:Undel
  #
  class MenuBarItem

    attr_accessor :key
    attr_accessor :label

    attr_accessor :action


    def initialize( key, label )
      @key = key
      @label = label
    end

    def to_s
      "#{@key}:#{@label}"
    end

  end

end

{'fraction_non_alphanumeric': 0.12979952429493713, 'fraction_numerical': 0.0, 'mean_word_length': 2.0539419087136928, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7186979', 'n_tokens_mistral': 1007, 'n_tokens_neox': 954, 'n_words': 215}