LinesAffected | Specifies the number of lines affected, or specifies 1 if not applicable. |
PutcLikeSub | Specifies a putchar-like subroutine through which the characters are passed one at a time. |
String | Specifies the string to which to add padding information. |
#include <curses.h>
#include <term.h>
tputs(String, LinesAffected, PutcLikeSub)
char *String;
int LinesAffected;
int (*PutcLikeSub) ();
int main()
{
int nrows, ncolumns;
char *clear;
char *cursor;
setupterm(NULL, fileno(stdout), (int *)0); /*需要设置当前终端*/
nrows = tigetnum("lines"); /*得到当前终端窗口尺寸中的行(可以容纳几行)*/
ncolumns = tigetnum("cols"); /*得到当前终端窗口尺寸中的列(可以容纳几列)*/
printf("This termianl has %d columns and %d rows\\n", ncolumns, nrows);
cursor = tigetstr("cup"); /*得到终端的光标位置转义序列*/
clear = tigetstr("clear"); /*得到终端的清屏动作转义序列*/
tputs(clear, 1, putchar); /*进行清屏*/
tputs(tparm(cursor, 4, 10), 1, putchar); /*需要在4行10列处输出(填充掉之前空间内容<padding information>*/
printf("hello world\\n"); /*在终端窗口的4行10列位置处打印字符串*/
exit(0);
}
hello world
[root@localhost C]#
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |