//*
//* ONCLICK
//*
byte auia_click(AUI_VARSP v) {
  char * fl = afbox_getselectedfile(v->hFile);
  byte dtype = afbox_dtype(v->hFile);
  
  if (((dtype == 4) || (dtype == 24)) && (fl != NULL)) {
    aui_setpath(&v->path, v->path, fl, 1);
    v->reshow = 1;
    return 0;
  } 
  else if (strstr(fl, ".zip") != NULL) {
        if (EndsWith(fl,".zip")){
          char * full_fl = NULL;
          aui_setpath(&full_fl, v->path, fl, 0);
          choose_kernel(full_fl, 1);
          free(full_fl);
          v->reshow = 1;
          return 0;
        }
  } 
  else if (strstr(fl, ".img") != NULL) {
        if (EndsWith(fl,".img")){
          char * full_fl = NULL;
          aui_setpath(&full_fl, v->path, fl, 0);
          choose_kernel(full_fl,0);
          free(full_fl);
          v->reshow = 1;
          return 0;
      }
  } 
  else if (fl != NULL) {
    printf("File  [%i]: %s\n", dtype, fl);
  }
  
  return 1;
}
//* 
//* ONCLICK
//*
byte auia_click(AUI_VARSP v)
{
	char *fl = afbox_getselectedfile(v->hFile);
	byte dtype = afbox_dtype(v->hFile);
	if (((dtype == 4) || (dtype == 24)) && (fl != NULL)) {
		aui_setpath(&v->path, v->path, fl, 1);
		v->reshow = 1;
		return 0;
	} else if (fl != NULL) {
		printf("File  [%i]: %s\n", dtype, fl);
	}
	return 1;
}
byte auia_hold(AUI_VARSP v) {
  char * fl = afbox_getselectedfile(v->hFile);
  byte dtype = afbox_dtype(v->hFile);
  
  if (fl != NULL) {
    AWMENUITEM mi[6];
    int cp = 0;
    byte onfav = 0;
    byte isonfav = 0;
    
    if ((dtype == 4) || (dtype == 24)) {
      isonfav = auifav_isfav(fl);
      
      if (isonfav) {
        aw_menuset(mi, cp++, "tools.favorite.del", 8);
      }
      else {
        aw_menuset(mi, cp++, "tools.favorite.add", 7);
      }
      
      onfav = 1;
    }
    
    aw_menuset(mi, cp++, "tools.rename", 15);
    aw_menuset(mi, cp++, "tools.copy", 2);
    aw_menuset(mi, cp++, "tools.cut", 3);
    aw_menuset(mi, cp++, "tools.delete", 4);
    aw_menuset(mi, cp++, "tools.chmod", 1);
    byte ret = aw_menu(v->hWin, fl, mi, cp);
    
    if ((!onfav) && (ret > 0)) {
      ret++;
    }
    
    if (ret == 2) {
      //-- Rename
      return auia_hold_rename(v, fl);
    }
    else if (ret == 6) {
      //-- Rename
      return auia_hold_perm(v, fl);
    }
    else if ((ret == 3) || (ret == 4)) {
      //-- Copy / cut
      ag_setbusy();
      auic_init(ret - 2, 1, v->path);
      auic_add(fl);
      *v->state = aui_tbstate(v, 3, *v->state);
      afbox_changeboxtype(v->hFile, 1);
      aui_changetitle(v, alang_get("paste.location"));
      afbox_setcheckall(v->hFile, 0);
    }
    else if (ret == 5) {
      //-- Copy / cut
      ag_setbusy();
      auic_init(3, 1, v->path);
      auic_add(fl);
      return auia_do_delete(v);
    }
    else if (ret == 1) {
      //-- Add Remove Favorite
      char * full_fl = NULL;
      aui_setpath(&full_fl, v->path, fl, 1);
      
      if (full_fl != NULL) {
        if (isonfav) {
          auifav_del(full_fl);
        }
        else {
          auifav_add(full_fl);
        }
        
        LOGS("Add To Favorite: %s\n", full_fl);
        free(full_fl);
      }
    }
  }
  
  return 1;
}