-
Notifications
You must be signed in to change notification settings - Fork 0
/
arrow.c
108 lines (100 loc) · 2.38 KB
/
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* arrow.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ctreton <ctreton@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/05 10:05:15 by ctreton #+# #+# */
/* Updated: 2014/01/10 20:17:47 by ctreton ### ########.fr */
/* */
/* ************************************************************************** */
#include "select.h"
void move_cur(char *cr)
{
t_elem *e;
e = g_all.c.cur;
if (cr[0] == 27 && cr[1] == 91 && cr[2] == 66)
{
if (g_all.c.cur == g_all.c.end)
g_all.c.cur = g_all.c.start;
else
g_all.c.cur = e->next;
}
if (cr[0] == 27 && cr[1] == 91 && cr[2] == 65)
{
if (g_all.c.cur == g_all.c.start)
g_all.c.cur = g_all.c.end;
else
g_all.c.cur = e->prev;
}
if (cr[0] == 32 && cr[1] == 0 && cr[2] == 0)
{
if (e->sel)
e->sel = 0;
else
e->sel = 1;
}
move_l(cr);
}
void move_l(char *cr)
{
t_elem *end;
t_elem *cur;
t_elem *e;
int i;
cur = g_all.c.cur;
e = g_all.c.cur;
end = g_all.c.end;
i = end->x;
if (cr[0] == 27 && cr[1] == 91 && cr[2] == 68)
{
if (e->x == 0)
{
i = ((end->y < e->y) ? (i - 1) : i);
while (!((e->x == i) && (e->y == cur->y)))
e = e->next;
}
else
{
while (!((e->x == (cur->x - 1)) && (e->y == cur->y)))
e = e->prev;
}
g_all.c.cur = e;
}
move_r(cr);
}
void move_r(char *cr)
{
t_elem *end;
t_elem *cur;
t_elem *e;
cur = g_all.c.cur;
e = g_all.c.cur;
end = g_all.c.end;
if (cr[0] == 27 && cr[1] == 91 && cr[2] == 67)
{
if (e->x == end->x)
{
while (!((e->x == 0) && (e->y == cur->y)))
e = e->prev;
g_all.c.cur = e;
}
else
{
e = g_all.c.end;
while (!((e->x == (cur->x + 1)) && (e->y == cur->y))
&& !((e->x == 0) && (e->y == cur->y)))
e = e->prev;
g_all.c.cur = e;
}
}
}
void stop_z(char *cr)
{
if (cr[0] == 26 && cr[1] == 0 && cr[2] == 0)
{
exit(30);
g_all.term.c_cc[VSUSP] = 1;
}
}