diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_init.h | 1 | ||||
-rw-r--r-- | src/c_keys.c | 14 | ||||
-rw-r--r-- | src/c_utils.c | 16 |
3 files changed, 19 insertions, 12 deletions
diff --git a/src/c_init.h b/src/c_init.h index a1b7c9a..730ba9f 100644 --- a/src/c_init.h +++ b/src/c_init.h @@ -30,6 +30,7 @@ typedef struct s_caps struct winsize ws; uint32_t cpos; /*cursor position (column)*/ uint32_t lpos; /*cursor position (line)*/ + uint32_t nlines; /*cursor position (line)*/ char *cm_str; /*cursor mobility*/ char *nl; /*newline, returned by tgoto()*/ char *ks; /*indicate that keys transmit from now on*/ diff --git a/src/c_keys.c b/src/c_keys.c index 47d9c93..c303a91 100644 --- a/src/c_keys.c +++ b/src/c_keys.c @@ -58,13 +58,19 @@ int16_t c_end_key(uint16_t size, t_caps *tcaps) { uint16_t i; + uint16_t j; - i = tcaps->cpos; - while (i < size) + i = (tcaps->lpos > 0) ? tcaps->cpos : (tcaps->ws.ws_col * tcaps->nlines - 1); + j = 0; + if (tcaps->cpos < size && tcaps->lpos > 0) { - tputs(tgetstr("nd", NULL), 1, ft_putchar); - i++; + while (j++ < (tcaps->nlines - 1)) + tputs(tgetstr("do", NULL), 1, ft_putchar); + tputs(tgetstr("cr", NULL), 1, ft_putchar); } + else + while (i++ < size) + tputs(tgetstr("nd", NULL), 1, ft_putchar); tcaps->cpos = size; return (1); } diff --git a/src/c_utils.c b/src/c_utils.c index de71ef3..834f192 100644 --- a/src/c_utils.c +++ b/src/c_utils.c @@ -24,10 +24,11 @@ /* ** TODO: -** REPRINT edit +** delchar MOVE +** END MONGARS +** NORME ** FLECHES UP DOWN ** C-c globul pid -** NORME */ uint16_t @@ -132,10 +133,9 @@ int16_t uint32_t len; uint32_t mod; int16_t ret; - uint32_t nlines; i = 0; - nlines = c_get_line_num(line, tcaps->cpos, ft_strlen(msh->ps[0]), tcaps); + tcaps->nlines = c_get_line_num(line, tcaps->cpos, ft_strlen(msh->ps[0]), tcaps); len = ft_strlen(line); mod = (tcaps->ws.ws_col); tputs(tgetstr("cr", NULL), 1, ft_putchar); @@ -155,14 +155,14 @@ int16_t tputs(tgetstr("nd", NULL), 1, ft_putchar); i++; } - nlines = c_get_line_num(line, tcaps->cpos, ft_strlen(msh->ps[0]), tcaps); + tcaps->nlines = c_get_line_num(line, tcaps->cpos, ft_strlen(msh->ps[0]), tcaps); ret = ft_printf("%s", line); - i = (nlines == (tcaps->lpos)) ? 0 : tcaps->ws.ws_col * (tcaps->lpos - 1); + i = (tcaps->nlines == (tcaps->lpos)) ? 0 : tcaps->ws.ws_col * (tcaps->lpos - 1); if (tcaps->cpos != len) { - if (nlines != tcaps->lpos) + if (tcaps->nlines != tcaps->lpos) { - while (--nlines > tcaps->lpos) + while (--tcaps->nlines > tcaps->lpos) tputs(tgetstr("up", NULL), 1, ft_putchar); tputs(tgetstr("up", NULL), 1, ft_putchar); tputs(tgetstr("cr", NULL), 1, ft_putchar); /* cr, cpos mauvaise col, bonne ligne */ |