int main(int ac, char **av) { char *name_term; struct termios term; t_dlist *arg; if (ac == 1) return (0); arg = ft_dlist_new(); ft_init_arg(arg, av, ac); if ((name_term = getenv("TERM")) == NULL) return (-1); if (tgetent(NULL, name_term) == -1) return (-1); if (tcgetattr(0, &term) == -1) return (-1); tputs(tgetstr("ti", NULL), 1, ft_putchar); term.c_lflag &= ~(ICANON | ECHO); term.c_cc[VMIN] = 1; term.c_cc[VTIME] = 0; if (tcsetattr(0, TCSADRAIN, &term) == -1) return (-1); if ((arg->fd = open("/dev/tty", O_RDWR) == -1)) return (-1); ft_select(arg, term); close(arg->fd); return (0); }
void history_add(t_context *context, const char *command_line) { static size_t entry_number = 1; t_history new_entry; t_dlist *new_link; if (*command_line != '\0') { new_entry.entry_number = entry_number; new_entry.entry = ft_strdup(command_line); new_link = ft_dlist_new(&new_entry, sizeof(t_history)); ft_dlist_append(&context->history, new_link); ++entry_number; } }