diff --git a/42sh/Makefile b/42sh/Makefile index 8d15f1b5..d1e649ce 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -6,14 +6,14 @@ # By: wescande +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2016/08/29 21:32:58 by wescande #+# #+# # -# Updated: 2017/03/18 14:17:54 by gwojda ### ########.fr # +# Updated: 2017/03/19 15:14:11 by gwojda ### ########.fr # # # # **************************************************************************** # NAME = 42sh CC = gcc -FLAGS = -Wall -Wextra -Werror -fvisibility=hidden +FLAGS = -Wall -Wextra -Werror -g D_FLAGS = -g DELTA = $$(echo "$$(tput cols)-47"|bc) diff --git a/42sh/src/completion/c_find_abspath.c b/42sh/src/completion/c_find_abspath.c index b29bcdca..8e169306 100644 --- a/42sh/src/completion/c_find_abspath.c +++ b/42sh/src/completion/c_find_abspath.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/09 16:54:59 by gwojda #+# #+# */ -/* Updated: 2017/03/18 14:04:24 by gwojda ### ########.fr */ +/* Updated: 2017/03/19 15:22:06 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,6 +24,8 @@ void c_seek_abs_path(t_comp *c, char *current_word) len = ft_strrchr(c->rcmd, '/') - current_word + 1; if (len < 0) return ; + if (c->cpath) + ft_strdel(&c->cpath); c->cpath = ft_strndup(current_word, len); if (current_word[0] == '~') { diff --git a/42sh/src/completion/c_match.c b/42sh/src/completion/c_match.c index ce15d99e..06440ac5 100644 --- a/42sh/src/completion/c_match.c +++ b/42sh/src/completion/c_match.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/03/16 10:20:44 by gwojda ### ########.fr */ +/* Updated: 2017/03/19 15:34:38 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,8 @@ static int c_chevron(t_comp *c) size_t pos; pos = c->ircmd; + if (pos >= ft_strlen(c->rcmd)) + pos = ft_strlen(c->rcmd) - (ft_strlen(data_singleton()->line.input) - pos); while (pos) { if (c->rcmd[pos] == '<' || c->rcmd[pos] == '>') @@ -38,9 +40,12 @@ static int c_chevron(t_comp *c) static char *c_current_words(t_comp *c) { - int pos; + size_t pos; pos = c->ircmd; + if (pos >= ft_strlen(c->rcmd)) + pos = ft_strlen(c->rcmd) - + (ft_strlen(data_singleton()->line.input) - pos + 1); while (pos && c->rcmd[pos] != ' ') --pos; if (c->rcmd[pos] == ' ') @@ -57,6 +62,7 @@ int c_matching(t_data *s, t_comp *c) char *current_word; current_word = c_current_words(c); + DG("current_word = %s", current_word); if (ft_strchr(c->rcmd, '/')) c_seek_abs_path(c, current_word); else if (ft_strchr(c->rcmd, '$')) diff --git a/42sh/src/completion/c_match_update.c b/42sh/src/completion/c_match_update.c index bbbee3b2..00f32313 100644 --- a/42sh/src/completion/c_match_update.c +++ b/42sh/src/completion/c_match_update.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 12:03:30 by alao #+# #+# */ -/* Updated: 2017/03/17 12:03:26 by gwojda ### ########.fr */ +/* Updated: 2017/03/19 15:28:50 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/completion/c_output.c b/42sh/src/completion/c_output.c index e3c207e2..70c11f7e 100644 --- a/42sh/src/completion/c_output.c +++ b/42sh/src/completion/c_output.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/03 13:10:38 by alao #+# #+# */ -/* Updated: 2017/03/17 16:48:49 by gwojda ### ########.fr */ +/* Updated: 2017/03/19 15:18:55 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -105,12 +105,6 @@ int c_keypress(t_comp *c, long int key) { t_clst *ptr; - if (key == 27 || key == 127 || key == 2117294875) - { - c_term_clear(c); - c_clear(data_singleton()); - return (0); - } if (key == 10 || key == 32) { ptr = c->lst; @@ -119,10 +113,16 @@ int c_keypress(t_comp *c, long int key) c_updater(c, ptr->name); return (1); } - if (key == KP_U || key == KP_D || key == KP_L || key == KP_R) + else if (key == KP_U || key == KP_D || key == KP_L || key == KP_R) { c_arrow(c, key); return (0); } + else if (!ft_isprint(key)) + { + c_term_clear(c); + c_clear(data_singleton()); + return (0); + } return ((c_rematch(c, key)) ? (0) : (1)); }