-
Notifications
You must be signed in to change notification settings - Fork 0
/
other_functions_3.c
105 lines (96 loc) · 2.39 KB
/
other_functions_3.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* other_functions_3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aulamber <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/05/04 20:39:58 by aulamber #+# #+# */
/* Updated: 2014/05/04 20:40:03 by aulamber ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include "ft_select.h"
#include "libft/libft.h"
#include <termios.h>
#include <termcap.h>
char *tab_zero(char *read_char)
{
int i;
i = 0;
while (read_char[i])
{
read_char[i] = 0;
i++;
}
return (read_char);
}
void move_curse(t_list *list, int fun)
{
t_list *tmp;
t_list *save;
save = list;
tmp = NULL;
while (list->curs != 1)
{
tmp = list;
list = list->next;
}
if (fun == 1)
{
if (tmp == NULL)
{
tmp = list;
while (tmp->next)
tmp = tmp->next;
}
tmp->curs = 1;
}
else if (list->next)
list->next->curs = 1;
else
save->curs = 1;
list->curs = 0;
}
void print_ft_list(t_list *list)
{
tputs(tgetstr("cl", NULL), ENT, tputs_putchar);
while (list)
{
if (list->curs)
tputs(tgetstr("us", NULL), ENT, tputs_putchar);
if (list->rev == 1)
tputs(tgetstr("mr", NULL), ENT, tputs_putchar);
ft_dprintf(ENT, "%s\n", list->arg);
if (list->rev == 1)
tputs(tgetstr("me", NULL), ENT, tputs_putchar);
if (list->curs)
tputs(tgetstr("ue", NULL), ENT, tputs_putchar);
list = list->next;
}
tputs(tgetstr("me", NULL), ENT, tputs_putchar);
while (list)
{
tputs(tgetstr("up", NULL), ENT, tputs_putchar);
list = list->prev;
}
tputs(tgetstr("te", NULL), ENT, tputs_putchar);
}
int tputs_putchar(int c)
{
write(1, &c, 1);
return (1);
}
void select_list(t_list *list)
{
t_list *tmp;
tmp = list;
while (tmp->curs != 1)
tmp = tmp->next;
tmp->rev = (tmp->rev) ? 0 : 1;
tmp->curs = 0;
if (tmp->next)
tmp->next->curs = 1;
else
list->curs = 1;
}