def run
      loop do
        begin
          number_pressed = false
          ret = case (c = Curses.getch)
          when 10, 13  # enter, return
            enter
          when 27  # ESC
            q
          when ' '  # space
            space
          when 127  # DEL
            del
          when Curses::KEY_DOWN
            j
          when Curses::KEY_UP
            k
          when Curses::KEY_LEFT
            h
          when Curses::KEY_RIGHT
            l
          when Curses::KEY_CTRL_A..Curses::KEY_CTRL_Z
            chr = ((c - 1 + 65) ^ 0b0100000).chr
            public_send "ctrl_#{chr}" if respond_to?("ctrl_#{chr}")
          when ?0..?9
            public_send c
            number_pressed = true
          when ?!..?~
            if respond_to? c
              public_send c
            else
              debug "key: #{c}" if ENV['DEBUG']
            end
          when Curses::KEY_MOUSE
            if (mouse_event = Curses.getmouse)
              case mouse_event.bstate
              when Curses::BUTTON1_CLICKED
                click y: mouse_event.y, x: mouse_event.x
              when Curses::BUTTON1_DOUBLE_CLICKED
                double_click y: mouse_event.y, x: mouse_event.x
              end
            end
          else
            debug "key: #{c}" if ENV['DEBUG']
          end
          Curses.doupdate if ret
          @times = nil unless number_pressed
        rescue StopIteration
          raise
        rescue => e
          command_line.show_error e.to_s
          raise if ENV['DEBUG']
        end
      end
    ensure
      Curses.close_screen
    end
def run
      loop do
        begin
          number_pressed = false
          ret = case (c = Curses.getch)
          when 10, 13  # enter, return
            enter
          when 27  # ESC
            q
          when ' '  # space
            space
          when 127  # DEL
            del
          when Curses::KEY_DOWN
            j
          when Curses::KEY_UP
            k
          when Curses::KEY_LEFT
            h
          when Curses::KEY_RIGHT
            l
          when Curses::KEY_CTRL_A..Curses::KEY_CTRL_Z
            chr = ((c - 1 + 65) ^ 0b0100000).chr
            public_send "ctrl_#{chr}" if respond_to?("ctrl_#{chr}")
          when ?0..?9
            public_send c
            number_pressed = true
          when ?!..?~
            if respond_to? c
              public_send c
            else
              debug "key: #{c}" if ENV['DEBUG']
            end
          when Curses::KEY_MOUSE
            if (mouse_event = Curses.getmouse)
              case mouse_event.bstate
              when Curses::BUTTON1_CLICKED
                click y: mouse_event.y, x: mouse_event.x
              when Curses::BUTTON1_DOUBLE_CLICKED
                double_click y: mouse_event.y, x: mouse_event.x
              end
            end
          else
            debug "key: #{c}" if ENV['DEBUG']
          end
          Curses.doupdate if ret
          @times = nil unless number_pressed
        rescue StopIteration
          raise
        rescue => e
          command_line.show_error e.to_s
          raise if ENV['DEBUG']
        end
      end
    ensure
      Curses.close_screen
    end
:nodoc:
 The main loop.