Rebase current
This commit is contained in:
parent
4ea6fb5801
commit
f8753ccae1
11 changed files with 65 additions and 34 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:30:57 by alao #+# #+# */
|
/* Created: 2017/01/09 13:30:57 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 21:03:18 by alao ### ########.fr */
|
/* Updated: 2017/02/17 14:56:04 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -29,7 +29,8 @@ int c_seek_binary(t_data *s, t_comp *c)
|
||||||
if (!(tmp = ft_strdup(ft_getenv(s->env, "PATH"))))
|
if (!(tmp = ft_strdup(ft_getenv(s->env, "PATH"))))
|
||||||
return (-1);
|
return (-1);
|
||||||
paths = ft_strsplit(tmp, ':');
|
paths = ft_strsplit(tmp, ':');
|
||||||
c->match = ft_strdup(c->rcmd);
|
if (c->match == NULL)
|
||||||
|
c->match = ft_strdup(c->rcmd);
|
||||||
while (paths[i])
|
while (paths[i])
|
||||||
c_parser(c, paths[i++], c->rcmd);
|
c_parser(c, paths[i++], c->rcmd);
|
||||||
tmp ? ft_memdel((void *)&tmp) : (0);
|
tmp ? ft_memdel((void *)&tmp) : (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/10 11:37:43 by alao #+# #+# */
|
/* Created: 2017/01/10 11:37:43 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:03:41 by alao ### ########.fr */
|
/* Updated: 2017/02/17 14:57:09 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -21,6 +21,8 @@ int c_clear_lst(t_comp *c)
|
||||||
t_clst *c_lst;
|
t_clst *c_lst;
|
||||||
t_clst *p_lst;
|
t_clst *p_lst;
|
||||||
|
|
||||||
|
if (c->lst == NULL)
|
||||||
|
return (0);
|
||||||
c_lst = c->lst;
|
c_lst = c->lst;
|
||||||
c->lst->prev ? (c->lst = c->lst->prev) : (0);
|
c->lst->prev ? (c->lst = c->lst->prev) : (0);
|
||||||
c_lst->prev->next = NULL;
|
c_lst->prev->next = NULL;
|
||||||
|
|
@ -48,6 +50,8 @@ int c_clear(t_data *s)
|
||||||
{
|
{
|
||||||
t_comp *ptr;
|
t_comp *ptr;
|
||||||
|
|
||||||
|
if (s->comp == NULL)
|
||||||
|
return (0);
|
||||||
ptr = s->comp;
|
ptr = s->comp;
|
||||||
ptr->rcmd ? ft_memdel((void *)&ptr->rcmd) : (0);
|
ptr->rcmd ? ft_memdel((void *)&ptr->rcmd) : (0);
|
||||||
ptr->match ? ft_memdel((void *)&ptr->match) : (0);
|
ptr->match ? ft_memdel((void *)&ptr->match) : (0);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:31:21 by alao #+# #+# */
|
/* Created: 2017/01/09 13:31:21 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:14:51 by alao ### ########.fr */
|
/* Updated: 2017/02/17 15:34:30 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -27,15 +27,22 @@ static int c_exclusion_folder(t_comp *c)
|
||||||
char *tmp2;
|
char *tmp2;
|
||||||
|
|
||||||
tmp = ft_strjoin(c->cpath, c->match);
|
tmp = ft_strjoin(c->cpath, c->match);
|
||||||
|
tmp2 = NULL;
|
||||||
if ((rep = opendir(tmp)) && (!closedir(rep)))
|
if ((rep = opendir(tmp)) && (!closedir(rep)))
|
||||||
{
|
{
|
||||||
|
tmp ? ft_memdel((void *)&tmp) : (0);
|
||||||
|
if (c->rcmd[ft_strlen(c->rcmd) - 1] == '/')
|
||||||
|
{
|
||||||
|
c_clear(data_singleton());
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
tmp2 = ft_strjoin(c->match, "/");
|
tmp2 = ft_strjoin(c->match, "/");
|
||||||
c_updater(c, tmp2);
|
c_updater(c, tmp2);
|
||||||
tmp ? ft_memdel((void *)&tmp) : (0);
|
|
||||||
tmp2 ? ft_memdel((void *)&tmp2) : (0);
|
tmp2 ? ft_memdel((void *)&tmp2) : (0);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
tmp ? ft_memdel((void *)&tmp) : (0);
|
tmp ? ft_memdel((void *)&tmp) : (0);
|
||||||
|
tmp ? ft_memdel((void *)&tmp) : (0);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -63,7 +70,7 @@ static char *c_slicer(t_comp *c)
|
||||||
i--;
|
i--;
|
||||||
tmp[i] == '/' ? i++ : (0);
|
tmp[i] == '/' ? i++ : (0);
|
||||||
rt = (i == (int)ft_strlen(tmp) - 1) ? NULL : ft_strsub(tmp, 0, i);
|
rt = (i == (int)ft_strlen(tmp) - 1) ? NULL : ft_strsub(tmp, 0, i);
|
||||||
if (i <= (int)ft_strlen(tmp) - i + 1)
|
// if (i <= (int)ft_strlen(tmp) - i + 1)
|
||||||
c->match = ft_strsub(tmp, i, ft_strlen(tmp) - i);
|
c->match = ft_strsub(tmp, i, ft_strlen(tmp) - i);
|
||||||
tmp ? ft_memdel((void *)&tmp) : (0);
|
tmp ? ft_memdel((void *)&tmp) : (0);
|
||||||
return (rt);
|
return (rt);
|
||||||
|
|
@ -85,7 +92,12 @@ int c_seek_files(t_data *s, t_comp *c)
|
||||||
path ? ft_memdel((void *)&path) : (0);
|
path ? ft_memdel((void *)&path) : (0);
|
||||||
}
|
}
|
||||||
c_parser(c, c->cpath, c->match);
|
c_parser(c, c->cpath, c->match);
|
||||||
if (c->lst == NULL)
|
if (c->lst == NULL && c->isrematch == 0)
|
||||||
c_exclusion_folder(c);
|
c_exclusion_folder(c);
|
||||||
|
else if ((c->lst && (c->lst == c->lst->next)) && c->isrematch == 0)
|
||||||
|
{
|
||||||
|
if (c->match && ft_strequ(c->match, c->lst->name))
|
||||||
|
c_exclusion_folder(c);
|
||||||
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 11:21:16 by alao #+# #+# */
|
/* Created: 2017/01/09 11:21:16 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:08:25 by alao ### ########.fr */
|
/* Updated: 2017/02/17 13:44:39 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -55,9 +55,11 @@ static void c_init_base(t_comp *c)
|
||||||
|
|
||||||
ioctl(0, TIOCGWINSZ, &win);
|
ioctl(0, TIOCGWINSZ, &win);
|
||||||
c->win_x = win.ws_col;
|
c->win_x = win.ws_col;
|
||||||
|
c->win_y = win.ws_row;
|
||||||
c->cutpoint = 0;
|
c->cutpoint = 0;
|
||||||
c->between = NULL;
|
c->between = NULL;
|
||||||
c->isfolder = 0;
|
c->isfolder = 0;
|
||||||
|
c->isrematch = 0;
|
||||||
c->match = NULL;
|
c->match = NULL;
|
||||||
c->cpath = NULL;
|
c->cpath = NULL;
|
||||||
c->lst = NULL;
|
c->lst = NULL;
|
||||||
|
|
@ -72,7 +74,6 @@ static void c_init_base(t_comp *c)
|
||||||
|
|
||||||
void c_init(t_data *s, long int input)
|
void c_init(t_data *s, long int input)
|
||||||
{
|
{
|
||||||
|
|
||||||
int len_trail;
|
int len_trail;
|
||||||
|
|
||||||
if (!(s->comp = (t_comp *)malloc((sizeof(t_comp)))))
|
if (!(s->comp = (t_comp *)malloc((sizeof(t_comp)))))
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
/* Created: 2016/10/15 13:27:14 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 21:57:47 by alao ### ########.fr */
|
/* Updated: 2017/02/17 12:29:20 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ int c_matching(t_data *s, t_comp *c)
|
||||||
c_seek_binary(s, c);
|
c_seek_binary(s, c);
|
||||||
else
|
else
|
||||||
c_seek_files(s, c);
|
c_seek_files(s, c);
|
||||||
if (s->comp && c->lst)
|
if (s->comp && s->comp->lst)
|
||||||
{
|
{
|
||||||
c_sizing(c);
|
c_sizing(c);
|
||||||
return (1);
|
return (1);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/03 13:10:38 by alao #+# #+# */
|
/* Created: 2017/02/03 13:10:38 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:00:38 by alao ### ########.fr */
|
/* Updated: 2017/02/17 13:44:51 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/09 13:52:07 by alao #+# #+# */
|
/* Created: 2017/01/09 13:52:07 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:00:49 by alao ### ########.fr */
|
/* Updated: 2017/02/17 15:34:57 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -49,8 +49,6 @@ static int c_storing(t_comp *c, char *value, unsigned char type)
|
||||||
return (0);
|
return (0);
|
||||||
if (c->match && ft_strnequ(c->match, value, ft_strlen(c->match)) != 1)
|
if (c->match && ft_strnequ(c->match, value, ft_strlen(c->match)) != 1)
|
||||||
return (0);
|
return (0);
|
||||||
if (c->match && ft_strequ(c->match, value))
|
|
||||||
return (0);
|
|
||||||
if (!(tmp = (t_clst *)malloc(sizeof(t_clst))))
|
if (!(tmp = (t_clst *)malloc(sizeof(t_clst))))
|
||||||
return (-1);
|
return (-1);
|
||||||
tmp->name = ft_strdup(value);
|
tmp->name = ft_strdup(value);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/15 12:03:30 by alao #+# #+# */
|
/* Created: 2017/02/15 12:03:30 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:03:42 by alao ### ########.fr */
|
/* Updated: 2017/02/17 14:57:22 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -50,22 +50,17 @@ int c_rematch(t_comp *c, long int keypress)
|
||||||
{
|
{
|
||||||
if (ft_isascii(keypress))
|
if (ft_isascii(keypress))
|
||||||
{
|
{
|
||||||
|
c->isrematch = 1;
|
||||||
c_term_clear(c);
|
c_term_clear(c);
|
||||||
c_refresh_match(c, keypress);
|
c_refresh_match(c, keypress);
|
||||||
c_clear_lst(c);
|
c_clear_lst(c);
|
||||||
c_matching(data_singleton(), c);
|
c_matching(data_singleton(), c);
|
||||||
if (c->lst == NULL)
|
if (c->lst == NULL)
|
||||||
{
|
|
||||||
c_clear(data_singleton());
|
c_clear(data_singleton());
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
else if (c->lst == c->lst->next)
|
else if (c->lst == c->lst->next)
|
||||||
return (1);
|
return (1);
|
||||||
else
|
ft_print(keypress);
|
||||||
{
|
return(1);
|
||||||
ft_print(keypress);
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/10 08:50:26 by alao #+# #+# */
|
/* Created: 2017/01/10 08:50:26 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:01:47 by alao ### ########.fr */
|
/* Updated: 2017/02/17 13:45:33 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -56,10 +56,12 @@ int c_sizing(t_comp *c)
|
||||||
c->c_line = 0;
|
c->c_line = 0;
|
||||||
while ((c->c_line * c->c_pline) < c->c_sy)
|
while ((c->c_line * c->c_pline) < c->c_sy)
|
||||||
c->c_line++;
|
c->c_line++;
|
||||||
if (c->win_x < c->c_sx)
|
if ((c->win_x < c->c_sx))
|
||||||
{
|
{
|
||||||
c->c_pline = 0;
|
c->c_pline = 0;
|
||||||
c->c_line = 0;
|
c->c_line = 0;
|
||||||
}
|
}
|
||||||
|
if ((c->win_y < c->c_line))
|
||||||
|
c_clear(data_singleton());
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/10/11 10:44:40 by alao #+# #+# */
|
/* Created: 2016/10/11 10:44:40 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:01:37 by alao ### ########.fr */
|
/* Updated: 2017/02/17 18:36:56 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -84,3 +84,22 @@ void c_term_mv_down(t_comp *c)
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** If the terminal has chaged in size, the function will refresh these values
|
||||||
|
** and clear the previous print list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int c_term_resize(t_comp *c)
|
||||||
|
{
|
||||||
|
struct winsize win;
|
||||||
|
|
||||||
|
ioctl(0, TIOCGWINSZ, &win);
|
||||||
|
if ((win.ws_col == c->win_x) && (win.ws_row == c->win_y))
|
||||||
|
return (0);
|
||||||
|
c->win_x = win.ws_col;
|
||||||
|
c->win_y = win.ws_row;
|
||||||
|
c_sizing(c);
|
||||||
|
c_term_clear(c);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/09/20 14:50:33 by alao #+# #+# */
|
/* Created: 2016/09/20 14:50:33 by alao #+# #+# */
|
||||||
/* Updated: 2017/02/16 22:01:18 by alao ### ########.fr */
|
/* Updated: 2017/02/17 18:36:14 by alao ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -38,18 +38,16 @@ static void c_next_item(t_comp *c)
|
||||||
|
|
||||||
static int c_dispatcher(t_data *s)
|
static int c_dispatcher(t_data *s)
|
||||||
{
|
{
|
||||||
if (s->comp && s->comp->lst == NULL && s->comp->isfolder)
|
|
||||||
{
|
|
||||||
c_clear(s);
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
if (s->comp && s->comp->lst == NULL)
|
if (s->comp && s->comp->lst == NULL)
|
||||||
{
|
{
|
||||||
c_clear(s);
|
c_clear(s);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
else if (s->comp && s->comp->lst == s->comp->lst->next)
|
else if (s->comp && s->comp->lst == s->comp->lst->next)
|
||||||
return (c_updater(s->comp, s->comp->lst->name));
|
{
|
||||||
|
c_updater(s->comp, s->comp->lst->name);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
else if (s->comp && s->comp->lst != s->comp->lst->next)
|
else if (s->comp && s->comp->lst != s->comp->lst->next)
|
||||||
{
|
{
|
||||||
c_term_mv_down(s->comp);
|
c_term_mv_down(s->comp);
|
||||||
|
|
@ -96,6 +94,7 @@ int completion(long int keypress)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
c_term_resize(s->comp);
|
||||||
if (keypress == TOUCHE_TAB)
|
if (keypress == TOUCHE_TAB)
|
||||||
c_next_item(s->comp);
|
c_next_item(s->comp);
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue