Exemplo n.º 1
0
void
on_show_listing1_activate (GtkMenuItem * menuitem, gpointer user_data)
{
  GString *list;
  GtkWidget *cont;

  /* assemble */
  on_assemble1_activate (NULL, NULL);
  if (asm_error == FALSE)
	return;

  list = asm_listing_generate (b_get_src ());

  //gui_editor_set_text (app->editor, list->str);

  /* show */
  wind = create_window_listing ();
  cont = lookup_widget (wind, "listing_vbox");
  g_assert (cont);
  edit = gui_editor_new ();
  g_assert (edit);
  gui_editor_show (edit);
  gui_editor_set_text (edit, list->str);
  gui_editor_set_readonly (edit, TRUE);
  gtk_box_pack_end (GTK_BOX (cont), edit->scroll, TRUE, TRUE, 0);
  gtk_window_maximize (GTK_WINDOW (wind));
  gtk_widget_show_all (wind);
  /* TODO clean up of listing window editor on delete event */

  /* clean up */
  g_string_free (list, TRUE);
}
Exemplo n.º 2
0
void
show_tutorial ()
{
  GString* tutorial_text = read_tutorial ();
  GtkWidget *cont;

  /* show */
  tutorial = create_window_tutorial ();
  cont = lookup_widget (tutorial, "tutorial_vbox");
  g_assert (cont);
  edit = gui_editor_new ();
  g_assert (edit);
  gui_editor_show (edit);
  if (tutorial_text == NULL)
  {
    tutorial_text = g_string_new (_("The tutorial file, asm-guide.txt, was not found. It should be present in directory - "));
    g_string_append (tutorial_text, PACKAGE_DOC_DIR);  
  }
  gui_editor_set_text (edit, tutorial_text->str);
  gui_editor_set_readonly (edit, TRUE);
  gui_editor_set_show_line_numbers (edit, FALSE);
  gtk_box_pack_end (GTK_BOX (cont), edit->scroll, TRUE, TRUE, 0);
  gtk_window_maximize (GTK_WINDOW (tutorial));
  gtk_widget_show_all (tutorial);

  /* clean up */
  g_string_free (tutorial_text, TRUE);
}
Exemplo n.º 3
0
void
ori_open (gchar * fn, gboolean replace)
{

  GString *gstr;
  GFile *fp;
  GFileInputStream *file_in;
  char *nullstr = "NULLSTRING";
  gssize bytes = 1;

  if (!fn)
	fn = nullstr;

  fp = g_file_new_for_uri (fn);

  if (fp == NULL)
	{
	  gchar errmsg[MAX_ERR_MSG_SIZE + 1];
	  g_snprintf (errmsg, MAX_ERR_MSG_SIZE, _("Failed to open <%s>"),
				  fn);
	  gui_app_show_msg (GTK_MESSAGE_ERROR, errmsg);
	  return;
	}

  gstr = g_string_new ("");
  file_in = g_file_read (fp, NULL, NULL);
  
  while (bytes != 0)
	{
	  gchar buf[100] = { 0 };
	  bytes = g_input_stream_read (G_INPUT_STREAM (file_in), buf, 100, NULL, NULL);
	  g_string_append_len (gstr, buf, bytes);
	}
  g_input_stream_close (G_INPUT_STREAM (file_in), NULL, NULL);

  gui_editor_set_text (app->editor, gstr->str);
  gtk_text_buffer_set_modified ((GtkTextBuffer *)app->editor->buffer, FALSE);

  /* Set breakpoints as instructed in the source */
  {
	gchar *str = gstr->str;
	gint ln = 0;

	gchar **lines = NULL;

	g_assert (str);

	lines = g_strsplit (str, "\n", -1);
	g_assert (lines);

	/* for each line */
	while (lines[ln])
	  {
		/* check for ;@ */
		if (strlen (lines[ln]) > 1)
		  {
			if (lines[ln][0] == ';'
				&& lines[ln][1] == '@')
			  {
				/* add breakpoint */
				gui_editor_set_mark (app->editor,
									 ln + 1, TRUE);
				//exit(99);
			  }
		  }
		ln++;
	  }

	g_strfreev (lines);
  }

  g_string_free (gstr, TRUE);
  if (replace)
	_set_file_name (fn);
}
Exemplo n.º 4
0
void
ori_open (gchar * fn, gboolean replace)
{

  GString *gstr;
  FILE *fp;
  char *nullstr = "NULLSTRING";
  char *ret;
  if (!fn)
	fn = nullstr;

  fp = fopen (fn, "r");

  if (fp == NULL)
	{
	  gchar errmsg[MAX_ERR_MSG_SIZE + 1];
	  g_snprintf (errmsg, MAX_ERR_MSG_SIZE, _("Failed to open <%s>"),
				  fn);
	  gui_app_show_msg (GTK_MESSAGE_ERROR, errmsg);
	  return;
	}

  gstr = g_string_new ("");

  while (!feof (fp))
	{
	  gchar buf[300] = { 0 };
	  // return value stored just to avoid compiler warnings.
	  ret = fgets (buf, 100, fp);
	  g_string_append (gstr, buf);
	}

  gui_editor_set_text (app->editor, gstr->str);
  gtk_text_buffer_set_modified ((GtkTextBuffer *)app->editor->buffer, FALSE);

  /* Set breakpoints as instructed in the source */
  {
	gchar *str = gstr->str;
	gint ln = 0;

	gchar **lines = NULL;

	g_assert (str);

	lines = g_strsplit (str, "\n", -1);
	g_assert (lines);

	/* for each line */
	while (lines[ln])
	  {
		/* check for ;@ */
		if (strlen (lines[ln]) > 1)
		  {
			if (lines[ln][0] == ';'
				&& lines[ln][1] == '@')
			  {
				/* add breakpoint */
				gui_editor_set_mark (app->editor,
									 ln + 1, TRUE);
				//exit(99);
			  }
		  }
		ln++;
	  }

	g_strfreev (lines);
  }

  g_string_free (gstr, TRUE);
  if (replace)
	_set_file_name (fn);
}