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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* c_utils_next.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <stddef.h>
#include <term.h>
#include "c_init.h"
#include "c_keys.h"
#include "c_utils.h"
#include "d_define.h"
void c_set_ptr_norme(char key, t_bool *sw, char **p, char **context)
{
if ((key == -1 && *p - *context != 0) || key == 1)
{
*p += (key == -1) ? (2 * key) : (0);
while (*sw == FALSE && ((key == -1 && *p - *context != 0) || key == 1)
&& **p != C_LF && **p != C_NUL)
*p += key;
if (*sw == TRUE)
*sw = FALSE;
if (*p - *context != 0 && **p != C_NUL)
*p += 1;
}
}
short c_set_key(char *buf)
{
if (((*((unsigned int *)buf)) == UP_K) ||
((*((unsigned int *)buf)) == CTRL_P))
return (-1);
else
return (1);
}
t_msh *c_get_msh(int mode, t_msh *src)
{
static t_msh *msh;
if (mode == 1)
{
msh = src;
}
return (msh);
}
void c_key_up_down(char *line[], t_caps *tcaps, t_msh *msh)
{
char tmp[ARG_MAX];
char *ptr;
ptr = c_set_ptr(FALSE, tcaps->key, msh);
c_home_key(tcaps->plen, tcaps);
ft_substr_s(tmp, ptr, 0, ft_strclen(ptr, '\n'));
ft_memdel((void*)&(*line));
tputs(tgetstr("ce", NULL), 1, ft_putchar);
*line = ft_strdup(tmp);
tcaps->cpos = ft_strlen(*line);
c_redraw_line(*line, tcaps);
}
|