示例#1
0
文件: main.c 项目: k0ink0in/42sh
void	mysh_param(char **env, t_struct *pile)
{
  int		flag;
  int		n;

  n = 0;
  flag = 0;
  pile->my_env = 0;
  pile->hist = 0;
  pile->save_cd = 0;
  while (env[n] != 0)
    {
      if (env[n] != 0 && my_strncmp(PWD, env[n], 3) == 0)
	catch_pwd(env[n], pile);
      add_elem_to_liste(env[n], &pile->my_env);
      n++;
      if (env[n] != 0)
	flag = 1;
    }
  if (flag == 1)
    while (pile->my_env->prev)
      pile->my_env = pile->my_env->prev;
  pile->home = my_aff_param_list(pile->my_env, HOME);
  init_variable(pile);
  fichier_conf(pile);
  aff_prompt(pile);
}
示例#2
0
static void		sighandler(int signum)
{
  if (signum == SIGINT)
    {
      printf("\n");
      aff_prompt();
    }
}
示例#3
0
void 		my_exit(t_mysh *mysh)
{
  int 		exite;

  exite = (mysh->tab_com[1]) ? check_str(mysh->tab_com[1]) : 0;
  if (comp_str(mysh->tab_com[0], "exit") == 1)
    {
      if (aff_prompt() == 1)
	my_putstr("exit\n");
      free_command(mysh);
      free_struct(mysh);
      exit(exite);
    }
}
示例#4
0
文件: ncurse_2.c 项目: rotarui/42sh
static t_bool	bentor(t_shell *shell, int *i, char *c, char *buff)
{
  if (complete_part(shell, buff, i, c) == FALSE)
    return (FALSE);
  if (g_sigint == 1)
    {
      bzero(buff, sizeof(char) * BUFF_SIZE);
      shell->history_on = FALSE;
      shell->com.on = FALSE;
      aff_prompt(shell);
      g_sigint = 0;
      return (FALSE);
    }
  process_keys(shell, i, c, buff);
  aff_cmd(shell, buff, i);
  return (TRUE);
}
示例#5
0
文件: history.c 项目: atipex/Projets
void	aff_nicely(t_his *tmp, char **cmd, int *i)
{
  int	j;

  j = 0;
  ft_putstr(tgetstr("cb", NULL), 1);
  ft_putstr(tgetstr("ce", NULL), 1);
  ft_putstr(tgoto(tgetstr("ch", NULL), 1, 0), 1);
  aff_prompt();
  if (tmp->var)
    while (tmp->var[j])
      {
	(*cmd)[j] = tmp->var[j];
	j++;
      }
  while (j < g_prompt.size)
    (*cmd)[j++] = '\0';
  ft_putstr(*cmd, 1);
  *i = ft_strlen(*cmd) + 1;
}
示例#6
0
文件: main.c 项目: cohen-h/projects
int			main(int ac, char **av, char **env)
{
  t_system		sys;

  (void)av;
  (void)ac;
  if (signal(SIGINT, &handle_sig) == SIG_ERR)
    return (EXIT_FAILURE);
  if (init_sys(&sys, &sys.history, env) == -1)
    return (EXIT_FAILURE);
  get_sys(&sys);
  process_conf_file(&sys);
  aff_prompt(&sys);
  get_cmd_line(&sys);
  unset_termcaps(&sys);
  free_all(&sys);
  if (sys.exit.exit == true)
    return (sys.exit.value);
  return (EXIT_SUCCESS);
}
示例#7
0
int	auto_completation(char buf[3], char **cmd, int *i, t_data *data)
{
	int		ret;
	int		nbr_words;
	char	*cmd_bloc;

	(void)buf;
	cmd_bloc = gimme_last_cmd_bloc(*cmd);
	nbr_words = gimme_nbr_words(cmd_bloc);
	cmd_bloc = gimme_last_word(cmd_bloc);
	if (nbr_words == 0)
		ret = aff_current_directory();
	else if (nbr_words == 1)
		ret = aff_bin(cmd_bloc, data);
	else
		ret = aff_path(cmd_bloc);
	aff_prompt();
	ft_putstr(*cmd, 1);
	*i = ft_strlen(*cmd) + 1;
	return (ret);
}
示例#8
0
文件: ncurse_2.c 项目: rotarui/42sh
char	*gnl_ncurse(t_shell *shell)
{
  char	buff[BUFF_SIZE + 1];
  int	i[5];
  char	c[RD_SIZE];

  shell->history_on = FALSE;
  bzero(buff, sizeof(char) * BUFF_SIZE);
  write(1, shell->key.nocurs, strlen(shell->key.nocurs));
  bzero(i, sizeof(int) * 4);
  *i = -1;
  i[4] = 1;
  aff_prompt(shell);
  while ((read(STDIN_FILENO, c, RD_SIZE)) > 0 && *c != 4)
    {
      mv_curs(shell, i, buff);
      i[2] = strlen(buff);
      if ((bentor(shell, i, c, buff)) == FALSE)
	break ;
    }
  return (give_it_to_guigui(shell, buff, c));
}