summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/c_init.c21
-rw-r--r--src/c_input.c5
2 files changed, 12 insertions, 14 deletions
diff --git a/src/c_init.c b/src/c_init.c
index 2718ac8..196a8ff 100644
--- a/src/c_init.c
+++ b/src/c_init.c
@@ -74,10 +74,10 @@ static int16_t
((*((unsigned int *)buf)) == CTRL_F))
return (c_key_right(ft_strlen(line), plen, tcaps));
else if (((*((unsigned int *)buf)) == HOME_K) ||
- ((*((unsigned int *)buf)) == CTRL_A))
+ ((*((unsigned int *)buf)) == CTRL_A))
return (c_home_key(plen, tcaps));
else if (((*((unsigned int *)buf)) == END_K) ||
- ((*((unsigned int *)buf)) == CTRL_E))
+ ((*((unsigned int *)buf)) == CTRL_E))
return (c_end_key(ft_strlen(line), plen, tcaps));
else if ((*((unsigned int *)buf)) == CTRL_L)
return (c_ctrl_l(line, tcaps, msh));
@@ -113,26 +113,19 @@ static char
c_redraw_line(line, tcaps, msh);
}
else
- if (c_read_cap(buf, line, tcaps, msh) == 130)
- {
- return (c_new_line(ft_strdup("\n"), tcaps));
- }
- if (buf[0] == '\n')
- return (c_new_line(line, tcaps));
- return (NULL);
+ {
+ return ((c_read_cap(buf, line, tcaps, msh) == 130) ?
+ c_new_line(ft_strdup("\n"), tcaps) : NULL);
+ }
+ return ((buf[0] == '\n') ? c_new_line(line, tcaps) : NULL);
}
int16_t
c_gnl(int32_t fd, char **line, uint8_t psx, t_msh *msh)
{
t_caps tcaps;
- char *term;
char nread[5];
- term = getenv("TERM");
- signal(SIGINT, SIG_DFL);
- if (!tgetent(NULL, term))
- return (-1);
c_init_line(psx, &tcaps);
tputs(tgetstr("cr", NULL), 1, ft_putchar);
m_prompt_psx(psx, msh);
diff --git a/src/c_input.c b/src/c_input.c
index d680552..cab18b8 100644
--- a/src/c_input.c
+++ b/src/c_input.c
@@ -25,8 +25,13 @@
int16_t
c_init_line(uint8_t psx, t_caps *tcaps)
{
+ char *term;
+
if (tcaps)
{
+ term = getenv("TERM");
+ if (!tgetent(NULL, term))
+ return (-1);
c_set_term_raw(1);
signal(SIGINT, SIG_IGN);
tcaps->cpos = 0;