⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test13_1.txt

📁 Linux下的C语言编程
💻 TXT
字号:
#include <stdlib.h>
#include <stdio.h>
#include <term.h>
#include <curses.h>
#define NUMCAPS 3

int main(void)
{
	int j;
	int retval=0;
	char *buf;
	char *boolcaps[NUMCAPS]={"am", "bce", "km"};
	char *numcaps[NUMCAPS]={"cols", "lines", "colors"};
	char *strcaps[NUMCAPS]={"cup", "flash", "hpa"};
	/*初始化terminfo数据结构 */
		
	if(setupterm(NULL,fileno(stdin),NULL)!=OK){
		perror("setupterm( )");
		exit(EXIT_FAILURE);
	}

	for(j=0;j<NUMCAPS;++j){
		retval=tigetflag(boolcaps[j]);
		if(retval==FALSE)
			printf("'%s' unsupported\n",boolcaps[j]);
		else
			printf("'%s' supported\n",boolcaps[j]);
	}
	/*测试终端对am、bce和km三种布尔型能力 */
	fputc('\n',stdout);

	for(j=0;j<NUMCAPS;++j){
		retval=tigetnum(numcaps[j]);
		if(retval==ERR)
			printf("'%s' unsupported\n",numcaps[j]);
		else
			printf("'%s' is %d\n",numcaps[j],retval);
	}
	fputc('\n',stdout);
	/*查询数值型能力 */

	for(j=0;j<NUMCAPS;++j){
		buf=tigetstr(strcaps[j]);
		if(buf=NULL)
			printf("'%s' unsupported\n",strcaps[j]);
		else
			printf("'%s' is %s\n",strcaps[j],buf[0]);
	}
	/*查询字符型能力*/
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -