GNU readline是一个开源的跨平台程序库,提供了交互式的文本编辑功能。它最早由Brian Fox使用C语言开发在1989年发布,遵守GNU/GPL协议。
GNU readline是一个开源的跨平台程序库,提供了交互式的文本功能。它最早由Brian Fox使用C语言开发在1989年发布,遵守GNU/GPL协议。
VB、ActiveX等其他语言或组件中也有类似的实现。
readline 是一个强大的库,只要使用了它的程序,都可以用同一个配置文件配置,而且用同样的方法操作命令行,让你可以方便的命令行。
使用 readline 的程序现在主要有 Bash, GDB,ftp 等。readline 赋予这些程序强大的 Emacs 似的命令行方式,你可以随意绑定你的键盘,搜索命令历史等。
ReadLine 方法 描述从一个 TextStream文件读取一整行(到换行符但不包括换行符)并返回得到的字符串。ReadLine 方法可从 TextStream 文件中读取一整行字符,并以字符串返回结果。
语法object.ReadLine中object参数始终是一个 TextStream对象的名字。
1,gnu readline
#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <readline/readline.h>#include <readline/history.h> int main(){ char* input, shell_prompt; // Configure readline to auto-complete paths when the tab key is hit. rl_bind_key('t', rl_complete); for(;;) { // Create prompt string from user name and current working directory. snprintf(shell_prompt, sizeof(shell_prompt), "%s:%s $ ", getenv("USER"), getcwd(NULL, 1024)); // Display prompt and read input (n.b. input must be freed after use)... input = readline(shell_prompt); // Check for EOF. if (!input) break; // Add input to history. add_history(input); // Do stuff... // Free input. free(input); }}2,ActiveX readline
function GetLine(){ var fso, f, r; var ForReading = 1, ForWriting = 1; fso = new ActiveXObject("scripting.FileSystemObject"); f = fso.OpenTextFile("c:testfile.txt", ForWriting, true); f.WriteLine("Hello world!"); f.WriteLine("Jscript is fun"); f.Close(); f = fso.OpenTextFile("c:testfile.txt", ForReading); r = f.ReadLine(); return(r);}