Add early arrow support
This commit is contained in:
parent
328db0b260
commit
b8324bdc51
5 changed files with 101 additions and 6 deletions
|
|
@ -6,7 +6,7 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||
# Updated: 2017/03/10 08:47:51 by alao ### ########.fr #
|
||||
# Updated: 2017/03/10 09:14:50 by alao ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -46,6 +46,7 @@ builtin/builtin_unsetenv.c\
|
|||
builtin/is_builtin.c\
|
||||
c_seek_env.c\
|
||||
completion/c_abs_path.c\
|
||||
completion/c_arrow.c\
|
||||
completion/c_binary.c\
|
||||
completion/c_clear.c\
|
||||
completion/c_files.c\
|
||||
|
|
@ -242,7 +243,7 @@ NB = $(words $(SRC_BASE))
|
|||
INDEX = 0
|
||||
|
||||
all :
|
||||
@make -f $(NAME)
|
||||
@make $(NAME)
|
||||
|
||||
$(NAME): $(LIBFT_LIB) $(OBJ_DIR) $(OBJS)
|
||||
@$(CC) $(FLAGS) $(D_FLAGS) \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/02/18 11:13:04 by alao #+# #+# */
|
||||
/* Updated: 2017/03/10 08:31:49 by alao ### ########.fr */
|
||||
/* Updated: 2017/03/10 09:15:27 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -176,5 +176,6 @@ int c_glob_matching(void);
|
|||
void c_add_to_lst(t_comp *c, t_clst *node);
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
87
42sh/src/completion/c_arrow.c
Normal file
87
42sh/src/completion/c_arrow.c
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* c_arrow.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/10 09:04:42 by alao #+# #+# */
|
||||
/* Updated: 2017/03/10 09:57:44 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "completion.h"
|
||||
|
||||
static void c_arrow_right(t_comp *c)
|
||||
{
|
||||
t_clst *ptr;
|
||||
int i;
|
||||
|
||||
ptr = c->lst;
|
||||
i = 0;
|
||||
while (!ptr->cursor)
|
||||
ptr = ptr->next;
|
||||
ptr->cursor = 0;
|
||||
while (i < c->c_line)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
if (ptr == c->lst)
|
||||
i += c->c_line - (c->c_sy - ((c->c_pline - 1) * c->c_line));
|
||||
i++;
|
||||
}
|
||||
ptr->cursor = 1;
|
||||
}
|
||||
|
||||
static void c_arrow_left(t_comp *c)
|
||||
{
|
||||
t_clst *ptr;
|
||||
int i;
|
||||
|
||||
ptr = c->lst;
|
||||
i = 0;
|
||||
while (!ptr->cursor)
|
||||
ptr = ptr->next;
|
||||
ptr->cursor = 0;
|
||||
while (i < c->c_line)
|
||||
{
|
||||
ptr = ptr->prev;
|
||||
if (ptr == c->lst)
|
||||
i += c->c_line - (c->c_sy - ((c->c_pline - 1) * c->c_line));
|
||||
i++;
|
||||
}
|
||||
ptr->cursor = 1;
|
||||
}
|
||||
|
||||
static void c_arrow_down(t_comp *c)
|
||||
{
|
||||
t_clst *ptr;
|
||||
|
||||
ptr = c->lst;
|
||||
while (!ptr->cursor)
|
||||
ptr = ptr->next;
|
||||
ptr->cursor = 0;
|
||||
ptr->next->cursor = 1;
|
||||
}
|
||||
|
||||
static void c_arrow_up(t_comp *c)
|
||||
{
|
||||
t_clst *ptr;
|
||||
|
||||
ptr = c->lst;
|
||||
while (!ptr->cursor)
|
||||
ptr = ptr->next;
|
||||
ptr->cursor = 0;
|
||||
ptr->prev->cursor = 1;
|
||||
}
|
||||
|
||||
void c_arrow(t_comp *c, long int keypress)
|
||||
{
|
||||
if (keypress == 4283163)
|
||||
c_arrow_up(c);
|
||||
if (keypress == 4348699)
|
||||
c_arrow_down(c);
|
||||
if (keypress == 4479771)
|
||||
c_arrow_left(c);
|
||||
if (keypress == 4414235)
|
||||
c_arrow_right(c);
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/02/03 13:10:38 by alao #+# #+# */
|
||||
/* Updated: 2017/02/17 13:44:51 by alao ### ########.fr */
|
||||
/* Updated: 2017/03/10 09:05:23 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -114,5 +114,11 @@ int c_gtfo(t_comp *c, long int keypress)
|
|||
c_updater(c, ptr->name);
|
||||
return (1);
|
||||
}
|
||||
if (keypress == 4283163 || keypress == 4348699
|
||||
|| keypress == 4479771 || keypress == 4414235)
|
||||
{
|
||||
c_arrow(c, keypress);
|
||||
return (0);
|
||||
}
|
||||
return ((c_rematch(c, keypress)) ? (0) : (1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/10/11 10:44:40 by alao #+# #+# */
|
||||
/* Updated: 2017/03/10 08:46:13 by alao ### ########.fr */
|
||||
/* Updated: 2017/03/10 10:00:03 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ void c_term_mv_down(t_comp *c)
|
|||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < c->m_size)
|
||||
while (i < c->m_size + 1)
|
||||
{
|
||||
ft_putstr(tgetstr("do", NULL));
|
||||
ft_putstr(tgetstr("cd", NULL));
|
||||
|
|
|
|||
Loading…
Reference in a new issue