diff options
Diffstat (limited to '')
| -rw-r--r-- | src/c_init.c | 36 | ||||
| -rw-r--r-- | src/c_input.c | 2 | ||||
| -rw-r--r-- | src/c_keys.c | 4 | ||||
| -rw-r--r-- | src/c_utils.c | 11 | 
4 files changed, 29 insertions, 24 deletions
| diff --git a/src/c_init.c b/src/c_init.c index 9196d51..0e48b2f 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -65,20 +65,20 @@ c_read_cap(char *buf,  		   t_caps *tcaps,  		   t_msh *msh)  { -		if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B)) -			return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps)); -		else if (((*((unsigned int *)buf)) == RIGHT_K) || ((*((unsigned int *)buf)) == CTRL_F)) -			return (c_key_right(ft_strlen(line), ft_strlen(msh->ps[tcaps->psx]), tcaps)); -		else if ((*((unsigned int *)buf)) == HOME_K) -			return (c_home_key(tcaps)); -		else if ((*((unsigned int *)buf)) == END_K) -			return (c_end_key(ft_strlen(line), tcaps)); -		else if ((*((unsigned int *)buf)) == CTRL_C) -			return (c_ctrl_c(NULL, tcaps, msh)); -		else if ((*((unsigned int *)buf)) == CTRL_L) -			return (c_ctrl_l(line, tcaps, msh)); -		else -			return (0); +	if (((*((unsigned int *)buf)) == LEFT_K) || ((*((unsigned int *)buf)) == CTRL_B)) +		return (c_key_left(ft_strlen(msh->ps[tcaps->psx]), tcaps)); +	else if (((*((unsigned int *)buf)) == RIGHT_K) || ((*((unsigned int *)buf)) == CTRL_F)) +		return (c_key_right(ft_strlen(line), ft_strlen(msh->ps[tcaps->psx]), tcaps)); +	else if ((*((unsigned int *)buf)) == HOME_K) +		return (c_home_key(tcaps)); +	else if ((*((unsigned int *)buf)) == END_K) +		return (c_end_key(ft_strlen(line), tcaps)); +	else if ((*((unsigned int *)buf)) == CTRL_C) +		return (c_ctrl_c(NULL, tcaps, msh)); +	else if ((*((unsigned int *)buf)) == CTRL_L) +		return (c_ctrl_l(line, tcaps, msh)); +	else +		return (0);  }  static char @@ -98,8 +98,14 @@ static char  	if (ft_isprint(buf[0]))  	{  		line = c_insert_char(line, buf[0], tcaps); -		c_redraw_line(line, tcaps, msh);  		tcaps->cpos++; +		if ((((tcaps->cpos) + ft_strlen(msh->ps[tcaps->psx])) % +			tcaps->ws.ws_col) == 0) +		{ +			write(1, "\n", 1); +			return (NULL); +		} +		c_redraw_line(line, tcaps, msh);  	}  	else if ((*((unsigned int *)buf)) == DEL_K)  	{ diff --git a/src/c_input.c b/src/c_input.c index 1c14342..1cc9ce0 100644 --- a/src/c_input.c +++ b/src/c_input.c @@ -69,7 +69,7 @@ c_get_line_num(char *line,  	while (it < len)  	{  		it += (it == 0) ? (tcaps->ws.ws_col - plen) : tcaps->ws.ws_col; -		tcaps->lpos += (it <= (cpos)) ? 1 : 0; +		tcaps->lpos += (it < (cpos)) ? 1 : 0;  		line_num++;  	}  	return (line_num); diff --git a/src/c_keys.c b/src/c_keys.c index a5b90fb..5a036e6 100644 --- a/src/c_keys.c +++ b/src/c_keys.c @@ -51,6 +51,7 @@ int16_t  			tputs(tgetstr("le", NULL), 1, ft_putchar);  	}  	tcaps->cpos = 0; +	tcaps->lpos = 1;  	return (1);  } @@ -79,6 +80,7 @@ int16_t  		while (i++ < size)  			tputs(tgetstr("nd", NULL), 1, ft_putchar);  	tcaps->cpos = size; +	tcaps->lpos = tcaps->nlines;  	return (1);  } @@ -93,6 +95,7 @@ int16_t  		tputs(tgetstr("do", NULL), 1, ft_putchar);  		tputs(tgetstr("cr", NULL), 1, ft_putchar);  		tcaps->cpos++; +		tcaps->lpos++;  	}  	else if (tcaps->cpos < len)  	{ @@ -116,6 +119,7 @@ int16_t  		while(++pos <= (tcaps->ws.ws_col))  			tputs(tgetstr("nd", NULL), 1, ft_putchar);  		tcaps->cpos--; +		tcaps->lpos--;  	}  	else if (tcaps->cpos >= 1)  	{ diff --git a/src/c_utils.c b/src/c_utils.c index b18b949..ad1ccba 100644 --- a/src/c_utils.c +++ b/src/c_utils.c @@ -120,16 +120,17 @@ static int16_t  			tputs(tgetstr("up", NULL), 1, ft_putchar);  		tputs(tgetstr("up", NULL), 1, ft_putchar);  		tputs(tgetstr("cr", NULL), 1, ft_putchar); -		while (i <= (tcaps->cpos + plen)) +		while (i < (tcaps->cpos + plen))  		{  			tputs(tgetstr("nd", NULL), 1, ft_putchar);  			i++;  		}  	}  	else -		while (--len > tcaps->cpos) +		while (len > tcaps->cpos)  		{  			tputs(tgetstr("le", NULL), 1, ft_putchar); +			len--;  		}  	return (len);  } @@ -147,12 +148,6 @@ int16_t  	i = 0;  	j = tcaps->lpos;  	tputs(tgetstr("cr", NULL), 1, ft_putchar); -	if ((((tcaps->cpos + 1) + ft_strlen(msh->ps[tcaps->psx])) % -		tcaps->ws.ws_col) == 0) -	{ -		tputs(tgetstr("sf", NULL), 1, ft_putchar); -		return (1); -	}  	while (--j > 0)  	{  		tputs(tgetstr("sf", NULL), 1, ft_putchar); | 
