Example #1
0
int			ft_quit(t_env *e, char *inputs)
{
	if (inputs[0] == 3)
		return (0);
	else if (inputs[0] == 10)
	{
		if (e->histo->str)
			free(e->histo->str);
		e->histo->str = ft_strdup(e->str);
		ft_endline(e);
		return (1);
	}
	else if (inputs[0] == 4)
	{
		if (e->histo->str)
			free(e->histo->str);
		e->histo->str = ft_strdup(e->str);
		ft_endline(e);
		return (0);
	}
	return (0);
}
Example #2
0
int			ft_get_inputs(t_env *e)
{
	char	inputs[7];
	int		value;

	ft_bzero(inputs, 7);
	ft_clean_histo(e);
	ft_lstr_inputsinit(e);
	tputs(e->name, 1, ft_putc);
	while ((read(0, inputs, 7)) != EOF)
	{
		if ((value = ft_manage_inputs(e, inputs)) >= 0)
			return (value);
		ft_bzero(inputs, 7);
	}
	ft_endline(e);
	return (0);
}
Example #3
0
char				*ft_get_inputs(char *str)
{
	static t_env	*e = NULL;
	char			inputs[7];
	int				value;
	char			*test;
	static int		i = 0;

	if (!e)
		e = ft_init_env();
	test = NULL;
	e->name = str;
	e->index = 0;
	e->max = 0;
	if (i++ == 0)
	{
		dprintf(1, "Tgetent\n");
		// if (tgetent(e->buf, test) < 1)
		// 	exit(-1);
		if (!(e->str = (char *)malloc(sizeof(char))))
			return (NULL);
	}
	ft_bzero(inputs, 7);
	ft_clean_histo(e);
	ft_lstr_inputsinit(e);
	tputs(e->name, 1, ft_putc);
	start_termcaps();
	while ((read(0, inputs, 7)) != EOF)
	{
		if ((value = ft_manage_inputs(e, inputs)) >= 0)
			return (e->str);
		ft_bzero(inputs, 7);
	}
	pause_termcaps();
	ft_endline(e);
	return (e->str);
}