From 39d5b250847d87d42ca2cf115e29716b229ab4d4 Mon Sep 17 00:00:00 2001 From: gwojda Date: Wed, 15 Mar 2017 14:40:19 +0100 Subject: [PATCH] fix bug completion resize sur fenetre minuscule --- 42sh/includes/completion.h | 5 +++-- 42sh/src/completion/c_files.c | 6 +----- 42sh/src/completion/c_matching.c | 2 +- 42sh/src/completion/c_printer.c | 5 +++-- 42sh/src/completion/c_seek_env.c | 9 ++++----- 42sh/src/completion/c_sizing.c | 4 ++-- 42sh/src/completion/c_terminal.c | 4 ++-- 42sh/src/completion/completion.c | 2 +- 42sh/src/job-control/put_job_in_foreground.c | 3 ++- 42sh/src/line-editing/ft_prompt.c | 2 +- 42sh/src/line-editing/get_key.c | 4 +++- 42sh/src/line-editing/resize.c | 3 +-- 42sh/src/main/main.c | 2 +- 42sh/src/main/shell_init.c | 3 +-- 14 files changed, 26 insertions(+), 28 deletions(-) diff --git a/42sh/includes/completion.h b/42sh/includes/completion.h index 1f341a15..7cb2ccf6 100644 --- a/42sh/includes/completion.h +++ b/42sh/includes/completion.h @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/02/18 11:13:04 by alao #+# #+# */ -/* Updated: 2017/03/14 12:09:55 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 13:47:27 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,7 +14,7 @@ # define COMPLETION_H # include "minishell.h" -#define RETARDED_BEHAVIOR 0 +# define RETARDED_BEHAVIOR 0 /* ** Autocompletion list for the valid candidates from the parser. @@ -178,5 +178,6 @@ int c_seek_env(t_comp *c, char *current_word); void c_seek_abs_path(t_comp *c, char *current_word); void c_arrow(t_comp *c, long int keypress); int c_chevron(t_comp *c); +int c_dispatcher(t_data *s); #endif diff --git a/42sh/src/completion/c_files.c b/42sh/src/completion/c_files.c index 7144b386..b4fd8fed 100644 --- a/42sh/src/completion/c_files.c +++ b/42sh/src/completion/c_files.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:31:21 by alao #+# #+# */ -/* Updated: 2017/03/14 12:09:36 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 11:47:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -70,10 +70,6 @@ static char *c_slicer(t_comp *c) i--; tmp[i] == '/' ? i++ : (0); rt = (i == (int)ft_strlen(tmp) - 1) ? NULL : ft_strsub(tmp, 0, i); -/* if (c_chevron(c)) - c->match = ft_strdup(""); - else - c->match = ft_strsub(tmp, i, ft_strlen(tmp) - i);*/ tmp ? ft_memdel((void *)&tmp) : (0); return (rt); } diff --git a/42sh/src/completion/c_matching.c b/42sh/src/completion/c_matching.c index f9d6c375..ca3d6192 100644 --- a/42sh/src/completion/c_matching.c +++ b/42sh/src/completion/c_matching.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/15 13:27:14 by alao #+# #+# */ -/* Updated: 2017/03/14 12:29:12 by gwojda ### ########.fr */ +/* Updated: 2017/03/14 17:22:10 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/completion/c_printer.c b/42sh/src/completion/c_printer.c index 050212e8..85bd5adf 100644 --- a/42sh/src/completion/c_printer.c +++ b/42sh/src/completion/c_printer.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 12:55:39 by alao #+# #+# */ -/* Updated: 2017/03/10 16:09:46 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 14:30:37 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -126,7 +126,8 @@ void c_printer(t_comp *c) //int offset; loop = c->c_line; - + if (!c->c_line) + return ; max_line = c->c_line - (c->m_size - 1); ptr = c_rolling(c); if ((c->pos_y * (c->m_size - 1)) > c->c_line) diff --git a/42sh/src/completion/c_seek_env.c b/42sh/src/completion/c_seek_env.c index dfc8198c..e63e1135 100644 --- a/42sh/src/completion/c_seek_env.c +++ b/42sh/src/completion/c_seek_env.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/09 15:50:24 by gwojda #+# #+# */ -/* Updated: 2017/03/14 17:21:37 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 11:50:15 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -28,17 +28,16 @@ static int c_storing(t_comp *c, char *value) int c_seek_env(t_comp *c, char *current_word) { - char *match; char **env; int i; i = 0; env = data_singleton()->env; - match = ft_strdupi_w(current_word + 1); + c->match = ft_strdupi_w(current_word + 1); while (env[i]) { - if (!ft_strncmp(match, env[i], ft_strlen(match)) && - env[i][ft_strlen(match)] != '=') + if (!ft_strncmp(c->match, env[i], ft_strlen(c->match)) && + env[i][ft_strlen(c->match)] != '=') c_storing(c, ft_strndup(env[i], ft_strchr(env[i], '=') - env[i])); ++i; } diff --git a/42sh/src/completion/c_sizing.c b/42sh/src/completion/c_sizing.c index 542f5a13..10da2078 100644 --- a/42sh/src/completion/c_sizing.c +++ b/42sh/src/completion/c_sizing.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 08:50:26 by alao #+# #+# */ -/* Updated: 2017/03/10 08:45:52 by alao ### ########.fr */ +/* Updated: 2017/03/15 14:25:54 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,7 +54,7 @@ int c_sizing(t_comp *c) c->lst && c->lst->name ? c_max_length(c) : 0; c->c_pline = c->win_x / (c->c_sx + 2); c->c_line = 0; - while ((c->c_line * c->c_pline) < c->c_sy) + while (c->c_pline && (c->c_line * c->c_pline) < c->c_sy) c->c_line++; if ((c->win_x < c->c_sx)) { diff --git a/42sh/src/completion/c_terminal.c b/42sh/src/completion/c_terminal.c index ebef1cee..e441d5a5 100644 --- a/42sh/src/completion/c_terminal.c +++ b/42sh/src/completion/c_terminal.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/10/11 10:44:40 by alao #+# #+# */ -/* Updated: 2017/03/14 10:51:14 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 14:36:43 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -92,7 +92,7 @@ void c_term_mv_down(t_comp *c) value = c->m_size - 1; else value = c->c_line - 1; - while (i != value) + while (value >= 0 && i != value) { ft_putstr(tgetstr("up", NULL)); i++; diff --git a/42sh/src/completion/completion.c b/42sh/src/completion/completion.c index 498261a9..1eba71eb 100644 --- a/42sh/src/completion/completion.c +++ b/42sh/src/completion/completion.c @@ -6,7 +6,7 @@ /* By: alao +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/09/20 14:50:33 by alao #+# #+# */ -/* Updated: 2017/03/14 11:22:04 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 14:37:34 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index 5237ed9b..6b33dec1 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ -/* Updated: 2017/03/14 12:45:22 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 11:14:27 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -22,6 +22,7 @@ int put_job_in_foreground(t_job *j, int cont) tcsetpgrp(STDIN, j->pgid); if (cont) { +// j->tmodes = pas initialisé ! tcsetattr(STDIN, TCSADRAIN, &j->tmodes); if (kill(-j->pgid, SIGCONT) < 0) DG("kill(SIGCONT) failed"); diff --git a/42sh/src/line-editing/ft_prompt.c b/42sh/src/line-editing/ft_prompt.c index cda5a0ad..908479b4 100644 --- a/42sh/src/line-editing/ft_prompt.c +++ b/42sh/src/line-editing/ft_prompt.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */ -/* Updated: 2017/03/14 16:00:05 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 13:55:22 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/get_key.c b/42sh/src/line-editing/get_key.c index 03e45b7c..811d7aa8 100644 --- a/42sh/src/line-editing/get_key.c +++ b/42sh/src/line-editing/get_key.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */ -/* Updated: 2017/03/05 19:38:09 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 14:07:20 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,11 +57,13 @@ char *ft_read_stdin(void) ft_is_str(); if (data_singleton()->comp) c_clear(data_singleton()); + signal(SIGWINCH, sigwinch_resize); while (42) { ret = 0; j = 0; read(0, &ret, sizeof(int)); + DG("key hexa value = %X", ret); if (ft_completion(ret)) continue ; while (g_key[j].value && g_key[j].value != ret) diff --git a/42sh/src/line-editing/resize.c b/42sh/src/line-editing/resize.c index 8963c96d..8d6042e8 100644 --- a/42sh/src/line-editing/resize.c +++ b/42sh/src/line-editing/resize.c @@ -6,12 +6,11 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/14 10:56:08 by gwojda #+# #+# */ -/* Updated: 2017/03/14 12:00:29 by gwojda ### ########.fr */ +/* Updated: 2017/03/15 14:25:51 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -int c_dispatcher(t_data *s); void sigwinch_resize(int sig) { diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index ffe4a3c3..a5bedb24 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/03/15 03:52:32 by wescande ### ########.fr */ +/* Updated: 2017/03/15 13:46:36 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index ca14c64e..7d2fce00 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/03/14 23:25:40 by jhalford ### ########.fr */ +/* Updated: 2017/03/15 13:55:49 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,7 +35,6 @@ static int interactive_settings(void) signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); signal(SIGCHLD, SIG_DFL); - signal(SIGWINCH, sigwinch_resize); *shell_pgid = getpid(); if (setpgid(*shell_pgid, *shell_pgid)) {