예제 #1
0
파일: init.c 프로젝트: 42rdavid/42sh
int				init(t_data *data)
{
	char		buf_ent[2048];

	init_tab_keys(data);
	if (tgetent(buf_ent, getenv("TERM")) < 1)
		return (0);
	tcgetattr(0, &data->term);
	init_term(&data->term);
	init_history(data);
	data->cursor = 0;
	data->c_y = 0;
	data->nb_c = 0;
	signal(SIGINT, &signal_action);
	signal(SIGHUP, &signal_action);
	signal(SIGQUIT, &signal_action);
	signal(SIGTTIN, &signal_action);
	signal(SIGTERM, &signal_action);
	signal(SIGTSTP, &signal_action);
	signal(SIGCONT, &signal_action);
	signal(SIGILL, &signal_action);
	signal(SIGABRT, &signal_action);
	signal(SIGBUS, &signal_action);
	signal(SIGSEGV, &signal_action);
	return (1);
}
예제 #2
0
파일: core.c 프로젝트: Wayt/AnciensProjets
void	run(t_params const* params)
{
  int	fd;
  pid_t	master;
  pid_t	ptyfk;
  struct termios	term;

  fd = open(params->file, O_WRONLY | O_CREAT |
      (params->append == 1 ? O_APPEND : O_TRUNC), 0644);
  if (fd == -1)
      xperror();
  ptyfk = my_forkpty(&master, NULL);
  if (ptyfk == -1)
    xperror();
  if (ptyfk == 0)
  {
    dup2_fd(master);
    execl(params->shell, params->shell, NULL);
    exit(0);
  }
  update_win_size(master);
  signal(SIGWINCH, handle_resize);
  remove_block(master, 0);
  init_term(&term);
  printf("Script started, file is %s\n", params->file);
  read_input(ptyfk, master, fd);
  restore_term(&term);
  close(fd);
  printf("Script done, file is %s\n", params->file);
}
예제 #3
0
파일: scan.c 프로젝트: vcourtin/42.sh
char	*ft_seek_symbol(char *buff, t_data *st)
{
	char	stdin[3];
	char	*newbuff;
	int		i;

	ft_bzero(stdin, 3);
	i = 0;
	newbuff = (char *)malloc(sizeof(char));
	newbuff[i] = '\0';
	buff = add_to_tab(buff, '\n', ft_strlen(buff));
	tputs(tgetstr("cr", NULL), 0, ft_outc);
	ft_putstr_fd("\n> ", isatty(1));
	init_term(st);
	while (read(1, &stdin, 3))
	{
		if (stdin[0] == 10)
			return (ft_scan_buff(ft_strjoin(buff, newbuff), st));
		else if (stdin[0] >= 32 && stdin[1] == 0)
			newbuff = func1(st, &i, newbuff, stdin);
		else if (stdin[0] == 27 && stdin[1] == 91)
			i = func2(st, i, newbuff, stdin);
		ft_bzero(stdin, 3);
	}
	return (buff);
}
예제 #4
0
파일: jinxes.c 프로젝트: raedwulf/libjinxes
/* initialise the library and sets up the terminal */
int jx_initialise()
{
	if (!(tty = open("/dev/tty", O_RDWR)))
		return JX_ERR_OPEN_TTY;

	if (init_term()) {
		close(tty);
		return JX_ERR_UNSUPPORTED_TERMINAL;
	}

	if (pipe(winch_fds)) {
		close(tty);
		return JX_ERR_PIPE_TRAP_ERROR;
	}

	struct sigaction sa;
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = 0;
	sa.sa_handler = sigwinch_handler;
	sigaction(SIGWINCH, &sa, 0);

	if (tcgetattr(tty, &old_t))
		return JX_ERR_TERMIOS;

	struct termios t = old_t;
	cfmakeraw(&t);
	t.c_cc[VMIN] = 0;
	t.c_cc[VTIME] = 0;
	if (tcsetattr(tty, TCSAFLUSH, &t))
		return JX_ERR_TERMIOS;

	OUT_index = 0; IN_index = 0;

	BUF_PUTE(OUT, TS_CLEAR_SCREEN);
	BUF_PUTE(OUT, TS_ENTER_CA_MODE);
	BUF_PUTE(OUT, TS_KEYPAD_XMIT);
	BUF_PUTE(OUT, TS_CURSOR_INVISIBLE);
	BUF_DEBUG(OUT);
	BUF_FLUSH(OUT);

	/* TODO: check if this is needed */
	int ret;
	sigwinch_handler(0);
	read(winch_fds[0], &ret, sizeof(int));
	read(winch_fds[0], &t_columns, sizeof(unsigned short));
	read(winch_fds[0], &t_lines, sizeof(unsigned short));

	if (ret == -1)
		return JX_ERR_IOCTL;

	/* create first window for the screen */
	window_head = window_tail = calloc(sizeof(jx_window), 1);
	window_head->w = t_columns;
	window_head->h = t_lines;
	window_head->flags = JX_WF_AUTOSIZE | JX_WF_AUTOSIZE;

	initialised = true;

	return JX_SUCCESS;
}
예제 #5
0
파일: game.c 프로젝트: Ragnahr/Allum1
void			my_game(t_game *game)
{
  struct termios	termios;
  t_term		*term;

  game->x = 0;
  game->y = 0;
  term = malloc(sizeof(*term));
  init_term(term);
  set_getattr(term->fo, &termios);
  my_refresh(game, term);
  while ((game->fileread = read(0, game->buffer, 6)))
    {
      if (game->player1 == 1)
	my_keys(game, &termios, term);
      else if (game->player2 == 1)
	my_keys(game, &termios, term);
      if (game->buffer[0] == 10)
        my_enter(game);
      if (game->buffer[0] == 27 && game->fileread == 1)
        my_esc(term, &termios);
      my_refresh(game, term);
    }
  termios.c_lflag |= (ICANON | ECHO);
  tcsetattr(term->fo, TCSADRAIN, &termios);
}
예제 #6
0
int			termcaps(t_llist *env, t_memory *memo, int len, t_win *win)
{
	struct termios		term;
	int					code;

	init_term(&term, env, win, len);
	while (win->buffer[0] != RETURN)
	{
		ft_bzero(win->buffer, 4);
		read(0, win->buffer, 4);
		if (win->buffer[0] == CTRL_D)
			termcaps_exit("close", &term);
		if ((ft_isalnum(win->buffer[0])) == 1 || (my_ctrl(win->buffer[0])) == 1)
		{
			memo->line = push_line(win->buffer[0], memo->line, win);
			ft_putchar(win->buffer[0]);
		}
		else if ((code = termc_ctrl(memo->line, win, env, memo)) > 0)
			memo->line = parsing_term(code, memo->line, win);
	}
	if (memo->c_t_r + RETURN == TAB + RETURN)
		tabulation(memo->line, win);
	bring_back_shell(&term);
	win->pos[1]++;
	return (0);
}
예제 #7
0
int		main(int ac, char **av)
{
	t_list	*list;
	t_list	*current;
	int		i;

	i = 1;
	list = NULL;
	init_term();
	if (ac > 1)
	{
		while (av[i] != 0)
		{
			ft_new_elem(&list, av[i]);
			i++;
		}
		current = list;
		print_list(list, current);
		while (42)
			read_button(&list, &current);
	}
	else
		ft_putendl_fd("Too few arguments", 2);
	return (0);
}
예제 #8
0
파일: main.c 프로젝트: Etienne-Breda/school
int			main(int argc, char **argv)
{
  struct termios	oldline;
  t_area		ar;

  if (argc > 1)
    {
      non_canonical_mode(&oldline);
      init_term(&ar, argv, argc);
      display_arguments(&ar);
      while ((ar.len = read(0, ar.buff, sizeof(ar.buff))))
	{
	  x_read(ar.len);
	  init_lines(&ar, &oldline);
	  check_ctrl(&ar);
	  check_keys(&ar, ar.len);
	  check_select(&ar);
	  if (my_exit(&oldline, &ar) == 1 || void_exit(&ar, &oldline) == 1)
	    return (EXIT_SUCCESS);
	}
      restore_mode(&oldline, &ar);
      free_struct(&ar);
    }
  else
    my_put_error(ERR_ARGV);
  return (EXIT_SUCCESS);
}
예제 #9
0
파일: main.c 프로젝트: Arigowin/ft_select
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);
}
예제 #10
0
int main(int argc, char* argv[]) {
  int ch;
  int i = 0;
  int f_flag = 0;
  char *filename = "data";
  ToxWindow* a;

    for(i = 0; i < argc; i++) {
        if(argv[i][0] == '-') {
            if(argv[i][1] == 'f') {
                if(argv[i + 1] != NULL)
                    filename = argv[i + 1];
                else {
                    f_flag = -1;
                }
            }
        }
    }

  init_term();
  init_tox();
  load_data(filename);
  init_windows();

  if(f_flag == -1) {
    attron(COLOR_PAIR(3) | A_BOLD);
    wprintw(prompt->window, "You passed '-f' without giving an argument!\n"
                            "defaulting to 'data' for a keyfile...\n");
    attroff(COLOR_PAIR(3) | A_BOLD);
  }
    

  while(true) {
    // Update tox.
    do_tox();

    // Draw.
    a = &windows[w_active];
    prepare_window(a->window);
    a->blink = false;
    draw_bar();
    a->onDraw(a);

    // Handle input.
    ch = getch();
    if(ch == '\t') {
      w_active = (w_active + 1) % w_num;
    }
    else if(ch == KEY_BTAB) {
      w_active = (w_active + w_num - 1) % w_num;
    }
    else if(ch != ERR) {
      a->onKey(a, ch);
    }

  }

  return 0;
}
예제 #11
0
파일: conunix.cpp 프로젝트: cunhalima/cgcam
bool Syscon_Init()
{
    input_on = true;
    init_term();
    set_raw(false);
    con_redirectOutput(Syscon_Print);
    return true;
}
예제 #12
0
파일: termcap.c 프로젝트: Jaharmi/zsh
static int
bin_echotc(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
{
    char *s, buf[2048], *t, *u;
    int num, argct;

    s = *argv++;
    if (termflags & TERM_BAD)
	return 1;
    if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
	return 1;
    /* if the specified termcap has a numeric value, display it */
    if ((num = tgetnum(s)) != -1) {
	printf("%d\n", num);
	return 0;
    }
    /* if the specified termcap is boolean, and set, say so  */
    switch (ztgetflag(s)) {
    case -1:
	break;
    case 0:
	puts("no");
	return 0;
    default:
	puts("yes");
	return 0;
    }
    /* get a string-type capability */
    u = buf;
    t = tgetstr(s, &u);
    if (t == (char *)-1 || !t || !*t) {
	/* capability doesn't exist, or (if boolean) is off */
	zwarnnam(name, "no such capability: %s", s);
	return 1;
    }
    /* count the number of arguments required */
    for (argct = 0, u = t; *u; u++)
	if (*u == '%') {
	    if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' ||
		      *u == '+'))
		argct++;
	}
    /* check that the number of arguments provided is correct */
    if (arrlen(argv) != argct) {
	zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" :
		 "too many arguments");
	return 1;
    }
    /* output string, through the proper termcap functions */
    if (!argct)
	tputs(t, 1, putraw);
    else {
	/* This assumes arguments of <lines> <columns> for cap 'cm' */
	num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
	tputs(tgoto(t, num, atoi(*argv)), 1, putraw);
    }
    return 0;
}
예제 #13
0
void af_unix_connection(void *xxx)
{
	socklen_t l = s_unix_l;
	int ns;
	memset(s_unix_acc, 0, l);
	ns = accept(s_unix_fd, (struct sockaddr *)s_unix_acc, &l);
	if (ns == -1) return;
	init_term(ns, ns, win_func);
	set_highpri();
}
예제 #14
0
static HashNode
gettermcap(UNUSED(HashTable ht), char *name)
{
    int len, num;
    char *tcstr, buf[2048], *u;
    Param pm = NULL;

    /* This depends on the termcap stuff in init.c */
    if (termflags & TERM_BAD)
	return NULL;
    if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
	return NULL;

    unmetafy(name, &len);

    pm = (Param) hcalloc(sizeof(struct param));
    pm->nam = dupstring(name);
    pm->flags = PM_READONLY;
    u = buf;

    /* logic in the following cascade copied from echotc, above */

    if ((num = tgetnum(name)) != -1) {
	pm->gsu.i = &nullsetinteger_gsu;
	pm->u.val = num;
	pm->flags |= PM_INTEGER;
	return (HashNode) pm;
    }

    pm->gsu.s = &nullsetscalar_gsu;
    switch (ztgetflag(name)) {
    case -1:
	break;
    case 0:
	pm->u.str = dupstring("no");
	pm->flags |= PM_SCALAR;
	return (HashNode) pm;
    default:
	pm->u.str = dupstring("yes");
	pm->flags |= PM_SCALAR;
	return (HashNode) pm;
    }
    if ((tcstr = (char*)tgetstr(name, &u)) != NULL && tcstr != (char *)-1)
    {
	pm->u.str = dupstring(tcstr);
	pm->flags |= PM_SCALAR;
    }
    else
    {
	/* zwarn("no such capability: %s", name, 0); */
	pm->u.str = dupstring("");
	pm->flags |= PM_UNSET;
    }
    return (HashNode) pm;
}
예제 #15
0
파일: termbox.c 프로젝트: nsf/termbox
int tb_init_fd(int inout_)
{
	inout = inout_;
	if (inout == -1) {
		return TB_EFAILED_TO_OPEN_TTY;
	}

	if (init_term() < 0) {
		close(inout);
		return TB_EUNSUPPORTED_TERMINAL;
	}

	if (pipe(winch_fds) < 0) {
		close(inout);
		return TB_EPIPE_TRAP_ERROR;
	}

	struct sigaction sa;
	memset(&sa, 0, sizeof(sa));
	sa.sa_handler = sigwinch_handler;
	sa.sa_flags = 0;
	sigaction(SIGWINCH, &sa, 0);

	tcgetattr(inout, &orig_tios);

	struct termios tios;
	memcpy(&tios, &orig_tios, sizeof(tios));

	tios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
                           | INLCR | IGNCR | ICRNL | IXON);
	tios.c_oflag &= ~OPOST;
	tios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
	tios.c_cflag &= ~(CSIZE | PARENB);
	tios.c_cflag |= CS8;
	tios.c_cc[VMIN] = 0;
	tios.c_cc[VTIME] = 0;
	tcsetattr(inout, TCSAFLUSH, &tios);

	bytebuffer_init(&input_buffer, 128);
	bytebuffer_init(&output_buffer, 32 * 1024);

	bytebuffer_puts(&output_buffer, funcs[T_ENTER_CA]);
	bytebuffer_puts(&output_buffer, funcs[T_ENTER_KEYPAD]);
	bytebuffer_puts(&output_buffer, funcs[T_HIDE_CURSOR]);
	send_clear();

	update_term_size();
	cellbuf_init(&back_buffer, termw, termh);
	cellbuf_init(&front_buffer, termw, termh);
	cellbuf_clear(&back_buffer);
	cellbuf_clear(&front_buffer);

	return 0;
}
예제 #16
0
int main(int argc, char *argv[])
{
  int ch;
  int f_flag = 0;
  char *filename = "data";
  ToxWindow* a;

  int i = 0;
  for (i = 0; i < argc; ++i) {
    if (argv[i] == NULL)
      break;
    else if (argv[i][0] == '-') {
      if (argv[i][1] == 'f') {
        if (argv[i + 1] != NULL)
          filename = argv[i + 1];
        else
          f_flag = -1;
      }
    }
  }

  init_term();
  init_tox();
  load_data(filename);
  init_windows();
  init_window_status();

  if (f_flag == -1) {
    attron(COLOR_PAIR(3) | A_BOLD);
    wprintw(prompt->window, "You passed '-f' without giving an argument!\n"
                            "defaulting to 'data' for a keyfile...\n");
    attroff(COLOR_PAIR(3) | A_BOLD);
  }
  
  while(true) {
    /* Update tox */
    do_tox();

    /* Draw */
    a = &windows[active_window];
    prepare_window(a->window);
    a->blink = false;
    draw_bar();
    a->onDraw(a);

    /* Handle input */
    ch = getch();
    if (ch == '\t' || ch == KEY_BTAB)
      set_active_window(ch);
    else if (ch != ERR)
      a->onKey(a, ch);
  }
  return 0;
}
예제 #17
0
파일: nterm.c 프로젝트: Firewiz/nterm
int main(int argc, char ** argv) {
  init_x();
  init_term();
  pthread_t thread_term, thread_gui;
  pthread_create(&thread_gui, NULL, x_main_loop, NULL);
  pthread_create(&thread_term, NULL, term_main_loop, NULL);
  pthread_join(thread_gui, NULL);
  pthread_cancel(thread_term);
  close_term();
  close_x();
}
예제 #18
0
파일: prog.c 프로젝트: bignolles/ft_select
static int	*init_prog(struct termios *term, t_list *list, int max, int **coord)
{
	int		*index;

	tcgetattr(0, term);
	init_term(*term);
	index = init_index(max);
	*coord = print_list(list, index[0]);
	init_signal();
	return (index);
}
예제 #19
0
파일: main.c 프로젝트: Bth8/Dionysus
void kmain(uint32_t magic, multiboot_info_t *mboot, uintptr_t ebp) {
	monitor_clear();

	printf("Booting Dionysus!\n");

	ASSERT(magic == MULTIBOOT_BOOTLOADER_MAGIC && "Not booted with multiboot.");
	ASSERT(mboot->flags & MULTIBOOT_INFO_MEMORY && "No memory info.");
	ASSERT(mboot->flags & MULTIBOOT_INFO_MEM_MAP && "No memory map.");

	printf("Initializing GDT\n");
	init_gdt();

	printf("Initializing IDT\n");
	init_idt();

	// Check for modules
	if (mboot->flags & MULTIBOOT_INFO_MODS && mboot->mods_count) {
		multiboot_module_t *mods = (multiboot_module_t *)mboot->mods_addr;
		placement_address = mods[mboot->mods_count - 1].mod_end + KERNEL_BASE;
	}

	printf("Setting up paging\n");
	init_paging(mboot->mem_lower + mboot->mem_upper, mboot->mmap_addr,
		mboot->mmap_length);

	printf("Initializing timers\n");
	init_time();
	init_timer();

	printf("Starting task scheduling\n");
	init_tasking(ebp);
	init_syscalls();

	printf("Initializing vfs\n");
	init_vfs();

	printf("Initializing driver subsystem\n");
	init_blockdev();

	init_chardev();
	init_term();

	printf("Enumerating PCI bus(ses)\n");
	init_pci();
	dump_pci();

	init_devfs();
	ASSERT(mount(NULL, "/dev", "devfs", 0) == 0);

	init_ide();

	halt();
}
예제 #20
0
파일: termbox.c 프로젝트: rofl0r/termbox
int tb_init(void)
{
	out = open("/dev/tty", O_WRONLY);
	in = fopen("/dev/tty", "r");

	if (out == -1 || !in)
		return TB_EFAILED_TO_OPEN_TTY;

	out_fileno = out;
	in_fileno = fileno(in);

	if (init_term() < 0)
		return TB_EUNSUPPORTED_TERMINAL;

	if (pipe(winch_fds) < 0)
		return TB_EPIPE_TRAP_ERROR;

	struct sigaction sa;
	sa.sa_handler = sigwinch_handler;
	sa.sa_flags = 0;
	sigaction(SIGWINCH, &sa, 0);

	tcgetattr(out_fileno, &orig_tios);

	struct termios tios;
	memcpy(&tios, &orig_tios, sizeof(tios));

	tios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
                           | INLCR | IGNCR | ICRNL | IXON);
	tios.c_oflag &= ~OPOST;
	tios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
	tios.c_cflag &= ~(CSIZE | PARENB);
	tios.c_cflag |= CS8;
	tios.c_cc[VMIN] = 0;
	tios.c_cc[VTIME] = 0;
	tcsetattr(out_fileno, TCSAFLUSH, &tios);
	
	memstream_init(&write_buffer, out_fileno, write_buffer_data, sizeof(write_buffer_data));

	memstream_puts(&write_buffer, funcs[T_ENTER_CA]);
	memstream_puts(&write_buffer, funcs[T_ENTER_KEYPAD]);
	memstream_puts(&write_buffer, funcs[T_HIDE_CURSOR]);
	send_clear();

	update_term_size();
	cellbuf_init(&back_buffer, termw, termh);
	cellbuf_init(&front_buffer, termw, termh);
	cellbuf_clear(&back_buffer);
	cellbuf_clear(&front_buffer);
	init_ringbuffer(&inbuf, 4096);

	return 0;
}
예제 #21
0
void		move_bot(t_select **begin_list)
{
	t_select *tmp;

	tmp = *begin_list;
	while (tmp->hover == 0)
		tmp = tmp->next;
	tmp->hover = 0;
	tmp = tmp->next;
	tmp->hover = 1;
	init_term(0);
}
예제 #22
0
파일: file.c 프로젝트: Munix-Project/micro
file_t * create_file(char * where, char * filename) {
	file_t * file = malloc(sizeof(file_t));
	file->term = init_term();
	file->buff = init_buff();
	file->modbuff = init_buff();
	file->rend = init_renderer();
	file->path = where;
	file->filename = filename;
	file->size = 0;
	file->is_modal = 0;

	init_keys();
	init_func(file);
	return file;
}
예제 #23
0
파일: main.c 프로젝트: ebichu/dd-wrt
int attach_terminal(int in, int out, int ctl, void *info, int len)
{
	struct terminal *term;
	fcntl(terminal_pipe[0], F_SETFL, O_NONBLOCK);
	fcntl(terminal_pipe[1], F_SETFL, O_NONBLOCK);
	handle_trm(in, out, out, terminal_pipe[1], ctl, info, len);
	mem_free(info);
	if ((term = init_term(terminal_pipe[0], out, win_func))) {
		handle_basic_signals(term);	/* OK, this is race condition, but it must be so; GPM installs it's own buggy TSTP handler */
		return terminal_pipe[1];
	}
	close(terminal_pipe[0]);
	close(terminal_pipe[1]);
	return -1;
}
예제 #24
0
파일: Main.cpp 프로젝트: KevinRoeschke/CIDE
/*static*/
int Main::main(void)
{
	init_term();

    printf("\nEDBMS Start");

	pM = &m;

	InitEndian();

	m.execute();

    printf("\nEDBMS Stop");

    return 0;
}
예제 #25
0
int						env_sw(void)
{
	static int				i = 0;
	static struct termios	*term;
	static struct termios	*reset;
	char					*term_name;

	term_name = getenv("TERM");
	if (!term)
		if (!(init_term(&term, &reset)))
			return (0);
	if (!(set_env(term, reset, term_name, i)))
		return (0);
	i = i ^ 1;
	return (1);
}
예제 #26
0
파일: read_key.c 프로젝트: Strade288/42
int main(int ac, char **av)
{
	char        buff[6] = {0};
	t_term_data data;
	int			j;

	init_term(data);
	while (!(buff[0] == 27 && buff[1] == 0 && buff[2] == 0))
	{
		bzero(buff, 6);
		read(0, buff, 6);
		for (j = 0; j < 6; j++)
			printf("%x\n", buff[j]);
	}
	return (0);
}
예제 #27
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);
}
예제 #28
0
파일: main.c 프로젝트: engine12/links
int attach_terminal(int in, int out, int ctl, void *info, int len)
{
	struct terminal *term;
	int rs;
	set_nonblock(terminal_pipe[0]);
	set_nonblock(terminal_pipe[1]);
	handle_trm(in, out, out, terminal_pipe[1], ctl, info, len);
	mem_free(info);
	if ((term = init_term(terminal_pipe[0], out, win_func))) {
		handle_basic_signals(term);	/* OK, this is race condition, but it must be so; GPM installs it's own buggy TSTP handler */
		return terminal_pipe[1];
	}
	EINTRLOOP(rs, close(terminal_pipe[0]));
	EINTRLOOP(rs, close(terminal_pipe[1]));
	return -1;
}
예제 #29
0
void		selected(t_select **begin_list)
{
	t_select *tmp;

	tmp = *begin_list;
	while (tmp->hover == 0)
		tmp = tmp->next;
	tmp->hover = 0;
	if (tmp->selected == 1)
		tmp->selected = 0;
	else
		tmp->selected = 1;
	tmp = tmp->next;
	tmp->hover = 1;
	init_term(0);
}
예제 #30
0
void		move_top(t_select **begin_list)
{
	t_select *tmp;
	t_select *tmp2;

	tmp = *begin_list;
	tmp2 = *begin_list;
	tmp = tmp->next;
	while (tmp->hover == 0)
	{
		tmp = tmp->next;
		tmp2 = tmp2->next;
	}
	tmp->hover = 0;
	tmp2->hover = 1;
	init_term(0);
}