From e93ce58b0dec4d6ab4ac03e137d2e37c161eeb9c Mon Sep 17 00:00:00 2001
From: salad <fmoenne-@student.le-101.fr>
Date: Wed, 7 Oct 2020 14:59:18 +0200
Subject: qsd

---
 src/c_init.c  |  3 +++
 src/c_input.c | 18 +++---------------
 src/c_utils.c |  1 -
 3 files changed, 6 insertions(+), 16 deletions(-)

(limited to 'src')

diff --git a/src/c_init.c b/src/c_init.c
index 745fad9..9196d51 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -102,7 +102,10 @@ static char
 		tcaps->cpos++;
 	}
 	else if ((*((unsigned int *)buf)) == DEL_K)
+	{
 		c_back_slash(&line, ft_strlen(msh->ps[tcaps->psx]), tcaps);
+		c_redraw_line(line, tcaps, msh);
+	}
 	else
 		c_read_cap(buf, line, tcaps, msh);
 	if (buf[0] == '\n')
diff --git a/src/c_input.c b/src/c_input.c
index 7eb8084..1c14342 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -16,6 +16,7 @@
 #include <signal.h>
 
 #include "c_init.h"
+#include "c_keys.h"
 #include "c_input.h"
 #include "c_utils.h"
 #include "m_prompt.h"
@@ -79,24 +80,11 @@ int16_t
 				 uint32_t plen,
 				 t_caps *tcaps)
 {
-	int32_t pos;
-
-	pos = -1;
 	if (tcaps->cpos >= 1)
 	{
-		if (((tcaps->cpos + plen) % (tcaps->ws.ws_col)) == 0)
-		{
-			tputs(tgetstr("up", NULL), 1, ft_putchar);
-			while(++pos <= (tcaps->ws.ws_col))
-				tputs(tgetstr("nd", NULL), 1, ft_putchar);
-		}
-		else
-		{
-			tputs(tgetstr("le", NULL), 1, ft_putchar);
-		}
-		tputs(tgetstr("dc", NULL), 1, ft_putchar);
 		*line = c_delchar(*line, tcaps->cpos);
-		tcaps->cpos--;
+		c_key_left(plen, tcaps);
+		tputs(tgetstr("cd", NULL), 1, ft_putchar);
 	}
 	return (1);
 }
diff --git a/src/c_utils.c b/src/c_utils.c
index 23d5007..b18b949 100644
--- a/src/c_utils.c
+++ b/src/c_utils.c
@@ -112,7 +112,6 @@ static int16_t
 	uint32_t	i;
 	uint32_t	j;
 
-	/* ft_printf("%u%u", tcaps->nlines, tcaps->lpos); */
 	i = (tcaps->nlines == tcaps->lpos) ? 0 : tcaps->ws.ws_col * (tcaps->lpos - 1);
 	j = tcaps->nlines;
 	if (tcaps->nlines != tcaps->lpos)
-- 
cgit v1.2.3