Ejemplo n.º 1
0
int				get_key(t_env *env_list, t_cmd_path *cmds,
		t_hist *history, char *key)
{
	t_hist		*tmp;
	int			i;

	i = 0;
	while (read(0, key, 15))
	{
		if (is_arrow(key))
			i = press_arrow(key[2], history, &tmp, i);
		else if (is_enter(key))
		{
			history = press_enter(env_list, history);
			tmp = history->next;
			i = 0;
		}
		else if (is_delete(key))
			press_delete();
		else if (key[0] > 30)
			print_letter(key);
		else if (key[0] == 9 && key[1] == 0 && key[2] == 0)
			autocomplete(cmds);
		else
			is_special_action(key);
		ft_bzero(key, 15);
	}
	return (0);
}
Ejemplo n.º 2
0
int					handle_input(t_env *e, char *input)
{
	if (ft_strncmp(input, K_ESC, BUFFSIZE) == 0)
		input_exit();
	else if (is_enter(input))
		return (0);
	else if (is_del(input) && !input_del(e))
		return (0);
	else if (ft_strncmp(input, K_TOP, BUFFSIZE) == 0)
		e->current_index--;
	else if (ft_strncmp(input, K_BOTTOM, BUFFSIZE) == 0)
		e->current_index++;
	else if (ft_strncmp(input, K_RIGHT, BUFFSIZE) == 0)
		input_right(e);
	else if (ft_strncmp(input, K_LEFT, BUFFSIZE) == 0)
		input_left(e);
	else if (ft_strncmp(input, K_SPACE, BUFFSIZE) == 0)
		input_space(e);
	if (e->current_index < 0
			|| e->current_index > e->chain_size - e->deleted - 1)
		e->current_index = (e->current_index + e->chain_size - e->deleted)
							% (e->chain_size - e->deleted);
	return (1);
}