Termcap with parameters

纵饮孤独 提交于 2019-12-14 03:59:47

问题


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 ?


回答1:


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);



回答2:


To clear the screen use this :

write(1, tgetstr("cl", 0), strlen(tgetstr("cl", 0)));


来源:https://stackoverflow.com/questions/23581397/termcap-with-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!