Ncurses <一>
前言: 最好的ncurses教程是 ncurses HOWTO,网上有中文版
编译ncurses引用的程序,需要加编译参数 -lncurses
并在.c文件中包含 ncurses.h头文件
1. 启动ncurses
initscr(); 结束ncurse
endwin();
2. 判断是否支持彩色
has_color();
3. 进入无缓存模式
raw();
noecho();
4. 获取输入键值
getch();
例子:
/** @file engine.c
* created by xx, 2013-09-25
*
* Definition of ncurses related functions
*
* This file presents ncurses implements functions of game's
* graphics
*/ #include <ncurses.h>
#include "engine.h" /** @function engine_init
*
* This function init ncurses configurations
*/ void engine_init()
{
//if(isColorEnabled() == TRUE)
//{
// console support color mode
// do something when it support color
//} //start ncurse
int ch=0;
initscr();
raw();
noecho();
printw("hello!\n");
refresh(); while( (ch=getch()) != '\n' )
{
addch(ch);
refresh();
}
} static int isColorEnabled()
{
return has_colors();
} /** @function engine_shut
* This function will shutdown mcurse
*/ void engine_shut()
{
endwin();
}
6. 判断当前console是否满足最小窗口大小
int win_row=0;
int win_col=0;
getmaxyx(stdscr, win_row, win_col); if(win_row < MIN_ROW || win_col < MIN_COL)
{
game_abort("YOUR CONSOLE IS SMALLER THAN MIN WINDOW THE GAME NEEDED!");
}
Ncurses <一>的更多相关文章
- ncurses库的一些函数
为了实现一个简单的聊天程序,如果使用普通的输入输出函数,会很凌乱.so,便想着能不能用下 ncurses这个字符图形库 总结一下,就是这样. 使用ncurses时,先需要初始化窗口,程序结束时,主动调 ...
- Linux编译内核提示'make menuconfig' requires the ncurses libraries错误
原来使用的ubuntu 11.10系统由于误操作,导致系统崩溃,重新安装了ubuntu 11.10: 在编译内核的时候,提示如下错误: dingq@wd-u1110:~/hwsvn/2sw/1prj_ ...
- Unable to find the ncurses libraries or the required header files解决
问题: 解决方法: sudo apt-get install ncurses-dev 参考:Unable to find the ncurses libraries or the required h ...
- 基于文本图形(ncurses)的文本搜索工具 ncgrep
背景 作为一个VIM党,日常工作开发中,会经常利用grep进行关键词搜索,以快速定位到文件.如图: 利用grep进行文本搜索 但是,这一过程会有两个效率问题: 展示的结果无法进行直接交互,需要手动粘贴 ...
- Unable to find the ncurses libraries的解决办法
我们在更新CentOS或者Ubuntu的内核时,执行make menuconfig可能看如这样的错误: *** Unable to find the ncurses libraries or the* ...
- 编译linux内核前用make menuconfig设置时 Unable to find the ncurses ibraries的解决办法
今天在更新CentOS或者Ubuntu的内核时,执行make menuconfig可能看如这样的错误: *** Unable to find the ncurses libraries or the ...
- Ubuntu18.04下make menuconfig缺少ncurses库
kent@hu:~/work/03-kernel/linux-4.15.1$ make menuconfig *** Unable to find the ncurses libraries or t ...
- Ncurses - Panel
当你需要创建许多窗口时,你很快就会发现它们会变得难以管理.Panel library提供了很好的解决方案. Panel 实际上是一个窗口,通过容器 - 栈 来管理,栈顶的 panel 是完全可见的,其 ...
- EasyARM-iMX283A的make menuconfig出现错误:Install ncurses(ncurses-devel) and try again。
lin@lin-machine:~/linux-2.6.35.3$ make menuconfig *** Unable to find the ncurses libraries or the ** ...
随机推荐
- 多次读取请求request里数据
如果请求是GET方法,可以直接通过getParameter(String param)方法读取指定参数,可读取多次: 而POST方法的参数是存储在输入流中,只能读一次,不能多次读取. 有时需要在fil ...
- 关于开发环境 git 重新部署
apps 开发机器 多次因为升级出现无法登陆 下面就重新部署 流程做笔记 1 备份 根目录下的 那一堆shell 和 Cache/data 下的系统配置 2 shell : su www ...
- linux诡异的半连接(SYN_RECV)队列长度
linux诡异的半连接(SYN_RECV)队列长度(一) >>转载请注明来源:飘零的代码 piao2010 ’s blog,谢谢!^_^>>本文链接地址:linux诡异的半连接 ...
- list-style无颜色问题解决,list-style-type无颜色解决
list-style无颜色问题解决,list-style-type无颜色解决 >>>>>>>>>>>>>>>& ...
- 关于EF查询表里的部分字段
这个在项目中用到了,在网上找了一下才找到,留下来以后自已使用. List<UniversalInfo> list =new List<UniversalInfo>(); lis ...
- 表达式:使用API创建表达式树(4)DynamicExpression
DynamicExpression:表示动态操作.这个网上可见的资料少得可怜,但想到MVC和第三方的动态语言能在NET运行.好奇的倒腾了下 先声明两个类(有相同的方法和字段,但不是继承于同一接口的类) ...
- sql查询过程中 update,insert,delete可视化收影响行数
insert into test_tb output inserted.id,inserted.data values('c'),('d') delete from test_tb output de ...
- 用PHP实现一个高效安全的ftp服务器(二)
接前文. 1.实现用户类CUser. 用户的存储采用文本形式,将用户数组进行json编码. 用户文件格式: * array( * 'user1' => array( * 'pass'=>' ...
- linux常用命令之tail
从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件,tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新,使你看到最新的 ...
- 关于cocoapods和swift中使用oc第三方
mac 系统自带ruby,使用cocoapods,直接安装cocoapods就行 终端:$ sudo gem install cocoapods {安装较慢是因为有墙,查看ruby镜像列表:$ gem ...