Example #1
0
static int enum_docs(struct pldraw *pldraw, char * const *file_names,
		     size_t n_files, const struct epdoc_opt *opt,
		     unsigned long pause_ms, int infinite_loop)
{
	size_t n;
	int first = 1;

	do {
		for (n = 0; n < n_files; ++n) {
			const char *file_name = file_names[n];

			if (!g_run)
				return 0;

			if (first)
				first = 0;
			else
				usleep(pause_ms * 1000);

			if (!g_run)
				return 0;

			LOG("showing file: %s", file_name);

			if (show_doc(pldraw, file_name, opt) < 0)
				return -1;
		}
	} while (infinite_loop);

	return 0;
}
Example #2
0
static int show_contents(struct pldraw *pldraw, char * const *file_names,
			 size_t n_files, struct epdoc_opt *opt,
			 unsigned long pause_ms, int do_infinite_loop,
			 const char *background)
{
	struct plep_waveform_info wfinfo;

	if (plep_get_waveform_info(pldraw_get_plep(pldraw),
				   opt->wfid, &wfinfo)) {
		LOG("failed to get waveform info");
		return -1;
	}

	LOG_N("waveform: ");
	log_waveform_path(&wfinfo);

	if (set_background_opt(pldraw, opt, background) < 0) {
		LOG("Failed to set background option");
		return -1;
	}

	if (!n_files) {
		if (opt->doc_type == NULL) {
			LOG("document type required when reading from stdin");
			return -1;
		}

		LOG("reading from stdin as %s", opt->doc_type);

		return show_doc(pldraw, NULL, opt);
	}

	return enum_docs(pldraw, file_names, n_files, opt, pause_ms,
			 do_infinite_loop);
}
Example #3
0
/*********************************
 * For debugging - display the parameters
 * of a given model
 ********************************* */
void show_model(MODEL *model)
{
  int i;

  printf("------------------------------\n");
  printf("sv_num %ld\n", model->sv_num);
  printf("at_ub %ld\n", model->at_upper_bound);
  printf("b %f", model->b);

  printf("alphas\n");
  if (model->alpha != NULL)
    {
      for (i = 0; i < model->totdoc; i++)
	printf("%d  %f\n",i,  model->alpha[i]);
    }

  printf("indices:\n");
  for (i = 0; i < model->totdoc; i++)
    printf("%d %ld\n", i, model->index[i]);

  show_kparm(&model->kernel_parm);

  for (i = 0; i < model->sv_num; i++)
    show_doc(model->supvec[i]);

  printf("------------------------------\n");


}
Example #4
0
static void
kb_doc(G_GNUC_UNUSED guint key_id)
{
	gchar *word = current_word();
	if (word)
	{
		show_doc(word, 0);
		g_free(word);
	}
}
Example #5
0
static void
show_doc(const gchar * word, gint cmd_num)
{
	GeanyDocument *doc;
	const gchar *ftype;
	gchar *command;
	gchar *tmp;
	gboolean intern;

	doc = document_get_current();
	g_return_if_fail(doc != NULL && doc->file_name != NULL);

	ftype = doc->file_type->name;
	command = config_get_command(ftype, cmd_num, &intern);
	if (EMPTY(command))
	{
		g_free(command);
		return;
	}

	tmp = strstr(command, "%w");
	if (tmp != NULL)
	{
		tmp[1] = 's';
		setptr(command, g_strdup_printf(command, word));
	}

	if (intern)
	{
		g_spawn_command_line_sync(command, &tmp, NULL, NULL, NULL);
		if (! EMPTY(tmp))
		{
			show_output(tmp, "*DOC*", NULL, doc->file_type->id);
		}
		else
		{
			show_doc(word, cmd_num + 1);
		}
		g_free(tmp);
	}
	else
	{
		g_spawn_command_line_async(command, NULL);
	}
	g_free(command);
}
Example #6
0
static void
kb_doc_ask(G_GNUC_UNUSED guint key_id)
{
	gchar *word = NULL;
	GtkWidget *dialog, *entry;

	/* example configuration dialog */
	dialog = create_Interactive();

	/* run the dialog and check for the response code */
	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
	{
		entry = ui_lookup_widget(dialog, "entry_word");
		word = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));
	}
	gtk_widget_destroy(dialog);

	if (word)
	{
		show_doc(word, 0);
		g_free(word);
	}
}