Ejemplo n.º 1
0
static	char	*ft_move_x(char *str, int i, int x, char *buff)
{
	unsigned int nb_char;

	ft_copy(str, buff, i - x - 1);
	nb_char = 0;
	while (nb_char < 4)
	{
		if (str[i] == '#')
		{
			if (buff[i - x] != '\n')
			{
				buff[i - x] = '#';
				buff[i] = '.';
			}
			else
			{
				buff[i - (x + 1)] = '#';
				buff[i] = '.';
			}
			nb_char++;
		}
		i++;
	}
	return (buff);
}
Ejemplo n.º 2
0
int		get_next_line(int const fd, char **line)
{
	static char	*str;
	int			end;
	int			i;

	end = 1;
	i = 0;
	if (fd == 1 || fd < 0 || line == NULL)
		return (-1);
	if (str == NULL)
	{
		str = (char*)malloc(sizeof(char) * 1);
		if (str == NULL)
			return (-1);
		*str = '\0';
	}
	while (str[i] != '\n' && str[i] != '\0')
		i++;
	if (str[i] == '\0')
		ft_alloc_n_read(fd, &str, &end, BUFF_SIZE);
	if (end != -1 && str != NULL)
		ft_copy(&str, line, &end, 0);
	return (end);
}
Ejemplo n.º 3
0
int		ft_save(char **ptr_map, char ptr_map_saved[16][16], char taille, char nb_figure)
{
	unsigned int	i;
	unsigned int	j;
	int				cpt;

	i = 0;
	j = 0;
	cpt = 0;
	ft_clean(ptr_map_saved, (int)taille);
	ft_copy(ptr_map, ptr_map_saved, taille);
	ft_free(ptr_map);
	if (taille > ft_sqrt(nb_figure * 4))
		return (nb_figure);
	return (-1);
}
Ejemplo n.º 4
0
int	get_next_line(int const fd, char **line)
{
	static t_list	*lst;
//	t_list			*lstnow;
	int				end;
	int				i;

//	lstnow = (t_list *)malloc(sizeof(t_list));
//	lst = &lstnow;
//	lst->next = (t_list *)malloc(sizeof(t_list));
//	
//	lst = lst->next;
	end = 1;
	i = 0;
//	lstnow = &lst;
	if(!(lst = ft_help(&lst, fd)) || line == NULL || fd < 0 || fd == 1)
		return (-1);
/*	if (lstnow != NULL)
	{
		end = 2;
		while (lstnow != NULL && end == 2)
		{
			if (lstnow->content_size != fd)
				lstnow = lstnow->next;
			else
				end = 1;
		}	
	}
	if (lstnow == NULL)
	{
		if (!(lstnow = (t_list*)malloc(sizeof(t_list))))
			return (-1);
		if (!(listnow->content = (ft_strnew(0))))
			return (-1);
		lstnow->content_size = fd;
	}*/
	while ((((char*)lst->content)[i]) != '\n' && (((char*)lst->content)[i]) != '\0')
		i++;
	if ((((char*)lst->content)[i]) == '\0')
		lst->content = ft_alloc_n_read(fd, lst->content, &end);
	if (end != -1)
		line = ft_copy((char**)(&(lst->content)), line, &end, 0);
//	if ((*line) != NULL)
//		if ((*line)[0] == '\0')
//			free(*line);
	return (end);
}
Ejemplo n.º 5
0
void		ft_sel_mode_key(char key[4], t_cmd_line *line)
{
	if (KEY_LEFT)
		ft_sel_left(line);
	if (KEY_RIGHT)
		ft_sel_right(line);
	else if (KEY_CO)
		ft_copy(line);
	else if (KEY_CU)
		ft_cut(line);
	else if (KEY_HOME)
		ft_sel_home(line);
	else if (KEY_END)
		ft_sel_end(line);
	else if (KEY_ESC)
		ft_sel_cancel(line);
}
Ejemplo n.º 6
0
int		get_next_line(int const fd, char **line)
{
	static char *str;
	char		end;

//	if (line == NULL)
//		return (-1);
	end = 1;
	if (fd == 1 || fd < 0)
		return (-1);
	if (str == NULL)
	{
		str = (char*)malloc(sizeof(char) * 1);
		if (str == NULL)
			return (-1);
		str[0] = '\0';
		if ((str = ft_alloc_n_read(fd, str, &end)) == NULL)
			return (-1);
	}
	line = ft_copy(&str, line, &end);
	return (end);
}