int ft_while(t_data *d, struct termios *term, t_list *list) { while (42) { ft_bzero(d->read_char, 3); read(0, d->read_char, 3); if (is_rtn(d->read_char)) { ft_quit(term); final_print(list); return (1); } if (ft_while_help(d, term, list, d->read_char)) ; else if (is_arrow(d->read_char, d, list) == 0) ; else if (is_spc(d->read_char, list, d) == 0) ; else if (is_del(d->read_char)) list = ft_del_elem(list, d, term); if (list == NULL) return (0); } return (0); }
int get_key(t_env *env_list, t_cmd_path *cmds, t_hist *history, char *key) { t_hist *tmp; int i; i = 0; while (read(0, key, 15)) { if (is_arrow(key)) i = press_arrow(key[2], history, &tmp, i); else if (is_enter(key)) { history = press_enter(env_list, history); tmp = history->next; i = 0; } else if (is_delete(key)) press_delete(); else if (key[0] > 30) print_letter(key); else if (key[0] == 9 && key[1] == 0 && key[2] == 0) autocomplete(cmds); else is_special_action(key); ft_bzero(key, 15); } return (0); }
int is_prog(t_list *list, int max_elem) { int *index; int *coords; struct termios term; char *buf; char buffer[2048]; if (tgetent(buffer, getenv("TERM")) < 1) return (-1); index = init_prog(&term, list, max_elem, &coords); while (1) { buf = init_read(list, index); if (buf[0] == 27 && buf[1] == 0 && buf[2] == 0) is_escape(term); else if (buf[0] == 27 && buf[1] == 91 && buf[2] != 51) coords = is_arrow(list, buf, index, coords); else if ((buf[0] == 127 && buf[1] == 0 && buf[2] == 0) || (buf[0] == 27 && buf[1] == 91 && buf[2] == 51)) coords = is_del(&list, term, index, coords); else if (buf[0] == 10 && buf[1] == 0 && buf[2] == 0) is_return(term, list); else if (buf[0] == 32 && buf[1] == 0 && buf[2] == 0) coords = is_space(list, index, coords); } return (0); }
void get_key_pressed(t_select *params) { char *key; key = ft_strnew(4); while (read(0, key, 3)) { if (is_escape(key)) break ; else if (is_space(key)) space_key_pressed(params); else if (is_return(key)) return_key_pressed(params); else if (is_arrow(key)) arrow_key_pressed(key[2] - 64, params); ft_bzero(key, 4); } }
static int check_key(t_elem **list, struct termios *backup, char *buf) { int key; if ((key = is_return(buf))) { ft_strdel(&buf); handle_rtn(*list, backup); exit(0); } else if ((key = is_del(buf))) { if (handle_del(list)) return (-1); } else if ((key = is_arrow(buf))) handle_arrow(*list, key); else if ((key = is_space(buf))) handle_space(*list); else return (0); return (key); }
void expr_cell::set_is_arrow(bool flag) { unsigned mask = flag ? 1 : 2; m_flags |= mask; lean_assert(is_arrow() && *is_arrow() == flag); }