예제 #1
0
void open_file(gchar *utf8_name)
{
	gchar *name;
	GeanyDocument *doc;

	name = utils_get_locale_from_utf8(utf8_name);
	doc = document_find_by_filename(utf8_name);

	if (!doc)
	{
		document_open_file(name, FALSE, NULL, NULL);
	}
	else
	{
		GtkNotebook *notebook;
		gint page_num;

		notebook = GTK_NOTEBOOK(geany->main_widgets->notebook);
		page_num = gtk_notebook_page_num(notebook, GTK_WIDGET(doc->editor->sci));

		gtk_notebook_set_current_page(notebook, page_num);
	}

	g_free(name);
}
예제 #2
0
/* name should be in UTF-8, and can have a path. */
static void
show_output(const gchar * std_output, const gchar * name, const gchar * force_encoding,
	    gint filetype_new_file)
{
	gint page;
	GtkNotebook *book;
	GeanyDocument *doc, *cur_doc;

	if (std_output)
	{
		cur_doc = document_get_current();
		doc = document_find_by_filename(name);
		if (doc == NULL)
		{
			doc = document_new_file(name,
						   filetypes[filetype_new_file],
						   std_output);
		}
		else
		{
			sci_set_text(doc->editor->sci, std_output);
			book = GTK_NOTEBOOK(geany->main_widgets->notebook);
			page = gtk_notebook_page_num(book, GTK_WIDGET(doc->editor->sci));
			gtk_notebook_set_current_page(book, page);
		}
		document_set_text_changed(doc, FALSE);
		document_set_encoding(doc, (force_encoding ? force_encoding : "UTF-8"));
		navqueue_goto_line(cur_doc, document_get_current(), 1);
	}
	else
	{
		ui_set_statusbar(FALSE, _("Could not parse the output of command"));
	}
}
예제 #3
0
파일: markers.c 프로젝트: geh/geany-plugins
/*
 * adds frame marker
 */
void markers_add_frame(char* file, int line)
{
	GeanyDocument *doc = document_find_by_filename(file);
	if (doc)
	{
		sci_set_marker_at_line(doc->editor->sci, line - 1, M_FRAME);
	}
}
예제 #4
0
파일: msgwindow.c 프로젝트: cirne100/geany
static gboolean goto_compiler_file_line(const gchar *filename, gint line, gboolean focus_editor)
{
	if (!filename || line <= -1)
		return FALSE;

	/* If the path doesn't exist, try the current document.
	 * This happens when we receive build messages in the wrong order - after the
	 * 'Leaving directory' messages */
	if (!g_file_test(filename, G_FILE_TEST_EXISTS))
	{
		gchar *cur_dir = utils_get_current_file_dir_utf8();
		gchar *name;

		if (cur_dir)
		{
			/* we let the user know we couldn't find the parsed filename from the message window */
			setptr(cur_dir, utils_get_locale_from_utf8(cur_dir));
			name = g_path_get_basename(filename);
			setptr(name, g_build_path(G_DIR_SEPARATOR_S, cur_dir, name, NULL));
			g_free(cur_dir);

			if (g_file_test(name, G_FILE_TEST_EXISTS))
			{
				ui_set_statusbar(FALSE, _("Could not find file '%s' - trying the current document path."),
					filename);
				filename = name;
			}
			else
				g_free(name);
		}
	}

	{
		gchar *utf8_filename = utils_get_utf8_from_locale(filename);
		GeanyDocument *doc = document_find_by_filename(utf8_filename);
		GeanyDocument *old_doc = document_get_current();

		g_free(utf8_filename);

		if (doc == NULL)	/* file not already open */
			doc = document_open_file(filename, FALSE, NULL, NULL);

		if (doc != NULL)
		{
			gboolean ret;

			if (! doc->changed && editor_prefs.use_indicators)	/* if modified, line may be wrong */
				editor_indicator_set_on_line(doc->editor, GEANY_INDICATOR_ERROR, line - 1);

			ret = navqueue_goto_line(old_doc, doc, line);
			if (ret && focus_editor)
				gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));

			return ret;
		}
	}
	return FALSE;
}
예제 #5
0
파일: markers.c 프로젝트: geh/geany-plugins
/*
 * removes frame marker
 */
void markers_remove_frame(char* file, int line)
{
	GeanyDocument *doc = document_find_by_filename(file);
	if (doc)
	{
		sci_delete_marker_at_line(doc->editor->sci, line - 1, M_FRAME);
		scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
	}
}
예제 #6
0
파일: markers.c 프로젝트: geh/geany-plugins
/*
 * adds current instruction marker
 */
