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 ?

soueuls
  • 2,281
  • 2
  • 19
  • 27
  • 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
  • 2,916
  • 18
  • 23
0

To clear the screen use this :

write(1, tgetstr("cl", 0), strlen(tgetstr("cl", 0)));
Jonsmoke
  • 764
  • 7
  • 17