fix histo avec ! + completion multiligne + rematch
This commit is contained in:
parent
cffec70bf1
commit
40f852345e
8 changed files with 51 additions and 42 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||||
# Updated: 2017/03/18 14:15:21 by gwojda ### ########.fr #
|
# Updated: 2017/03/18 14:17:54 by gwojda ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_strlen.c :+: :+: :+: */
|
/* ft_strlen.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:58:22 by jhalford #+# #+# */
|
/* Created: 2016/11/03 14:58:22 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/03/07 11:06:41 by ariard ### ########.fr */
|
/* Updated: 2017/03/18 14:25:09 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,34 +6,12 @@
|
||||||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/10/11 10:44:40 by alao #+# #+# */
|
/* Created: 2016/10/11 10:44:40 by alao #+# #+# */
|
||||||
/* Updated: 2017/03/17 17:07:20 by gwojda ### ########.fr */
|
/* Updated: 2017/03/18 15:19:18 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "completion.h"
|
#include "completion.h"
|
||||||
|
|
||||||
/*
|
|
||||||
** Clear the previous list from the screen and restore the same position.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void c_term_clear(t_comp *c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int lcmd;
|
|
||||||
|
|
||||||
ft_putstr(tgetstr("do", NULL));
|
|
||||||
ft_putstr(tgetstr("cd", NULL));
|
|
||||||
ft_putstr(tgetstr("up", NULL));
|
|
||||||
i = 0;
|
|
||||||
lcmd = 0;
|
|
||||||
c->rcmd ? lcmd += c->ircmd + c->prompt + 1 : 0;
|
|
||||||
while (i < lcmd)
|
|
||||||
{
|
|
||||||
ft_putstr(tgetstr("nd", NULL));
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t c_virtual_position(t_comp *c)
|
static size_t c_virtual_position(t_comp *c)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
|
@ -50,6 +28,28 @@ static size_t c_virtual_position(t_comp *c)
|
||||||
return (virtual_pos - pos);
|
return (virtual_pos - pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Clear the previous list from the screen and restore the same position.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void c_term_clear(t_comp *c)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int lcmd;
|
||||||
|
|
||||||
|
ft_putstr(tgetstr("do", NULL));
|
||||||
|
ft_putstr(tgetstr("cd", NULL));
|
||||||
|
ft_putstr(tgetstr("up", NULL));
|
||||||
|
i = 0;
|
||||||
|
lcmd = 0;
|
||||||
|
c->rcmd ? lcmd += c_virtual_position(c) + c->prompt + 1 : 0;
|
||||||
|
while (i < lcmd)
|
||||||
|
{
|
||||||
|
ft_putstr(tgetstr("nd", NULL));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Move the terminal up by the number of line needed and move it back up to
|
** Move the terminal up by the number of line needed and move it back up to
|
||||||
** the original position.
|
** the original position.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
|
/* Created: 2017/01/25 11:39:47 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 12:10:17 by gwojda ### ########.fr */
|
/* Updated: 2017/03/18 15:04:16 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -60,6 +60,20 @@ static int ft_history_parsing_3(char *str, int *i)
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ft_history_parsing_2(int has_prompt, char **input)
|
||||||
|
{
|
||||||
|
data_singleton()->line.pos = 0;
|
||||||
|
has_prompt ? ft_prompt() : ft_putstr("> ");
|
||||||
|
if (ft_read_stdin(input) < 0)
|
||||||
|
return (-1);
|
||||||
|
if (data_singleton()->line.input)
|
||||||
|
ft_current_str(data_singleton()->line.input,
|
||||||
|
data_singleton()->line.pos);
|
||||||
|
ft_putchar('\n');
|
||||||
|
ft_history_parsing(has_prompt, input);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int ft_history_parsing(int has_prompt, char **input)
|
int ft_history_parsing(int has_prompt, char **input)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -81,7 +95,7 @@ int ft_history_parsing(int has_prompt, char **input)
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
if (boolean)
|
if (boolean && ft_history_parsing_2(has_prompt, input))
|
||||||
return (readline(has_prompt, input));
|
return (-1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
|
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 16:06:09 by gwojda ### ########.fr */
|
/* Updated: 2017/03/18 14:29:15 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -79,19 +79,17 @@ int ft_surch_in_history(char **str, size_t *pos)
|
||||||
ft_give_new_prompt(str_srch, srch_pos);
|
ft_give_new_prompt(str_srch, srch_pos);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
read(0, &ret, sizeof(int));
|
read(0, &ret, sizeof(int));
|
||||||
if (ft_isprint(ret))
|
if (ft_isprint(ret) &&
|
||||||
{
|
ft_surch_and_realloc(str, &str_srch, ret, &srch_pos) < 0)
|
||||||
if (ft_surch_and_realloc(str, &str_srch, ret, &srch_pos) < 0)
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
else if (!ft_isprint(ret) && ret == 127 && srch_pos)
|
||||||
else if (ret == 127 && srch_pos)
|
|
||||||
{
|
{
|
||||||
--srch_pos;
|
--srch_pos;
|
||||||
str_srch = ft_remove_imput(str_srch, srch_pos);
|
str_srch = ft_remove_imput(str_srch, srch_pos);
|
||||||
ft_puttermcaps("le");
|
ft_puttermcaps("le");
|
||||||
*str = (!*str_srch) ? NULL : ft_strget_history(str_srch);
|
*str = (!*str_srch) ? NULL : ft_strget_history(str_srch);
|
||||||
}
|
}
|
||||||
else if (ret != 127)
|
else if (ret != 127 && !ft_isprint(ret))
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
ft_modify_str(str_srch, srch_pos, str, pos);
|
ft_modify_str(str_srch, srch_pos, str, pos);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */
|
/* Created: 2017/02/02 15:17:28 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/17 12:32:16 by gwojda ### ########.fr */
|
/* Updated: 2017/03/18 15:13:46 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
|
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/18 00:14:42 by wescande ### ########.fr */
|
/* Updated: 2017/03/18 14:23:53 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -92,8 +92,6 @@ static int ft_currend_dir(void)
|
||||||
return (ft_strlen(currend_dir + 1));
|
return (ft_strlen(currend_dir + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Une fois nouveau prompt avec git fait -> protection des pointeurs/malloc a faire ici !
|
|
||||||
|
|
||||||
void ft_prompt(void)
|
void ft_prompt(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
|
||||||
/* Updated: 2017/03/18 10:57:19 by gwojda ### ########.fr */
|
/* Updated: 2017/03/18 14:55:08 by gwojda ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,7 +22,6 @@ int readline(int has_prompt, char **input)
|
||||||
return ((ret = get_next_line(data_singleton()->fd, input)) >= 0 ? !ret : ret);
|
return ((ret = get_next_line(data_singleton()->fd, input)) >= 0 ? !ret : ret);
|
||||||
readline_init(has_prompt);
|
readline_init(has_prompt);
|
||||||
ret = ft_read_stdin(input);
|
ret = ft_read_stdin(input);
|
||||||
DG("input = %s", *input);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return (ret);
|
return (ret);
|
||||||
if (data_singleton()->line.input)
|
if (data_singleton()->line.input)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue