lib/cryptum/ui.rb in cryptum-0.0.386 vs lib/cryptum/ui.rb in cryptum-0.0.387

- old
+ new

@@ -44,17 +44,13 @@ Curses.use_default_colors # This object is used to pass all of the UI sections # around to various Cryptum modules Cryptum::UI::TerminalWindow.new - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Create New Curses Window public_class_method def self.window(opts = {}) height = opts[:height].to_i @@ -69,17 +65,14 @@ left ) window.nodelay = true window - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Draw a Box Around a Window public_class_method def self.line(opts = {}) ui_win = opts[:ui_win] @@ -95,17 +88,13 @@ ui_win: ui_win, color: color, style: style, string: "\u2500" * Curses.cols ) - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Jump to First Column public_class_method def self.colorize(opts = {}) ui_win = opts[:ui_win] @@ -171,11 +160,12 @@ color_id = 255 Curses.init_color(color_id, red, green, blue) color_fg = color_id color_bg = bg else - raise "Color Not Implemented for this Method: #{color}" + e = "Color Not Implemented for this Method: #{color}" + Cryptum::Log.append(level: :error, msg: e, which_self: self) end case style when :blink font = Curses::A_BLINK @@ -186,86 +176,63 @@ when :normal font = Curses::A_NORMAL when :reverse font = Curses::A_REVERSE else - raise "Font Style Not Implemented for this Method: #{style}" + e = "Font Style Not Implemented for this Method: #{style}" + Cryptum::Log.append(level: :error, msg: e, which_self: self) end Curses.init_pair(color_id, color_fg, color_bg) ui_win.attron(Curses.color_pair(color_id) | font) do ui_win.addstr(string) end - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Jump to First Column public_class_method def self.col_center(opts = {}) str = opts[:str] str_divided_by_two = str.length / 2 (Curses.cols / 2) - str_divided_by_two - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end public_class_method def self.col_first 0 - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Jump to Second Column public_class_method def self.col_second (Curses.cols / 8) + 5 - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Jump to Third Column public_class_method def self.col_third ((Curses.cols / 8) * 3) + 2 - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Jump to Fourth Column public_class_method def self.col_fourth ((Curses.cols / 4) * 3) - 3 - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end public_class_method def self.detect_key_press_in_ui(opts = {}) key_press_event = opts[:key_press_event] ui_win = opts[:ui_win] @@ -318,16 +285,12 @@ key_press_event.key_end = true if key_press == '4' end end key_press_event - rescue Interrupt - # Exit Gracefully if CTRL+C is Pressed During Session - Cryptum::UI::Exit.gracefully - rescue StandardError => e + rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else - Curses.close_screen - raise e + Cryptum::Log.append(level: :error, msg: e, which_self: self) end # Display a List of Every UI Module public_class_method def self.help