1

I am coding a shell-like in C and I want to implement the line edition functionality, I already implemented the basic of it, now I want to implement ctrl+l which clear the screen then display the prompt and the line I was working on.

I need to use the termcap :

'cm' String to position the cursor at line l, column c.

My question is how to I pass the variable l and c to the termcap ?

Swann
  • 2,413
  • 2
  • 20
  • 28
  • maybe this would help: http://www.gnu.org/software/termutils/manual/termcap-1.3/html_chapter/termcap_2.html#SEC16 – Greg May 10 '14 at 13:19

2 Answers2

2

Suppose you have the cm capability stored in the term_cm variable. Then you would substitute parameters using the tgoto function:

char *s = tgoto (term_cm, c, l);
tputs (s, 1, putchar);
Gavin Smith
  • 3,076
  • 1
  • 19
  • 25
0

To clear the screen use this :

write(1, tgetstr("cl", 0), strlen(tgetstr("cl", 0)));
Jonsmoke
  • 822
  • 9
  • 18