return NULL;
}
+/* edit line */
+char *edit_line = NULL;
+int edit_hook ()
+{
+ static int state = 0;
+ if (edit_line) {
+ if (state == 0) {
+ state = 1;
+ } else {
+ state = 0;
+ free (edit_line);
+ edit_line = NULL;
+ }
+ }
+ return rl_insert_text (edit_line);
+}
+
/* main function */
int main (int argc, char *argv[])
completion_list = generate_completion_list ();
rl_attempted_completion_function = completion;
+ /* startup hook */
+ rl_startup_hook = edit_hook;
+
/* read from input stream */
while (1) {
void edit (int id)
{
+ extern char *edit_line;
int n = lookfor_program (id);
if (n == -1) {
VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id));
}
/* set string program */
- fprintf (stdout, "edit: %s\n", programs[n]->string);
+ if (edit_line) {
+ free (edit_line);
+ }
+ edit_line = strdup (programs[n]->string);
+ //fprintf (stdout, "edit: %s\n", programs[n]->string);
}
void savestring (int id, char *string)