void ghid_handle_user_command (gboolean raise) { char *command; static char *previous = NULL; if (ghidgui->use_command_window) ghid_command_window_show (raise); else { command = ghid_command_entry_get (_("Enter command:"), (Settings.SaveLastCommand && previous) ? previous : (gchar *)""); if (command != NULL) { /* copy new comand line to save buffer */ g_free (previous); previous = g_strdup (command); hid_parse_command (command); g_free (command); } else if (previous) { command = g_strdup (previous); hid_parse_command (command); g_free (command); } } ghid_window_set_name_label (PCB->Name); ghid_set_status_line_label (); }
static void batch_do_export (HID_Attr_Val * options) { int interactive; char line[1000]; if (isatty (0)) interactive = 1; else interactive = 0; if (interactive) { printf("Entering %s version %s batch mode.\n", PACKAGE, VERSION); printf("See http://pcb.gpleda.org for project information\n"); } while (1) { if (interactive) { printf("%s> ", prompt); fflush(stdout); } if (fgets(line, sizeof(line)-1, stdin) == NULL) return; hid_parse_command (line); } }
/* Called when user hits "Enter" key in command entry. The action to take | depends on where the combo box is. If it's in the command window, we can | immediately execute the command and carry on. If it's in the status | line hbox, then we need stop the command entry g_main_loop from running | and save the allocated string so it can be returned from | ghid_command_entry_get() */ static void command_entry_activate_cb (GtkWidget * widget, gpointer data) { gchar *command; command = g_strdup (ghid_entry_get_text (GTK_WIDGET (ghidgui->command_entry))); gtk_entry_set_text (ghidgui->command_entry, ""); if (*command) command_history_add (command); if (ghidgui->use_command_window) { hid_parse_command (command); g_free (command); } else { if (loop && g_main_loop_is_running (loop)) /* should always be */ g_main_loop_quit (loop); command_entered = command; /* Caller will free it */ } }