diff --git a/42sh/includes/ft_readline.h b/42sh/includes/ft_readline.h index 852800a7..dabaaa87 100644 --- a/42sh/includes/ft_readline.h +++ b/42sh/includes/ft_readline.h @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */ -/* Updated: 2017/01/26 14:58:14 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 15:10:44 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -71,7 +71,7 @@ typedef struct s_line t_list_history *list_beg; } t_line; -int builtin_history(const char *path, char *const av[], char *const envp[]); +int builtin_history(const char *path, char *const av[], char *const envp[]); void ft_check_backslash(char **str); char *ft_strget_history(char *str); void ft_surch_in_history(char **str, size_t *pos); diff --git a/42sh/libft b/42sh/libft index fa4a21e3..ab92f0e5 160000 --- a/42sh/libft +++ b/42sh/libft @@ -1 +1 @@ -Subproject commit fa4a21e3d0d0545831d661df1863a399e9154218 +Subproject commit ab92f0e5d817c9d726a8ccf2f11c084ba446bbdf diff --git a/42sh/src/line-editing/check_backslash.c b/42sh/src/line-editing/check_backslash.c index 108ba5df..fa91a8ab 100644 --- a/42sh/src/line-editing/check_backslash.c +++ b/42sh/src/line-editing/check_backslash.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 13:32:52 by gwojda #+# #+# */ -/* Updated: 2017/01/31 15:03:59 by jhalford ### ########.fr */ +/* Updated: 2017/01/26 13:50:00 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/copy_cut_paste.c b/42sh/src/line-editing/copy_cut_paste.c index 0282e916..19f24b47 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/25 17:58:33 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 15:16:33 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,18 +26,14 @@ 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); - sleep(1); - ft_putnc('\b', *pos - tmp_pos + 1); + ft_putnc('\b', *pos - tmp_pos); (*pos) = tmp_pos; } @@ -94,7 +90,6 @@ void ft_cxv(int ret, size_t *pos, char **str) if (tmp) ft_strdel(&tmp); 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.c b/42sh/src/line-editing/get_touch.c index affc537c..6668421f 100644 --- a/42sh/src/line-editing/get_touch.c +++ b/42sh/src/line-editing/get_touch.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */ -/* Updated: 2017/01/26 11:36:19 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 16:50:57 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,9 +18,9 @@ static int ft_lecture_3(int ret, char **str, size_t *i) ft_suppr(str, i); else if (ret == TOUCHE_DELETE && (*str) && (*i) < ft_strlen((*str))) ft_del(str, i); - else if (ret == TOUCHE_HOME) + else if (ret == TOUCHE_HOME && *str) ft_home(*str, i); - else if (ret == TOUCHE_END) + else if (ret == TOUCHE_END && *str) ft_end(*str, i); else return (0); @@ -68,7 +68,6 @@ char *ft_lecture(t_list_history *head) } while (42) { - ft_check_end_of_line(str, i); ret = 0; read(0, &ret, sizeof(int)); if (ret == TOUCHE_F6 && read(0, &ret, sizeof(int)) > 0) @@ -82,12 +81,28 @@ char *ft_lecture(t_list_history *head) ** if (ret == TOUCHE_TAB) ** ret = ft_completion(&str, &i); */ - if (ret == TOUCHE_CTRL_C || ret == TOUCHE_CTRL_D) - exit(1); + if (ret == TOUCHE_CTRL_D) + { + if (!str || str[0] == '\0') + exit(0); + else if (i < ft_strlen(str)) + ft_del(&str, &i); + else + ft_puttermcaps("bl"); + } + if (ret == TOUCHE_CTRL_C) + { + ft_putchar('\n'); + ft_prompt(); + ft_strdel(&str); + i = 0; + } if (ft_lecture_2(ret, &str, &i)) continue ; else if (ret == FLECHE_BAS || ret == FLECHE_HAUT) { + if (!head) + continue ; ft_history(&str, ret, &head, &i); if (str) i = ft_strlen_next(str, i); diff --git a/42sh/src/line-editing/get_touch_toolz.c b/42sh/src/line-editing/get_touch_toolz.c index 06cba8b4..beae3600 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/25 15:49:11 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 16:45:22 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,8 +39,6 @@ void ft_history_2(char **str, int ret, t_list_history **head void ft_history(char **str, int ret, t_list_history **head, size_t *pos) { - if (!*head) - return ; ft_history_2(str, ret, head, pos); if (ret == FLECHE_HAUT) { diff --git a/42sh/src/line-editing/get_touch_toolz_2.c b/42sh/src/line-editing/get_touch_toolz_2.c index c38664e4..ad7d2372 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/25 16:26:42 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 15:29:20 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,6 +92,7 @@ void ft_move_left(size_t *pos, char *str) --(*pos); return ; } + printf("here\n\n"); ft_puttermcaps("cd"); (*pos) -= 2; ft_get_beggin(str, pos); diff --git a/42sh/src/line-editing/print_and_del.c b/42sh/src/line-editing/print_and_del.c index 2dfe8996..be81a660 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/25 16:37:45 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 15:25:19 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,6 +34,7 @@ void ft_print(char **str, int ret, size_t *i) ft_putchar(*((*str) + *i + j)); ++j; } + ft_check_end_of_line(*str, *i + j); ft_putnc('\b', j - 1); ++(*i); } diff --git a/42sh/src/line-editing/prompt.c b/42sh/src/line-editing/prompt.c index 4e26763d..94482a27 100644 --- a/42sh/src/line-editing/prompt.c +++ b/42sh/src/line-editing/prompt.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */ -/* Updated: 2017/01/31 15:02:39 by jhalford ### ########.fr */ +/* Updated: 2017/01/25 16:31:24 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,7 +54,6 @@ void ft_prompt(void) { int ret; - do_job_notification(); ft_get_date(); ft_putstr("\033[22;36m"); ret = ft_currend_dir(); diff --git a/42sh/src/line-editing/readline.c b/42sh/src/line-editing/readline.c index 67a48bbd..154089c8 100644 --- a/42sh/src/line-editing/readline.c +++ b/42sh/src/line-editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/01/31 15:04:02 by jhalford ### ########.fr */ +/* Updated: 2017/01/26 13:38:29 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/tool_line.c b/42sh/src/line-editing/tool_line.c index b0b116cb..0745579b 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/24 11:36:56 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 15:27:31 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -47,6 +47,7 @@ void ft_current_str(char *str, size_t pos) while (str[pos + len] && str[pos + len] != '\n') ++len; write(1, str + pos, len); + ft_check_end_of_line(str, pos + len); } int ft_strlen_next(char *str, size_t pos) diff --git a/42sh/src/line-editing/tool_line_2.c b/42sh/src/line-editing/tool_line_2.c index cffc021c..4ef5fe9a 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/24 11:37:27 by gwojda ### ########.fr */ +/* Updated: 2017/02/01 15:24:50 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -69,10 +69,8 @@ void ft_check_end_of_line(char *str, size_t pos) { if (!str) return ; - //ft_printf("\n\n\nnd = %d\n\n", ft_nb_last_line(str, pos)); if (ft_nb_last_line(str, pos) == 0) { - //ft_printf("\n\n\nhere\n\n"); ft_putchar(' '); ft_puttermcaps("le"); }