readline() について #146
JUNNETWORKS
started this conversation in
General
Replies: 1 comment
-
|
テストプログラム #include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
char *input_str;
while (1)
{
input_str = readline("> ");
if (!input_str)
{
printf("receive EOF\n");
break;
}
printf("input_str: |%s|\n", input_str);
free(input_str);
}
}コンパイルは |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
readline()系の各関数のメモchar *readline (char *prompt): プロンプトを表示し, 標準入力から文字列を受け取る. 返す文字列はmalloc()されたものであるため呼び出し側でfree()が必要. 履歴や矢印キーでの移動などの実装の大変なところは全てやってくれるすごいやつ.char * rl_line_buffer: 行に今まで入力された文字列.int rl_on_new_line (void): 改行を出力し, 更新ルーチンに次の行に行ったことを伝える.void rl_replace_line (const char *text, int clear_undo):rl_line_bufferをtextに置き換える.clear_undoが 0 じゃない場合現在の行のundoリストはクリアされる. (とりあえずclear_undoは 0 でよい?)void rl_redisplay (void): 画面を更新し,rl_line_bufferの内容を画面に反映させる.参考サイト
Beta Was this translation helpful? Give feedback.
All reactions