I am currently learning the Termcaps Library
and i want to underline a line.
My problem, when i do it, my character becomes a C
. Does someone have an idea why ?
I compiled with -lcurses
This is how I initialized my termcaps :
void init_termcaps(t_env *e)
{
char *name_term;
int ierror[2];
name_term = getenv("TERM");
ierror[0] = tgetent(NULL, name_term);
ierror[1] = tcgetattr(0, &e->term);
print_termcaps_error(ierror);
e->term.c_lflag &= ~(ECHO | ICANON);
e->term.c_cc[VMIN] = 1;
e->term.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSANOW, &e->term) == -1)
ft_printexit("ERROR init termcaps\n", 1);
else
ft_putendl("termcaps init done.");
}
and this is how I underlined :
void underline_line(t_llist *tmp)
{
int i;
i = 0;
tputs(ft_tgetstr("us"), AFFCNT, ft_iputchar);
while (CONTENT->word[i])
{
tputs(ft_tgetstr("kr"), AFFCNT, ft_iputchar);
i++;
}
tputs(ft_tgetstr("ue"), AFFCNT, ft_iputchar);
while (i-- >= 0)
tputs(ft_tgetstr("le"), AFFCNT, ft_iputchar);
}