diff --git a/42sh/Makefile b/42sh/Makefile index c565f7df..d500f869 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,7 +6,7 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/21 10:36:25 by gwojda ### ########.fr # +# Updated: 2017/03/21 11:05:18 by gwojda ### ########.fr # # # # **************************************************************************** # diff --git a/42sh/src/completion/c_terminal.c b/42sh/src/completion/c_terminal.c index a46135e3..68d9359d 100644 --- a/42sh/src/completion/c_terminal.c +++ b/42sh/src/completion/c_terminal.c @@ -6,28 +6,12 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/11 10:44:40 by alao #+# #+# */ -/* Updated: 2017/03/18 15:19:18 by gwojda ### ########.fr */ +/* Updated: 2017/03/21 11:22:03 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ #include "completion.h" -static size_t c_virtual_position(t_comp *c) -{ - char *str; - size_t pos; - size_t virtual_pos; - - pos = c->ircmd; - virtual_pos = pos; - str = data_singleton()->line.input; - while (pos && str[pos] != '\n') - --pos; - if (str[pos] == '\n') - ++pos; - return (virtual_pos - pos); -} - /* ** Clear the previous list from the screen and restore the same position. */ @@ -42,7 +26,8 @@ void c_term_clear(t_comp *c) ft_putstr(tgetstr("up", NULL)); i = 0; lcmd = 0; - c->rcmd ? lcmd += c_virtual_position(c) + c->prompt + 1 : 0; + lcmd = (c->rcmd) ? ft_nb_last_line(data_singleton()->line.input, + data_singleton()->line.pos) : 0; while (i < lcmd) { ft_putstr(tgetstr("nd", NULL)); @@ -73,8 +58,8 @@ void c_term_mv_back(t_comp *c) } ft_putstr(tgetstr("cr", NULL)); i = 0; - lcmd = 0; - c->rcmd ? lcmd += c_virtual_position(c) + c->prompt + 1 : 0; + lcmd = (c->rcmd) ? ft_nb_last_line(data_singleton()->line.input, + data_singleton()->line.pos) : 0; while (i < lcmd) { ft_putstr(tgetstr("nd", NULL));