def handle_key ch #:nodoc:
      if header_row?
        ret = header_handle_key ch
        return ret unless ret == :UNHANDLED
      end
      case ch
      when ?\C-a.getbyte(0) #, ?0.getbyte(0)
        # take care of data that exceeds maxlen by scrolling and placing cursor at start
        @repaint_required = true if @pcol > 0 # tried other things but did not work
        set_form_col 0
        @pcol = 0
      when ?\C-e.getbyte(0), ?$.getbyte(0)
        # take care of data that exceeds maxlen by scrolling and placing cursor at end
        # This use to actually pan the screen to actual end of line, but now somewhere
        # it only goes to end of visible screen, set_form probably does a sanity check
        blen = @buffer.rstrip.length
        set_form_col blen
        # search related 
      when KEY_ENTER, FFI::NCurses::KEY_ENTER
        #fire_handler :PRESS, self
        fire_action_event
      when ?0.getbyte(0)..?9.getbyte(0)
        # FIXME the assumption here was that if numbers are being entered then a 0 is a number
        # not a beg-of-line command.
        # However, after introducing universal_argument, we can enters numbers using C-u and then press another
        # C-u to stop. In that case a 0 should act as a command, even though multiplier has been set
        if ch == ?0.getbyte(0) and $multiplier == 0
          # copy of C-a - start of line
          @repaint_required = true if @pcol > 0 # tried other things but did not work
          set_form_col 0
          @pcol = 0
          return 0
        end
        # storing digits entered so we can multiply motion actions
        $multiplier *= 10 ; $multiplier += (ch-48)
        return 0
      when ?\C-c.getbyte(0)
        $multiplier = 0
        return 0
      else
        # check for bindings, these cannot override above keys since placed at end
        begin
          ret = process_key ch, self
        rescue => err
          $error_message.value = err.to_s
          #          @form.window.print_error_message # changed 2011 dts  
          $log.error " Tabularwidget ERROR #{err} "
          $log.debug(err.backtrace.join("\n"))
          textdialog ["Error in TabularWidget: #{err} ", *err.backtrace], :title => "Exception"
          # XXX caller app has no idea error occurred so can't do anything !
        end
        return :UNHANDLED if ret == :UNHANDLED
      end
      $multiplier = 0 # you must reset if you've handled a key. if unhandled, don't reset since parent could use
      set_form_row
      $status_message.value =  "F10 quit, F1 Help, : menu, toprow #{@toprow} current #{@current_index} " if $log.debug?
      return 0 # added 2010-01-12 22:17 else down arrow was going into next field
    end
def handle_key ch #:nodoc:
      if header_row?
        ret = header_handle_key ch
        return ret unless ret == :UNHANDLED
      end
      case ch
      when ?\C-a.getbyte(0) #, ?0.getbyte(0)
        # take care of data that exceeds maxlen by scrolling and placing cursor at start
        @repaint_required = true if @pcol > 0 # tried other things but did not work
        set_form_col 0
        @pcol = 0
      when ?\C-e.getbyte(0), ?$.getbyte(0)
        # take care of data that exceeds maxlen by scrolling and placing cursor at end
        # This use to actually pan the screen to actual end of line, but now somewhere
        # it only goes to end of visible screen, set_form probably does a sanity check
        blen = @buffer.rstrip.length
        set_form_col blen
        # search related 
      when KEY_ENTER, FFI::NCurses::KEY_ENTER
        #fire_handler :PRESS, self
        fire_action_event
      when ?0.getbyte(0)..?9.getbyte(0)
        # FIXME the assumption here was that if numbers are being entered then a 0 is a number
        # not a beg-of-line command.
        # However, after introducing universal_argument, we can enters numbers using C-u and then press another
        # C-u to stop. In that case a 0 should act as a command, even though multiplier has been set
        if ch == ?0.getbyte(0) and $multiplier == 0
          # copy of C-a - start of line
          @repaint_required = true if @pcol > 0 # tried other things but did not work
          set_form_col 0
          @pcol = 0
          return 0
        end
        # storing digits entered so we can multiply motion actions
        $multiplier *= 10 ; $multiplier += (ch-48)
        return 0
      when ?\C-c.getbyte(0)
        $multiplier = 0
        return 0
      else
        # check for bindings, these cannot override above keys since placed at end
        begin
          ret = process_key ch, self
        rescue => err
          $error_message.value = err.to_s
          #          @form.window.print_error_message # changed 2011 dts  
          $log.error " Tabularwidget ERROR #{err} "
          $log.debug(err.backtrace.join("\n"))
          textdialog ["Error in TabularWidget: #{err} ", *err.backtrace], :title => "Exception"
          # XXX caller app has no idea error occurred so can't do anything !
        end
        return :UNHANDLED if ret == :UNHANDLED
      end
      $multiplier = 0 # you must reset if you've handled a key. if unhandled, don't reset since parent could use
      set_form_row
      $status_message.value =  "F10 quit, F1 Help, : menu, toprow #{@toprow} current #{@current_index} " if $log.debug?
      return 0 # added 2010-01-12 22:17 else down arrow was going into next field
    end
Tabularwidget