<commit_before># ----------------------------------------------------------------------------- #
#         File: promptmenu.rb
#  Description: a simple 'most' type menu at bottom of screen.
#               Moved from io.rb
#       Author: <NAME>  http://github.com/mare-imbrium/canis/
#         Date: 2014-04-25 - 12:32
#      License: MIT
#  Last update: 2014-04-27 00:10
# ----------------------------------------------------------------------------- #
#  promptmenu.rb  Copyright (C) 2012-2014 <NAME>
#  Depends on rcommandwindow for display_menu

module Canis

  ## A *simple* way of creating menus that will appear in a single row.
  # This copies the menu at the bottom of "most" upon pressing ":".
  # hotkey is the key to invoke an item (a single digit letter)
  #
  # label is an action name
  #
  # desc is a description displayed after an item is chosen. Usually, its like:
  #+ "Folding has been enabled" or "Searches will now be case sensitive"
  #
  # action may be a Proc or a symbol which will be called if item selected
  #+ action may be another menu, so recursive menus can be built, but each
  #+ should fit in a line, its a simple system.

  CMenuItem = Struct.new( :hotkey, :label, :desc, :action )


  ## An encapsulated form of yesterday's Most Menu
  # It keeps the internals away from the user.
  # Its not really OOP in the sense that the PromptMenu is not a MenuItem. That's how it is in
  # our Menu system, and that led to a lot of painful coding (at least for me). This is quite
  # simple. A submenu contains a PromptMenu in its action object and is evaluated in a switch.
  # A recursive loop handles submenus.
  #
  # Prompting of menu options with suboptions etc.
  # A block of code or symbol or proc is executed for any leaf node
  # This allows us to define different menus for different objects on the screen, and not have to map 
  # all kinds of control keys for operations, and have the user remember them. Only one key invokes the menu
  # and the rest are ordinary characters.
  # 
  #  == Example
  #    menu = PromptMenu.new self do
  #      item :s, :goto_start
  #      item :b, :goto_bottom
  #      item :r, :scroll_backward<commit_msg>added line<commit_after># ----------------------------------------------------------------------------- #
#         File: promptmenu.rb
#  Description: a simple 'most' type menu at bottom of screen.
#               Moved from io.rb
#       Author: <NAME>  http://github.com/mare-imbrium/canis/
#         Date: 2014-04-25 - 12:32
#      License: MIT
#  Last update: 2014-08-09 18:55
# ----------------------------------------------------------------------------- #
#  promptmenu.rb  Copyright (C) 2012-2014 <NAME>
#  Depends on rcommandwindow for display_menu

module Canis

  ## A *simple* way of creating menus that will appear in a single row.
  # This copies the menu at the bottom of "most" upon pressing ":".
  # hotkey is the key to invoke an item (a single digit letter)
  #
  # label is an action name
  #
  # desc is a description displayed after an item is chosen. Usually, its like:
  #+ "Folding has been enabled" or "Searches will now be case sensitive"
  #
  # action may be a Proc or a symbol which will be called if item selected
  #+ action may be another menu, so recursive menus can be built, but each
  #+ should fit in a line, its a simple system.

  CMenuItem = Struct.new( :hotkey, :label, :desc, :action )


  ## An encapsulated form of yesterday's Most Menu
  # It keeps the internals away from the user.
  # Its not really OOP in the sense that the PromptMenu is not a MenuItem. That's how it is in
  # our Menu system, and that led to a lot of painful coding (at least for me). This is quite
  # simple. A submenu contains a PromptMenu in its action object and is evaluated in a switch.
  # A recursive loop handles submenus.
  #
  # Prompting of menu options with suboptions etc.
  # A block of code or symbol or proc is executed for any leaf node
  # This allows us to define different menus for different objects on the screen, and not have to map 
  # all kinds of control keys for operations, and have the user remember them. Only one key invokes the menu
  # and the rest are ordinary characters.
  # 
  #  == Example
  #
  #    menu = PromptMenu.new self do
  #      item :s, :goto_start
  #      item :b, :goto_bottom
  #      item :r, :scroll_backward
{'fraction_non_alphanumeric': 0.13789160759204208, 'fraction_numerical': 0.014635261833981249, 'mean_word_length': 2.2520446096654276, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '7037926', 'n_tokens_mistral': 1271, 'n_tokens_neox': 1190, 'n_words': 600}