Example #1
0
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);
}
Example #2
0
int		main(int ac, char **av)
{
	t_all			all;
	int				ret;

	all.elem = NULL;
	all.win.nb_elem = 0;
	all.show = 1;
	if (ac > 1 && av[1] != NULL)
	{
		ft_signal();
		if (init_term(&all))
			return (-1);
		if ((ret = init_lst(&(all.elem), av, &all)) == TRUE)
		{
			memoire(&all, 0);
			ret = ft_select(&all);
		}
		if (reset_term(&all) == -1)
			return (-1);
		if (ret == -2)
			print_select(&all);
		if (all.win.nb_elem > 0)
			freelst(&all);
	}
	return (0);
}
Example #3
0
void				loop_client(t_client *client)
{
	int				type;
	int				i;
	static int		type_enum[TYPE_SIZE] = TYPE_ENUM;
	static char		*(*type_funct[TYPE_SIZE])(t_client *) = TYPE_FUNCT;
	char			*error;

	while (42)
	{
		print_prompt(client);
		while ((type = ft_select(client)) == -1)
			;
		refresh();
		if (type == QUIT)
			break ;
		error = NULL;
		i = 0;
		while (i < TYPE_SIZE)
		{
			if (type == type_enum[i])
				error = type_funct[i](client);
			i++;
		}
		put_error(client, error);
	}
}
Example #4
0
void		ft_print(t_list *list, t_opt flags)
{
	void	(*f_print)(t_list*, t_opt);

	f_print = ft_select(flags);
	f_print(list, flags);
}
Example #5
0
char				*autocomp_command(char *str, char *path)
{
	struct dirent	*rd;
	DIR				*rep;
	int				i;
	int				j;
	char			**tb;
	char			**sp;

	i = -1;
	j = -1;
	sp = ft_strsplit(path, ':');
	tb = autocomp_size(str, path);
	if (!tb)
		return (str);
	while (sp[++j])
	{
		if (!(rep = opendir(sp[j])))
			return (NULL);
		while ((rd = readdir(rep)))
			if (!(ft_strncmp(str, rd->d_name, ft_strlen(str))))
				tb[++i] = ft_strdup(rd->d_name);
		closedir(rep);
	}
	tb[++i] = NULL;
	ft_arrfree(&sp);
	return (ft_select(tb));
}
Example #6
0
int		main(int argc, char **argv, char **envp)
{
    (void)envp;
    if (argc > 1)
        return (ft_select(argc, argv));
    else
    {
        ft_putendl("Usage : ft_select item1 item2 item3 item...");
        return (0);
    }
}
Example #7
0
int		main(int argc, char **argv)
{
    t_link	*list_chain;

    if (argc <= 1)
        show_usage();
    else
    {
        list_chain = make_list(argc, argv);
        ft_select(list_chain);
    }
    return (0);
}
Example #8
0
int	main(int argc, char **argv)
{
	t_alst	*data;
	int		width;

	if (argc == 1)
	{
		ft_putendl("Pliss, gimme some list.");
		return (-1);
	}
	data = NULL;
	width = ft_get_param(&data, argv, argc);
	ft_select(data, width);
	return (0);
}
Example #9
0
int				main(int ac, char **av)
{
	t_select	params;

	params.list = NULL;
	if (ac <= 1)
		return (-1);
	ft_signal();
	if (init_term(&params) == -1)
		return (-1);
	if (ft_select(ac, av, &params) == -1)
		return (-1);
	if (restore_term(&params) == -1)
		return (-1);
	return (0);
}
Example #10
0
void	term_event(unsigned int key, t_caps *caps)
{
	if (key == 27)
		ft_exit(caps, 1);
	else if (ft_check_size(caps) == -1)
		return ;
	else if (key == 4345627)
		move_down(caps);
	else if (key == 4280091)
		move_top(caps);
	else if (key == 32)
		ft_select(caps);
	else if (key == 127 || key == 2117294875)
		ft_delete(caps);
	else if (key == 10 || key == 5066523)
		ft_return(caps);
}
Example #11
0
int			main(int argc, char **argv)
{
	if (argc < 1)
	{
		ft_putendl("And then...?");
		return (1);
	}
	if (tgetent(NULL, getenv("TERM")) == 1)
	{
		ft_select(argv);
	}
	else
	{
		ft_putendl_fd("Error: Terminal not found", 2);
		return (1);
	}
	return (0);
}
Example #12
0
int			main(int argc, char **argv)
{
	if (getenv("TERM") != NULL)
	{
		if (argc > 1)
		{
			--argc;
			++argv;
			check_empty_arguments(&argc, argv);
			if (argc)
				ft_select(argv);
		}
		else
			exit(1);
	}
	else
		ft_puterrdl("Error: No TERM in env.");
	return (0);
}
Example #13
0
void			completion(t_cursor *cursor, t_hist **hist)
{
	t_info		info;
	int			i;

	(void)hist;
	g_shell->comp = 1;
	g_shell->info = &info;
	i = cursor->cur_col - 3 + cursor->max_col * (cursor->cur_line - 1);
	if (cursor->line[i] == ' ' || cursor->line[i] == '\0')
	{
		find_files(cursor, &info, i);
		if (info.arg)
			ft_select(&info, cursor);
		ft_strdel(&info.file);
		free(info.dir);
	}
	g_shell->comp = 0;
}
Example #14
0
int						init_env(t_select *sel)
{
	int		*pos;

	if (!(pos = ft_memalloc(sizeof(int) * 2)))
		sel_error(MALLER);
	if (!(sel->io = ft_memalloc(sizeof(struct winsize))))
		sel_error(MALLER);
	if (env_sw() == 0)
		sel_error(ENV_ERROR);
	signal(SIGINT, res_and_quit);
	signal(SIGKILL, res_and_quit);
	signal(SIGTERM, res_and_quit);
	signal(SIGTSTP, suspend);
	signal(SIGWINCH, restart_display);
	if (signal(SIGCONT, restart))
		display_arg(sel->first, sel);
	ft_select(sel, pos);
	return (1);
}
Example #15
0
int					main(int argc, char **argv)
{
	int				x;
	int				i;

	i = 1;
	x = 0;
	if (argc == 1)
		error(argv[0]);
	ard = lst_new();
	ard = makelst(ard, argc, argv, 1);
	ft_select(ard);
	i = 0;
	while (i < (int)ard->len)
	{
		if (ard->start->bol == 2 || ard->start->bol == 3)
				printr(ard->start->str, x++, ft_celement(ard));
		ard->start = ard->start->next;
		i++;
	}
	return (0);
}
Example #16
0
void	ft_doublecoms(t_env *env, t_main *w)
{
	char		**coms;
	int 		i;

	i = 0;
	coms = NULL;
	w->line = NULL;
	ft_selectinit(w);
	while (ft_select(w, &w->line))
		;
	ft_selectend(w);
	w = ft_keep_main(*w, 0);
	if (ft_strchr(w->line, '>') != 0 || ft_strchr(w->line, '<') != 0)
		ft_redirect(w, env);
	if (ft_strchr(w->line, ';') == 0 && ft_strchr(w->line, '|') == 0)
		ft_minishell(env, w);
	else if (ft_strchr(w->line, '|') == 0 && ft_strchr(w->line, ';') != 0)
		semicolon(w, env, coms);
	else if (ft_strchr(w->line, '|') != 0)
		com_pipes(w, env, coms);
	if (i == 0)
		ft_doublecoms(env, w);
}
Example #17
0
int			main(int ac, char **av)
{
	t_output	*output;
	t_elems		*select;
	int			fd;

	if ((fd = ft_open()) == -1)
		return (0);
	if (tgetent(NULL, getenv("TERM")) == -1)
		return (0);
	if (!(select = ft_fillselect(ac, av)))
		return (0);
	if (ft_termios(1) == -1)
		return (0);
	if ((output = ft_managedisplay(select, fd)))
	{
		ft_saveelems(select);
		ft_setsignals(output->fd);
		ft_select(select, output);
		free(ft_saveoutput(NULL));
	}
	ft_termios(0);
	return (0);
}