From a223de42f7a9a81972d9cd14a46f34e4c5ab617e Mon Sep 17 00:00:00 2001
From: salad <fmoenne-@student.le-101.fr>
Date: Thu, 17 Sep 2020 17:27:13 +0200
Subject: norm, new file, ctrl + c

---
 src/c_init.c | 34 +++++++++-------------------------
 1 file changed, 9 insertions(+), 25 deletions(-)

(limited to 'src/c_init.c')

diff --git a/src/c_init.c b/src/c_init.c
index ac0c579..8870b27 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -11,15 +11,13 @@
 /* ************************************************************************** */
 
 #include <unistd.h>
-#include <termios.h>
 #include <stdlib.h>
-#include <string.h>
 #include <term.h>
-#include <signal.h>
 #include <libft.h>
 
 #include "c_init.h"
 #include "c_input.h"
+#include "c_keys.h"
 #include "c_utils.h"
 #include "s_struct.h"
 #include "m_prompt.h"
@@ -83,34 +81,20 @@ int16_t
 	}
 	else
 	{
-		if (strncmp(buf, tcaps->KL, 4) == 0)
-		{
+		if (ft_strncmp(buf, tcaps->KL, 4) == 0)
 			return (c_key_left(ft_strlen(line), tcaps));
-		}
-		else if (strncmp(buf, tcaps->KR, 4) == 0)
-		{
+		else if (ft_strncmp(buf, tcaps->KR, 4) == 0)
 			return (c_key_right(ft_strlen(line), tcaps));
-		}
-		else if (strncmp(buf, tcaps->HM, 4) == 0)
-		{
+		else if (ft_strncmp(buf, tcaps->HM, 4) == 0)
 			return (c_home_key(tcaps));
-		}
-		else if (strncmp(buf, tcaps->ND, 4) == 0)
-		{
+		else if (ft_strncmp(buf, tcaps->ND, 4) == 0)
 			return (c_end_key(ft_strlen(line), tcaps));
-		}
-		else if (strncmp(buf, tcaps->CC, 4) == 0)
-		{
-			return (c_new_line(NULL, msh, tcaps));
-		}
-		else if (strncmp(buf, tcaps->CL, 4) == 0)
-		{
+		else if (ft_strncmp(buf, tcaps->CC, 4) == 0)
+			return (c_ctrl_c(NULL, tcaps, msh));
+		else if (ft_strncmp(buf, tcaps->CL, 4) == 0)
 			return (c_ctrl_l(line, tcaps, msh));
-		}
-		else if (strncmp(buf, tgetstr("kb", NULL), ft_strlen(tgetstr("kb", NULL))) == 0)
-		{
+		else if (ft_strncmp(buf, tgetstr("kb", NULL), ft_strlen(tgetstr("kb", NULL))) == 0)
 			return (c_back_slash(&line, tcaps));
-		}
 		else if (buf[0] == '\n')
 		{
 			c_new_line(ft_strdup(line), msh, tcaps);
-- 
cgit v1.2.3