void markers_add_current_instruction(char* file, int line)
{
	GeanyDocument *doc = document_find_by_filename(file);
	if (doc)
	{
		sci_set_marker_at_line(doc->editor->sci, line - 1, M_CI_ARROW);
		sci_set_marker_at_line(doc->editor->sci, line - 1, M_CI_BACKGROUND);
	}
}
예제 #7
0
파일: navqueue.c 프로젝트: Aligorith/geany
static gboolean goto_file_pos(const gchar *file, gint pos)
{
	GeanyDocument *doc = document_find_by_filename(file);

	if (doc == NULL)
		return FALSE;

	return editor_goto_pos(doc->editor, pos, TRUE);
}
예제 #8
0
파일: markers.c 프로젝트: geh/geany-plugins
/*
 * removes current instruction marker
 */
void markers_remove_current_instruction(char* file, int line)
{
	GeanyDocument *doc = document_find_by_filename(file);
	if (doc)
	{
		sci_delete_marker_at_line(doc->editor->sci, line - 1, M_CI_ARROW);
		sci_delete_marker_at_line(doc->editor->sci, line - 1, M_CI_BACKGROUND);
		scintilla_send_message(doc->editor->sci, SCI_SETFOCUS, TRUE, 0);
	}
}
예제 #9
0
static PyObject*
Document_find_by_filename(PyObject *self, PyObject *args, PyObject *kwargs)
{
	gchar *fn;
	GeanyDocument *doc;
	static gchar *kwlist[] = { "filename", NULL };

	if (PyArg_ParseTupleAndKeywords(args, kwargs, "s", kwlist, &fn))
	{
		doc = document_find_by_filename(fn);
		if (DOC_VALID(doc))
			return (PyObject *) Document_create_new_from_geany_document(doc);
	}
	Py_RETURN_NONE;
}
예제 #10
0
파일: markers.c 프로젝트: geh/geany-plugins
/*
 * add breakpoint marker
 * enabled or disabled, based on bp->enabled value
 * arguments:
 * 		bp - breakpoint to add marker for  
 */
void markers_add_breakpoint(breakpoint* bp)
{
	GeanyDocument *doc = document_find_by_filename(bp->file);
	if (doc)
	{
		if (!bp->enabled)
		{
			sci_set_marker_at_line(doc->editor->sci, bp->line - 1, M_BP_DISABLED);
		}
		else if (strlen(bp->condition) || bp->hitscount)
		{
				sci_set_marker_at_line(doc->editor->sci, bp->line - 1, M_BP_CONDITIONAL);
		}
		else
		{
				sci_set_marker_at_line(doc->editor->sci, bp->line - 1, M_BP_ENABLED);
		}
	}
}
예제 #11
0
void open_file(gchar *utf8_name)
{
	gchar *name;
	GeanyDocument *doc;

	name = utils_get_locale_from_utf8(utf8_name);
	doc = document_find_by_filename(utf8_name);

	if (!doc)
		doc = document_open_file(name, FALSE, NULL, NULL);
	else
	{
		gtk_notebook_set_current_page(GTK_NOTEBOOK(geany->main_widgets->notebook),
			document_get_notebook_page(doc));
	}
	
	if (doc)
		gtk_widget_grab_focus(GTK_WIDGET(doc->editor->sci));

	g_free(name);
}
예제 #12
0
파일: markers.c 프로젝트: geh/geany-plugins
/*
 * removes breakpoints marker
 */
void markers_remove_breakpoint(breakpoint *bp)
{
	static int breakpoint_markers[] = {
		M_BP_ENABLED,
		M_BP_DISABLED,
		M_BP_CONDITIONAL
	};

	GeanyDocument *doc = document_find_by_filename(bp->file);
	if (doc)
	{
		int markers = scintilla_send_message(doc->editor->sci, SCI_MARKERGET, bp->line - 1, (long)NULL);
		int markers_count = sizeof(breakpoint_markers) / sizeof(breakpoint_markers[0]);
		int i = 0;
		for (; i < markers_count; i++)
		{
			int marker = breakpoint_markers[i];
			if (markers & (0x01 << marker))
			{
				sci_delete_marker_at_line(doc->editor->sci, bp->line - 1, marker);
			}
		}
	}
}
예제 #13
0
static void workspace_add_tag(gchar *filename, TagObject *obj, gpointer foo)
{
	TMWorkObject *tm_obj = NULL;

	if (!document_find_by_filename(filename))
	{
		gchar *locale_filename;

		locale_filename = utils_get_locale_from_utf8(filename);
		tm_obj = tm_source_file_new(locale_filename, FALSE, filetypes_detect_from_file(filename)->name);
		g_free(locale_filename);

		if (tm_obj)
		{
			tm_workspace_add_object(tm_obj);
			tm_source_file_update(tm_obj, TRUE, FALSE, TRUE);
		}
	}

	if (obj->tag)
		tm_workspace_remove_object(obj->tag, TRUE, TRUE);

	obj->tag = tm_obj;
}