add some work

This commit is contained in:
Gautier WOJDA 2017-01-20 18:17:57 +01:00
parent 608567d8a2
commit a11d97c432
9 changed files with 63 additions and 31 deletions

View file

@ -6,7 +6,7 @@
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/08 18:02:25 by sbenning #+# #+# */
/* Updated: 2017/01/19 16:47:18 by gwojda ### ########.fr */
/* Updated: 2017/01/20 17:35:02 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -58,6 +58,7 @@ typedef struct s_list_history
struct s_list_history *next;
} t_list_history;
int ft_is_next_char(char *str, char c);
long long ft_pow(int nbr, int power);
char *ft_strndup(char const *s, int n);
char *ft_strdupi(char const *s);

Binary file not shown.

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/05 16:02:43 by gwojda #+# #+# */
/* Updated: 2017/01/19 18:08:54 by gwojda ### ########.fr */
/* Updated: 2017/01/20 17:49:25 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,8 +25,8 @@ void ft_print(char **str, int ret, size_t *i)
}
ft_putnc('\b', j - 1);
++(*i);
}
*/
}*/
void ft_print(char **str, int ret, size_t *i)
{
size_t len;
@ -39,34 +39,48 @@ void ft_print(char **str, int ret, size_t *i)
boolean2 = 0;
*str = ft_realloc_imput(*str, ret, *i);
tmp_len = ft_strlen(*str);
sleep(1);
ft_puttermcaps("cd");
write(1, *str + *i, 1);
if ((ft_nb_last_line(*str, *i + 1)
+ (len % ft_size_term()) == ft_size_term() - 1) && (*str)[*i + 1] == '\n')
sleep(1);
if (ft_is_next_char(*str, '\n') &&
ft_nb_last_line(*str, *i + 1) + (len % ft_size_term()) == ft_size_term() - 2)
{
ft_putchar(' ');
sleep(1);
write(1, *str + *i, 1);
sleep(1);
ft_putnc(' ', ft_size_term());
sleep(1);
write(1, *str + *i + 1, ft_strlen(*str + *i + 1));
sleep(1);
ft_puttermcaps("up");
boolean2 = 1;
}
if ((*str)[*i + 1] == '\n' && (*str)[*i + 2] && ft_strlen(*str) > *i + 2)
write(1, *str + *i + 1, ft_strlen(*str + *i + 2));
else
write(1, *str + *i + 1, ft_strlen(*str + *i + 1));
write(1, *str + *i, ft_strlen(*str + *i));
sleep(1);
++(*i);
while ((*str)[*i + len] && (*str)[*i + len] != '\n')
++len;
if ((*i && !(ft_nb_last_line(*str, *i)
+ (len % ft_size_term()))) || ft_nb_last_line(*str, *i)
+ (len % ft_size_term()) == ft_size_term() - 1)
{
--(tmp_len);
ft_move_to_beggin(*str, &tmp_len);
boolean = 1;
}
else
sleep(1);
if (len)
--len;
// if (ft_nb_last_line(*str, *i) + (len % ft_size_term()) == ft_size_term() - 1)
// {
// --(tmp_len);
// ft_move_to_beggin(*str, &tmp_len);
// boolean = 1;
// }
// else
ft_move_to_beggin(*str, &tmp_len);
// ft_printf("\n\n\n%d\n\n\n\n", ft_nb_last_line(*str, *i) + (len % ft_size_term()) );
sleep(1);
if (boolean2)
ft_puttermcaps("up");
write(1, *str, *i);
if (boolean2)
ft_puttermcaps("do");
sleep(1);
if (boolean)
ft_putstr(" \b");
}

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:51:33 by gwojda #+# #+# */
/* Updated: 2017/01/19 16:48:32 by gwojda ### ########.fr */
/* Updated: 2017/01/20 11:30:17 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/19 16:52:57 by gwojda #+# #+# */
/* Updated: 2017/01/19 16:43:13 by gwojda ### ########.fr */
/* Updated: 2017/01/20 18:15:12 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -48,7 +48,7 @@ void ft_read_it(int input, size_t *pos, char **str)
++i;
while (i < 4)
{
if (t[i])
if (t[i] && ft_isprint(t[i]))
{
*str = ft_realloc_imput(*str, t[i], *pos);
++(*pos);

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */
/* Updated: 2017/01/19 16:43:16 by gwojda ### ########.fr */
/* Updated: 2017/01/20 12:07:02 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -50,14 +50,14 @@ int ft_readline(void)
static t_list_history *head = NULL;
ft_prompt();
if (tcsetattr(0, TCSADRAIN, ft_stats_term_termcaps()) == -1)
if (tcsetattr(0, TCSANOW, ft_stats_term_termcaps()) == -1)
return (-1);
data_singleton()->line.input = ft_lecture(head);
ft_putstr("\n");
ft_check_quotes(&data_singleton()->line.input, head);
if (data_singleton()->line.input)
ft_push_back_history(&head, ft_create_history_list(data_singleton()->line.input));
if (tcsetattr(0, TCSADRAIN, ft_save_stats_term()) == -1)
if (tcsetattr(0, TCSANOW, ft_save_stats_term()) == -1)
return (-1);
return (0);
}

View file

@ -6,12 +6,26 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/16 17:06:30 by gwojda #+# #+# */
/* Updated: 2017/01/19 16:43:28 by gwojda ### ########.fr */
/* Updated: 2017/01/20 17:34:57 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
int ft_is_next_char(char *str, char c)
{
int i;
i = 0;
while (str[i])
{
if (str[i] == c)
return (1);
++i;
}
return (0);
}
void ft_putnc(char c, int n)
{
int i;

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/07 11:00:28 by gwojda #+# #+# */
/* Updated: 2017/01/19 16:43:32 by gwojda ### ########.fr */
/* Updated: 2017/01/20 12:36:28 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 12:35:11 by gwojda #+# #+# */
/* Updated: 2017/01/19 16:43:23 by gwojda ### ########.fr */
/* Updated: 2017/01/20 18:03:59 by gwojda ### ########.fr */
/* */
/* ************************************************************************** */
@ -48,6 +48,8 @@ int ft_nb_last_line(char *str, size_t pos)
int len;
len = 0;
if (str[pos] == '\n')
--pos;
if (!ft_get_ind_prev(str, pos))
len += data_singleton()->line.prompt_size;
len += ft_get_size_prev(str, pos);
@ -79,6 +81,7 @@ void ft_move_to_beggin(char *str, size_t *pos)
{
if (str[*pos] == '\n')
{
ft_printf("\n\n\nft_nb_line(str, *pos - 1) = %d\n\n\n", ft_nb_line(str, *pos - 1));
str_len = ft_nb_line(str, *pos - 1) + 1;
while (str_len)
{