int ft_treatment(char **ptr_map, char ptr_map_saved[16][16], char order_figure[27], int i) { int pos[3]; int end; end = 0; pos[0] = 0; pos[1] = 0; pos[2] = ft_len(ptr_map); if (ft_place(ptr_map, order_figure[i], ((char)i + 64), pos)) { if (i == order_figure[0]) { end = ft_save(ptr_map, ptr_map_saved, pos[2], order_figure[0]); } else { while (!end) { end = ft_treatment(ptr_map, ptr_map_saved, order_figure, (i + 1)); if (end < 26 && end >= 0) { if (!ft_deplace(ptr_map, order_figure[i], (i + 64), pos)) { ft_del(ptr_map, (i + 64), pos[2]); end = 1; } } } } } else return (0); return (end - 1); }
int cd(t_shell *shell, t_tree *tree) { char *pwd; char *path; char *home; if (cd_needed(shell, tree, &pwd, &home) == EXIT_FAILURE) return (EXIT_FAILURE); cd_get_path(tree->argv, &path, pwd, home); if (!path) { if (!(path = get_env(shell->env, "OLDPWD"))) { ft_putmsg(CD_OLDPWD, NULL); return (EXIT_FAILURE); } ft_putendl(path); } if (chdir(path) == -1) return (cd_error(&path, tree->argv[1])); else end_cd(shell, &path, &pwd); ft_del(&path, &pwd, &home); return (EXIT_SUCCESS); }
int ft_deplace(char **map, char figure, char letter, int tab[3]) { ft_del(map, letter, tab[2]); if (tab[1] < tab[2] - 1) tab[1] += 1; else if (tab[0] < tab[2] - 1) { tab[0]++; tab[1] = 0; } else return (0); return (ft_place(map, figure, letter, tab)); }
void ft_which_key(char *k, t_list **list, t_env *envir) { if (*(int*)k == 27) { restore_term(envir); exit(EXIT_SUCCESS); } else if (*(int*)k == 10) ft_enter(list, envir); else if (ft_strcmp(k, tgetstr("ku", NULL)) == 0) { ft_dprintf(ENT, "%s\n", k); move_curse(*list, 1); } else if (ft_strcmp(k, tgetstr("kd", NULL)) == 0) move_curse(*list, 0); else if (ft_strcmp(k, " ") == 0) select_list(*list); else if ((ft_strcmp(k, "\177") == 0) || *(int*)k == 2117294875) ft_del(list); }
int ft_loop(int *buff, t_list **list, int ac) { while (1) { g_list = list; ft_chk_sig(); tputs(tgoto(tgetstr("cm", NULL), 0, (*list)->y), FD, ft_putint); buff[0] = 0; read(0, buff, 3); ft_chk_up(buff, list); ft_chk_down(buff, list); if (buff[0] == 32) { ft_chk_slct(list); ft_down(list); } ft_del(buff, list); ft_echap(buff, ac); if (buff[0] == 10) return (0); tputs(tgetstr("me", NULL), FD, ft_putint); } }