[Cgdb-devel] cgdb and readline
Brought to you by:
bobbybrasko,
crouchingturbo
|
From: Bob R. <bob...@co...> - 2003-02-20 03:12:38
|
Hey guys,
Look at this small example. It reads a line at a time and prints it.
#include <readline/readline.h>
#include <readline/history.h>
#include <stdlib.h>
/* Gets called when the user hits '\t' */
int rl_complete (int ignore, int invoking_key) {
fprintf(stderr, "complete\n");
return 0;
}
int main(int argc, char **argv){
static char *line;
while(1) {
line =3D readline("PROMPT:");
fprintf(stderr, "LINE=3D(%s)\n", line);
}
return 0;
}
I am trying to integrate readline into cgdb and ran into a problem.
Readline has a function called 'readline' that gets a line of input from
stdin. This is great, however, it is a blocking call ( It reads a whole
line and then returns). This is not good, since cgdb should also be able
to receive input if the user is in cgdb mode.=20
For example, the users types 'info sour' and the ESC 'j' ( to go down a lin=
e )=20
and then 'i' ( to get back into gdb mode ) and then 'e<CR>'.=20
How would we get readline to give up control? Or feed it a char at a
time? I don't know how to resolve this problem.
By the way, currently cgdb sits in a select loop reading from stdin,
gdb's stdout, and the debugged programs stdout (tty). How could we make
readline be a part of this?
Any suggestions?
Thanks,
Bobby
|