def getch
      #c = @window.getch
      #FFI::NCurses::nodelay(@window, true)
      #FFI::NCurses::wtimeout(@window, 0)
      #$log.debug " #{Time.now.to_f} inside MAIN before getch " 
      c = FFI::NCurses.wgetch(@window)
      # the only reason i am doing this is so ESC can be returned if no key is pressed
      # after that, not sure how this effects everything. most likely I should just
      # go back to using a wtimeout, and not worry about resize requiring a keystroke
      if c == 27
        $escstart = Time.now.to_f
        # if ESC pressed don't wait too long for next key
        Ncurses::wtimeout(@window, $ncurses_timeout || 500) # will wait n millisecond on wgetch so that we can return if no
      else
        FFI::NCurses.set_escdelay(100)
        # this means keep waiting for a key.
        Ncurses::nowtimeout(@window, true)
      end
      c

    rescue SystemExit, Interrupt 
      #FFI::NCurses.flushinp
      3 # is C-c
    rescue StandardError
      -1 # is C-c
    ensure
      # whatever the default is, is to be set here in case caller changed it.
      #FFI::NCurses::nodelay(@window, true)
    end
def getch
      #c = @window.getch
      #FFI::NCurses::nodelay(@window, true)
      #FFI::NCurses::wtimeout(@window, 0)
      #$log.debug " #{Time.now.to_f} inside MAIN before getch " 
      c = FFI::NCurses.wgetch(@window)
      # the only reason i am doing this is so ESC can be returned if no key is pressed
      # after that, not sure how this effects everything. most likely I should just
      # go back to using a wtimeout, and not worry about resize requiring a keystroke
      if c == 27
        $escstart = Time.now.to_f
        # if ESC pressed don't wait too long for next key
        Ncurses::wtimeout(@window, $ncurses_timeout || 500) # will wait n millisecond on wgetch so that we can return if no
      else
        FFI::NCurses.set_escdelay(100)
        # this means keep waiting for a key.
        Ncurses::nowtimeout(@window, true)
      end
      c

    rescue SystemExit, Interrupt 
      #FFI::NCurses.flushinp
      3 # is C-c
    rescue StandardError
      -1 # is C-c
    ensure
      # whatever the default is, is to be set here in case caller changed it.
      #FFI::NCurses::nodelay(@window, true)
    end
reads a character from keyboard and returns
 NOTE:
   if a function key is pressed, multiple such ints will be returned one after the other
   so the caller must decipher the same. See +getchar()+

 @return int
 @return -1 if no char read
 ORIGINALLY After esc there was a timeout, but after others there was notimeout, so it would wait
 indefinitely for a key
 NOTE : caller may set a timeout prior to calling, but not change setting after since this method
 maintains the default state in +ensure+. e.g. +widget.rb+ does a blocking get in +_process_key+
 Curses sets a timeout when ESCAPE is pressed, it is called ESCDELAY and is 1000 milliseconds.
 You may reduce it if you are not on some old slow telnet session. This returns faster from an esc
 although there are still some issues. ESC-ESC becomes an issue, but if i press ESC-ESC-1 then esc-esc comes
 together. otherwise there is a -1 between each esc.