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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
++i;
}
sleep(1);
if (*pos)
{
--(*pos);
ft_get_beggin_with_curs(*str, pos);
}
sleep(1);
ft_current_str(*str, *pos);
sleep(1);
ft_get_next_str(*str, pos);
ft_putnc('\b', *pos - tmp_pos);
sleep(1);
ft_putnc('\b', *pos - tmp_pos + 1);
(*pos) = tmp_pos;
}
@ -44,15 +48,18 @@ static char *ft_strdupi_space(char const *s)
i = 0;
while (s[i] && s[i] != '\n')
i++;
++i;
if (s[i] == '\n')
++i;
str = (char *)malloc(sizeof(char) * (i + 1));
if (str)
{
str[i--] = '\0';
str[i] = '\0';
--i;
while (i >= 0)
{
str[i] = s[i];
i--;
--i;
}
}
return (str);
@ -87,7 +94,8 @@ void ft_cxv(int ret, size_t *pos, char **str)
{
if (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)
ft_v(tmp, pos, str);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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,7 +16,8 @@ void ft_history_2(char **str, int ret, t_list_history **head, size_t *pos)
{
if (*str)
{
--(*pos);
if (*pos)
--(*pos);
ft_get_beggin_with_curs(*str, pos);
ft_puttermcaps("cd");
*pos = 0;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
if (!str[*pos])
--(*pos);
++(*pos);
ft_get_beggin_with_curs(str, pos);
if (*pos > 0 && str[*pos - 1] == '\n')
ft_puttermcaps("nd");
}
else
{

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
tmp = *i;
if (boolean)
{
ft_get_beggin_with_curs(*str, i);
*str = ft_remove_imput((*str), tmp);
}
else
{
*str = ft_remove_imput((*str), tmp);
ft_get_beggin(*str, i);
*str = ft_remove_imput((*str), tmp);
}
ft_puttermcaps("cd");
ft_current_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);
ft_putnc('\b', *i - tmp);
(*i) = tmp;
@ -71,12 +76,14 @@ void ft_del(char **str, size_t *i)
tmp = *i;
*str = ft_remove_imput((*str), tmp);
if (*i)
{
--(*i);
ft_get_beggin_with_curs(*str, i);
ft_get_beggin_with_curs(*str, i);
}
ft_puttermcaps("cd");
ft_current_str(*str, *i);
ft_get_next_str(*str, i);
if (str[*i])
if ((*str)[*i])
++(*i);
ft_putnc('\b', *i - tmp);
(*i) = tmp;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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')
--(*pos);
if (str[(*pos)] == '\n')
if (*pos && str[(*pos)] == '\n')
++(*pos);
}
@ -24,7 +24,7 @@ void ft_get_next_str(char *str, size_t *pos)
{
while (str[(*pos)] && str[(*pos)] != '\n')
++(*pos);
if (str[(*pos)] == '\n')
if (*pos && str[(*pos)] == '\n')
--(*pos);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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,13 +53,15 @@ void ft_printall(char *str, size_t *pos)
ft_puttermcaps("rc");
ft_puttermcaps("cd");
ft_putstr("\033[37m");
--(*pos);
if (*pos)
--(*pos);
ft_get_beggin(str, pos);
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
if (!str[*pos])
if (*pos && !str[*pos])
--(*pos);
ft_putnc('\b', *pos - pos_tmp + 1);
if (*pos)
ft_putnc('\b', *pos - pos_tmp + 1);
*pos = pos_tmp;
}
@ -83,7 +85,7 @@ void ft_get_beggin_with_curs(char *str, size_t *pos)
--(*pos);
ft_puttermcaps("le");
}
if (!*pos)
if (!*pos && str[(*pos)] != '\n')
ft_puttermcaps("le");
if (str[(*pos)] == '\n')
++(*pos);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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,7 +128,8 @@ void ft_found_next_word(char *str, size_t *pos)
(*pos) += 2;
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
--(*pos);
if (!str[*pos])
--(*pos);
ft_get_beggin_with_curs(str, pos);
}
else

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
len = 1;
if (str[pos] == '\n')
if (pos && str[pos] == '\n')
--pos;
len += data_singleton()->line.prompt_size;
len += ft_get_size_prev(str, pos);