884 logger

Large diffs are not rendered by default.

@@ -6,7 +6,7 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/13 04:23:45 by aroulin #+# #+# */
/* Updated: 2017/08/22 23:01:12 by aroulin ### ########.fr */
/* Updated: 2017/08/23 13:51:38 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

@@ -30,9 +30,6 @@ int init_tab_(t_tab *tab_, int li)
tab_->nbr = (tgetnum("co") / tab_->len);
tab_->li = tgetnum("li");
tab_->elem_page = (tab_->li - li) * tab_->nbr;
NBR_FD(tab_->elem_page, fdb);
CHAR_FD(10,fdb);

return (1);
}
void rst(t_read **read_std, int to)
@@ -6,7 +6,7 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/13 04:40:22 by aroulin #+# #+# */
/* Updated: 2017/08/22 23:47:50 by aroulin ### ########.fr */
/* Updated: 2017/08/23 17:07:28 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

@@ -6,7 +6,7 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/13 06:58:08 by aroulin #+# #+# */
/* Updated: 2017/08/22 23:47:45 by aroulin ### ########.fr */
/* Updated: 2017/08/23 17:06:02 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

@@ -32,13 +32,16 @@ int init_page(t_read **read_std, t_file **tmp)

int print_element(t_file *file, int color)
{
NBR_FD(file->index, fdb);
CHAR_FD(10,fdb);
(!color) ? P_INV_FD(init_fd()) : NULL;
color_completion(file->type, color);
my_togoto(file->ms.y, file->ms.x);
STR_FD(file->name, init_fd());
STR_FD(RST, init_fd());
add_little_char(file->type);
my_tobackto(file->ms.y, file->ms.x + 100);
P_RST_FD(init_fd());
return (1);
}

@@ -6,76 +6,63 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/20 14:15:25 by aroulin #+# #+# */
/* Updated: 2017/08/20 17:47:20 by aroulin ### ########.fr */
/* Updated: 2017/08/23 17:34:23 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

#include <sh.h>

int to_up2(t_read **r, t_file *tmp, int to_p)
{
tmp = (*r)->comp->tab_->file;
while (tmp->index != to_p)
tmp = tmp->next;
(*r)->comp->tab_->index = to_p;
print_element(tmp, 0);
return (1);
}

void to_up(t_read **r, int d, int to_p)
void to_up(t_read **read_std)
{
t_file *tmp;

tmp = (*r)->comp->tab_->file;
while (tmp)
{
if (tmp->index == (*r)->comp->tab_->index && print_element(tmp, 1))
{
P_INV_FD(init_fd());
if ((((to_p = tmp->index - (*r)->comp->tab_->nbr) %
(*r)->comp->tab_->element) >= 0) && to_up2(r, tmp, to_p))
break ;
else
{
while ((((*r)->comp->tab_->element - ++d) %
(*r)->comp->tab_->nbr) != (tmp->index % (*r)->comp->tab_->nbr))
;
(*r)->comp->tab_->index = (*r)->comp->tab_->element - d;
tmp = (*r)->comp->tab_->file;
while (tmp->index != (*r)->comp->tab_->index)
tmp = tmp->next;
print_element(tmp, 0);
}
}
tmp = (*read_std)->comp->tab_->file;
while (tmp->index != (*read_std)->comp->tab_->index)
tmp = tmp->next;
update_index(read_std, (*read_std)->comp->tab_->nbr * -1);
if (((*read_std)->comp->tab_->index / (*read_std)->comp->tab_->elem_page) != (*read_std)->comp->tab_->page)
{
reprint_cmd(read_std, 1);
print_tab_(read_std);
reprint_cmd(read_std, 0);
}
else
{
SAVE;
MV_BOT;
print_element(tmp, 1);
tmp = (*read_std)->comp->tab_->file;
while (tmp->index != (*read_std)->comp->tab_->index)
tmp = tmp->next;
print_element(tmp, 0);
RESTORE;
}
}

int to_down(t_read **r)
int to_down(t_read **read_std)
{
t_file *tmp;
int to_p;
int d = 0;

tmp = (*r)->comp->tab_->file;
while (tmp)
{
if (tmp->index == (*r)->comp->tab_->index && print_element(tmp, 1))
{
P_INV_FD(init_fd());
if ((((to_p = tmp->index + (*r)->comp->tab_->nbr) < (*r)->comp->tab_->element)) && to_up2(r, tmp, to_p))
break ;
else
{
d = tmp->index;
tmp = (*r)->comp->tab_->file;
while ((d % (*r)->comp->tab_->nbr) != (tmp->index % (*r)->comp->tab_->nbr))
tmp = tmp->next;
(*r)->comp->tab_->index = tmp->index;
print_element(tmp, 0);
}
}
tmp = (*read_std)->comp->tab_->file;
while (tmp->index != (*read_std)->comp->tab_->index)
tmp = tmp->next;
update_index(read_std, (*read_std)->comp->tab_->nbr * 1);
if (((*read_std)->comp->tab_->index / (*read_std)->comp->tab_->elem_page) != (*read_std)->comp->tab_->page)
{
reprint_cmd(read_std, 1);
print_tab_(read_std);
reprint_cmd(read_std, 0);
}
else
{
SAVE;
MV_BOT;
print_element(tmp, 1);
tmp = (*read_std)->comp->tab_->file;
while (tmp->index != (*read_std)->comp->tab_->index)
tmp = tmp->next;
print_element(tmp, 0);
RESTORE;
}
return (1);
}
@@ -6,22 +6,20 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/22 18:27:56 by aroulin #+# #+# */
/* Updated: 2017/08/22 23:47:48 by aroulin ### ########.fr */
/* Updated: 2017/08/23 17:02:03 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

#include <sh.h>

void update_index(t_read **read_std, int i)
{
if ((i == 1) && ((*read_std)->comp->tab_->index + 1) ==
(*read_std)->comp->tab_->element)
(*read_std)->comp->tab_->index = 0;
else if ((i == -1) && !((*read_std)->comp->tab_->index))
{
(*read_std)->comp->tab_->index = ((*read_std)->comp->tab_->element - 1);
}
else
(*read_std)->comp->tab_->index += i;
(*read_std)->comp->tab_->index += i;
if ((*read_std)->comp->tab_->index >= (*read_std)->comp->tab_->element)
(*read_std)->comp->tab_->index = 0 + ((*read_std)->comp->tab_->index
% (*read_std)->comp->tab_->element);
else if ((*read_std)->comp->tab_->index < 0)
(*read_std)->comp->tab_->index = (*read_std)->comp->tab_->element +
((*read_std)->comp->tab_->index);

}
@@ -6,7 +6,7 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/11 03:27:42 by aroulin #+# #+# */
/* Updated: 2017/08/22 23:47:47 by aroulin ### ########.fr */
/* Updated: 2017/08/23 17:06:50 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

@@ -64,12 +64,8 @@ int arrow_up(t_read **read_std)
{
if ((*read_std)->completion)
{
SAVE;
MV_BOT;
P_RST_FD(init_fd());
to_up(read_std, 0, 0);
to_up(read_std);
(*read_std)->completion++;
RESTORE;
}
else
;
@@ -80,12 +76,8 @@ int arrow_down(t_read **read_std)
{
if ((*read_std)->completion)
{
SAVE;
MV_BOT;
P_RST_FD(init_fd());
to_down(read_std);
(*read_std)->completion++;
RESTORE;
}
else
;
@@ -6,7 +6,7 @@
/* By: aroulin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/12 17:39:56 by aroulin #+# #+# */
/* Updated: 2017/08/19 14:19:53 by aroulin ### ########.fr */
/* Updated: 2017/08/23 13:37:20 by aroulin ### ########.fr */
/* */
/* ************************************************************************** */

@@ -16,8 +16,7 @@ int key_tab(t_read **read_std)
{
if ((*read_std)->completion)
{
(*read_std)->completion++;
continue_completion(read_std);
arrow_right(read_std);
}
else
{