diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_init.c | 9 | ||||
-rw-r--r-- | src/c_utils.c | 19 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/c_init.c b/src/c_init.c index effcc7d..18482c1 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -9,6 +9,9 @@ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ +# define FT_KEY_LEFT (char[4]){ 27, 91, 68, 0 } +# define FT_KEY_RIGHT (char[4]){ 27, 91, 67, 0 } + #include <unistd.h> #include <termios.h> @@ -110,9 +113,11 @@ int16_t } else { - if (strncmp(buf, tgetstr("kr", NULL), ft_strlen(tgetstr("kr", NULL))) == 0) + /* if (strncmp(buf, tgetstr("kr", NULL), ft_strlen(tgetstr("kr", NULL))) == 0) */ + /* if ((*((unsigned int*)buf)) == FT_KEY_RIGHT) */ + if (strncmp(buf, FT_KEY_LEFT, 4) == 0) { - return (c_key_right(ft_strlen(line), tcaps)); + return (c_key_left(ft_strlen(line), tcaps)); } else if (buf[0] == '\n') { diff --git a/src/c_utils.c b/src/c_utils.c index 6621a1a..8433d40 100644 --- a/src/c_utils.c +++ b/src/c_utils.c @@ -24,11 +24,13 @@ /* ** TODO: -** 1 : cleanup -** 2 : prompt on beginning -** 3 : c_set_term(0) on command -** 4 : MAKE IT WORK ON XTERM FFS (arrows + reset term) -** 5 : leaks +** cursor on char insert +** quotes +** MAKE IT WORK ON XTERM FFS (arrows + reset term) +** leaks +** cleanup DONE +** prompt on beginning DONE +** c_set_term(0) on command DONE */ uint16_t @@ -45,9 +47,9 @@ uint16_t } char -*c_insert_char(char *str, - char c, - t_caps *tcaps) + *c_insert_char(char *str, + char c, + t_caps *tcaps) { size_t i; size_t j; @@ -70,6 +72,7 @@ char j++; } } + tcaps->cpos++; dst[len] = '\0'; ft_memdel((void*)&str); return (dst); |