/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* c_input.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include #include "c_init.h" #include "c_input.h" #include "c_utils.h" #include "m_prompt.h" #include "m_loop.h" int16_t c_new_line(char *buf, char **line, t_msh *msh, t_caps *tcaps) { write(1, buf, ft_strlen(buf)); tputs(tgetstr("cr", NULL), 1, ft_putchar); c_set_term_raw(0); m_parse_and_run_line(*line, msh); *line = NULL; tcaps->cpos = 0; tputs(tgetstr("cr", NULL), 1, ft_putchar); c_set_term_raw(1); m_prompt_psx(1, msh); return (1); } int16_t c_back_slash(char **line, t_caps *tcaps) { if (tcaps->cpos >= 1) { *line = c_delchar(*line, tcaps->cpos); tcaps->cpos -= 1; tputs(tgetstr("le", NULL), 1, ft_putchar); tputs(tgetstr("dc", NULL), 1, ft_putchar); } return (1); } int16_t c_ctrl_l(char *line, t_caps *tcaps, t_msh *msh) { tputs(tgetstr("cl", NULL), 1, ft_putchar); c_redraw_line(line, tcaps->cpos, msh); return (1); } int16_t c_key_right(uint32_t len, t_caps *tcaps) { if (tcaps->cpos < len) { tputs(tgetstr("nd", NULL), 1, ft_putchar); tcaps->cpos++; } return (1); } int16_t c_key_left(uint32_t len, t_caps *tcaps) { (void)len; if (tcaps->cpos >= 1) { tputs(tgetstr("le", NULL), 1, ft_putchar); tcaps->cpos--; } return (1); }