diff options
author | salad <fmoenne-@student.le-101.fr> | 2020-09-02 14:27:14 +0200 |
---|---|---|
committer | salad <fmoenne-@student.le-101.fr> | 2020-09-02 14:27:14 +0200 |
commit | e5c9f1aaff9f53ee24514807be7aa9076c76d6ca (patch) | |
tree | 5aa16b481f20985874fc28facbf7244925ff574f | |
parent | HOLY SHIT MAN (diff) | |
download | 42-minishell-e5c9f1aaff9f53ee24514807be7aa9076c76d6ca.tar.gz 42-minishell-e5c9f1aaff9f53ee24514807be7aa9076c76d6ca.tar.bz2 42-minishell-e5c9f1aaff9f53ee24514807be7aa9076c76d6ca.tar.xz 42-minishell-e5c9f1aaff9f53ee24514807be7aa9076c76d6ca.tar.zst 42-minishell-e5c9f1aaff9f53ee24514807be7aa9076c76d6ca.zip |
cursor soon(TM)
-rw-r--r-- | src/c_init.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/c_init.c b/src/c_init.c index 2c0b7c3..401d0e2 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -20,6 +20,31 @@ #include "c_init.h" +static char + *ft_strjoin_m(char *s1, + char *s2) +{ + size_t i; + size_t j; + char *dst; + size_t size1; + size_t size2; + + i = -1; + j = -1; + size1 = ft_strlen(s1); + size2 = ft_strlen(s2); + if (!(dst = (char*)malloc((size1 + size2 + 1) * sizeof(char)))) + return (NULL); + while (++i < size1) + dst[i] = s1[i]; + while (++j < size2) + dst[i + j] = s2[j]; + dst[i + j] = '\0'; + ft_memdel((void*)&s1); + return (dst); +} + t_caps *c_get_struct(int mode, t_caps *src) { @@ -55,27 +80,35 @@ int16_t return (1); } -int16_t c_process_key(char *buf) +int16_t + c_process_key(char *buf) { int i; + static char *line; - /* tputs(tgetstr("cl", NULL), 1, ft_putchar); */ - i = 0; - + i = -1; + if (line == NULL) + if (!(line = ft_calloc(2, sizeof(char)))) + return (0); if (ft_isprint(buf[0])) { if (*buf == 'q') exit(0); - write(1, buf, 1); + line = ft_strjoin_m(line, buf); + ft_printf("line [%s][%lu]\n", line, ft_strlen(line)); } else { - ft_printf("escaped char inc,[%c] [%c] [%c]\n", buf[0], buf[1], buf[2]); if(strncmp(buf, tgetstr("kr", NULL), ft_strlen(tgetstr("kr", NULL))) == 0) { tputs(tgetstr("nd", NULL), 1, ft_putchar); return (1); } + else if(strncmp(buf, tgetstr("kl", NULL), ft_strlen(tgetstr("kl", NULL))) == 0) + { + tputs(tgetstr("le", NULL), 1, ft_putchar); + return (1); + } } return (0); } |