fixe bugs sur la completion

This commit is contained in:
gwojda 2017-02-16 14:23:04 +01:00
parent 3dfc6abb61
commit ec9f2c91f3

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 14:15:55 by gwojda #+# #+# */ /* Created: 2017/02/03 14:15:55 by gwojda #+# #+# */
/* Updated: 2017/02/05 16:48:20 by gwojda ### ########.fr */ /* Updated: 2017/02/16 14:22:44 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -15,13 +15,17 @@
int ft_completion(int ret) int ft_completion(int ret)
{ {
size_t tmp; size_t tmp;
size_t pos_tmp;
int beg_len;
char boolean; char boolean;
boolean = 0; boolean = 0;
beg_len = ft_strlen(data_singleton()->line.input);
if (((ret != TOUCHE_TAB && ret != 10) if (((ret != TOUCHE_TAB && ret != 10)
|| (ret == 10)) && !(data_singleton()->comp)) || (ret == 10)) && !(data_singleton()->comp))
return (0); return (0);
tmp = POS; tmp = POS;
pos_tmp = POS;
if (data_singleton()->comp || ret == TOUCHE_TAB) if (data_singleton()->comp || ret == TOUCHE_TAB)
boolean = completion(ret); boolean = completion(ret);
if (boolean || ret == 10) if (boolean || ret == 10)
@ -29,7 +33,9 @@ int ft_completion(int ret)
ft_puttermcaps("cd"); ft_puttermcaps("cd");
ft_current_str(STR, tmp); ft_current_str(STR, tmp);
ft_get_next_str(STR, &tmp); ft_get_next_str(STR, &tmp);
POS = tmp; ft_putnc('\b', tmp -
(pos_tmp + ft_strlen(data_singleton()->line.input) - beg_len));
POS = pos_tmp + ft_strlen(data_singleton()->line.input) - beg_len;
} }
return (1); return (1);
} }