Bugs resolus, prevenez moi si vous en trouvez que j'ai raté ! Je passe a l'affichage de l'historique :)

This commit is contained in:
Gautier WOJDA 2017-01-24 14:42:08 +01:00
parent a8471df8a7
commit c0d7d5cfd0
8 changed files with 45 additions and 29 deletions

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */ /* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
/* Updated: 2017/01/22 14:10:31 by gwojda ### ########.fr */ /* Updated: 2017/01/24 14:28:57 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -26,14 +26,18 @@ static void ft_v(char *tmp, size_t *pos, char **str)
*str = ft_realloc_imput(*str, tmp[i], *pos + i); *str = ft_realloc_imput(*str, tmp[i], *pos + i);
++i; ++i;
} }
sleep(1);
if (*pos) if (*pos)
{ {
--(*pos); --(*pos);
ft_get_beggin_with_curs(*str, pos); ft_get_beggin_with_curs(*str, pos);
} }
sleep(1);
ft_current_str(*str, *pos); ft_current_str(*str, *pos);
sleep(1);
ft_get_next_str(*str, pos); ft_get_next_str(*str, pos);
ft_putnc('\b', *pos - tmp_pos); sleep(1);
ft_putnc('\b', *pos - tmp_pos + 1);
(*pos) = tmp_pos; (*pos) = tmp_pos;
} }
@ -44,15 +48,18 @@ static char *ft_strdupi_space(char const *s)
i = 0; i = 0;
while (s[i] && s[i] != '\n') while (s[i] && s[i] != '\n')
i++; ++i;
if (s[i] == '\n')
++i;
str = (char *)malloc(sizeof(char) * (i + 1)); str = (char *)malloc(sizeof(char) * (i + 1));
if (str) if (str)
{ {
str[i--] = '\0'; str[i] = '\0';
--i;
while (i >= 0) while (i >= 0)
{ {
str[i] = s[i]; str[i] = s[i];
i--; --i;
} }
} }
return (str); return (str);
@ -87,7 +94,8 @@ void ft_cxv(int ret, size_t *pos, char **str)
{ {
if (tmp) if (tmp)
ft_strdel(&tmp); ft_strdel(&tmp);
tmp = ft_strdupi_space(&(*str)[(*pos)]); tmp = ft_strdupi_space((*str) + (*pos));
ft_printf("\n\ntmp = \"%s\"\n\n", tmp);
} }
else if (ret == TOUCHE_OPT_V) else if (ret == TOUCHE_OPT_V)
ft_v(tmp, pos, str); ft_v(tmp, pos, str);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:42:54 by gwojda #+# #+# */ /* Created: 2016/12/19 16:42:54 by gwojda #+# #+# */
/* Updated: 2017/01/21 11:40:51 by gwojda ### ########.fr */ /* Updated: 2017/01/24 10:21:48 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,6 +16,7 @@ void ft_history_2(char **str, int ret, t_list_history **head, size_t *pos)
{ {
if (*str) if (*str)
{ {
if (*pos)
--(*pos); --(*pos);
ft_get_beggin_with_curs(*str, pos); ft_get_beggin_with_curs(*str, pos);
ft_puttermcaps("cd"); ft_puttermcaps("cd");

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:43:58 by gwojda #+# #+# */ /* Created: 2016/12/19 16:43:58 by gwojda #+# #+# */
/* Updated: 2017/01/23 15:17:18 by gwojda ### ########.fr */ /* Updated: 2017/01/24 11:22:42 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -74,10 +74,7 @@ void ft_move_term(int ret, size_t *pos, char *str)
ft_get_next_str(str, pos); ft_get_next_str(str, pos);
if (!str[*pos]) if (!str[*pos])
--(*pos); --(*pos);
++(*pos);
ft_get_beggin_with_curs(str, pos); ft_get_beggin_with_curs(str, pos);
if (*pos > 0 && str[*pos - 1] == '\n')
ft_puttermcaps("nd");
} }
else else
{ {

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */ /* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */
/* Updated: 2017/01/23 15:13:57 by gwojda ### ########.fr */ /* Updated: 2017/01/24 14:40:21 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -49,14 +49,19 @@ void ft_suppr(char **str, size_t *i)
--(*i); --(*i);
tmp = *i; tmp = *i;
if (boolean) if (boolean)
{
ft_get_beggin_with_curs(*str, i); ft_get_beggin_with_curs(*str, i);
else
ft_get_beggin(*str, i);
*str = ft_remove_imput((*str), tmp); *str = ft_remove_imput((*str), tmp);
}
else
{
*str = ft_remove_imput((*str), tmp);
ft_get_beggin(*str, i);
}
ft_puttermcaps("cd"); ft_puttermcaps("cd");
ft_current_str(*str, *i); ft_current_str(*str, *i);
ft_get_next_str(*str, i); ft_get_next_str(*str, i);
if (str[*i] && ft_found_next_char(*str, *i)) if (*i && (*str)[*i] && ft_found_next_char(*str, *i))
++(*i); ++(*i);
ft_putnc('\b', *i - tmp); ft_putnc('\b', *i - tmp);
(*i) = tmp; (*i) = tmp;
@ -71,12 +76,14 @@ void ft_del(char **str, size_t *i)
tmp = *i; tmp = *i;
*str = ft_remove_imput((*str), tmp); *str = ft_remove_imput((*str), tmp);
if (*i) if (*i)
{
--(*i); --(*i);
ft_get_beggin_with_curs(*str, i); ft_get_beggin_with_curs(*str, i);
}
ft_puttermcaps("cd"); ft_puttermcaps("cd");
ft_current_str(*str, *i); ft_current_str(*str, *i);
ft_get_next_str(*str, i); ft_get_next_str(*str, i);
if (str[*i]) if ((*str)[*i])
++(*i); ++(*i);
ft_putnc('\b', *i - tmp); ft_putnc('\b', *i - tmp);
(*i) = tmp; (*i) = tmp;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 18:20:23 by gwojda #+# #+# */ /* Created: 2017/01/20 18:20:23 by gwojda #+# #+# */
/* Updated: 2017/01/21 17:04:13 by gwojda ### ########.fr */ /* Updated: 2017/01/24 11:36:56 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -16,7 +16,7 @@ void ft_get_beggin(char *str, size_t *pos)
{ {
while ((*pos) && str[(*pos)] != '\n') while ((*pos) && str[(*pos)] != '\n')
--(*pos); --(*pos);
if (str[(*pos)] == '\n') if (*pos && str[(*pos)] == '\n')
++(*pos); ++(*pos);
} }
@ -24,7 +24,7 @@ void ft_get_next_str(char *str, size_t *pos)
{ {
while (str[(*pos)] && str[(*pos)] != '\n') while (str[(*pos)] && str[(*pos)] != '\n')
++(*pos); ++(*pos);
if (str[(*pos)] == '\n') if (*pos && str[(*pos)] == '\n')
--(*pos); --(*pos);
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 19:07:52 by gwojda #+# #+# */ /* Created: 2017/01/20 19:07:52 by gwojda #+# #+# */
/* Updated: 2017/01/23 11:31:36 by gwojda ### ########.fr */ /* Updated: 2017/01/24 11:37:27 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -53,12 +53,14 @@ void ft_printall(char *str, size_t *pos)
ft_puttermcaps("rc"); ft_puttermcaps("rc");
ft_puttermcaps("cd"); ft_puttermcaps("cd");
ft_putstr("\033[37m"); ft_putstr("\033[37m");
if (*pos)
--(*pos); --(*pos);
ft_get_beggin(str, pos); ft_get_beggin(str, pos);
ft_current_str(str, *pos); ft_current_str(str, *pos);
ft_get_next_str(str, pos); ft_get_next_str(str, pos);
if (!str[*pos]) if (*pos && !str[*pos])
--(*pos); --(*pos);
if (*pos)
ft_putnc('\b', *pos - pos_tmp + 1); ft_putnc('\b', *pos - pos_tmp + 1);
*pos = pos_tmp; *pos = pos_tmp;
} }
@ -83,7 +85,7 @@ void ft_get_beggin_with_curs(char *str, size_t *pos)
--(*pos); --(*pos);
ft_puttermcaps("le"); ft_puttermcaps("le");
} }
if (!*pos) if (!*pos && str[(*pos)] != '\n')
ft_puttermcaps("le"); ft_puttermcaps("le");
if (str[(*pos)] == '\n') if (str[(*pos)] == '\n')
++(*pos); ++(*pos);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */ /* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */
/* Updated: 2017/01/23 13:40:41 by gwojda ### ########.fr */ /* Updated: 2017/01/24 14:14:31 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -128,6 +128,7 @@ void ft_found_next_word(char *str, size_t *pos)
(*pos) += 2; (*pos) += 2;
ft_current_str(str, *pos); ft_current_str(str, *pos);
ft_get_next_str(str, pos); ft_get_next_str(str, pos);
if (!str[*pos])
--(*pos); --(*pos);
ft_get_beggin_with_curs(str, pos); ft_get_beggin_with_curs(str, pos);
} }

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 12:35:11 by gwojda #+# #+# */ /* Created: 2017/01/08 12:35:11 by gwojda #+# #+# */
/* Updated: 2017/01/23 11:23:23 by gwojda ### ########.fr */ /* Updated: 2017/01/24 11:19:34 by gwojda ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -37,7 +37,7 @@ int ft_nb_last_line(char *str, size_t pos)
int len; int len;
len = 1; len = 1;
if (str[pos] == '\n') if (pos && str[pos] == '\n')
--pos; --pos;
len += data_singleton()->line.prompt_size; len += data_singleton()->line.prompt_size;
len += ft_get_size_prev(str, pos); len += ft_get_size_prev(str, pos);