static void ft_read(char **line, int *position, int *autocomp) { int ret; char *buf; ret = 1; buf = ft_memalloc(42); g_env.saved_line = line; while (!ft_strchr(buf, '\n') && ret > 0) { ft_bzero(buf, 42); ret = read(0, buf, 1024); buf[ret] = '\0'; if (ft_isprint(*buf)) { *autocomp = 0; ft_putchar(*buf); ft_add_char(line, *position, *buf); (*position)++; if ((*position + g_prompt_len + 1) % g_ws.ws_col == 1) tputs(tgetstr("sf", NULL), 1, ft_put); } else if (*buf != '\n') ft_check_key(buf, line, position, autocomp); } free(buf); }
int ft_place_tetri(t_tetri *list, char **map, t_pos p, t_nb nb) { p.y = 0; if (((list->n) - 65) > (nb.nb_list / 2)) { if (ft_heuristic(list, map, nb.max) == 0) return (0); } while (map[p.y]) { p.x = 0; while (map[p.y][p.x]) { if (list && ft_verify_tetri(list, map, p, nb.max)) { ft_add_char(list, map, p); if (list->next == NULL) return (1); if (ft_place_tetri(list->next, map, p, nb)) return (1); ft_remove_list(list->pos, map, p); } p.x++; } p.y++; } return (0); }
void ft_paste(t_cmd_line *line) { char *str; if ((str = ft_clipboard(NULL))) { while (*str) { ft_add_char(*str, line); ++str; } } }