实现类似于shell中按“向上”,“向下”箭头的功能————readline库
2012-04-14 09:58
295 查看
[转载] 正确编译使用readline库
$ gcc readInput.c
readline.c:2: fatal error: readline/readline.h: No such file or directory
compilation terminated.
If you come across this error, you must install readline dev package
$ sudo apt-get install libreadline6 libreadline6-dev
The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands. This function gives the user the default behaviour of TAB completion: completion on file names. If you do not want Readline to complete on filenames, you can change the binding of the TAB key with rl_bind_key(). int rl_bind_key (int key, rl_command_func_t *function); rl_bind_key() takes two arguments: key is the character that you want to bind, and function is the address of the function to call when key is pressed. Binding TAB to rl_insert() makes TAB insert itself. rl_bind_key() returns non-zero if key is not a valid ASCII character code (between 0 and 255). Thus, to disable the default TAB behavior, the following suffices: rl_bind_key ('\t', rl_insert); This code should be executed once at the start of your program; you might write a function called initialize_readline() which performs this and other desired initializations, such as installing custom completers. ------------------------------------------------------------ GNU Readline Offical Site: http://cnswww.cns.cwru.edu/~chet/readline/rltop.html If you want to use GNU Readline library in your program: * 1st, include <readline/readline.h> and <readline/history.h> * 2nd, invoke readline function such as char *readline (const char *prompt); add_history (line); * 3rd, link source file with -lreadline -ltermcap arguments Trackback: http://tb.donews.net/TrackBack.aspx?PostId=71391 |
readline.c:2: fatal error: readline/readline.h: No such file or directory
compilation terminated.
If you come across this error, you must install readline dev package
$ sudo apt-get install libreadline6 libreadline6-dev
相关文章推荐
- jQuery 实现全部到精简的转换 点击“显示全部品牌按钮”显示到第二幅图,个别文字高亮显示,并且“显示全部品牌”按钮文字变为“精简显示品牌”并且向上向下箭头改变,用JQuery实现本功能。
- JQuery实现置顶、置底、向上、向下、取消排序功能
- Jquery EasyUI 实现面板开启、关闭、向上合并、向下打开、最大化、恢复等功能(2)
- 使用PHP+Readline库实现类似于Shell解析命令功能
- Shell中实现类似于结构体/数组功能的脚本
- shell脚本实现ssh自动登录功能分享
- 利用shell + python + expect实现类似xshell功能(测试环境:ubuntu)
- [IMX6Q][Android5.1]移植笔记 --- Recovery mode的shell功能实现(sh+toolbox)
- 让 TreeView 实现向上全选 功能
- 类似于手机qq空间的下拉tableView上面的图片放大的功能的实现
- Android编程实现文件浏览功能的方法【类似于FileDialog的功能】
- ExtJs实现类似于jQuery中live的绑定功能,并且实现多个进行绑定
- 按下按钮后页面的滚动条向下(或向上)滑动,松开之后便停留在当前位置的效果如何实现?
- 基于jquery框架实现以下行的向上、向下和删除
- 实现类似于百度实时搜索将结果在下拉框中显示的功能
- 用html5页面引入了一个jquery插件,实现平板上的向上滑动加载更多的功能
- 如何用JavaScript实现类似于ListBox功能
- 实现类似于新浪微博@的功能
- 实现类似于google,baidu的搜索提示功能,带有上下键选择功能
- linux操作系统编程——用exec函数族实现shell功能