-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_arrow.c
70 lines (63 loc) · 2.24 KB
/
ft_arrow.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_arrow.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gpetrov <gpetrov@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/10 17:10:42 by gpetrov #+# #+# */
/* Updated: 2014/01/12 16:38:47 by gpetrov ### ########.fr */
/* */
/* ************************************************************************** */
#include "header.h"
void ft_arrow_1(t_list *list, t_data *d)
{
tputs(tgoto(tgetstr("cm", NULL), 0, 0), 1, tputs_putchar);
d->pos = (d->pos + 1) - d->pos_init;
tputs(tgetstr("cl", NULL), 1, tputs_putchar);
make_header(d);
print_multi_tab(list, d);
}
void ft_arrow_2(t_list *list, t_data *d)
{
tputs(tgetstr("do", NULL), 1, tputs_putchar);
d->pos += 1;
tputs(tgetstr("cl", NULL), 1, tputs_putchar);
make_header(d);
print_multi_tab(list, d);
}
void ft_arrow_3(t_list *list, t_data *d)
{
int i;
i = 1;
while (++i <= d->pos_init)
tputs(tgetstr("do", NULL), 1, tputs_putchar);
d->pos = d->pos_init;
tputs(tgetstr("cl", NULL), 1, tputs_putchar);
make_header(d);
print_multi_tab(list, d);
}
void ft_arrow_4(t_list *list, t_data *d)
{
tputs(tgetstr("cl", NULL), 1, tputs_putchar);
tputs(tgetstr("up", NULL), 1, tputs_putchar);
d->pos -= 1;
make_header(d);
print_multi_tab(list, d);
}
int is_arrow(char *buf, t_data *d, t_list *list)
{
if (buf[0] != 27 && buf[1] != 91)
return (-1);
if ((buf[0] == 27 && buf[1] == 91 && buf[2] == 66) && d->pos == d->pos_init)
ft_arrow_1(list, d);
else if (buf[0] == 27 && buf[1] == 91 && buf[2] == 66)
ft_arrow_2(list, d);
else if ((buf[0] == 27 && buf[1] == 91 && buf[2] == 65) && d->pos == 1)
ft_arrow_3(list, d);
else if (buf[0] == 27 && buf[1] == 91 && buf[2] == 65)
ft_arrow_4(list, d);
else
return (-1);
return (0);
}