コード例 #1
0
ファイル: window.c プロジェクト: GabrielPora/ft_select
void		window_resize(t_select *sl)
{
	struct winsize ws;

	sl->max_col = get_column(sl->argc, &ws);
	sl->max_row = ws.ws_row;
	sl->col_len = ws.ws_col;
	sl->lc = get_list(sl->argc, sl->lt, sl->max_row, sl->max_col);
	free(sl->sp);
	sl->sp = (int*)malloc(sizeof(int) * sl->max_col + 1);
	get_sp(sl);
	last_col(*sl, &(sl->l_row), &(sl->l_col));
	sl->enable = check_window_size(*sl);
}
コード例 #2
0
ファイル: list.c プロジェクト: GabrielPora/ft_select
t_select		init_list(int argc, char **argv)
{
	t_select		list;
	struct winsize	ws;

	if ((list.max_col = get_column(argc, &ws)) == 0)
	{
		list.lc = NULL;
		return (list);
	}
	list.max_row = ws.ws_row;
	list.col_len = ws.ws_col;
	list.argc = argc;
	list.lt = get_tab(argc, argv);
	list.lc = get_list(argc, list.lt, list.max_row, list.max_col);
	list.sp = (int*)malloc(sizeof(int) * list.max_col + 1);
	list.fd_tty = open("/dev/tty", O_RDWR);
	get_sp(&list);
	list.enable = check_window_size(list);
	last_col(list, &list.l_row, &list.l_col);
	return (list);
}
コード例 #3
0
ファイル: key_handle.c プロジェクト: agadiffe/ft_select
void			handle_key(t_elem **list, struct termios *backup)
{
	char	*buf;
	int		update_screen;
	int		*enought_space;

	buf = ft_strnew(4);
	update_screen = 1;
	enought_space = get_enought_space();
	while (!is_esc(buf))
	{
		*enought_space = check_window_size(*list);
		if (update_screen && *enought_space)
			print_arg_list(*list);
		ft_bzero(buf, ft_strlen(buf));
		if (read(0, buf, 3) == -1)
			ft_error("Read error", 1);
		if (*enought_space
				&& (update_screen = check_key(list, backup, buf)) == -1)
			break ;
	}
	ft_strdel(&buf);
}
コード例 #4
0
ファイル: key_handle.c プロジェクト: agadiffe/ft_select
static int		handle_del(t_elem **list)
{
	t_elem	*tmp;
	int		nbr_elem;
	int		current_max_len;

	current_max_len = list_get_max_len(*list);
	nbr_elem = (*list)->prev->pos_list;
	if (nbr_elem == 1)
		return (1);
	tmp = get_current_elem(*list);
	if (tmp->pos_list == 1)
		(*list) = (*list)->next;
	tmp->prev->next = tmp->next;
	tmp->next->prev = tmp->prev;
	tmp->next->cursor = 1;
	list_update_pos(*list, tmp->pos_list);
	if (current_max_len != list_get_max_len(*list))
		check_window_size(*list);
	ft_memdel((void **)&tmp);
	clear_all_screen();
	return (0);
}
コード例 #5
0
ファイル: ed.inputl.c プロジェクト: Lance0312/tcsh
int
GetNextChar(Char *cp)
{
    int num_read;
    int     tried = 0;
    char cbuf[MB_LEN_MAX];
    size_t cbp;

    if (haveungetchar) {
	haveungetchar = 0;
	*cp = ungetchar;
	return 1;
    }
    for (;;) {
	if (MacroLvl < 0) {
	    if (!Load_input_line())
		break;
	}
	if (*KeyMacro[MacroLvl] == 0) {
	    MacroLvl--;
	    continue;
	}
	*cp = *KeyMacro[MacroLvl]++ & CHAR;
	if (*KeyMacro[MacroLvl] == 0) {	/* Needed for QuoteMode On */
	    MacroLvl--;
	}
	return (1);
    }

    if (Rawmode() < 0)		/* make sure the tty is set up correctly */
	return 0;		/* oops: SHIN was closed */

#ifdef WINNT_NATIVE
    __nt_want_vcode = 1;
#endif /* WINNT_NATIVE */
#ifdef SIG_WINDOW
    if (windowchg)
	(void) check_window_size(0);	/* for window systems */
#endif /* SIG_WINDOW */
    cbp = 0;
    for (;;) {
	while ((num_read = xread(SHIN, cbuf + cbp, 1)) == -1) {
	    if (!tried && fixio(SHIN, errno) != -1)
		tried = 1;
	    else {
# ifdef convex
		/* need to print error message in case the file is migrated */
		stderror(ERR_SYSTEM, progname, strerror(errno));
# endif  /* convex */
# ifdef WINNT_NATIVE
		__nt_want_vcode = 0;
# endif /* WINNT_NATIVE */
		*cp = '\0'; /* Loses possible partial character */
		return -1;
	    }
	}
	if (AsciiOnly) {
	    *cp = (unsigned char)*cbuf;
	} else {
	    cbp++;
	    if (normal_mbtowc(cp, cbuf, cbp) == -1) {
		reset_mbtowc();
		if (cbp < MB_CUR_MAX)
		    continue; /* Maybe a partial character */
		/* And drop the following bytes, if any */
		*cp = (unsigned char)*cbuf | INVALID_BYTE;
	    }
	}
	break;
    }
#ifdef WINNT_NATIVE
    /* This is the part that doesn't work with WIDE_STRINGS */
    if (__nt_want_vcode == 2)
	*cp = __nt_vcode;
    __nt_want_vcode = 0;
#endif /* WINNT_NATIVE */
    return num_read;
}