Exemplo n.º 1
0
/*
 * sends command to the menu 
 */
static int wdg_file_driver(struct wdg_object *wo, int key, struct wdg_mouse_event *mouse)
{
   WDG_WO_EXT(struct wdg_file_handle, ww);
   int c;
   struct stat buf;
   
   c = menu_driver(ww->m, wdg_file_virtualize(key) );
   
   /* skip non selectable items */
   if ( !(item_opts(current_item(ww->m)) & O_SELECTABLE) )
      c = menu_driver(ww->m, wdg_file_virtualize(key) );

   /* one item has been selected */
   if (c == E_UNKNOWN_COMMAND) {
      /* the item is not selectable (probably selected with mouse) */
      if ( !(item_opts(current_item(ww->m)) & O_SELECTABLE) )
         return WDG_ESUCCESS;
         
      stat(item_name(current_item(ww->m)), &buf);
      /* if it is a directory, change to it */
      if (S_ISDIR(buf.st_mode)) {
         chdir(item_name(current_item(ww->m)));
         return -WDG_ENOTHANDLED;
      } else {
         /* invoke the callback and return */
         wdg_file_callback(wo, ww->curpath, (char *)item_name(current_item(ww->m)));
         return WDG_ESUCCESS;
      }
   
   }

   wnoutrefresh(ww->mwin);
      
   return WDG_ESUCCESS;
}
Exemplo n.º 2
0
static VALUE rbncurs_c_item_opts(VALUE rb_item)
{
  ITEM *item = get_item(rb_item);
  return INT2NUM(item_opts(item));
}