Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在用 C 编写类似 shell 的代码,我想实现行编辑功能,我已经实现了它的基本功能,现在我想实现 ctrl+l 清除屏幕然后显示提示和我正在处理的行.
我需要使用 termcap :
'cm' 将光标定位在第 l 行 c 列的字符串。
我的问题是如何将变量 l 和 c 传递给 termcap ?
假设您有cm存储在term_cm变量中的能力。tgoto然后,您将使用该函数替换参数:
cm
term_cm
tgoto
char *s = tgoto (term_cm, c, l); tputs (s, 1, putchar);
要清除屏幕,请使用:
write(1, tgetstr("cl", 0), strlen(tgetstr("cl", 0)));