/
keyboard_line_updown.c
46 lines (40 loc) · 1.76 KB
/
keyboard_line_updown.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* keyboard_line_updown.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ulefebvr <ulefebvr@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/02/07 16:40:50 by ulefebvr #+# #+# */
/* Updated: 2016/02/07 17:44:51 by ulefebvr ### ########.fr */
/* */
/* ************************************************************************** */
#include "command_line_termcaps.h"
#include "libft.h"
void move_line_up(t_info *info)
{
int plen;
int pos_c;
t_termcaps *term;
term = info->term;
pos_c = term->pos_c;
plen = ft_strlen(term->prompt);
move_cursor(term->capa, pos_c, plen,
(pos_c >= termcap_winsz_x()) ? pos_c - termcap_winsz_x() : 0);
term->pos_c = (pos_c >= termcap_winsz_x()) ? pos_c - termcap_winsz_x() : 0;
}
void move_line_down(t_info *info)
{
int len;
int plen;
int pos_c;
t_termcaps *term;
term = info->term;
pos_c = term->pos_c;
len = ft_strlen(term->cmd);
plen = ft_strlen(term->prompt);
move_cursor(term->capa, pos_c, plen,
((pos_c + termcap_winsz_x()) < len) ? pos_c + termcap_winsz_x() : len);
term->pos_c =
((pos_c + termcap_winsz_x()) < len) ? pos_c + termcap_winsz_x() : len;
}