# frozen_string_literal: true

module Cryptum
  # This plugin is used to Switch through Order Plan / Order History
  # Window Panes when the TAB Key is Pressed.
  module Event
    module Pane
      # Supported Method Parameters::
      # Cryptum::Event::Pane.switch(
      # )
      public_class_method def self.switch(opts = {})
        terminal_win = opts[:terminal_win]
        event_history = opts[:event_history]

        terminal_win.key_press_event.key_tab = false

        if event_history.order_plan_win_active
          event_history.order_plan_win_active = false
          event_history.order_execute_win_active = true
        else
          event_history.order_plan_win_active = true
          event_history.order_execute_win_active = false
        end
      rescue StandardError => e
        raise e
      end

      # Display Usage for this Module
      public_class_method def self.help
        puts "USAGE:
          #{self}.switch()
        "
      end
    end
  end
end