def choose list1, config={}
      dirlist = true
      start = 0
      case list1
      when NilClass
        #list1 = Dir.glob("*")
        list1 = Dir.glob("*").collect { |f| File.directory?(f) ? f+"/" : f  }
      when String
        list1 = Dir.glob(list1).collect { |f| File.directory?(f) ? f+"/" : f  }
      when Array
        dirlist = false
        # let it be, that's how it should come
      else
        # Dir listing as default
        #list1 = Dir.glob("*")
        list1 = Dir.glob("*").collect { |f| File.directory?(f) ? f+"/" : f  }
      end
      require 'canis/core/util/rcommandwindow'
      prompt = config[:prompt] || "Choose: "
      layout = { :height => 5, :width => Ncurses.COLS-1, :top => Ncurses.LINES-6, :left => 0 }
      rc = CommandWindow.new nil, :layout => layout, :box => true, :title => config[:title]
      begin
        w = rc.window
        rc.display_menu list1
        # earlier wmove bombed, now move is (window.rb 121)
        str = ask(prompt) { |q| q.help_text = config[:help_text] ;  q.change_proc = Proc.new { |str| w.wmove(1,1) ; w.wclrtobot;  

          l = list1.select{|e| e.index(str)==0}  ;  # select those starting with str

          if (l.size == 0 || str[-1]=='/') && dirlist
            # used to help complete directories so we can drill up and down
            #l = Dir.glob(str+"*")
            l = Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f  }
          end
          rc.display_menu l; 
          l
        }
        q.key_handler_proc = Proc.new { |ch| 
          # this is not very good since it does not respect above list which is filtered
          # # need to clear the screen before printing - FIXME
          case ch
          when ?\C-n.getbyte(0)
            start += 2 if start < list1.length - 2

            w.wmove(1,1) ; w.wclrtobot;  
            rc.display_menu list1, :startindex => start
          when ?\C-p.getbyte(0)
            start -= 2 if start > 2
            w.wmove(1,1) ; w.wclrtobot;  
            rc.display_menu list1, :startindex => start
          else
            alert "unhalderlind by jey "
          end
        
        }
        }
        # need some validation here that its in the list TODO
      ensure
        rc.destroy
        rc = nil
        $log.debug "XXX: HIDE B IN ENSURE"
        hide_bottomline # since we called ask() we need to close bottomline
      end
        $log.debug "XXX: HIDE B AT END OF ASK"
      #hide_bottomline # since we called ask() we need to close bottomline
      return str
    end
def choose list1, config={}
      dirlist = true
      start = 0
      case list1
      when NilClass
        #list1 = Dir.glob("*")
        list1 = Dir.glob("*").collect { |f| File.directory?(f) ? f+"/" : f  }
      when String
        list1 = Dir.glob(list1).collect { |f| File.directory?(f) ? f+"/" : f  }
      when Array
        dirlist = false
        # let it be, that's how it should come
      else
        # Dir listing as default
        #list1 = Dir.glob("*")
        list1 = Dir.glob("*").collect { |f| File.directory?(f) ? f+"/" : f  }
      end
      require 'canis/core/util/rcommandwindow'
      prompt = config[:prompt] || "Choose: "
      layout = { :height => 5, :width => Ncurses.COLS-1, :top => Ncurses.LINES-6, :left => 0 }
      rc = CommandWindow.new nil, :layout => layout, :box => true, :title => config[:title]
      begin
        w = rc.window
        rc.display_menu list1
        # earlier wmove bombed, now move is (window.rb 121)
        str = ask(prompt) { |q| q.help_text = config[:help_text] ;  q.change_proc = Proc.new { |str| w.wmove(1,1) ; w.wclrtobot;  

          l = list1.select{|e| e.index(str)==0}  ;  # select those starting with str

          if (l.size == 0 || str[-1]=='/') && dirlist
            # used to help complete directories so we can drill up and down
            #l = Dir.glob(str+"*")
            l = Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f  }
          end
          rc.display_menu l; 
          l
        }
        q.key_handler_proc = Proc.new { |ch| 
          # this is not very good since it does not respect above list which is filtered
          # # need to clear the screen before printing - FIXME
          case ch
          when ?\C-n.getbyte(0)
            start += 2 if start < list1.length - 2

            w.wmove(1,1) ; w.wclrtobot;  
            rc.display_menu list1, :startindex => start
          when ?\C-p.getbyte(0)
            start -= 2 if start > 2
            w.wmove(1,1) ; w.wclrtobot;  
            rc.display_menu list1, :startindex => start
          else
            alert "unhalderlind by jey "
          end
        
        }
        }
        # need some validation here that its in the list TODO
      ensure
        rc.destroy
        rc = nil
        $log.debug "XXX: HIDE B IN ENSURE"
        hide_bottomline # since we called ask() we need to close bottomline
      end
        $log.debug "XXX: HIDE B AT END OF ASK"
      #hide_bottomline # since we called ask() we need to close bottomline
      return str
    end
Allows a selection in which options are shown over prompt. As user types
 options are narrowed down.
 NOTE: For a directory we are not showing a slash, so currently you
 have to enter the slash manually when searching.
 FIXME we can put remarks in fron as in memacs such as [No matches] or [single completion]
 @param [Array]  a list of items to select from
 NOTE: if you use this please copy it to your app. This does not conform to highline's
 choose, and I'd like to somehow get it to be identical.