summaryrefslogtreecommitdiffstats
path: root/src/c_init.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-09-11 16:01:55 +0200
committersalad <fmoenne-@student.le-101.fr>2020-09-11 16:01:55 +0200
commit5c8ded7ac978cde22cba31d1d03086f9a60a101b (patch)
tree0f75f3f47c2c43fed7b1fd24b1d78a435310ec85 /src/c_init.c
parenthome works, not END. lets go for a bit of norming (diff)
download42-minishell-5c8ded7ac978cde22cba31d1d03086f9a60a101b.tar.gz
42-minishell-5c8ded7ac978cde22cba31d1d03086f9a60a101b.tar.bz2
42-minishell-5c8ded7ac978cde22cba31d1d03086f9a60a101b.tar.xz
42-minishell-5c8ded7ac978cde22cba31d1d03086f9a60a101b.tar.zst
42-minishell-5c8ded7ac978cde22cba31d1d03086f9a60a101b.zip
grep TODO c_utils.c
Diffstat (limited to 'src/c_init.c')
-rw-r--r--src/c_init.c38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 3829a78..ee6782d 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -24,31 +24,6 @@
#include "s_struct.h"
#include "m_prompt.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);
-}
-
static t_caps
*c_get_struct(int mode,
t_caps *src)
@@ -86,8 +61,6 @@ int16_t
return (1);
}
-/* c_insert_char */
-
int16_t
c_process_key(char *buf,
t_caps *tcaps,
@@ -103,7 +76,7 @@ int16_t
if (ft_isprint(buf[0]))
{
if (tcaps->cpos == ft_strlen(line))
- line = ft_strjoin_m(line, buf);
+ line = ft_strjoin(line, buf);
else
line = c_insert_char(line, buf[0], tcaps);
c_redraw_line(line, tcaps->cpos, msh);
@@ -123,6 +96,10 @@ int16_t
{
return (c_ctrl_l(line, tcaps, msh));
}
+ else if (strncmp(buf, tcaps->CC, 4) == 0)
+ {
+ return (c_new_line(buf, NULL, msh, tcaps));
+ }
else if (strncmp(buf, tcaps->HM, 4) == 0)
{
return (c_home_key(tcaps));
@@ -147,14 +124,12 @@ int16_t
c_init_tcaps(t_msh *msh)
{
t_caps tcaps;
- char *bp;
char *term;
char nread[5];
int ret;
- bp = NULL;
term = getenv("TERM");
- if (!tgetent(bp, term))
+ if (!tgetent(NULL, term))
return (-1);
tcaps.cpos = 0;
c_set_term_raw(1);
@@ -168,7 +143,6 @@ int16_t
ft_bzero(nread, 5);
if (!(read(STDIN_FILENO, nread, 4)))
return (0);
- tputs(tgetstr("vi", NULL), 1, ft_putchar);
ret = c_process_key(nread, &tcaps, msh);
tputs(tgetstr("ve", NULL), 1, ft_putchar);
}