简体   繁体   English

带有参数的Termcap

[英]Termcap with parameters

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. 我正在用C编写类似shell的代码,并且想实现行版功能,我已经实现了它的基本功能,现在我想实现ctrl + l,它可以清除屏幕,然后显示提示和正在处理的行。

I need to use the termcap : 我需要使用termcap:

'cm' String to position the cursor at line l, column c. 'cm'将光标定位在行l,列c的字符串。

My question is how to I pass the variable l and c to the termcap ? 我的问题是如何将变量l和c传递给termcap?

Suppose you have the cm capability stored in the term_cm variable. 假设您具有存储在term_cm变量中的cm功能。 Then you would substitute parameters using the tgoto function: 然后,您可以使用tgoto函数替换参数:

char *s = tgoto (term_cm, c, l);
tputs (s, 1, putchar);

要清除屏幕,请使用以下命令:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM