Add rolling list
This commit is contained in:
parent
7508a136b2
commit
328db0b260
7 changed files with 74 additions and 19 deletions
|
|
@ -6,7 +6,7 @@
|
|||
# By: wescande <wescande@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2016/08/29 21:32:58 by wescande #+# #+# #
|
||||
# Updated: 2017/02/17 17:16:16 by wescande ### ########.fr #
|
||||
# Updated: 2017/03/10 08:47:51 by alao ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ NB = $(words $(SRC_BASE))
|
|||
INDEX = 0
|
||||
|
||||
all :
|
||||
@make -j $(NAME)
|
||||
@make -f $(NAME)
|
||||
|
||||
$(NAME): $(LIBFT_LIB) $(OBJ_DIR) $(OBJS)
|
||||
@$(CC) $(FLAGS) $(D_FLAGS) \
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/02/18 11:13:04 by alao #+# #+# */
|
||||
/* Updated: 2017/03/09 17:34:53 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/10 08:31:49 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -57,6 +57,9 @@ typedef struct s_clst
|
|||
** c_line : Number of line required to move to terminal up.
|
||||
** win_x : Size of the window in length.
|
||||
** win_y : Size of the window in height.
|
||||
** m_size : Max size of the list in pagination.
|
||||
** pos_x : Position of the element relative to the terminal in list mode (X).
|
||||
** pos_y : Position of the element relative to the terminal in list mode (Y).
|
||||
** key : The keypressed lastly.
|
||||
** isfolder : If the match is a folder. boolean.
|
||||
** lst : List of the item corresponding to the completion.
|
||||
|
|
@ -65,9 +68,9 @@ typedef struct s_clst
|
|||
**
|
||||
** Exemple: [ ls / ; cd (tab) ; pwd ]
|
||||
**
|
||||
** (int)cutpoint
|
||||
** |
|
||||
** |
|
||||
** (int)cutpoint
|
||||
** |
|
||||
** |
|
||||
** Become: [ls / ;] [ ] [cd ] [ ; pwd]
|
||||
** | | | |
|
||||
** | | | |
|
||||
|
|
@ -93,6 +96,9 @@ typedef struct s_comp
|
|||
int c_line;
|
||||
int win_x;
|
||||
int win_y;
|
||||
int m_size;
|
||||
int pos_x;
|
||||
int pos_y;
|
||||
int key;
|
||||
int isfolder;
|
||||
int isrematch;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/09 11:21:16 by alao #+# #+# */
|
||||
/* Updated: 2017/03/09 14:45:21 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/10 08:32:11 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -56,6 +56,12 @@ static void c_init_base(t_comp *c)
|
|||
ioctl(0, TIOCGWINSZ, &win);
|
||||
c->win_x = win.ws_col;
|
||||
c->win_y = win.ws_row;
|
||||
c->m_size = data_singleton()->line.prompt_size;
|
||||
c->m_size += ft_strlen(data_singleton()->line.input);
|
||||
c->m_size = (c->m_size / c->win_y);
|
||||
c->m_size = c->win_y - c->m_size - 1;
|
||||
c->pos_x = 1;
|
||||
c->pos_y = 1;
|
||||
c->cutpoint = 0;
|
||||
c->between = NULL;
|
||||
c->isfolder = 0;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/10 12:55:39 by alao #+# #+# */
|
||||
/* Updated: 2017/02/16 22:11:48 by alao ### ########.fr */
|
||||
/* Updated: 2017/03/10 08:45:06 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -72,6 +72,48 @@ static int c_printer_line(t_comp *c, t_clst *lst, int loop, int i)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
** Controlling the offset value for the rolling list if the space in the
|
||||
** terminal is too small to display the whole list.
|
||||
**
|
||||
** Controlled value are:
|
||||
** - x : the column of the element currently selected.
|
||||
*/
|
||||
|
||||
static t_clst *c_rolling(t_comp *c)
|
||||
{
|
||||
t_clst *ptr;
|
||||
int x;
|
||||
int y;
|
||||
int id;
|
||||
|
||||
ptr = c->lst;
|
||||
while (!ptr->cursor)
|
||||
ptr = ptr->next;
|
||||
|
||||
x = 1;
|
||||
while ((x * c->c_line) < ptr->id)
|
||||
x++;
|
||||
id = ((x == 1) ? ptr->id : (ptr->id - ((x - 1) * c->c_line)));
|
||||
y = 1;
|
||||
while ((y * (c->m_size - 1)) < id)
|
||||
y++;
|
||||
if (y > 1)
|
||||
{
|
||||
c->pos_x = x;
|
||||
c->pos_y = y;
|
||||
x = (y - 1) * (c->m_size - 1);
|
||||
ptr = c->lst;
|
||||
while (x)
|
||||
{
|
||||
ptr = ptr->next;
|
||||
x--;
|
||||
}
|
||||
return (ptr);
|
||||
}
|
||||
return (c->lst);
|
||||
}
|
||||
|
||||
/*
|
||||
** Control the number of time it cycle for LINE
|
||||
*/
|
||||
|
|
@ -80,14 +122,17 @@ void c_printer(t_comp *c)
|
|||
{
|
||||
t_clst *ptr;
|
||||
int loop;
|
||||
int max_line;
|
||||
|
||||
ptr = c->lst;
|
||||
loop = c->c_line;
|
||||
while (loop)
|
||||
max_line = c->m_size - 1;
|
||||
ptr = c_rolling(c);
|
||||
while (loop && max_line)
|
||||
{
|
||||
c_printer_line(c, ptr, c->c_pline, 1);
|
||||
loop > 1 ? ft_putstr(tgetstr("do", NULL)) : (0);
|
||||
ptr = ptr->next;
|
||||
loop--;
|
||||
max_line--;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2017/01/10 08:50:26 by alao #+# #+# */
|
||||
/* Updated: 2017/02/17 13:45:33 by alao ### ########.fr */
|
||||
/* Updated: 2017/03/10 08:45:52 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -61,7 +61,5 @@ int c_sizing(t_comp *c)
|
|||
c->c_pline = 0;
|
||||
c->c_line = 0;
|
||||
}
|
||||
if ((c->win_y < c->c_line))
|
||||
c_clear(data_singleton());
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/10/11 10:44:40 by alao #+# #+# */
|
||||
/* Updated: 2017/02/17 18:36:56 by alao ### ########.fr */
|
||||
/* Updated: 2017/03/10 08:46:13 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ void c_term_mv_back(t_comp *c)
|
|||
int lcmd;
|
||||
|
||||
i = 0;
|
||||
while (i != (c->c_line))
|
||||
while (i != (c->m_size))
|
||||
{
|
||||
ft_putstr(tgetstr("up", NULL));
|
||||
i++;
|
||||
|
|
@ -71,14 +71,14 @@ void c_term_mv_down(t_comp *c)
|
|||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < c->c_line)
|
||||
while (i < c->m_size)
|
||||
{
|
||||
ft_putstr(tgetstr("do", NULL));
|
||||
ft_putstr(tgetstr("cd", NULL));
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
while (i != (c->c_line - 1))
|
||||
while (i != (c->m_size - 1))
|
||||
{
|
||||
ft_putstr(tgetstr("up", NULL));
|
||||
i++;
|
||||
|
|
@ -86,7 +86,7 @@ void c_term_mv_down(t_comp *c)
|
|||
}
|
||||
|
||||
/*
|
||||
** If the terminal has chaged in size, the function will refresh these values
|
||||
** If the terminal has changed in size, the function will refresh these values
|
||||
** and clear the previous print list.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: alao <alao@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2016/09/20 14:50:33 by alao #+# #+# */
|
||||
/* Updated: 2017/03/09 14:44:52 by gwojda ### ########.fr */
|
||||
/* Updated: 2017/03/10 08:46:26 by alao ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue