Merge branch 'master' of https://github.com/jzck/42sh
This commit is contained in:
commit
fe0ea7930f
9 changed files with 225 additions and 98 deletions
|
|
@ -267,8 +267,12 @@ line_editing/print_and_del.c\
|
||||||
line_editing/queue.c\
|
line_editing/queue.c\
|
||||||
line_editing/readline.c\
|
line_editing/readline.c\
|
||||||
line_editing/resize.c\
|
line_editing/resize.c\
|
||||||
|
line_editing/underline_end.c\
|
||||||
line_editing/underline_function.c\
|
line_editing/underline_function.c\
|
||||||
|
line_editing/underline_home.c\
|
||||||
|
line_editing/underline_left.c\
|
||||||
line_editing/underline_reset.c\
|
line_editing/underline_reset.c\
|
||||||
|
line_editing/underline_right.c\
|
||||||
main/data_exit.c\
|
main/data_exit.c\
|
||||||
main/data_init.c\
|
main/data_init.c\
|
||||||
main/data_singleton.c\
|
main/data_singleton.c\
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
|
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 21:14:55 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 23:19:10 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
# define TOUCHE_F5 892427035
|
# define TOUCHE_F5 892427035
|
||||||
# define TOUCHE_F6 925981467
|
# define TOUCHE_F6 925981467
|
||||||
|
|
||||||
# define SIZE_LINE 512
|
# define SIZE_LINE 16384
|
||||||
|
|
||||||
# define CORRUPT 1
|
# define CORRUPT 1
|
||||||
|
|
||||||
|
|
@ -127,11 +127,14 @@ int ft_nb_of_line(char *str, size_t pos);
|
||||||
int ft_get_size_prev(char *str, size_t pos);
|
int ft_get_size_prev(char *str, size_t pos);
|
||||||
void sigwinch_resize(int sig);
|
void sigwinch_resize(int sig);
|
||||||
size_t ft_hist_len(void);
|
size_t ft_hist_len(void);
|
||||||
void underline_right(char **str, size_t *pos, size_t pos_ref);
|
|
||||||
void underline_left(char **str, size_t *pos, size_t pos_ref);
|
int underline_right(char **str, size_t *pos, size_t pos_ref);
|
||||||
|
int underline_left(char **str, size_t *pos, size_t pos_ref);
|
||||||
|
void underline_home(char **str, size_t *pos, size_t pos_ref);
|
||||||
|
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_term(char **str, size_t *pos);
|
||||||
void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp);
|
void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp);
|
||||||
int reset_term_hard(void);
|
|
||||||
|
|
||||||
int ft_read_stdin(char **input);
|
int ft_read_stdin(char **input);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
|
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 21:14:34 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 23:19:57 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -27,12 +27,10 @@ int ft_x(char **str, size_t *pos)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (read(STDIN, &ret, sizeof(int)) < 0)
|
if (read(STDIN, &ret, sizeof(int)) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
if ((*str)[*pos] == '\n')
|
if (ret == FLECHE_GAUCHE && !underline_left(str, pos, pos_ref))
|
||||||
return (reset_term_hard());
|
return (0);
|
||||||
if (ret == FLECHE_GAUCHE)
|
else if (ret == FLECHE_DROITE && !underline_right(str, pos, pos_ref))
|
||||||
underline_left(str, pos, pos_ref);
|
return (0);
|
||||||
else if (ret == FLECHE_DROITE)
|
|
||||||
underline_right(str, pos, pos_ref);
|
|
||||||
else
|
else
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
@ -56,13 +54,15 @@ int ft_c(char **str, size_t *pos)
|
||||||
ret = 0;
|
ret = 0;
|
||||||
if (read(STDIN, &ret, sizeof(int)) < 0)
|
if (read(STDIN, &ret, sizeof(int)) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
if ((*str)[*pos] == '\n')
|
if (ret == FLECHE_GAUCHE && !underline_left(str, pos, pos_ref))
|
||||||
return (reset_term_hard());
|
return (0);
|
||||||
if (ret == FLECHE_GAUCHE)
|
else if (ret == FLECHE_DROITE && !underline_right(str, pos, pos_ref))
|
||||||
underline_left(str, pos, pos_ref);
|
return (0);
|
||||||
else if (ret == FLECHE_DROITE)
|
else if (ret == TOUCHE_HOME)
|
||||||
underline_right(str, pos, pos_ref);
|
underline_home(str, pos, pos_ref);
|
||||||
else
|
else if (ret == TOUCHE_END)
|
||||||
|
underline_end(str, pos, pos_ref);
|
||||||
|
else if (ret != FLECHE_DROITE && ret != FLECHE_GAUCHE)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
reset_term(str, pos);
|
reset_term(str, pos);
|
||||||
|
|
|
||||||
35
42sh/src/line_editing/underline_end.c
Normal file
35
42sh/src/line_editing/underline_end.c
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* underline_end.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/22 23:18:15 by gwojda #+# #+# */
|
||||||
|
/* Updated: 2017/03/22 23:42:27 by gwojda ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
void underline_end(char **str, size_t *pos, size_t pos_ref)
|
||||||
|
{
|
||||||
|
size_t pos_tmp;
|
||||||
|
|
||||||
|
pos_tmp = *pos;
|
||||||
|
if ((*str)[pos_tmp] == '\n')
|
||||||
|
{
|
||||||
|
underline_right(str, pos, pos_ref);
|
||||||
|
++pos_tmp;
|
||||||
|
}
|
||||||
|
while ((*str)[pos_tmp] && (*str)[pos_tmp] != '\n')
|
||||||
|
{
|
||||||
|
underline_right(str, pos, pos_ref);
|
||||||
|
++pos_tmp;
|
||||||
|
}
|
||||||
|
if ((*str)[pos_tmp] == '\n')
|
||||||
|
{
|
||||||
|
underline_left(str, pos, pos_ref);
|
||||||
|
--pos_tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/22 20:55:24 by gwojda #+# #+# */
|
/* Created: 2017/03/22 20:55:24 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 21:28:31 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 22:59:02 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
static void underline_check_end_of_line(char *str, size_t pos)
|
void underline_check_end_of_line(char *str, size_t pos)
|
||||||
{
|
{
|
||||||
if (!str)
|
if (!str)
|
||||||
return ;
|
return ;
|
||||||
|
|
@ -22,61 +22,3 @@ static void underline_check_end_of_line(char *str, size_t pos)
|
||||||
ft_puttermcaps("le");
|
ft_puttermcaps("le");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void underline_right(char **str, size_t *pos, size_t pos_ref)
|
|
||||||
{
|
|
||||||
if (!(*pos < ft_strlen(*str)))
|
|
||||||
return ;
|
|
||||||
if (*pos >= pos_ref)
|
|
||||||
{
|
|
||||||
ft_puttermcaps("mr");
|
|
||||||
data_singleton()->line.copy_tmp = ft_realloc_imput(data_singleton()->
|
|
||||||
line.copy_tmp, (*str)[*pos], data_singleton()->line.pos_tmp);
|
|
||||||
ft_putchar((*str)[*pos]);
|
|
||||||
ft_puttermcaps("me");
|
|
||||||
++(data_singleton()->line.pos_tmp);
|
|
||||||
++(*pos);
|
|
||||||
underline_check_end_of_line(*str, *pos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data_singleton()->line.copy_tmp = ft_remove_imput(data_singleton()->
|
|
||||||
line.copy_tmp, data_singleton()->line.pos_tmp);
|
|
||||||
ft_putchar((*str)[*pos]);
|
|
||||||
if (data_singleton()->line.pos_tmp)
|
|
||||||
--(data_singleton()->line.pos_tmp);
|
|
||||||
++(*pos);
|
|
||||||
underline_check_end_of_line(*str, *pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void underline_left(char **str, size_t *pos, size_t pos_ref)
|
|
||||||
{
|
|
||||||
if (!*pos)
|
|
||||||
return ;
|
|
||||||
if (*pos > pos_ref)
|
|
||||||
{
|
|
||||||
--(*pos);
|
|
||||||
ft_putchar('\b');
|
|
||||||
ft_putchar((*str)[*pos]);
|
|
||||||
underline_check_end_of_line(*str, *pos + 1);
|
|
||||||
ft_putchar('\b');
|
|
||||||
data_singleton()->line.copy_tmp = ft_remove_imput(data_singleton()->
|
|
||||||
line.copy_tmp, data_singleton()->line.pos_tmp);
|
|
||||||
if (data_singleton()->line.pos_tmp)
|
|
||||||
--(data_singleton()->line.pos_tmp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data_singleton()->line.pos_tmp = 0;
|
|
||||||
--(*pos);
|
|
||||||
ft_putchar('\b');
|
|
||||||
ft_puttermcaps("mr");
|
|
||||||
data_singleton()->line.copy_tmp = ft_realloc_imput(data_singleton()->
|
|
||||||
line.copy_tmp, (*str)[*pos], data_singleton()->line.pos_tmp);
|
|
||||||
ft_putchar((*str)[*pos]);
|
|
||||||
underline_check_end_of_line(*str, *pos + 1);
|
|
||||||
ft_puttermcaps("me");
|
|
||||||
ft_putchar('\b');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
32
42sh/src/line_editing/underline_home.c
Normal file
32
42sh/src/line_editing/underline_home.c
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* underline_home.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/22 23:11:05 by gwojda #+# #+# */
|
||||||
|
/* Updated: 2017/03/22 23:44:44 by gwojda ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
void underline_home(char **str, size_t *pos, size_t pos_ref)
|
||||||
|
{
|
||||||
|
size_t pos_tmp;
|
||||||
|
|
||||||
|
pos_tmp = *pos;
|
||||||
|
if ((*str)[pos_tmp] == '\n')
|
||||||
|
{
|
||||||
|
underline_left(str, pos, pos_ref);
|
||||||
|
--pos_tmp;
|
||||||
|
}
|
||||||
|
while ((pos_tmp && (*str)[pos_tmp] != '\n')
|
||||||
|
&& (pos_tmp + 1 > 0 && (*str)[pos_tmp - 1] != '\n'))
|
||||||
|
{
|
||||||
|
underline_left(str, pos, pos_ref);
|
||||||
|
--pos_tmp;
|
||||||
|
}
|
||||||
|
*pos = pos_tmp;
|
||||||
|
}
|
||||||
62
42sh/src/line_editing/underline_left.c
Normal file
62
42sh/src/line_editing/underline_left.c
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* underline_left.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/22 22:54:28 by gwojda #+# #+# */
|
||||||
|
/* Updated: 2017/03/22 23:08:58 by gwojda ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
static int reset_term_hard(void)
|
||||||
|
{
|
||||||
|
ft_putstr(data_singleton()->line.copy_tmp);
|
||||||
|
ft_putnc('\b', ft_strlen(data_singleton()->line.copy_tmp));
|
||||||
|
ft_strdel(&data_singleton()->line.copy_tmp);
|
||||||
|
data_singleton()->line.pos_tmp = 0;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void left_abs(char **str, size_t *pos)
|
||||||
|
{
|
||||||
|
--(*pos);
|
||||||
|
ft_putchar('\b');
|
||||||
|
data_singleton()->line.pos_tmp = 0;
|
||||||
|
ft_puttermcaps("mr");
|
||||||
|
data_singleton()->line.copy_tmp = ft_realloc_imput(data_singleton()->
|
||||||
|
line.copy_tmp, (*str)[*pos], data_singleton()->line.pos_tmp);
|
||||||
|
ft_putchar((*str)[*pos]);
|
||||||
|
underline_check_end_of_line(*str, *pos + 1);
|
||||||
|
ft_puttermcaps("me");
|
||||||
|
ft_putchar('\b');
|
||||||
|
}
|
||||||
|
|
||||||
|
static void left_mv_back(char **str, size_t *pos)
|
||||||
|
{
|
||||||
|
--(*pos);
|
||||||
|
ft_putchar('\b');
|
||||||
|
ft_putchar((*str)[*pos]);
|
||||||
|
underline_check_end_of_line(*str, *pos + 1);
|
||||||
|
data_singleton()->line.copy_tmp = ft_remove_imput(data_singleton()->
|
||||||
|
line.copy_tmp, data_singleton()->line.pos_tmp);
|
||||||
|
if (data_singleton()->line.pos_tmp)
|
||||||
|
--(data_singleton()->line.pos_tmp);
|
||||||
|
ft_putchar('\b');
|
||||||
|
}
|
||||||
|
|
||||||
|
int underline_left(char **str, size_t *pos, size_t pos_ref)
|
||||||
|
{
|
||||||
|
if (!*pos)
|
||||||
|
return (1);
|
||||||
|
if ((*str)[*pos - 1] == '\n')
|
||||||
|
return (reset_term_hard());
|
||||||
|
if (*pos > pos_ref)
|
||||||
|
left_mv_back(str, pos);
|
||||||
|
else
|
||||||
|
left_abs(str, pos);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/03/22 21:14:07 by gwojda #+# #+# */
|
/* Created: 2017/03/22 21:14:07 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/22 21:16:24 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 23:40:39 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ void reset_term(char **str, size_t *pos)
|
||||||
ft_current_str(*str, *pos);
|
ft_current_str(*str, *pos);
|
||||||
ft_get_next_str(*str, pos);
|
ft_get_next_str(*str, pos);
|
||||||
ft_putnc('\b', *pos - pos_ref);
|
ft_putnc('\b', *pos - pos_ref);
|
||||||
(*pos) = pos_ref;
|
(*pos) = pos_ref + (((*str)[*pos]) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp)
|
void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp)
|
||||||
|
|
@ -36,29 +36,20 @@ void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp)
|
||||||
pos_ref = *pos;
|
pos_ref = *pos;
|
||||||
if (!data_singleton()->line.pos_tmp)
|
if (!data_singleton()->line.pos_tmp)
|
||||||
pos_ref += ft_strlen(data_singleton()->line.copy_tmp);
|
pos_ref += ft_strlen(data_singleton()->line.copy_tmp);
|
||||||
|
if (*pos)
|
||||||
|
{
|
||||||
|
--(*pos);
|
||||||
|
ft_get_beggin_with_curs(*str, pos);
|
||||||
|
}
|
||||||
while (*copy_tmp)
|
while (*copy_tmp)
|
||||||
{
|
{
|
||||||
--pos_ref;
|
--pos_ref;
|
||||||
*str = ft_remove_imput(*str, pos_ref);
|
*str = ft_remove_imput(*str, pos_ref);
|
||||||
++copy_tmp;
|
++copy_tmp;
|
||||||
}
|
}
|
||||||
if (*pos)
|
|
||||||
{
|
|
||||||
--(*pos);
|
|
||||||
ft_get_beggin_with_curs(*str, pos);
|
|
||||||
}
|
|
||||||
ft_puttermcaps("cd");
|
ft_puttermcaps("cd");
|
||||||
ft_current_str(*str, *pos);
|
ft_current_str(*str, *pos);
|
||||||
ft_get_next_str(*str, pos);
|
ft_get_next_str(*str, pos);
|
||||||
ft_putnc('\b', *pos - pos_ref);
|
ft_putnc('\b', *pos - pos_ref);
|
||||||
(*pos) = pos_ref;
|
(*pos) = pos_ref + (((*str)[*pos]) ? 1 : 0);
|
||||||
}
|
|
||||||
|
|
||||||
int reset_term_hard(void)
|
|
||||||
{
|
|
||||||
ft_putnc('\b', ft_strlen(data_singleton()->line.copy_tmp));
|
|
||||||
ft_putstr(data_singleton()->line.copy_tmp);
|
|
||||||
ft_strdel(&data_singleton()->line.copy_tmp);
|
|
||||||
data_singleton()->line.pos_tmp = 0;
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
58
42sh/src/line_editing/underline_right.c
Normal file
58
42sh/src/line_editing/underline_right.c
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* underline_right.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/03/22 22:50:52 by gwojda #+# #+# */
|
||||||
|
/* Updated: 2017/03/22 23:00:32 by gwojda ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "minishell.h"
|
||||||
|
|
||||||
|
static int reset_term_hard(void)
|
||||||
|
{
|
||||||
|
ft_putnc('\b', ft_strlen(data_singleton()->line.copy_tmp));
|
||||||
|
ft_putstr(data_singleton()->line.copy_tmp);
|
||||||
|
ft_strdel(&data_singleton()->line.copy_tmp);
|
||||||
|
data_singleton()->line.pos_tmp = 0;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void right_abs(char **str, size_t *pos)
|
||||||
|
{
|
||||||
|
ft_puttermcaps("mr");
|
||||||
|
data_singleton()->line.copy_tmp = ft_realloc_imput(data_singleton()->
|
||||||
|
line.copy_tmp, (*str)[*pos], data_singleton()->line.pos_tmp);
|
||||||
|
ft_putchar((*str)[*pos]);
|
||||||
|
ft_puttermcaps("me");
|
||||||
|
++(data_singleton()->line.pos_tmp);
|
||||||
|
++(*pos);
|
||||||
|
underline_check_end_of_line(*str, *pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void right_mv_back(char **str, size_t *pos)
|
||||||
|
{
|
||||||
|
data_singleton()->line.copy_tmp = ft_remove_imput(data_singleton()->
|
||||||
|
line.copy_tmp, data_singleton()->line.pos_tmp);
|
||||||
|
ft_putchar((*str)[*pos]);
|
||||||
|
if (data_singleton()->line.pos_tmp)
|
||||||
|
--(data_singleton()->line.pos_tmp);
|
||||||
|
++(*pos);
|
||||||
|
underline_check_end_of_line(*str, *pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
int underline_right(char **str, size_t *pos, size_t pos_ref)
|
||||||
|
{
|
||||||
|
if (!(*pos < ft_strlen(*str)))
|
||||||
|
return (1);
|
||||||
|
if ((*str)[*pos] == '\n')
|
||||||
|
return (reset_term_hard());
|
||||||
|
if (*pos >= pos_ref)
|
||||||
|
right_abs(str, pos);
|
||||||
|
else
|
||||||
|
right_mv_back(str, pos);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue