void ft_write_list(t_dlist *arg, t_dlist_node *node, struct termios term, t_dlist_node *ls_n) { arg->index = -1; arg->line = 0; arg->cur_col = 1; node = ft_write_start(arg, node, term); while (++arg->index != (int)arg->size) { if (tgetnum("li") <= 2) { ft_terminal_small(arg); break ; } ft_calc_size(arg, node); if (arg->cur_col + arg->size_col > tgetnum("co") && arg->cur_col != 1) { ft_terminal_small(arg); break ; } if (arg->line == 0 && arg->cur_col != 1) arg->size_col = 0; arg->line = ft_define_x_y(arg, node, arg->line, arg->cur_col); node = ft_write_line(arg, node); } tputs(tgoto(tgetstr("cm", NULL), ls_n->pos_x, ls_n->pos_y), 1, ft_putchar); if (arg->index == (int)arg->size) ft_underline(arg, ls_n); }
t_dlist_node *ft_go_down(t_dlist *arg, t_dlist_node *node) { ft_desunderline(arg, node); node = node->next; tputs(tgoto(tgetstr("cm", NULL), node->pos_x, node->pos_y), 1, ft_putchar); ft_underline(arg, node); return (node); }
t_dlist_node *ft_select_arg(t_dlist *arg, t_dlist_node *node) { if (node->sel == 1) { node->sel = 0; write(arg->fd, " ", 1); } else { node->sel = 1; write(arg->fd, "X", 1); } tputs(tgetstr("le", NULL), 1, ft_putchar); ft_underline(arg, node); ft_desunderline(arg, node); node = node->next; tputs(tgoto(tgetstr("cm", NULL), node->pos_x, node->pos_y), 1, ft_putchar); ft_underline(arg, node); return (node); }
void ft_take_signal(int sign) { if (sign == SIGTSTP || sign == SIGTTIN || sign == SIGTTOU) ft_sigtstp(); if (sign == SIGCONT || sign == SIGURG || sign == SIGCHLD || sign == SIGIO || sign == SIGINFO) { ft_termios_init(); ft_underline(); signal(SIGTSTP, ft_take_signal); } if (sign == SIGINT || sign == SIGTERM || sign == SIGHUP || sign == SIGPIPE || sign == SIGALRM || sign == SIGXCPU || sign == SIGXFSZ || sign == SIGVTALRM || sign == SIGPROF || sign == SIGUSR1 || sign == SIGUSR2 || sign == SIGQUIT || sign == SIGILL || sign == SIGTRAP || sign == SIGABRT || sign == SIGEMT || sign == SIGFPE || sign == SIGBUS || sign == SIGSEGV || sign == SIGSYS) ft_sigint(); if (sign == SIGWINCH) { tputs(tgetstr("cl", NULL), 1, tty_putchar); ft_underline(); } }
void ft_select(t_dlist *arg, struct termios term) { char read_char[4]; t_dlist_node *node; signal(SIGWINCH, ft_resize); signal(SIGTSTP, ft_select_control_z); signal(SIGCONT, ft_select_fg); signal(SIGINT, ft_exit_signal); signal(SIGQUIT, ft_exit_signal); ((t_sing *)ft_get_instance())->arg = arg; ((t_sing *)ft_get_instance())->term = term; node = arg->head; ft_write_list(arg, node, term, node); node = arg->head; ft_underline(arg, node); ft_loop(arg, node, read_char, term); }
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); } }