normé
This commit is contained in:
parent
639caead01
commit
5df512d16a
3 changed files with 35 additions and 82 deletions
|
|
@ -267,6 +267,7 @@ 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_function.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 18:02:05 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 20:57:29 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -129,6 +129,8 @@ 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 ft_read_stdin(char **input);
|
int ft_read_stdin(char **input);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,41 +6,12 @@
|
||||||
/* 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 20:52:24 by gwojda ### ########.fr */
|
/* Updated: 2017/03/22 20:58:12 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
int ft_v(char **str, size_t *pos)
|
|
||||||
{
|
|
||||||
size_t tmp_pos;
|
|
||||||
int i;
|
|
||||||
char *tmp;
|
|
||||||
|
|
||||||
i = -1;
|
|
||||||
tmp_pos = *pos;
|
|
||||||
tmp = data_singleton()->line.copy_tmp;
|
|
||||||
if (!*str || !tmp)
|
|
||||||
return (0);
|
|
||||||
while (tmp[++i])
|
|
||||||
{
|
|
||||||
if (ft_strlen(*str) > SIZE_LINE)
|
|
||||||
break ;
|
|
||||||
*str = ft_realloc_imput(*str, tmp[i], *pos + i);
|
|
||||||
}
|
|
||||||
if (*pos)
|
|
||||||
{
|
|
||||||
--(*pos);
|
|
||||||
ft_get_beggin_with_curs(*str, pos);
|
|
||||||
}
|
|
||||||
ft_current_str(*str, *pos);
|
|
||||||
ft_get_next_str(*str, pos);
|
|
||||||
ft_putnc('\b', *pos - tmp_pos);
|
|
||||||
*pos = tmp_pos;
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset_term(char **str, size_t *pos)
|
static void reset_term(char **str, size_t *pos)
|
||||||
{
|
{
|
||||||
size_t pos_ref;
|
size_t pos_ref;
|
||||||
|
|
@ -58,56 +29,6 @@ static void reset_term(char **str, size_t *pos)
|
||||||
(*pos) = pos_ref;
|
(*pos) = pos_ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static 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);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static 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]);
|
|
||||||
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]);
|
|
||||||
ft_puttermcaps("me");
|
|
||||||
ft_putchar('\b');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp)
|
static void reset_and_remove_term(char **str, size_t *pos, char *copy_tmp)
|
||||||
{
|
{
|
||||||
size_t pos_ref;
|
size_t pos_ref;
|
||||||
|
|
@ -189,3 +110,32 @@ int ft_c(char **str, size_t *pos)
|
||||||
reset_term(str, pos);
|
reset_term(str, pos);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ft_v(char **str, size_t *pos)
|
||||||
|
{
|
||||||
|
size_t tmp_pos;
|
||||||
|
int i;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
i = -1;
|
||||||
|
tmp_pos = *pos;
|
||||||
|
tmp = data_singleton()->line.copy_tmp;
|
||||||
|
if (!*str || !tmp)
|
||||||
|
return (0);
|
||||||
|
while (tmp[++i])
|
||||||
|
{
|
||||||
|
if (ft_strlen(*str) > SIZE_LINE)
|
||||||
|
break ;
|
||||||
|
*str = ft_realloc_imput(*str, tmp[i], *pos + i);
|
||||||
|
}
|
||||||
|
if (*pos)
|
||||||
|
{
|
||||||
|
--(*pos);
|
||||||
|
ft_get_beggin_with_curs(*str, pos);
|
||||||
|
}
|
||||||
|
ft_current_str(*str, *pos);
|
||||||
|
ft_get_next_str(*str, pos);
|
||||||
|
ft_putnc('\b', *pos - tmp_pos);
|
||||||
|
*pos = tmp_pos;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue