Exemplo n.º 1
0
/*
**		If termcaps database isn't reachable:
**			=> returns fget_next_line (normal get_next_line).
**		Else => returns tc_get_next_line (using termcaps).
*/
char		*get_next_line(int fd, char **env)
{
  static char	*line = NULL;
  char		*str;
  int		i;

  i = 0;
  if ((i = init_termios(env)) == 1)
    return (fget_next_line(fd));
  if (i == -1)
    return (NULL);
  if ((str = line) != NULL)
    line = NULL;
  else
    if ((str = tc_get_next_line(fd, env)) != NULL)
      my_putchar('\n');
  while (str && str[i] && str[i] != ';')
    jump_inhibitors(str, &i);
  if (str && str[i])
    if (display_prompt(0, 0, 1) || (line = my_strdup(str + i + 1)) == NULL ||
        (str = my_xstrndup(str, i)) == NULL)
      return (NULL);
  if (init_termios(NULL))
    return (NULL);
  return (str);
}
Exemplo n.º 2
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.º 3
0
char			*usr_cmd(int fd, t_history *histo, t_options options)
{
  struct termios	set;
  struct termios	unset;
  char			*str;
  char			*cmd;
  int			rev_c;
  int			histo_pl;

  (void)options;
  if (init_termios(&set, &unset) == -1 ||
      init_values(&histo_pl, &rev_c, &str, &cmd) == -1)
    return (unset_termios(&unset));
  show_cmd(str[0], fd, cmd, rev_c);
  while (str[0] != 10 || str[1] != 0 || str[2] != 0)
    {
      if (read_cmd(fd, &str, &cmd, &rev_c) == -1)
	return (unset_termios(&unset));
      if (histo_pl < length_of_history(histo) && chk_str(str, 27, 91, 65) == 0)
	if (take_cmd_from_history(++histo_pl, &rev_c, &cmd, histo) == -1)
	  return (unset_termios(&unset));
      if (histo_pl > 0 && chk_str(str, 27, 91, 66) == 0)
	if (take_cmd_from_history(--histo_pl, &rev_c, &cmd, histo) == -1)
	  return (unset_termios(&unset));
      show_cmd(str[0], fd, cmd, rev_c);
    }
  return (finish_usr_cmd(cmd, str, unset));
}
Exemplo n.º 4
0
int		main(int argc, char **argv)
{
	t_env	e;

	if (argc == 1)
		exit(0);
	((t_stat *)get_instance())->env = &e;
	if (init_args(argv, &e, argc) == -1)
		return (make_error(&e, "Error initializing arguments\n"));
	if (init_termios(&e) == -1)
		return (make_error(&e, "Error initializing terminal\n"));
	if (init_select(&e) == -1)
		return (make_error(&e, "Configuration error\n"));
}
Exemplo n.º 5
0
int main(int ac, char **av, char **env)
{
	struct winsize win;
	struct termios term;

	if (ac <= 1)
		return 0;
	(void)env;
	(void)ac;
	(void)av;
	init_termios(&term);
	ioctl(0, TIOCGWINSZ, &win);
	// if (!*env)
	// 	return (0);
	// while(sig++ < 32)
	// 	signal(sig, func(sig));
	return (0);
}