t_elem *ft_get_input(char *s, t_elem *l, int *flag) { if (*flag == 1) *flag = 0; else if (s[0] == 27 && s[2] == 'A') ft_up(l); else if (s[0] == 27 && s[2] == 'B') ft_down(l); else if (s[0] == 32) ft_space(l); else if (s[0] == 1) ft_select_all(l); else if (s[0] == 24) ft_unselect_all(l); else if (s[0] == 27 && s[2] == 'F') ft_go_toend(l); else if (s[0] == 27 && s[2] == 'H') ft_go_home(l); else if ((s[0] == 27 && s[1] == 0) || s[0] == 4) ft_unset_canon(); else if (s[0] == '\n') ft_enter(l); else if (s[0] == 8 || s[0] == 127 || (s[0] == 27 && s[2] == '3')) l = ft_delete(l); return (l); }
void ft_while_main(int tab[4][4]) { int c; while ((c = getch())) { if (c == 27) break ; if (c == KEY_RIGHT) ft_down(tab); if (c == KEY_LEFT) ft_up(tab); if (c == KEY_UP) ft_left(tab); if (c == KEY_DOWN) ft_right(tab); if (!can_move(tab)) { refresh(); clear(); printw("Can't move mother f****r"); getch(); } ft_aff_square(tab); if (!ft_aff_square(tab)) printw("Window too small.\nThat's what she said."); } }
void ft_all(sel_list lalist, int argc, char *pos) { char read_char[5] = {0}; co_list coord; coord.x = 0; coord.y = 0; while (!(*(unsigned int *)read_char == 27)) { tputs(tgetstr("vi", NULL), 1, ft_putc); if (*(unsigned int *)read_char == 32) ft_space(&lalist, &coord, pos); if (*(unsigned int *)read_char == 4348699) ft_down(&lalist, argc, &coord, pos); if (*(unsigned int *)read_char == 4283163) ft_up(&lalist, argc, &coord, pos); if (*(unsigned int *)read_char == 10) { ft_aff(&lalist); exit(0); } ft_bzero(read_char, 5); read(0, read_char, 4); } tputs(tgetstr("te", NULL), 1, ft_putc); }
void ft_command(t_list **l, char buf[4], struct termios *term) { int ret; t_list *cursor; cursor = (*l)->next; while (!check_break(buf, cursor)) { buf[0] = 0; buf[1] = 0; buf[2] = 0; tputs(tgetstr("cl", NULL), 1, tty_putchar); ft_underline(cursor, l); ret = read(0, buf, 3); buf[ret] = '\0'; ft_space(&cursor, buf); ft_up(&cursor, buf); ft_down(&cursor, buf); ft_check_esc(buf, term); ft_delete(cursor, buf, &cursor); } }
int ft_loop(int *buff, t_list **list, int ac) { while (1) { g_list = list; ft_chk_sig(); tputs(tgoto(tgetstr("cm", NULL), 0, (*list)->y), FD, ft_putint); buff[0] = 0; read(0, buff, 3); ft_chk_up(buff, list); ft_chk_down(buff, list); if (buff[0] == 32) { ft_chk_slct(list); ft_down(list); } ft_del(buff, list); ft_echap(buff, ac); if (buff[0] == 10) return (0); tputs(tgetstr("me", NULL), FD, ft_putint); } }