ajout haut et bas pour le surlignement

This commit is contained in:
gwojda 2017-03-23 11:46:33 +01:00
parent dcda700d7d
commit 2fab4b2763
21 changed files with 106 additions and 19 deletions

View file

@ -244,15 +244,21 @@ lexer/token_cmp_type.c\
lexer/token_free.c\
lexer/token_init.c\
lexer/token_print.c\
line_editing/completion.c\
line_editing/control_features.c\
line_editing/copy_cut_paste.c\
line_editing/copy_cut_paste/copy_cut_paste.c\
line_editing/copy_cut_paste/underline_down.c\
line_editing/copy_cut_paste/underline_end.c\
line_editing/copy_cut_paste/underline_function.c\
line_editing/copy_cut_paste/underline_home.c\
line_editing/copy_cut_paste/underline_left.c\
line_editing/copy_cut_paste/underline_reset.c\
line_editing/copy_cut_paste/underline_right.c\
line_editing/copy_cut_paste/underline_up.c\
line_editing/ft_prompt.c\
line_editing/get_key.c\
line_editing/home_end.c\
line_editing/init_history.c\
line_editing/init_line.c\
line_editing/init_termcaps.c\
line_editing/init_line/init_history.c\
line_editing/init_line/init_line.c\
line_editing/init_line/init_termcaps.c\
line_editing/lib_line_editing/ft_nb_line.c\
line_editing/lib_line_editing/tool_line.c\
line_editing/lib_line_editing/tool_line_2.c\
@ -260,19 +266,15 @@ line_editing/lib_line_editing/toolz.c\
line_editing/lib_line_editing/toolz2.c\
line_editing/lib_line_editing/toolz_parseur.c\
line_editing/lib_line_editing/toolz_termcaps.c\
line_editing/move_left_and_right.c\
line_editing/move_to_word.c\
line_editing/move_up_and_down.c\
line_editing/print_and_del.c\
line_editing/queue.c\
line_editing/move_term/home_end.c\
line_editing/move_term/move_left_and_right.c\
line_editing/move_term/move_to_word.c\
line_editing/move_term/move_up_and_down.c\
line_editing/print_del_completion/completion.c\
line_editing/print_del_completion/print_and_del.c\
line_editing/print_del_completion/queue.c\
line_editing/readline.c\
line_editing/resize.c\
line_editing/underline_end.c\
line_editing/underline_function.c\
line_editing/underline_home.c\
line_editing/underline_left.c\
line_editing/underline_reset.c\
line_editing/underline_right.c\
main/data_exit.c\
main/data_init.c\
main/data_singleton.c\

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
/* Updated: 2017/03/23 00:30:06 by ariard ### ########.fr */
/* Updated: 2017/03/23 11:45:05 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -135,6 +135,8 @@ void underline_end(char **str, size_t *pos, size_t pos_ref);
void underline_check_end_of_line(char *str, size_t pos);
void reset_term(char **str, size_t *pos);
void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp);
void underline_down(char **str, size_t *pos, size_t pos_ref);
void underline_up(char **str, size_t *pos, size_t pos_ref);
int ft_read_stdin(char **input);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
/* Updated: 2017/03/22 23:53:57 by gwojda ### ########.fr */
/* Updated: 2017/03/23 11:44:51 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -35,6 +35,10 @@ int ft_x(char **str, size_t *pos)
underline_home(str, pos, pos_ref);
else if (ret == TOUCHE_END)
underline_end(str, pos, pos_ref);
else if (ret == FLECHE_HAUT)
underline_up(str, pos, pos_ref);
else if (ret == FLECHE_BAS)
underline_down(str, pos, pos_ref);
else if (ret != FLECHE_DROITE && ret != FLECHE_GAUCHE)
break ;
}
@ -66,6 +70,10 @@ int ft_c(char **str, size_t *pos)
underline_home(str, pos, pos_ref);
else if (ret == TOUCHE_END)
underline_end(str, pos, pos_ref);
else if (ret == FLECHE_HAUT)
underline_up(str, pos, pos_ref);
else if (ret == FLECHE_BAS)
underline_down(str, pos, pos_ref);
else if (ret != FLECHE_DROITE && ret != FLECHE_GAUCHE)
break ;
}

View file

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* underline_down.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/23 11:43:40 by gwojda #+# #+# */
/* Updated: 2017/03/23 11:45:20 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void underline_down(char **str, size_t *pos, size_t pos_ref)
{
size_t pos_tmp;
int i;
i = 0;
pos_tmp = *pos;
if ((*str)[pos_tmp] == '\n')
{
underline_right(str, pos, pos_ref);
++pos_tmp;
}
i = ft_size_term();
while (i && (*str)[pos_tmp] && (*str)[pos_tmp] != '\n')
{
underline_right(str, pos, pos_ref);
++pos_tmp;
--i;
}
if ((*str)[pos_tmp] == '\n')
{
underline_left(str, pos, pos_ref);
--pos_tmp;
}
}

View file

@ -0,0 +1,36 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* underline_up.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/23 11:35:48 by gwojda #+# #+# */
/* Updated: 2017/03/23 11:39:49 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void underline_up(char **str, size_t *pos, size_t pos_ref)
{
size_t pos_tmp;
int i;
i = 0;
pos_tmp = *pos;
if ((*str)[pos_tmp] == '\n')
{
underline_left(str, pos, pos_ref);
--pos_tmp;
}
i = ft_size_term();
while (i && (pos_tmp && (*str)[pos_tmp] != '\n')
&& (pos_tmp + 1 > 0 && (*str)[pos_tmp - 1] != '\n'))
{
underline_left(str, pos, pos_ref);
--pos_tmp;
--i;
}
*pos = pos_tmp;
}