def loop &block
      @form.repaint
      @window.wrefresh
      Ncurses::Panel.update_panels
      @break_key = ?\C-q.getbyte(0)
      # added this extra loop since from some places we exit using throw :close
      # amd that was in a much higher place, and was getting us right out, with
      # no chance of user canceling quit. This extra loop allows us to remain
      # added on 2011-11-24 
      while true
        catch :close do
          while((ch = @window.getchar()) != 999 )
            if ch == @break_key || ch == @quit_key
              break
            end


            # 2014-08-19 - 22:51 commented next line, too much choice. keep it simple. delete in a month FIXME
            #yield ch if block # <<<----

            # this is what the user should have control ove. earlier we would put this in
            # a try catch block so user could do what he wanted with the error. Now we
            # need to get it to him somehow, perhaps through a block or on_error event
            begin
              # execute a code block so caller program can handle keys from a hash or whatever.
              # NOTE: these keys will not appear in help
              # FIXME : ideally if its just a hash, we should allow user to give it to form
              #  or widget which it will use, or merge, and be able to print help from
              if @keyblock
                str = keycode_tos ch
                # why did we ever want to convert to a symbol. why not just pass it as is.
                #@keyblock.call(str.gsub(/-/, "_").to_sym) # not used ever
                ret = @keyblock.call(str) 
                if ret
                  @form.repaint 
                  next
                end
              end
              @form.handle_key ch
            rescue => err
              $log.debug( "app.rb handle_key rescue reached ")
              $log.debug( err.to_s) 
              $log.debug(err.backtrace.join("\n")) 
              textdialog [err.to_s, *err.backtrace], :title => "Exception"
            end
            @window.wrefresh
          end
        end # catch
        stopping = @window.fire_close_handler
        @window.wrefresh
        break if stopping.nil? || stopping
      end # while
    end
def loop &block
      @form.repaint
      @window.wrefresh
      Ncurses::Panel.update_panels
      @break_key = ?\C-q.getbyte(0)
      # added this extra loop since from some places we exit using throw :close
      # amd that was in a much higher place, and was getting us right out, with
      # no chance of user canceling quit. This extra loop allows us to remain
      # added on 2011-11-24 
      while true
        catch :close do
          while((ch = @window.getchar()) != 999 )
            if ch == @break_key || ch == @quit_key
              break
            end


            # 2014-08-19 - 22:51 commented next line, too much choice. keep it simple. delete in a month FIXME
            #yield ch if block # <<<----

            # this is what the user should have control ove. earlier we would put this in
            # a try catch block so user could do what he wanted with the error. Now we
            # need to get it to him somehow, perhaps through a block or on_error event
            begin
              # execute a code block so caller program can handle keys from a hash or whatever.
              # NOTE: these keys will not appear in help
              # FIXME : ideally if its just a hash, we should allow user to give it to form
              #  or widget which it will use, or merge, and be able to print help from
              if @keyblock
                str = keycode_tos ch
                # why did we ever want to convert to a symbol. why not just pass it as is.
                #@keyblock.call(str.gsub(/-/, "_").to_sym) # not used ever
                ret = @keyblock.call(str) 
                if ret
                  @form.repaint 
                  next
                end
              end
              @form.handle_key ch
            rescue => err
              $log.debug( "app.rb handle_key rescue reached ")
              $log.debug( err.to_s) 
              $log.debug(err.backtrace.join("\n")) 
              textdialog [err.to_s, *err.backtrace], :title => "Exception"
            end
            @window.wrefresh
          end
        end # catch
        stopping = @window.fire_close_handler
        @window.wrefresh
        break if stopping.nil? || stopping
      end # while
    end
This method is called by run, and thus in most cases this is what is used.
 +run+ calls this without a block
 not sure, but user shuld be able to trap keystrokes if he wants
 but do i still call handle_key if he does, or give him total control.
 But loop is already called by framework