change ret line editing

This commit is contained in:
gwojda 2017-03-17 10:52:01 +01:00
parent 037f968183
commit 934991beb4
15 changed files with 61 additions and 61 deletions

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 15:22:19 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:00:08 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:48:21 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -33,7 +33,7 @@ int ft_history_down(void)
head = data_singleton()->line.list_cur;
if (!head)
return (1);
return (0);
ft_clear_before_history(&STR);
if (head->next)
head = head->next;
@ -49,7 +49,7 @@ int ft_history_down(void)
else
POS = 0;
data_singleton()->line.list_cur = head;
return (1);
return (0);
}
int ft_history_up(void)
@ -58,7 +58,7 @@ int ft_history_up(void)
head = data_singleton()->line.list_cur;
if (!head)
return (1);
return (0);
ft_clear_before_history(&STR);
if (head->prev)
head = head->prev;
@ -74,5 +74,5 @@ int ft_history_up(void)
else
POS = 0;
data_singleton()->line.list_cur = head;
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:09:02 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:48:34 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -68,7 +68,7 @@ int ft_history_parsing(int has_prompt, char **input)
i = 0;
boolean = 0;
if (!STR)
return (1);
return (0);
while (STR && STR[i])
{
if (STR[i] == '!')
@ -83,5 +83,5 @@ int ft_history_parsing(int has_prompt, char **input)
}
if (boolean)
return (readline(has_prompt, input));
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:12:05 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:48:06 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -92,5 +92,5 @@ int ft_surch_in_history(void)
break ;
}
ft_modify_str(str_srch, srch_pos);
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/03 14:15:55 by gwojda #+# #+# */
/* Updated: 2017/03/16 10:33:10 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:45:06 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -53,5 +53,5 @@ int ft_completion(int ret)
ft_putnc('\b', right);
POS = ft_strleni_w(STR, pos_tmp, '\n') - right;
}
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */
/* Updated: 2017/03/16 16:45:43 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:45:20 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -19,7 +19,7 @@ int ft_buff_f6(void)
ret = 0;
if (read(0, &ret, sizeof(int)) < 0)
return (-1);
return (1);
return (0);
}
int ft_control_d(void)
@ -34,7 +34,7 @@ int ft_control_d(void)
ft_del();
else
ft_puttermcaps("bl");
return (1);
return (0);
}
int ft_control_c(void)
@ -55,5 +55,5 @@ int ft_control_l(void)
ft_prompt();
ft_strdel(&STR);
POS = 0;
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 12:45:06 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:12:40 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:45:37 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -47,7 +47,7 @@ int ft_v(void)
i = -1;
tmp_pos = POS;
if (!STR || !tmp)
return (1);
return (0);
while (tmp[++i])
if (!(STR = ft_realloc_imput(STR, tmp[i], POS + i)))
return (-1);
@ -60,7 +60,7 @@ int ft_v(void)
ft_get_next_str(STR, &POS);
ft_putnc('\b', POS - tmp_pos);
POS = tmp_pos;
return (1);
return (0);
}
int ft_x(void)
@ -70,7 +70,7 @@ int ft_x(void)
tmp = &data_singleton()->line.copy_tmp;
if (!STR)
return (1);
return (0);
if (*tmp)
ft_strdel(tmp);
if (!(*tmp = ft_strdupi_space(&STR[POS])))
@ -83,7 +83,7 @@ int ft_x(void)
--i;
}
ft_puttermcaps("cd");
return (1);
return (0);
}
int ft_c(void)
@ -97,5 +97,5 @@ int ft_c(void)
ft_strdel(tmp);
if (!(*tmp = ft_strdupi_space(STR + POS)))
return (-1);
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:28:49 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:13:48 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:49:59 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -69,7 +69,7 @@ int ft_read_stdin(char **input)
++j;
if (g_key[j].value)
{
if ((ret = g_key[j].f()) != 1)
if ((ret = g_key[j].f()))
return (ret);
}
else if (ft_isprint(ret))
@ -77,7 +77,7 @@ int ft_read_stdin(char **input)
else if (ret == 10)
{
*input = STR;
return (1);
return (0);
}
else if (ft_isascii(ret) == 0)
ft_read_it(ret, &POS, &STR);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/14 11:13:24 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:14:07 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:46:05 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -15,7 +15,7 @@
int ft_end(void)
{
if (!STR)
return (1);
return (0);
if (POS)
{
--POS;
@ -27,13 +27,13 @@ int ft_end(void)
ft_get_beggin(STR, &POS);
ft_current_str(STR, POS);
ft_get_next_str(STR, &POS);
return (1);
return (0);
}
int ft_home(void)
{
if (!STR)
return (1);
return (0);
if (POS)
{
--POS;
@ -49,5 +49,5 @@ int ft_home(void)
if (!STR[POS])
--POS;
ft_get_beggin_with_curs(STR, &POS);
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:43:58 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:15:21 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:46:27 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -17,7 +17,7 @@ int ft_move_right(void)
size_t tmp;
if (ft_strlen(STR) <= POS)
return (1);
return (0);
if (STR[POS] == '\n')
{
if (POS)
@ -37,20 +37,20 @@ int ft_move_right(void)
ft_putchar(STR[POS]);
++POS;
}
return (1);
return (0);
}
int ft_move_left(void)
{
if (!POS)
return (1);
return (0);
if (STR[POS - 1] == '\n')
{
if (POS - 1 == 0)
{
ft_puttermcaps("cd");
--POS;
return (1);
return (0);
}
ft_puttermcaps("cd");
POS -= 2;
@ -66,5 +66,5 @@ int ft_move_left(void)
ft_puttermcaps("le");
--POS;
}
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/14 11:12:09 by gwojda #+# #+# */
/* Updated: 2017/03/16 16:48:48 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:46:44 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -61,7 +61,7 @@ int ft_found_prev_word(void)
i = 0;
if (!POS || !STR)
return (1);
return (0);
ft_init_prev_word(&POS, STR);
if (POS >= 1 && STR[POS - 1] == '\n')
{
@ -69,7 +69,7 @@ int ft_found_prev_word(void)
{
ft_puttermcaps("cd");
--POS;
return (1);
return (0);
}
ft_puttermcaps("cd");
POS -= 2;
@ -82,7 +82,7 @@ int ft_found_prev_word(void)
}
else
ft_found_prev_word_2(i, STR, &POS);
return (1);
return (0);
}
static void ft_found_next_word_2(void)
@ -108,7 +108,7 @@ int ft_found_next_word(void)
i = 0;
if (!STR)
return (1);
return (0);
while (STR[i + POS] && STR[i + POS] == ' ')
{
ft_putchar(STR[i + POS]);
@ -125,5 +125,5 @@ int ft_found_next_word(void)
}
POS += i;
}
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:21:40 by gwojda #+# #+# */
/* Updated: 2017/03/16 16:49:34 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:46:55 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -41,7 +41,7 @@ static void ft_up_2(size_t *pos, char *str)
int ft_up(void)
{
if (!STR || !POS)
return (1);
return (0);
if (STR[POS - 1] == '\n')
{
ft_puttermcaps("cd");
@ -54,7 +54,7 @@ int ft_up(void)
}
else
ft_up_2(&POS, STR);
return (1);
return (0);
}
static void ft_down_2(size_t *pos, char *str)
@ -81,7 +81,7 @@ int ft_down(void)
i = 0;
if (!STR)
return (1);
return (0);
if (STR[POS] == '\n')
ft_down_2(&POS, STR);
else
@ -94,5 +94,5 @@ int ft_down(void)
}
POS += i;
}
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:15:41 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:47:11 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -38,7 +38,7 @@ int ft_print(int ret)
ft_check_end_of_line(STR, POS + j);
ft_putnc('\b', j - 1);
++POS;
return (1);
return (0);
}
static void ft_suppr_2(char **str, size_t *i, size_t tmp)
@ -61,7 +61,7 @@ int ft_suppr(void)
boolean = 0;
if (POS <= 0)
return (1);
return (0);
if (STR[POS - 1] != '\n')
boolean = 1;
--POS;
@ -79,7 +79,7 @@ int ft_suppr(void)
ft_get_beggin(STR, &POS);
}
ft_suppr_2(&STR, &POS, tmp);
return (1);
return (0);
}
int ft_del(void)
@ -90,7 +90,7 @@ int ft_del(void)
if (!(STR = ft_remove_imput(STR, tmp)))
return (-1);
if (!(STR && POS < ft_strlen(STR) + 1))
return (1);
return (0);
if (POS)
{
--POS;
@ -103,5 +103,5 @@ int ft_del(void)
++POS;
ft_putnc('\b', POS - tmp);
POS = tmp;
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:52:57 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:15:56 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:47:31 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -30,7 +30,7 @@ static int ft_read_it_3(char **str, char t[5], size_t *pos, int *j)
}
++i;
}
return (1);
return (0);
}
static void ft_read_it_2(int input, char t[5])
@ -62,16 +62,16 @@ int ft_read_it(int input, size_t *pos, char **str)
input == 126 || input == 993090331 || input == 925981467 ||
input == 21298 || input == 892427035 || input == 8270395 || input ==
942758683 || input == 993090331 || input == 18489 || input == 17977)
return (1);
return (0);
ft_read_it_2(input, t);
if (ft_read_it_3(str, t, pos, &j) < 0)
return (-1);
if (!*str)
return (1);
return (0);
*pos = pos_tmp;
ft_current_str((*str), *pos);
ft_get_next_str((*str), pos);
ft_putnc('\b', *pos - (pos_tmp + j));
*pos = (pos_tmp + j);
return (1);
return (0);
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/03/16 17:08:28 by gwojda ### ########.fr */
/* Updated: 2017/03/17 10:51:27 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -20,7 +20,7 @@ int readline(int has_prompt, char **input)
return ((ret = get_next_line(STDIN, input)) >= 0 ? !ret : ret);
readline_init(has_prompt);
ret = ft_read_stdin(input);
if (ret <= 0)
if (ret < 0)
return (ret);
if (STR)
ft_current_str(STR, POS);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
/* Updated: 2017/03/16 15:45:57 by jhalford ### ########.fr */
/* Updated: 2017/03/17 10:51:23 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */