Пример #1
0
Файл: RT1.C Проект: g8bpq/BPQ32
static void show_topics(void)
{
	TOPIC *topic;
	USER  *user;

	tputs("Topics in the RoundTable are:\n");

	for (topic = topic_hd; topic; topic = topic->next)
	{
		tprintf("%s\n", topic->name);

		if (topic->refcnt)
		{
			tputs("  ");
			for (user = user_hd; user; user = user->next)
				if (user->topic is topic) tprintf(" %s", user->call);
			tputc('\n');
		}
	}
}
Пример #2
0
void help()
{
  tcputs("Availible Commands:\n",COLOR_WHITE);
  NODE* current = &head;
  for (int i = 0; i < numOfCmds; i++)
  {
    tcputs(current->name, COLOR_WHITE);
    tputs("\n");
    current = current->next;  
  }
}
Пример #3
0
void		deal_with_col(t_struct *info)
{
	if (info->nb_item == 0)
	{
		info->coeff += 1;
		info->nb_item = (info->node->length) / info->nb_col;
		if (((info->node->length) % info->nb_col) != 0)
			info->nb_item += 1;
		tputs(tgoto(tgetstr("RI", NULL), 0,
					(info->size_w + 2) * info->coeff), 1, ft_putchar_int);
		tputs(tgoto(tgetstr("UP", NULL), 0, info->nb_item), 1, ft_putchar_int);
	}
	else if (info->coeff > 0)
		tputs(tgoto(tgetstr("RI", NULL), 0,
					(info->size_w + 2) * info->coeff), 1, ft_putchar_int);
	if (info->count <= info->nb_item)
		info->size_last += 1;
	info->nb_item -= 1;
	info->count--;
}
Пример #4
0
void			ft_move_right(int *position, char *str)
{
	if (*position == (int)ft_strlen(str))
	{
		ft_putchar(07);
		return ;
	}
	if (*(str + *position) == '\n')
	{
		tputs(tgetstr("sf", NULL), 1, ft_putchar);
		(*position)++;
	}
	else if (*(str + *position))
	{
		tputs(tgetstr("nd", NULL), 1, ft_putchar);
		(*position)++;
	}
	if ((*position + g_prompt_len + 1) % g_ws.ws_col == 1)
		tputs(tgetstr("sf", NULL), 1, ft_putchar);
}
Пример #5
0
char	*bell_for_tab(char *buff, int j)
{
	if (j >= 2 && ((buff[j - 1] == ' ' && buff[j - 2] != ' ') ||
		(buff[j - 1] == '\t' && buff[j - 2] != '\t')))
		return ("\0");
	else
	{
		tputs(tgetstr("bl", NULL), 0, ft_outc);
		return (NULL);
	}
}
Пример #6
0
void			go_inverse(void)
{
	char		a[2];

	a[0] = ' ';
	a[1] = '\n';
	tputs(tgetstr("mr", NULL), 0, tputs_putchar);
	press_home_key();
	press_printable_char(a);
	press_backspace_key();
}
Пример #7
0
/* Move the cursor to the terminal location of X and Y. */
void
terminal_goto_xy (int x, int y)
{
  if (terminal_goto_xy_hook)
    (*terminal_goto_xy_hook) (x, y);
  else
    {
      if (term_goto)
        tputs (tgoto (term_goto, x, y), 1, output_character_function);
    }
}
Пример #8
0
void		get_winsize()
{
  int		width;
  int		height;

  width = tgetnum("co");
  height = tgetnum("li");
  tputs(tgetstr("cl", NULL), 1, my_putchar);
  if (height < 500 || width < 500)
    my_putstr("Winsize too small !\n");
}
Пример #9
0
void				ft_go_end(int cols)
{
	int				i;

	i = 0;
	while (i < cols - 1)
	{
		tputs(tgetstr("nd", NULL), 1, ft_putput);
		++i;
	}
}
Пример #10
0
/*
 * meta --
 *    Turn on or off the terminal meta mode.
 */
int
meta(/*ARGSUSED*/ WINDOW *win, bool bf)
{
	(void)win;
	if (bf == TRUE) {
		if (meta_on != NULL) {
			tputs(meta_on, 0, __cputchar);
			_cursesi_screen->meta_state = TRUE;
			fflush(_cursesi_screen->outfd);
		}
	} else {
		if (meta_off != NULL) {
			tputs(meta_off, 0, __cputchar);
			_cursesi_screen->meta_state = FALSE;
			fflush(_cursesi_screen->outfd);
		}
	}

	return OK;
}
Пример #11
0
void	ft_key_end(t_cmd_line *line)
{
	int	len;

	len = ft_strlen(line->str);
	while (line->pos < len)
	{
		tputs(tgetstr("nd", NULL), 1, ft_put_term_char);
		++(line->pos);
	}
}
Пример #12
0
void		do_even_more_shit(char **env, char **path)
{
	int			i;
	t_print		*print;
/*	char		**commands;*/

	(void)env;
	(void)path;
	print = (t_print*)malloc(sizeof(t_print));
	print->line = NULL;
	print->histo = NULL;
	while (create_prompt(NULL))
	{
		change_term_info(malloc_struct());
		i = -1;
		wait_and_read(print);
		build_history_list(print);

/* ************************************************************************** */
/*  STRSPLIT SUR LES ; A REMPLACER PAR LE PARSER ? */
/*  LA LIGNE DE COMMANDE EST STOCKEE DANS LA STRUCTURE PRINT : PRINT->LINE */
		/*commands = ft_strsplit(print->line, ';');*/
/* ************************************************************************** */

/**************************************************************************** */
/*  JE FAIS UN STRCMP-exit POUR QUITTER EN ATTENDANT LA GESTION DES BUILTINS  */
/*  CE BLOC DEVRA ETRE SUPPRIME                                               */
		if (ft_strcmp(print->line, "exit") == 0)
		{
			change_back_term_info(NULL);
			exit(-1);
		}
/* ************************************************************************** */

/* ************************************************************************** */
/*  REMISE A ZERO DES PARAMETRES DU SHELL AVANT L'EXECUTION D'UNE COMMANDE    */
		if (print->line != NULL)
			free(print->line);
		FP("\n");
		tputs(tgetstr("ei", NULL), 1, out);
		change_back_term_info(NULL);
/* ************************************************************************** */

/* ************************************************************************** */
/*  EXECUTION DES COMMANDES SEPAREES PAR LES ;                                */
		/*while (++i, commands[i] != NULL)
			start_commands(commands[i], &env, path);
			delete_char_tab_tab(commands);*/
/* ************************************************************************** */

		revers_insert_mode(print);
	}
	free(print);
}
Пример #13
0
Файл: RT1.C Проект: g8bpq/BPQ32
static void show_circuits(void)
{
	CIRCUIT *circuit;
	NODE    *node;
	int     len;

	tprintf("Here %-6.6s <- ", Node->aliass);
	len = 0;

	for (node = node_hd; node; node = node->next) if (node->refcnt)
	{
		len += strlen(node->alias) + 1;
		if (len > 60) { len = strlen(node->alias) + 1; tputs(xxx); }
		tputs(node->alias);
		tputc(' ');
	}

	tputc('\n');

	for (circuit = circuit_hd; circuit; circuit = circuit->next)
	if (circuit->flags & p_linked)
	{
		tprintf("Link %-6.6s <- ", circuit->u.link->alias);
		len = 0;

		for (node = node_hd; node; node = node->next)
		if (node->refcnt && !cn_find(circuit, node))
		{
			len += strlen(node->alias) + 1;
			if (len > 60) { len = strlen(node->alias) + 1; tputs(xxx); }
			tputs(node->alias);
			tputc(' ');
		}

		tputc('\n');
	}
	else if (circuit->flags & p_user)
		tprintf("User %-6.6s\n", circuit->u.user->call);
	else if (circuit->flags & p_linkini)
		tprintf("Link %-6.6s (setup)\n", circuit->u.link->alias);
}
Пример #14
0
t_dlist_node	*ft_select_arg(t_dlist *arg, t_dlist_node *node)
{
	if (node->sel == 1)
	{
		node->sel = 0;
		write(arg->fd, " ", 1);
	}
	else
	{
		node->sel = 1;
		write(arg->fd, "X", 1);
	}
	tputs(tgetstr("le", NULL), 1, ft_putchar);
	ft_underline(arg, node);
	ft_desunderline(arg, node);
	node = node->next;
	tputs(tgoto(tgetstr("cm", NULL), node->pos_x, node->pos_y),
			1, ft_putchar);
	ft_underline(arg, node);
	return (node);
}
Пример #15
0
int		ft_backspace(t_data *d)
{
	char	*tmp;

	if (d->line && d->line->index > 0)
	{
		tmp = ft_strnew(d->line->len);
		ft_strncpy(tmp, d->line->str, d->line->index - 1);
		ft_strcat(tmp, d->line->str + d->line->index);
		ft_strdel(&d->line->str);
		d->line->str = tmp;
		d->line->index--;
		d->line->len--;
		tputs(tgetstr("le", NULL), 1, ft_int_putchar);
		tputs(tgetstr("dm", NULL), 1, ft_int_putchar);
		tputs(tgetstr("dc", NULL), 1, ft_int_putchar);
		tputs(tgetstr("ed", NULL), 1, ft_int_putchar);
	}
	ft_print_list(d);
	return (1);
}
Пример #16
0
/* At the line START, delete COUNT lines from the terminal display. */
static void
terminal_delete_lines (int start, int count)
{
  int lines;

  /* Normalize arguments. */
  if (start < 0)
    start = 0;

  lines = screenheight - start;
  terminal_goto_xy (0, start);
  if (term_DL)
    tputs (tgoto (term_DL, 0, count), lines, output_character_function);
  else
    {
      while (count--)
        tputs (term_dl, lines, output_character_function);
    }

  fflush (stdout);
}
Пример #17
0
int		ft_home(t_data *d)
{
	if (d->line)
	{
		while (d->line->index > 0)
		{
			tputs(tgetstr("le", NULL), 1, ft_int_putchar);
			d->line->index--;
		}
	}
	return (1);
}
Пример #18
0
int
endwin()
{
	__restore_stophandler();

	if (curscr != NULL) {
		if (curscr->flags & __WSTANDOUT) {
			tputs(SE, 0, __cputchar);
			curscr->flags &= ~__WSTANDOUT;
		}
		__mvcur(curscr->cury, curscr->curx, curscr->maxy - 1, 0, 0);
	}

	(void)tputs(VE, 0, __cputchar);
	(void)tputs(TE, 0, __cputchar);
	(void)fflush(stdout);
	(void)setvbuf(stdout, NULL, _IOLBF, 0);

	return (tcsetattr(STDIN_FILENO, __tcaction ?
	    TCSASOFT | TCSADRAIN : TCSADRAIN, &__orig_termios) ? ERR : OK);
}
Пример #19
0
int					tvi(void)
{
	char			*str;

	if ((str = tgetstr("vi", NULL)) == NULL)
	{
		ft_putendl("Cursor invisible mode activated");
		return (-1);
	}
	tputs(str, 1, ft_outc);
	return (0);
}
Пример #20
0
void	knowresize(int sig)
{
	struct winsize	wn;
	t_coor			cr;

	(void)sig;
	tputs(tgetstr("cl", NULL), 1, tputs_putchar);
	ioctl(0, TIOCGWINSZ, &wn);
	cr.y = wn.ws_row;
	cr.x = wn.ws_col;
	ft_print_list(NULL, NULL, &cr);
}
Пример #21
0
void	po_tmcp(t_data *data, t_opt *opt, t_game *game)
{
  int	xi;
  int	yi;

  game->end = 1;
  game->lpoal = opt->size / 2;
  game->lpoar = 0;
  xi = data->x;
  while (game->end != 0)
    {
      yi = data->y;
      tputs(tgetstr("ho", NULL), 1, f_putc);
      tputs(tgetstr("cd", NULL), 1, f_putc);
      aff_pyramide(data, opt);
      aff_promp_2p_cl(data, game, xi, yi);
      tputs(tgoto(tgetstr("cm", NULL), data->x, data->y), 1, f_putc);
      my_printf("◄%d►", game->lpoar);
      po_tmcp_key(data, opt, game);
    }
}
Пример #22
0
void		show_list(t_list *list)
{
  t_list	*tmp;

  tmp = list->next;
  tputs(tgoto(tgetstr("cm", NULL), 0, 0), 1, my_puts);
  while (tmp != list)
    {
      if (tmp->cursor == 1)
	tputs(tgetstr("us", NULL), 0, my_puts);
      if (tmp->selected == 1)
	tputs(tgetstr("mr", NULL), 0, my_puts);
      my_putstr(tmp->str);
      if (tmp->cursor == 1)
	tputs(tgetstr("ue", NULL), 0, my_puts);
      if (tmp->selected == 1)
	tputs(tgetstr("me", NULL), 0, my_puts);
      my_putchar('\n');
      tmp = tmp->next;
    }
}
Пример #23
0
static int			print_one_arg(t_param *buf)
{
	char	*standout;
	char	buf2[30];
	char	*ap;

	ap = buf2;
	if ((buf->select % 2) == 1 && (standout = tgetstr("us", &ap)) != NULL)
		tputs(standout, 1, fputchar);
	if ((buf->select / 2) == 1 && (standout = tgetstr("so", &ap)) != NULL)
		tputs(standout, 1, fputchar);
	get_colors(buf->var);
	ft_dprintf(get_fd(0), "%s\x1b[0;m", buf->var);
	if ((buf->select % 2) == 1 && (standout = tgetstr("ue", &ap)) != NULL)
		tputs(standout, 1, fputchar);
	if ((buf->select / 2) == 1 && (standout = tgetstr("se", &ap)) != NULL)
		tputs(standout, 1, fputchar);
	if ((int)ft_strlen(buf->var) > get_width())
		return (-1);
	return (0);
}
Пример #24
0
void		remove_line(t_print *print)
{
	int		i;

	i = ft_strlen(print->line);
	tputs(tgetstr("dm", NULL), 1, out);
	while (print->pos <= i)
	{
		tputs(tgetstr("nd", NULL), 1, out);
		print->pos += 1;
	}
	while (print->pos > 0)
	{
		tputs(tgetstr("le", NULL), 1, out);
		tputs(tgetstr("dc", NULL), 1, out);
		print->line[print->pos] = '\0';
		print->pos -= 1;
	}
	print->line[print->pos] = '\0';
	tputs(tgetstr("de", NULL), 1, out);
}
Пример #25
0
int	use_termcap(char *cap)
{
  char	*s;

  s = NULL;
  s = tgetstr(cap, NULL);
  if (s == NULL)
    return (EXIT_FAILURE);
  if (tputs(s, 1, &put_c) == -1)
    return (EXIT_FAILURE);
  return (0);
}
Пример #26
0
void
reset_tty(void)
{
	if (no_tty)
		return;
	if (pstate) {
		tputs(ULexit, 1, putch);
		fflush(stdout);
		pstate = 0;
	}
	tcsetattr(STDERR_FILENO, TCSANOW, &otty);
}
Пример #27
0
int		back_to_j(char *buff, int j)
{
	int		i;

	i = ft_strlen(buff) - j;
	while (i > 1)
	{
		tputs(tgetstr("le", NULL), 1, ft_outc);
		i--;
	}
	return (j);
}
Пример #28
0
void		ft_sel_right(t_cmd_line *line)
{
	if (line->pos == (int)ft_strlen(line->str) - 1)
		return ;
	if (!(line->pos + 1 > line->sel_end))
	{
		++line->sel_start;
		ft_putchar(line->str[line->pos]);
		++line->pos;
	}
	else
	{
		++line->sel_end;
		++line->pos;
		tputs(tgetstr("nd", NULL), 1, ft_put_term_char);
		tputs(tgetstr("mr", NULL), 1, ft_put_term_char);
		ft_putchar(line->str[line->pos]);
		tputs(tgetstr("me", NULL), 1, ft_put_term_char);
		tputs(tgetstr("le", NULL), 1, ft_put_term_char);
	}
}
Пример #29
0
void VReopen ()
{
# ifndef MSDOS
	TtySet ();
# ifdef STRINIT
	if (IS)
		tputs (IS);
# endif
	if (TI)
		tputs (TI);
	if (VS)
		tputs (VS);
# ifdef KEYPAD
	if (KS)
		tputs (KS);
# endif
# ifdef SIGTSTP
	signal (SIGTSTP, tstp);
# endif
# endif /* MSDOS */
}
Пример #30
0
/*
 * Print a buffer of n characters.
 */
void
prbuf(char *s, int n)
{
	char c;			/* next output character */
	int state;		/* next output char's UL state */
#define wouldul(s,n)	((n) >= 2 && (((s)[0] == '_' && (s)[1] == '\b') || ((s)[1] == '\b' && (s)[2] == '_')))

	while (--n >= 0) {
		if (!ul_opt)
			putchar(*s++);
		else {
			if (*s == ' ' && pstate == 0 && ulglitch &&
			    wouldul(s + 1, n - 1)) {
				s++;
				continue;
			}
			if ((state = wouldul(s, n))) {
				c = (*s == '_')? s[2] : *s ;
				n -= 2;
				s += 3;
			} else
				c = *s++;
			if (state != pstate) {
				if (c == ' ' && state == 0 && ulglitch &&
				    wouldul(s, n - 1))
					state = 1;
				else
					tputs(state ? ULenter : ULexit, 1, putch);
			}
			if (c != ' ' || pstate == 0 || state != 0 ||
			    ulglitch == 0)
				putchar(c);
			if (state && *chUL) {
				fputs(chBS, stdout);
				tputs(chUL, 1, putch);
			}
			pstate = state;
		}
	}
}