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 ** ...
随机推荐
- cocos2d&cocos2dx学习资源
汇总一下自己学习Cocos2d和cocos2dx认为比較好的一些资源: 书籍: <iPhone&iPad cocos2d游戏开发实战> Steffen Itterheim < ...
- 颜色渐变的RGB计算
均匀渐变 渐变(Gradient)是美学中一条重要的形式美法则,与其相对应的是突变.形状.大小.位置.方向.色彩等视觉因素都可以进行渐变.在色彩中,色相.明度.纯度也都可以产生渐变效果,并会表现出具有 ...
- android 35 ListView增删改差
MainActivity package com.sxt.day05_11; import java.util.ArrayList; import java.util.List; import and ...
- MAC 环境下 初始化新的mysql root 密码
mac 环境下初始化mysql的root密码 关掉mysql服务,打开系统设置最后的mysql,然后将mysql先关掉 生成一个文件命名mysql-init,文件中放入:一句话,这句话不同版本不一样, ...
- javascript新的原生态API
以下是最新的w3c标准的javascript,目前支持运行在firefox, chrome,IE9以上版本的浏览器 参考资料:https://developer.mozilla.org/ru/docs ...
- 10.23 noip模拟试题
尼玛蛋pdf好难粘 直接写了 T1 /*开始写wa了 我真弱2333 关于p的排序规则不只是差值 为了字典序最小 还要拍别的*/ #include<cstdio> #include< ...
- 每次打开VS2010都会报“ devenv.exe -Assert Failure”这个错误
把.net framework4.5中文包卸载掉,, 如果还不行就把.net framework4.5也卸载掉,,然后到微软官网下载net framework4.5安装包安装,安装完后把中文包卸载掉就 ...
- 【css面试题】三个DIV要求水平对齐,左右两个DIV宽度固定为100px,中间那个DIV充满剩余的宽度(至少2种方法)
这是我在一家公司面试时遇到的问题,当时没有答上来!! 所以看到的小伙伴一定要注意了!! 变化浏览器宽度可看到效果: 左 右 中 然后我们来看看代码: 第一种方法:(浮动) <style type ...
- 开源的Android开发框架-------PowerFramework使用心得(五)网络请求HTTPRequest
GET请求示例 //所有参数都使用Bundle,用putString Bundle bundle = new Bundle(); bundle.putString("username&quo ...
- (ternary operator)三元运算符.
ternary operator: advantage: make a terse simple conditional assignment statement of if-then-else. d ...