correction bug sur control R + d'autres ptits trucs
This commit is contained in:
parent
3ba3813c51
commit
01d8cbca7e
7 changed files with 31 additions and 20 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/08 23:48:33 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 11:55:17 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -84,6 +84,7 @@ typedef struct s_line
|
|||
int prompt_size;
|
||||
int list_size;
|
||||
char opt;
|
||||
char is_prompt;
|
||||
t_list_history *list_end;
|
||||
t_list_history *list_cur;
|
||||
t_list_history *list_beg;
|
||||
|
|
@ -127,6 +128,7 @@ int ft_nb_last_line(char *str, size_t pos);
|
|||
int ft_put(int nb);
|
||||
void ft_check_line(void);
|
||||
void ft_clear_window(void);
|
||||
void free_history_list(t_list_history *head);
|
||||
|
||||
char *ft_read_stdin(void);
|
||||
void ft_end(void);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
|
||||
/* Updated: 2017/03/08 23:25:01 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 11:17:21 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -35,6 +35,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
|
|||
status = ft_atoi(ft_getenv(data_singleton()->env, "?"));
|
||||
ft_save_termios(-1);
|
||||
ft_free_hash_table();
|
||||
free_history_list(data_singleton()->line.list_beg);
|
||||
data_exit();
|
||||
if (SH_IS_INTERACTIVE(data_singleton()->opts))
|
||||
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
|
||||
|
|
|
|||
|
|
@ -6,12 +6,26 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/17 11:37:47 by gwojda #+# #+# */
|
||||
/* Updated: 2017/02/02 16:08:01 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/09 11:21:06 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void free_history_list(t_list_history *head)
|
||||
{
|
||||
t_list_history *prev;
|
||||
|
||||
free(head->prev);
|
||||
while (head)
|
||||
{
|
||||
ft_strdel(&head->str);
|
||||
prev = head;
|
||||
head = head->next;
|
||||
free(prev);
|
||||
}
|
||||
}
|
||||
|
||||
t_list_history *ft_create_history_list(char *str)
|
||||
{
|
||||
t_list_history *list;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */
|
||||
/* Updated: 2017/02/04 15:50:26 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/09 12:15:09 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ static void ft_give_new_prompt(char *str_srch, size_t srch_pos)
|
|||
static void ft_modify_str(char *str_srch, size_t srch_pos)
|
||||
{
|
||||
ft_clear_prompt(STR, &POS, srch_pos);
|
||||
ft_prompt();
|
||||
data_singleton()->line.is_prompt ? ft_prompt() : ft_putstr("> ");
|
||||
if (STR)
|
||||
{
|
||||
STR = ft_strdup(STR);
|
||||
|
|
@ -84,6 +84,10 @@ void ft_surch_in_history(void)
|
|||
--srch_pos;
|
||||
str_srch = ft_remove_imput(str_srch, srch_pos);
|
||||
ft_puttermcaps("le");
|
||||
if (!*str_srch)
|
||||
STR = NULL;
|
||||
else
|
||||
STR = ft_strget_history(str_srch);
|
||||
}
|
||||
else if (ret != 127)
|
||||
break ;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/03/07 17:34:44 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/08 23:52:45 by ariard ### ########.fr */
|
||||
/* Updated: 2017/03/09 11:55:21 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -41,4 +41,5 @@ void readline_init(int prompt)
|
|||
data_singleton()->line.list_cur = data_singleton()->line.list_beg;
|
||||
POS = 0;
|
||||
prompt ? ft_putstr("> ") : ft_prompt();
|
||||
data_singleton()->line.is_prompt = prompt ? 0 : 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/20 19:07:52 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/07 17:32:58 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/09 11:09:59 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,16 +14,7 @@
|
|||
|
||||
void ft_clear_window(void)
|
||||
{
|
||||
pid_t soon_pid;
|
||||
char *tab_str[2];
|
||||
|
||||
tab_str[0] = "/usr/bin/clear";
|
||||
tab_str[1] = NULL;
|
||||
soon_pid = fork();
|
||||
if (soon_pid != 0)
|
||||
wait(NULL);
|
||||
else
|
||||
execve("/usr/bin/clear", tab_str, data_singleton()->env);
|
||||
ft_puttermcaps("cl");
|
||||
}
|
||||
|
||||
static void ft_read_tmp(void)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/12/16 16:14:46 by gwojda #+# #+# */
|
||||
/* Updated: 2017/03/05 15:31:42 by wescande ### ########.fr */
|
||||
/* Updated: 2017/03/09 12:07:09 by gwojda ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -14,12 +14,10 @@
|
|||
|
||||
char *ft_realloc_imput(char *str, int a, size_t pos)
|
||||
{
|
||||
// int i;
|
||||
char tmp[2];
|
||||
char *str_tmp;
|
||||
char *new_str;
|
||||
|
||||
// i = 0;
|
||||
tmp[0] = (char)a;
|
||||
tmp[1] = '\0';
|
||||
if (!str)
|
||||
|
|
|
|||
Loading…
Reference in a new issue