From c0d7d5cfd071a8ec948d93ac4f096ffe0b6ace3d Mon Sep 17 00:00:00 2001 From: Gautier WOJDA Date: Tue, 24 Jan 2017 14:42:08 +0100 Subject: [PATCH] =?UTF-8?q?Bugs=20resolus,=20prevenez=20moi=20si=20vous=20?= =?UTF-8?q?en=20trouvez=20que=20j'ai=20rat=C3=A9=20!=20Je=20passe=20a=20l'?= =?UTF-8?q?affichage=20de=20l'historique=20:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 42sh/src/line-editing/copy_cut_paste.c | 20 ++++++++++++++------ 42sh/src/line-editing/get_touch_toolz.c | 5 +++-- 42sh/src/line-editing/get_touch_toolz_2.c | 5 +---- 42sh/src/line-editing/print_and_del.c | 17 ++++++++++++----- 42sh/src/line-editing/tool_line.c | 6 +++--- 42sh/src/line-editing/tool_line_2.c | 12 +++++++----- 42sh/src/line-editing/toolz_parseur.c | 5 +++-- 42sh/src/line-editing/toolz_termcaps.c | 4 ++-- 8 files changed, 45 insertions(+), 29 deletions(-) diff --git a/42sh/src/line-editing/copy_cut_paste.c b/42sh/src/line-editing/copy_cut_paste.c index f74d7a6a..4aa21239 100644 --- a/42sh/src/line-editing/copy_cut_paste.c +++ b/42sh/src/line-editing/copy_cut_paste.c @@ -6,7 +6,7 @@ /* 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); ++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); diff --git a/42sh/src/line-editing/get_touch_toolz.c b/42sh/src/line-editing/get_touch_toolz.c index cd304a95..1f45a11c 100644 --- a/42sh/src/line-editing/get_touch_toolz.c +++ b/42sh/src/line-editing/get_touch_toolz.c @@ -6,7 +6,7 @@ /* 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,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; diff --git a/42sh/src/line-editing/get_touch_toolz_2.c b/42sh/src/line-editing/get_touch_toolz_2.c index 8419617e..768a1606 100644 --- a/42sh/src/line-editing/get_touch_toolz_2.c +++ b/42sh/src/line-editing/get_touch_toolz_2.c @@ -6,7 +6,7 @@ /* 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); if (!str[*pos]) --(*pos); - ++(*pos); ft_get_beggin_with_curs(str, pos); - if (*pos > 0 && str[*pos - 1] == '\n') - ft_puttermcaps("nd"); } else { diff --git a/42sh/src/line-editing/print_and_del.c b/42sh/src/line-editing/print_and_del.c index 1183b994..900e0dfa 100644 --- a/42sh/src/line-editing/print_and_del.c +++ b/42sh/src/line-editing/print_and_del.c @@ -6,7 +6,7 @@ /* 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); 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; diff --git a/42sh/src/line-editing/tool_line.c b/42sh/src/line-editing/tool_line.c index ac47c2f7..b0b116cb 100644 --- a/42sh/src/line-editing/tool_line.c +++ b/42sh/src/line-editing/tool_line.c @@ -6,7 +6,7 @@ /* 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') --(*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); } diff --git a/42sh/src/line-editing/tool_line_2.c b/42sh/src/line-editing/tool_line_2.c index 8b5b5af5..cffc021c 100644 --- a/42sh/src/line-editing/tool_line_2.c +++ b/42sh/src/line-editing/tool_line_2.c @@ -6,7 +6,7 @@ /* 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,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); diff --git a/42sh/src/line-editing/toolz_parseur.c b/42sh/src/line-editing/toolz_parseur.c index cd2c8d34..1f29046a 100644 --- a/42sh/src/line-editing/toolz_parseur.c +++ b/42sh/src/line-editing/toolz_parseur.c @@ -6,7 +6,7 @@ /* 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,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 diff --git a/42sh/src/line-editing/toolz_termcaps.c b/42sh/src/line-editing/toolz_termcaps.c index 6892ac83..901b026e 100644 --- a/42sh/src/line-editing/toolz_termcaps.c +++ b/42sh/src/line-editing/toolz_termcaps.c @@ -6,7 +6,7 @@ /* 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; 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);