Exemplo n.º 1
0
/*
**		Check_env: check the TERM environnement variable for tgetent.
**		Init_termios: init terminal settings (!raw mode + !Echo mode).
**		Create a list with arguments given by user.
**		After receving selection from my_select: reinit term settings.
**		Return selection to the shell.
*/
int		main(int ac, char **av, char **env)
{
  int		i;
  t_termios	t;
  t_list	*list;

  i = 1;
  if (ac == 1 || ac == 1)
    return (msg_error("error: to few arguments\n", 1));
  if (check_env(env) == 1)
    return (1);
  if (init_termios(&t) == 1)
    return (1);
  if ((list = my_create_list()) == NULL)
    return (reinit_termios(&t));
  while (i < ac)
    {
      my_put_end_list(list, av[i], i);
      i = i + 1;
    }
  if (my_select(t, list, i - 2) == 1)
    return (reinit_termios(&t));
  my_show_selected_list(list);
  if (reinit_termios(&t) == 1)
    return (msg_error("error: cannot reinit terminal settings\n", 1));
  my_rm_list(list);
  return (0);
}
Exemplo n.º 2
0
int		get_input(t_shprop *shell, int (*handle)(t_shprop *, int))
{
	int		read_ret;

	if (shell->term->term_name)
	{
		reinit_termios(shell->term);
		while (interrupt(-1) == 0)
		{
			read_ret = get_one_input();
			if (interrupt(-1) == 1)
				return (1);
			if (read_ret != -1)
			{
				if (shell->size_changed)
					reprint_all_line(shell);
				read_ret = handle(shell, read_ret);
				if ((read_ret = special_input(read_ret, shell)) != -1)
					return (read_ret);
			}
		}
	}
	else
		return (get_basic_input(shell));
	if (interrupt(-1) == 1)
		return (1);
	return (0);
}