# frozen_string_literal: true module Cryptum module UI # This Class is Used by Cryptum::Event to # Detect when the Terminal Window is Resized class TerminalWindow attr_accessor :cols, :key_press_event, :ticker_ui_resize, :ticker_section, :portfolio_section, :order_plan_section, :order_plan_details_section, :order_timer_section, :market_trend_section, :market_trend_ui_resize, :signal_engine_section, :order_execute_section, :order_execute_details_section, :command_section def initialize # Persist the column width of the terminal window # for resize detection in Cryptum::Event self.cols = Curses.cols self.key_press_event = Cryptum::UI::KeyPressEvent.new self.ticker_section = Cryptum::UI.window( height: 7, width: 0, top: 0, left: 0 ) self.portfolio_section = Cryptum::UI.window( height: 6, width: 0, top: 7, left: 0 ) self.order_plan_section = Cryptum::UI.window( height: 11, width: 0, top: 13, left: 0 ) self.order_plan_details_section = Cryptum::UI.window( height: 11, width: 0, top: 13, left: 0 ) self.order_timer_section = Cryptum::UI.window( height: 1, width: 0, top: 24, left: 0 ) self.market_trend_section = Cryptum::UI.window( height: 2, width: 0, top: 25, left: 0 ) self.signal_engine_section = Cryptum::UI.window( height: 2, width: 0, top: 27, left: 0 ) self.order_execute_section = Cryptum::UI.window( height: 11, width: 0, top: 29, left: 0 ) self.order_execute_details_section = Cryptum::UI.window( height: 11, width: 0, top: 29, left: 0 ) self.command_section = Cryptum::UI.window( height: 3, width: 0, top: 40, left: 0 ) end rescue Interrupt # Exit Gracefully if CTRL+C is Pressed During Session Cryptum::UI::Exit.gracefully(which_self: self) rescue StandardError => e # Produce a Stacktrace for anything else Curses.close_screen raise e end end end