summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-11-05 17:40:52 +0100
committersalad <fmoenne-@student.le-101.fr>2020-11-05 17:40:52 +0100
commit2dbcdc9fbe10f7bc6eb019b0dcb5ac138b3f8371 (patch)
tree44a54efb3a1af9531839d55f06b9fc5c8af51de5
parentplen fixed (diff)
download42-minishell-2dbcdc9fbe10f7bc6eb019b0dcb5ac138b3f8371.tar.gz
42-minishell-2dbcdc9fbe10f7bc6eb019b0dcb5ac138b3f8371.tar.bz2
42-minishell-2dbcdc9fbe10f7bc6eb019b0dcb5ac138b3f8371.tar.xz
42-minishell-2dbcdc9fbe10f7bc6eb019b0dcb5ac138b3f8371.tar.zst
42-minishell-2dbcdc9fbe10f7bc6eb019b0dcb5ac138b3f8371.zip
C-c arrows
-rw-r--r--src/c_init.c8
-rw-r--r--src/c_input.c18
2 files changed, 21 insertions, 5 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 1cc31b0..d80b9ea 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -121,20 +121,20 @@ short
c_gnl(int fd, char **line, char psx, t_msh *msh)
{
t_caps tcaps;
- char nread[5];
+ char nread[4];
c_init_line(psx, &tcaps);
tputs(tgetstr("cr", NULL), 1, ft_putchar);
m_prompt_psx(psx, msh);
- ft_bzero(nread, 5);
+ ft_bzero(nread, 4);
tcaps.plen = (unsigned int)m_plen(msh->ps[psx - 1]);
tcaps.plen += (psx != 1);
if (!(c_get_win_size(&tcaps.ws)))
return (-1);
while (!(ft_strchr(nread, '\n')))
{
- ft_bzero(nread, 5);
- if (!(read(fd, nread, 4)))
+ ft_bzero(nread, 4);
+ if (!(read(fd, nread, 3)))
return (0);
else
*line = c_process_key(nread, &tcaps, msh);
diff --git a/src/c_input.c b/src/c_input.c
index 7a23b90..8f15449 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -23,6 +23,21 @@
#include "m_prompt.h"
#include "m_loop.h"
+
+void c_signal_int(int signo)
+{
+ signal(SIGINT, c_signal_int);
+ (void)signo;
+ ioctl(1, TIOCSTI, "\002");
+}
+
+void signal_ign(int signo)
+{
+ signal(SIGINT, c_signal_int);
+ (void)signo;
+ signal(SIGTSTP, SIG_IGN);
+}
+
short
c_init_line(char psx, t_caps *tcaps)
{
@@ -34,7 +49,8 @@ short
if (!tgetent(NULL, term))
return (-1);
c_set_term_raw(1);
- signal(SIGINT, SIG_IGN);
+ signal(SIGINT, c_signal_int);
+ signal(SIGQUIT, signal_ign);
tcaps->cpos = 0;
tcaps->lpos = 0;
tcaps->nlines = 1;