From 1494b105cce7eac172bd07cf324ec48a37de46bf Mon Sep 17 00:00:00 2001 From: salad Date: Sat, 7 Nov 2020 23:37:26 +0100 Subject: ctrlc \ --- src/c_ctrls.c | 14 +++++++++++++- src/c_ctrls.h | 1 + src/c_input.c | 3 --- src/m_loop.c | 5 +++++ src/ret | Bin 0 -> 67 bytes 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/ret diff --git a/src/c_ctrls.c b/src/c_ctrls.c index 2f066d6..dce9db6 100644 --- a/src/c_ctrls.c +++ b/src/c_ctrls.c @@ -19,6 +19,17 @@ #include "c_utils.h" #include "m_prompt.h" +t_msh *c_get_msh(int mode, t_msh *src) +{ + static t_msh *msh; + + if (mode == 1) + { + msh = src; + } + return (msh); +} + short c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh) { tputs(tgetstr("cl", NULL), 1, ft_putchar); @@ -43,8 +54,9 @@ void c_signal_int(int signo) msh = NULL; signal(SIGINT, c_signal_int); (void)signo; - msh->ret = 130; + msh = c_get_msh(0, msh); ioctl(1, TIOCSTI, "\002"); + msh->ret = 130; } void c_signal_ign(int signo) diff --git a/src/c_ctrls.h b/src/c_ctrls.h index abce955..14adbda 100644 --- a/src/c_ctrls.h +++ b/src/c_ctrls.h @@ -16,6 +16,7 @@ # include "c_init.h" # include "s_struct.h" +t_msh *c_get_msh(int mode, t_msh *src); short c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh); char *c_ctrl_c(char **line, char *buf, t_msh *msh); void c_signal_int(int signo); diff --git a/src/c_input.c b/src/c_input.c index ce571ca..9023f37 100644 --- a/src/c_input.c +++ b/src/c_input.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include "c_ctrls.h" @@ -35,8 +34,6 @@ short if (!tgetent(NULL, term)) return (-1); c_set_term_raw(1); - signal(SIGINT, c_signal_int); - signal(SIGQUIT, c_signal_ign); tcaps->cpos = 0; tcaps->lpos = 0; tcaps->nlines = 1; diff --git a/src/m_loop.c b/src/m_loop.c index 03ce8e2..6444c1b 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef __linux__ # include #else @@ -21,6 +22,7 @@ #endif #include "c_init.h" +#include "c_ctrls.h" #include "d_define.h" #include "e_line.h" #include "m_loop_multis.h" @@ -136,6 +138,9 @@ unsigned char m_loop(int fd, t_msh *msh) gnl = 1; msh->curr_hist_ptr = hist; + c_get_msh(1, msh); + signal(SIGINT, c_signal_int); + signal(SIGQUIT, c_signal_ign); while (gnl > 0) { gnl = (fd == STDIN_FILENO) ? c_gnl(fd, &line, 1, msh) : diff --git a/src/ret b/src/ret new file mode 100644 index 0000000..42d8826 Binary files /dev/null and b/src/ret differ -- cgit v1.2.3