correction des heredocs + corrections de quelques bugs mineurs sur l'edition de ligne (le gain de ligne a peut-etre entrainé des bugs que j'ai raté)

This commit is contained in:
gwojda 2017-02-05 17:13:26 +01:00
parent c77af3da9f
commit 1afdd9528b
13 changed files with 230 additions and 283 deletions

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/26 13:32:52 by gwojda #+# #+# */
/* Updated: 2017/02/04 18:26:59 by gwojda ### ########.fr */
/* Updated: 2017/02/05 12:40:21 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -101,32 +101,28 @@ static int ft_brackets(char c)
void ft_check_line(void)
{
int i;
char *str;
short status;
i = 0;
i = -1;
status = 0;
str = STR;
ft_reset_tab((char *)g_brackets.tabl);
g_brackets.pos = 0;
if (!str)
if (!STR)
return ;
while (str[i])
while (STR[++i])
{
if (IS_BSLASH & status)
status = status ^ IS_BSLASH;
else
{
ft_check_this_char_quotes(str[i], &status);
if (!status && ft_brackets(str[i]))
ft_check_this_char_quotes(STR[i], &status);
if (!status && ft_brackets(STR[i]))
return ;
}
++i;
}
if (g_brackets.pos && g_brackets.tabl[0] == '(')
status = status | IS_BRACKET;
else if (g_brackets.pos && g_brackets.tabl[0] == '{')
status = status | IS_ACCOLADE;
if (status)
ft_read_more(status);
(status) ? ft_read_more(status) : 0;
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 14:15:55 by gwojda #+# #+# */
/* Updated: 2017/02/03 16:10:54 by gwojda ### ########.fr */
/* Updated: 2017/02/05 16:48:20 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -21,15 +21,15 @@ int ft_completion(int ret)
if (((ret != TOUCHE_TAB && ret != 10)
|| (ret == 10)) && !(data_singleton()->comp))
return (0);
tmp = data_singleton()->line.pos;
tmp = POS;
if (data_singleton()->comp || ret == TOUCHE_TAB)
boolean = completion(ret);
if (boolean || ret == 10)
{
ft_puttermcaps("cd");
ft_current_str(data_singleton()->line.input, tmp);
ft_get_next_str(data_singleton()->line.input, &tmp);
data_singleton()->line.pos = tmp;
ft_current_str(STR, tmp);
ft_get_next_str(STR, &tmp);
POS = tmp;
}
return (1);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */
/* Updated: 2017/02/03 18:27:23 by gwojda ### ########.fr */
/* Updated: 2017/02/05 16:49:10 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,17 +22,12 @@ void ft_buff_f6(void)
void ft_control_d(void)
{
char **str;
size_t *pos;
str = &data_singleton()->line.input;
pos = &data_singleton()->line.pos;
if (!(*str) || (*str)[0] == '\0')
if (!STR || STR[0] == '\0')
{
ft_putstr("exit\n");
builtin_exit(NULL, (char*[]){"exit", NULL}, NULL);
}
else if (*pos < ft_strlen(*str))
else if (POS < ft_strlen(STR))
ft_del();
else
ft_puttermcaps("bl");
@ -40,13 +35,8 @@ void ft_control_d(void)
void ft_control_c(void)
{
char **str;
size_t *pos;
str = &data_singleton()->line.input;
pos = &data_singleton()->line.pos;
ft_putchar('\n');
ft_prompt();
ft_strdel(str);
*pos = 0;
ft_strdel(&STR);
POS = 0;
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
/* Updated: 2017/02/04 14:55:05 by gwojda ### ########.fr */
/* Updated: 2017/02/05 17:07:12 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,48 +41,40 @@ void ft_v(void)
size_t tmp_pos;
int i;
char *tmp;
char **str;
size_t *pos;
tmp = data_singleton()->line.copy_tmp;
str = &STR;
pos = &POS;
i = -1;
tmp_pos = *pos;
if (!*str || !tmp)
tmp_pos = POS;
if (!STR || !tmp)
return ;
while (tmp[++i])
*str = ft_realloc_imput(*str, tmp[i], *pos + i);
if (*pos)
STR = ft_realloc_imput(STR, tmp[i], POS + i);
if (POS)
{
--(*pos);
ft_get_beggin_with_curs(*str, 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;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
ft_putnc('\b', POS - tmp_pos);
POS = tmp_pos;
}
void ft_x(void)
{
int i;
char **tmp;
char **str;
size_t *pos;
tmp = &data_singleton()->line.copy_tmp;
str = &STR;
pos = &POS;
if (!*str)
if (!STR)
return ;
if (*tmp)
ft_strdel(tmp);
*tmp = ft_strdupi_space(&(*str)[(*pos)]);
*tmp = ft_strdupi_space(&STR[POS]);
i = ft_strlen(*tmp);
while (i >= 0)
{
*str = ft_remove_imput(*str, *pos + i);
STR = ft_remove_imput(STR, POS + i);
--i;
}
ft_puttermcaps("cd");
@ -91,13 +83,9 @@ void ft_x(void)
void ft_c(void)
{
char *tmp;
char **str;
size_t *pos;
tmp = data_singleton()->line.copy_tmp;
str = &STR;
pos = &POS;
if (tmp)
ft_strdel(&tmp);
tmp = ft_strdupi_space((*str) + (*pos));
tmp = ft_strdupi_space(STR + POS);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */
/* Updated: 2017/02/04 15:39:49 by gwojda ### ########.fr */
/* Updated: 2017/02/05 16:57:57 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:42:54 by gwojda #+# #+# */
/* Updated: 2017/02/04 15:17:19 by gwojda ### ########.fr */
/* Updated: 2017/02/05 16:57:51 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,76 +58,70 @@ static void ft_found_prev_word_2(int i, char *str, size_t *pos)
void ft_found_prev_word(void)
{
int i;
char *str;
size_t *pos;
i = 0;
str = STR;
pos = &POS;
if (!*pos || !str)
if (!POS || !STR)
return ;
ft_init_prev_word(pos, str);
if (*pos >= 1 && str[*pos - 1] == '\n')
ft_init_prev_word(&POS, STR);
if (POS >= 1 && STR[POS - 1] == '\n')
{
if (POS - 1 == 0)
{
ft_puttermcaps("cd");
if (*pos >= 2)
(*pos) -= 2;
ft_get_beggin(str, pos);
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
++(*pos);
--POS;
return ;
}
ft_puttermcaps("cd");
POS -= 2;
ft_get_beggin(STR, &POS);
if (!POS && STR[POS] == '\n')
++POS;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
++POS;
}
else
ft_found_prev_word_2(i, str, pos);
ft_found_prev_word_2(i, STR, &POS);
}
static void ft_found_next_word_2(void)
{
char *str;
size_t *pos;
str = STR;
pos = &POS;
if (*pos)
if (POS)
{
--(*pos);
ft_get_beggin_with_curs(str, pos);
--POS;
ft_get_beggin_with_curs(STR, &POS);
}
ft_puttermcaps("cd");
ft_get_next_str(str, pos);
(*pos) += (*pos) ? 2 : 1;
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
if (!str[*pos])
--(*pos);
ft_get_beggin_with_curs(str, pos);
ft_get_next_str(STR, &POS);
POS += (POS || STR[0] != '\n') ? 2 : 1;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
if (!STR[POS])
--POS;
ft_get_beggin_with_curs(STR, &POS);
}
void ft_found_next_word(void)
{
int i;
char *str;
size_t *pos;
i = 0;
str = STR;
pos = &POS;
if (!str)
if (!STR)
return ;
while (str[i + *pos] && str[i + *pos] == ' ')
while (STR[i + POS] && STR[i + POS] == ' ')
{
ft_putchar(str[i + *pos]);
ft_putchar(STR[i + POS]);
++i;
}
if (str[*pos] == '\n')
if (STR[POS] == '\n')
ft_found_next_word_2();
else
{
while (str[i + *pos] && str[i + *pos] != '\n' && str[i + *pos] != ' ')
while (STR[i + POS] && STR[i + POS] != '\n' && STR[i + POS] != ' ')
{
ft_putchar(str[i + *pos]);
ft_putchar(STR[i + POS]);
++i;
}
*pos += i;
POS += i;
}
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:43:58 by gwojda #+# #+# */
/* Updated: 2017/02/04 15:34:10 by gwojda ### ########.fr */
/* Updated: 2017/02/05 17:07:43 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,106 +20,93 @@ int ft_put(int nb)
void ft_end(void)
{
char *str;
size_t *pos;
str = STR;
pos = &POS;
if (!str)
if (!STR)
return ;
if (*pos)
if (POS)
{
--(*pos);
ft_get_beggin_with_curs(str, pos);
--POS;
ft_get_beggin_with_curs(STR, &POS);
}
ft_puttermcaps("cd");
while (str[*pos])
++(*pos);
ft_get_beggin(str, pos);
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
while (STR[POS])
++POS;
ft_get_beggin(STR, &POS);
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
}
void ft_home(void)
{
char *str;
size_t *pos;
str = STR;
pos = &POS;
if (!str)
if (!STR)
return ;
if (*pos)
if (POS)
{
--(*pos);
ft_get_beggin_with_curs(str, pos);
if (str[*pos + 1] == '\n')
--POS;
ft_get_beggin_with_curs(STR, &POS);
if (STR[POS + 1] == '\n')
ft_puttermcaps("nd");
}
ft_puttermcaps("cd");
*pos = 0;
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
ft_check_end_of_line(str, *pos);
if (!str[*pos])
--(*pos);
ft_get_beggin_with_curs(str, pos);
POS = 0;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
ft_check_end_of_line(STR, POS);
if (!STR[POS])
--POS;
ft_get_beggin_with_curs(STR, &POS);
}
void ft_move_right(void)
{
size_t tmp;
size_t *pos;
pos = &POS;
if (ft_strlen(STR) <= *pos)
if (ft_strlen(STR) <= POS)
return ;
if (STR[*pos] == '\n')
if (STR[POS] == '\n')
{
if (*pos)
if (POS)
{
tmp = *pos - 1;
tmp = POS - 1;
ft_get_beggin_with_curs(STR, &tmp);
}
ft_puttermcaps("cd");
++(*pos);
ft_current_str(STR, *pos);
ft_get_next_str(STR, pos);
(*pos) = (!STR[*pos]) ? *pos - 1 : *pos;
ft_get_beggin_with_curs(STR, pos);
++POS;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
POS = (!STR[POS]) ? POS - 1 : POS;
ft_get_beggin_with_curs(STR, &POS);
}
else
{
ft_putchar(STR[*pos]);
++(*pos);
ft_putchar(STR[POS]);
++POS;
}
}
void ft_move_left(void)
{
size_t *pos;
pos = &POS;
if (!*pos)
if (!POS)
return ;
if (STR[*pos - 1] == '\n')
if (STR[POS - 1] == '\n')
{
if (*pos - 1 == 0)
if (POS - 1 == 0)
{
ft_puttermcaps("cd");
--(*pos);
--POS;
return ;
}
ft_puttermcaps("cd");
(*pos) -= 2;
ft_get_beggin(STR, pos);
ft_current_str(STR, *pos);
ft_get_next_str(STR, pos);
++(*pos);
POS -= 2;
ft_get_beggin(STR, &POS);
if (!POS && STR[POS] == '\n')
++POS;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
++POS;
}
else
{
ft_puttermcaps("le");
--(*pos);
--POS;
}
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/24 15:52:34 by gwojda #+# #+# */
/* Updated: 2017/02/03 18:15:07 by gwojda ### ########.fr */
/* Updated: 2017/02/05 12:21:21 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,13 +19,39 @@ char *ft_get_next_word(char *str)
j = 0;
k = 0;
while (str[j] && str[j] == ' ')
while (str[j] && (str[j] == ' ' || str[j] == '\n'))
++j;
while (str[j + k] && str[j + k] != ' ')
while (str[j + k] && str[j + k] != ' ' && str[j + k] != '\n')
++k;
return (ft_strndup(str + j, k));
}
static void ft_after_retline(char *str, int *i)
{
while (str[*i] && str[*i] != '\n')
++(*i);
if (str[*i] == '\n')
++(*i);
}
static int ft_is_keyword(char *str, char *end)
{
int i;
int j;
i = 0;
while (str[i])
{
ft_after_retline(str, &i);
j = 0;
while (str[i + j] && str[i + j] != '\n')
++j;
if (str[i] && ft_strncmp(str + i, end, j) == 0)
return (0);
}
return (1);
}
static void ft_check_heredoc_2(char **str, char *end)
{
char boolean;
@ -67,7 +93,12 @@ void ft_check_heredoc(char **str)
if ((*str)[i] == '<' && !ft_strncmp(*str + i, "<<", 2))
{
if ((*str)[i + 1] == '<' && (*str)[i + 2])
{
end = ft_get_next_word(*str + i + 2);
if (ft_is_keyword(*str, end))
ft_check_heredoc_2(str, end);
free(end);
}
else
return ;
}
@ -75,6 +106,4 @@ void ft_check_heredoc(char **str)
}
if (!end)
return ;
ft_check_heredoc_2(str, end);
free(end);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 15:22:19 by gwojda #+# #+# */
/* Updated: 2017/02/04 15:20:49 by gwojda ### ########.fr */
/* Updated: 2017/02/05 17:00:18 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,18 +14,15 @@
static void ft_clear_before_history(char **str)
{
size_t *pos;
pos = &POS;
if (*str)
{
if (*pos)
if (POS)
{
--(*pos);
ft_get_beggin_with_curs(*str, pos);
--POS;
ft_get_beggin_with_curs(*str, &POS);
}
ft_puttermcaps("cd");
*pos = 0;
POS = 0;
ft_strdel(str);
}
}
@ -33,53 +30,45 @@ static void ft_clear_before_history(char **str)
void ft_history_down(void)
{
t_list_history *head;
char **str;
size_t *pos;
str = &STR;
pos = &POS;
head = data_singleton()->line.list_cur;
if (!head)
return ;
ft_clear_before_history(str);
ft_clear_before_history(&STR);
if (head->next)
head = head->next;
if (!head->str)
*str = NULL;
STR = NULL;
else
*str = ft_strdup(head->str);
if (*str)
ft_current_str(*str, *pos);
if (*str)
*pos = ft_strlen_next(*str, *pos);
STR = ft_strdup(head->str);
if (STR)
ft_current_str(STR, POS);
if (STR)
POS = ft_strlen_next(STR, POS);
else
*pos = 0;
POS = 0;
data_singleton()->line.list_cur = head;
}
void ft_history_up(void)
{
t_list_history *head;
char **str;
size_t *pos;
str = &STR;
pos = &POS;
head = data_singleton()->line.list_cur;
if (!head)
return ;
ft_clear_before_history(str);
ft_clear_before_history(&STR);
if (head->prev)
head = head->prev;
if (!head->str)
*str = NULL;
STR = NULL;
else
*str = ft_strdup(head->str);
if (*str)
ft_current_str(*str, *pos);
if (*str)
*pos = ft_strlen_next(*str, *pos);
STR = ft_strdup(head->str);
if (STR)
ft_current_str(STR, POS);
if (STR)
POS = ft_strlen_next(STR, POS);
else
*pos = 0;
POS = 0;
data_singleton()->line.list_cur = head;
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
/* Updated: 2017/02/04 15:35:25 by gwojda ### ########.fr */
/* Updated: 2017/02/05 16:58:43 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -72,24 +72,22 @@ static void ft_history_parsing_2(void)
void ft_history_parsing(void)
{
char *str;
int i;
char boolean;
i = 0;
boolean = 0;
str = data_singleton()->line.input;
if (!str)
if (!STR)
return ;
while (str && str[i])
while (STR && STR[i])
{
if (str[i] == '!')
if (STR[i] == '!')
{
boolean = 1;
if (!ft_history_parsing_3(str, &i))
if (!ft_history_parsing_3(STR, &i))
boolean = 0;
}
str = data_singleton()->line.input;
STR = data_singleton()->line.input;
++i;
}
if (boolean)

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:21:40 by gwojda #+# #+# */
/* Updated: 2017/02/04 16:35:33 by gwojda ### ########.fr */
/* Updated: 2017/02/05 17:01:51 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,26 +41,22 @@ static void ft_up_2(size_t *pos, char *str)
void ft_up(void)
{
int i;
char *str;
size_t *pos;
i = 0;
str = data_singleton()->line.input;
pos = &data_singleton()->line.pos;
if (!str || !*pos)
if (!STR || !POS)
return ;
if (str[*pos - 1] == '\n')
if (STR[POS - 1] == '\n')
{
ft_puttermcaps("cd");
if (*pos >= 2)
(*pos) -= 2;
ft_get_beggin(str, pos);
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
++(*pos);
if (POS >= 2)
POS -= 2;
ft_get_beggin(STR, &POS);
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
++POS;
}
else
ft_up_2(pos, str);
ft_up_2(&POS, STR);
}
static void ft_down_2(size_t *pos, char *str)
@ -84,24 +80,20 @@ void ft_down(void)
{
int i;
int len;
char *str;
size_t *pos;
i = 0;
str = data_singleton()->line.input;
pos = &data_singleton()->line.pos;
if (!str)
if (!STR)
return ;
if (str[*pos] == '\n')
ft_down_2(pos, str);
if (STR[POS] == '\n')
ft_down_2(&POS, STR);
else
{
len = ft_size_term();
while (str[i + *pos] && str[i + *pos] != '\n' && --len + 1)
while (STR[i + POS] && STR[i + POS] != '\n' && --len + 1)
{
ft_putchar(str[i + *pos]);
ft_putchar(STR[i + POS]);
++i;
}
*pos += i;
POS += i;
}
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */
/* Updated: 2017/02/02 15:10:50 by gwojda ### ########.fr */
/* Updated: 2017/02/05 17:08:58 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,21 +26,17 @@ int ft_found_next_char(char *str, size_t i)
void ft_print(int ret)
{
int j;
char **str;
size_t *i;
j = 0;
str = &data_singleton()->line.input;
i = &data_singleton()->line.pos;
*str = ft_realloc_imput(*str, ret, *i);
while (*((*str) + *i + j) && *((*str) + *i + j) != '\n')
STR = ft_realloc_imput(STR, ret, POS);
while (*(STR + POS + j) && *(STR + POS + j) != '\n')
{
ft_putchar(*((*str) + *i + j));
ft_putchar(*(STR + POS + j));
++j;
}
ft_check_end_of_line(*str, *i + j);
ft_check_end_of_line(STR, POS + j);
ft_putnc('\b', j - 1);
++(*i);
++POS;
}
void ft_suppr_2(char **str, size_t *i, size_t tmp)
@ -60,53 +56,45 @@ void ft_suppr(void)
{
size_t tmp;
char boolean;
char **str;
size_t *i;
str = &data_singleton()->line.input;
i = &data_singleton()->line.pos;
boolean = 0;
if (*i <= 0)
if (POS <= 0)
return ;
if ((*str)[*i - 1] != '\n')
if (STR[POS - 1] != '\n')
boolean = 1;
--(*i);
tmp = *i;
--POS;
tmp = POS;
if (boolean)
{
ft_get_beggin_with_curs(*str, i);
*str = ft_remove_imput((*str), tmp);
ft_get_beggin_with_curs(STR, &POS);
STR = ft_remove_imput(STR, tmp);
}
else
{
*str = ft_remove_imput((*str), tmp);
ft_get_beggin(*str, i);
STR = ft_remove_imput(STR, tmp);
ft_get_beggin(STR, &POS);
}
ft_suppr_2(str, i, tmp);
ft_suppr_2(&STR, &POS, tmp);
}
void ft_del(void)
{
size_t tmp;
char **str;
size_t *i;
str = &data_singleton()->line.input;
i = &data_singleton()->line.pos;
tmp = *i;
*str = ft_remove_imput((*str), tmp);
if (!((*str) && (*i) < ft_strlen((*str))))
tmp = POS;
STR = ft_remove_imput(STR, tmp);
if (!(STR && POS < ft_strlen(STR + 1)))
return ;
if (*i)
if (POS)
{
--(*i);
ft_get_beggin_with_curs(*str, i);
--POS;
ft_get_beggin_with_curs(STR, &POS);
}
ft_puttermcaps("cd");
ft_current_str(*str, *i);
ft_get_next_str(*str, i);
if ((*str)[*i])
++(*i);
ft_putnc('\b', *i - tmp);
(*i) = tmp;
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
if (STR[POS] && STR[POS] != '\n')
++POS;
ft_putnc('\b', POS - tmp);
POS = tmp;
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 19:07:52 by gwojda #+# #+# */
/* Updated: 2017/02/04 16:27:34 by gwojda ### ########.fr */
/* Updated: 2017/02/05 17:06:07 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,29 +58,25 @@ void ft_change_affichage(void)
void ft_printall(void)
{
size_t pos_tmp;
char *str;
size_t *pos;
int ret;
str = STR;
pos = &POS;
ret = 0;
if (read(0, &ret, sizeof(int)) == -1 || ret != 126 || !str)
if (read(0, &ret, sizeof(int)) == -1 || ret != 126 || !STR)
return ;
ft_clear_window();
ft_prompt();
pos_tmp = *pos;
pos_tmp = POS;
ft_change_affichage();
if (*pos)
--(*pos);
ft_get_beggin(str, pos);
ft_current_str(str, *pos);
ft_get_next_str(str, pos);
if (*pos && !str[*pos])
--(*pos);
if (*pos)
ft_putnc('\b', *pos - pos_tmp + 1);
*pos = pos_tmp;
if (POS)
--POS;
ft_get_beggin(STR, &POS);
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
if (POS && !STR[POS])
--POS;
if (POS)
ft_putnc('\b', POS - pos_tmp + 1);
POS = pos_tmp;
}
void ft_get_beggin_with_curs(char *str, size_t *pos)