コード例 #1
0
ファイル: plugin.c プロジェクト: abderrahim/anjuta
static gboolean
match_keyword (MacroPlugin * plugin, GtkTreeIter * iter, const gchar *keyword)
{
	gchar *name;
	gint offset = 0;
	
	gtk_tree_model_get(macro_db_get_model(plugin->macro_db), iter,
		MACRO_NAME, &name, -1);
	if ( name && strcmp(keyword, name) == 0)
	{
		gchar* text = macro_db_get_macro(plugin, plugin->macro_db, iter, &offset);
		if (plugin->current_editor != NULL && text != NULL)
		{
			gint i;
			IAnjutaIterable *pos =
				ianjuta_editor_get_position (IANJUTA_EDITOR(plugin->current_editor),
											 NULL);
			ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor),
			                       pos, text, -1, NULL);
			for (i = 0; i < offset; i++)
				ianjuta_iterable_next (pos, NULL);
			ianjuta_editor_goto_position (IANJUTA_EDITOR(plugin->current_editor), 
			                              pos, NULL);
			g_free(text);
			g_object_unref (pos);
		}
		return TRUE;
	}
	return FALSE;
}
コード例 #2
0
ファイル: search-box.c プロジェクト: kyoushuu/anjuta
static void
on_replace_all_activated (GtkWidget* widget, SearchBox* search_box)
{
	IAnjutaIterable* cursor;

	if (!search_box->priv->current_editor)
		return;

	/* Cache current position and search from begin */
	cursor = ianjuta_editor_get_position (IANJUTA_EDITOR (search_box->priv->current_editor),
	                                      NULL);
	ianjuta_editor_goto_start (IANJUTA_EDITOR (search_box->priv->current_editor), NULL);
	
	/* Replace all instances of search_entry with replace_entry text */
	ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT (search_box->priv->current_editor), NULL);
	while (search_box_incremental_search (search_box, TRUE, TRUE, FALSE))
	{
		search_box_replace (search_box, widget, FALSE);
	}
	ianjuta_document_end_undo_action (IANJUTA_DOCUMENT (search_box->priv->current_editor), NULL);

	/* Back to cached position */
	ianjuta_editor_selection_set (IANJUTA_EDITOR_SELECTION (search_box->priv->current_editor),
	                              cursor, cursor, TRUE, NULL);
	g_object_unref (cursor);
}
コード例 #3
0
ファイル: plugin.c プロジェクト: VujinovM/anjuta
static void
on_toggle_comment (GtkAction *action, gpointer data)
{
    gint line;
    gboolean has_selection;

    CppJavaPlugin *lang_plugin;
    IAnjutaEditor *editor;
    lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
    editor = IANJUTA_EDITOR (lang_plugin->current_editor);

    ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);

    has_selection = ianjuta_editor_selection_has_selection
                        (IANJUTA_EDITOR_SELECTION (editor), NULL);
    if (has_selection)
    {
        IAnjutaIterable *sel_start, *sel_end;
        sel_start = ianjuta_editor_selection_get_start (IANJUTA_EDITOR_SELECTION (editor),
                                                        NULL);
        sel_end = ianjuta_editor_selection_get_end (IANJUTA_EDITOR_SELECTION (editor),
                                                    NULL);
        toggle_comment_multiline (editor, sel_start, sel_end);
        g_object_unref (sel_start);
        g_object_unref (sel_end);
    }
    else
    {
        line = ianjuta_editor_get_lineno (IANJUTA_EDITOR(editor), NULL);
        toggle_comment_singleline (lang_plugin, editor, line);
    }
    ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
}
コード例 #4
0
void
sourceview_io_save_as (SourceviewIO* sio, GFile* file)
{
	AnjutaShell* shell = ANJUTA_PLUGIN (sio->sv->priv->plugin)->shell;
	gboolean backup = TRUE;
	gsize len;

	g_return_if_fail (file != NULL);

	cancel_monitor (sio);

	backup = g_settings_get_boolean (sio->sv->priv->settings,
	                                 "backup");

	if (sio->last_encoding == NULL)
	{
		sio->write_buffer = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv),
														 NULL);
		len = strlen (sio->write_buffer);
	}
	else
	{
		GError* err = NULL;
		gchar* buffer_text = ianjuta_editor_get_text_all (IANJUTA_EDITOR(sio->sv),
														  NULL);
		sio->write_buffer = anjuta_convert_from_utf8 (buffer_text,
													  -1,
													  sio->last_encoding,
													  &len,
													  &err);
		g_free (buffer_text);
		if (err != NULL)
		{
			g_signal_emit_by_name (sio, "save-failed", err);
			g_error_free(err);
			return;
		}
	}
	g_cancellable_reset (sio->cancel);
	g_file_replace_contents_async (file,
	                               sio->write_buffer,
	                               len,
	                               NULL,
	                               backup,
	                               G_FILE_CREATE_NONE,
	                               sio->cancel,
	                               on_save_finished,
	                               sio);
	anjuta_shell_saving_push (shell);

	if (sio->file != file)
	{
		if (sio->file)
			g_object_unref (sio->file);
		sio->file = file;
		g_object_ref (file);
	}
	g_object_ref (sio);
}
コード例 #5
0
static void
on_added_current_document (AnjutaPlugin *plugin,
                           const gchar *name,
                           const GValue *value,
                           gpointer data)
{
    GObject *cur_editor = NULL;
    SnippetsManagerPlugin *snippets_manager_plugin = NULL;

    /* Assertions */
    g_return_if_fail (ANJUTA_IS_PLUGIN_SNIPPETS_MANAGER (plugin));
    snippets_manager_plugin = ANJUTA_PLUGIN_SNIPPETS_MANAGER (plugin);

    /* Get the current document and test if it's an IAnjutaEditor */
    cur_editor = g_value_get_object (value);
    if (IANJUTA_IS_EDITOR (cur_editor))
        snippets_interaction_set_editor (snippets_manager_plugin->snippets_interaction,
                                         IANJUTA_EDITOR (cur_editor));
    else
        snippets_interaction_set_editor (snippets_manager_plugin->snippets_interaction,
                                         NULL);

    /* Refilter the snippets shown in the browser */
    snippets_browser_refilter_snippets_view (snippets_manager_plugin->snippets_browser);

    /* Load the provider if needed */
    if (IANJUTA_IS_EDITOR_ASSIST (cur_editor))
        snippets_provider_load (snippets_manager_plugin->snippets_provider,
                                IANJUTA_EDITOR_ASSIST (cur_editor));

}
コード例 #6
0
ファイル: plugin.c プロジェクト: rosedu/anjuta
static void
iprovider_activate (IAnjutaProvider *obj, IAnjutaIterable* iter,  gpointer data, GError **err)
{
	DEBUG_PRINT("activate");

	JSLang *plugin = (JSLang*)obj;
	gchar *str = (gchar*)data;

	g_assert (plugin->current_editor);
	g_assert (str);

	gint a = ianjuta_iterable_diff (plugin->last, iter, NULL);

	ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor), iter, str + a, -1, NULL);
			
	gchar *sym = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);
	g_assert (sym != NULL);

	if (sym && code_completion_is_symbol_func (plugin, sym))
	{
		IAnjutaIterable *position = ianjuta_editor_get_position (IANJUTA_EDITOR (plugin->current_editor), NULL);

		if (g_settings_get_boolean (plugin->prefs, ADD_BRACE_AFTER_FUNCCALL))
		{
			ianjuta_editor_insert (IANJUTA_EDITOR (plugin->current_editor), position, " (", -1, NULL);
		}
		if (g_settings_get_boolean (plugin->prefs, SHOW_CALLTIPS))
		{
/*			GList *t = NULL;
			gchar *args = code_completion_get_func_tooltip (plugin, sym);
			t = g_list_append (t, args);
			if (args)
			{
				ianjuta_editor_tip_show (IANJUTA_EDITOR_TIP(plugin->current_editor), t,
							 position, NULL);

				g_free (args);
			}*/
		}
	}
	g_free (sym);
}
コード例 #7
0
ファイル: plugin.c プロジェクト: GNOME/anjuta-extras
static IAnjutaEditor*
itext_editor_factory_new_editor(IAnjutaEditorFactory* factory, 
								GFile* file,
								const gchar* filename, 
								GError** error)
{
	/* file can be NULL, if we open a buffer, not a file */
	gchar* uri = file ? g_file_get_uri (file) : NULL;
	IAnjutaEditor* editor = IANJUTA_EDITOR(text_editor_new(ANJUTA_PLUGIN (factory),
														   uri, filename));
	g_free(uri);
	return editor;
}
コード例 #8
0
ファイル: indentation.c プロジェクト: VujinovM/anjuta
void
cpp_auto_indentation (IAnjutaEditor *editor,
                      IndentCPlugin *lang_plugin,
                      IAnjutaIterable *start,
                      IAnjutaIterable *end)
{
	gint line_start, line_end;
	gint insert_line;
	gint line_indent;
	gboolean has_selection;

	has_selection = ianjuta_editor_selection_has_selection
		(IANJUTA_EDITOR_SELECTION (editor), NULL);
	if (start == NULL || end == NULL)
	{
		if (has_selection)
		{
			IAnjutaIterable *sel_start, *sel_end;
			sel_start = ianjuta_editor_selection_get_start (IANJUTA_EDITOR_SELECTION (editor),
				                                            NULL);
			sel_end = ianjuta_editor_selection_get_end (IANJUTA_EDITOR_SELECTION (editor),
				                                        NULL);
			line_start = ianjuta_editor_get_line_from_position (editor, sel_start, NULL);
			line_end = ianjuta_editor_get_line_from_position (editor, sel_end, NULL);
			g_object_unref (sel_start);
			g_object_unref (sel_end);
		}
		else
		{
			line_start = ianjuta_editor_get_lineno (IANJUTA_EDITOR(editor), NULL);
			line_end = line_start;
		}
	}
	else
	{
			line_start = ianjuta_editor_get_line_from_position (editor, start, NULL);
			line_end = ianjuta_editor_get_line_from_position (editor, end, NULL);
	}
	ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT(editor), NULL);

	for (insert_line = line_start; insert_line <= line_end; insert_line++)
	{
		gint parenthesis_indentation = 0;
		line_indent = get_line_auto_indentation (lang_plugin, editor,
		                                         insert_line,
		                                         &parenthesis_indentation);
		/* DEBUG_PRINT ("Line indent for line %d = %d", insert_line, line_indent); */
		set_line_indentation (lang_plugin, editor, insert_line, line_indent, parenthesis_indentation);
	}
	ianjuta_document_end_undo_action (IANJUTA_DOCUMENT(editor), NULL);
}
コード例 #9
0
ファイル: search-box.c プロジェクト: kyoushuu/anjuta
static void
on_document_changed (AnjutaDocman* docman, IAnjutaDocument* doc,
					SearchBox* search_box)
{
	if (!doc || !IANJUTA_IS_EDITOR (doc))
	{
		gtk_widget_hide (GTK_WIDGET (search_box));
		search_box->priv->current_editor = NULL;
	}
	else
	{
		search_box->priv->current_editor = IANJUTA_EDITOR (doc);
		if (search_box->priv->highlight_all) search_box_highlight_all (search_box);
	}
}
コード例 #10
0
ファイル: plugin.c プロジェクト: VujinovM/anjuta
static IAnjutaEditor*
language_support_get_editor_from_file (CppJavaPlugin* lang_plugin,
                                                      GFile *file)
{
    IAnjutaDocumentManager *document_manager = anjuta_shell_get_interface (
                                          ANJUTA_PLUGIN (lang_plugin)->shell,
                                          IAnjutaDocumentManager,
                                          NULL);

    IAnjutaDocument *document = ianjuta_document_manager_find_document_with_file
                                                        (document_manager,
                                                         file,
                                                         NULL);

    return IANJUTA_EDITOR (document);
}
コード例 #11
0
ファイル: parser-cxx-assist.c プロジェクト: VujinovM/anjuta
static IAnjutaIterable*
parser_cxx_assist_populate_completions (IAnjutaLanguageProvider* self,
                                        IAnjutaIterable* cursor,
                                        GError** e)
{
	ParserCxxAssist* assist = PARSER_CXX_ASSIST (self);
	IAnjutaIterable* start_iter = NULL;
	
	/* Check if completion was in progress */
	if (assist->priv->member_completion || assist->priv->autocompletion)
	{
		gchar* pre_word = anjuta_language_provider_get_pre_word (
		                              assist->priv->lang_prov,
		                              IANJUTA_EDITOR (assist->priv->iassist),
		                              cursor, &start_iter, WORD_CHARACTER);
		DEBUG_PRINT ("Preword: %s", pre_word);
		if (pre_word && g_str_has_prefix (pre_word, assist->priv->pre_word))
		{
			DEBUG_PRINT ("Continue autocomplete for %s", pre_word);
			
			/* Great, we just continue the current completion */			
			parser_cxx_assist_update_pre_word (assist, pre_word);
			parser_cxx_assist_populate_real (assist, TRUE);
			g_free (pre_word);
			return start_iter;
		}			
		g_free (pre_word);
	}
	
	parser_cxx_assist_clear_completion_cache (assist);
	
	/* Check for member completion */
	start_iter = parser_cxx_assist_create_member_completion_cache (assist,
	                                                               cursor);
	if (start_iter)
		assist->priv->member_completion = TRUE;
	else
	{
		start_iter = parser_cxx_assist_create_autocompletion_cache (assist,
		                                                            cursor);
		if (start_iter)
			assist->priv->autocompletion = TRUE;
	}
	
	return start_iter;
}
コード例 #12
0
ファイル: anjuta-docman.c プロジェクト: tuxdna/anjuta
/* CHECKME unused */
void
anjuta_docman_reload_file (AnjutaDocman *docman, GFile* file)
{
	IAnjutaDocument *doc;

	g_return_if_fail (file != NULL);

	doc = anjuta_docman_get_document_for_file (docman, file);
	if (doc && IANJUTA_IS_EDITOR (doc))
	{
		IAnjutaEditor *te;
		te = IANJUTA_EDITOR (doc);
		glong nNowPos = ianjuta_editor_get_lineno (te, NULL);
		ianjuta_file_open (IANJUTA_FILE (doc), file, NULL);
		ianjuta_editor_goto_line (te, nNowPos, NULL);
	}
}
コード例 #13
0
ファイル: parser-cxx-assist.c プロジェクト: VujinovM/anjuta
/**
 * parser_cxx_assist_create_autocompletion_cache:
 * @assist: self
 * @cursor: Current cursor position
 * 
 * Create completion cache for autocompletion. This is done async.
 *
 * Returns: the iter where a preword was detected, NULL otherwise
 */ 
static IAnjutaIterable*
parser_cxx_assist_create_autocompletion_cache (ParserCxxAssist* assist,
                                               IAnjutaIterable* cursor)
{
	IAnjutaIterable* start_iter;
	gchar* pre_word = anjuta_language_provider_get_pre_word (
	                                  assist->priv->lang_prov,
                                      IANJUTA_EDITOR (assist->priv->iassist),
									  cursor, &start_iter, WORD_CHARACTER);
	if (!pre_word || strlen (pre_word) <= 3)
	{
		if (start_iter)
			g_object_unref (start_iter);
		return NULL;
	}
	else
	{
		gchar *pattern = g_strconcat (pre_word, "%", NULL);

		parser_cxx_assist_update_pre_word (assist, pre_word);

		if (IANJUTA_IS_FILE (assist->priv->iassist))
		{
			GFile *file = ianjuta_file_get_file (
			                      IANJUTA_FILE (assist->priv->iassist), NULL);
			if (file != NULL)
			{
				assist->priv->async_file_id = 1;
				ianjuta_symbol_query_search_file (assist->priv->ac_query_file,
												  pattern, file, NULL);
				g_object_unref (file);
			}
		}
		/* This will avoid duplicates of FUNCTION and PROTOTYPE */
		assist->priv->async_project_id = 1;
		ianjuta_symbol_query_search (assist->priv->ac_query_project, pattern,
		                             NULL);
		assist->priv->async_system_id = 1;
		ianjuta_symbol_query_search (assist->priv->ac_query_system, pattern,
		                             NULL);
		g_free (pre_word);
		g_free (pattern);
		
		return start_iter;
	}
}
コード例 #14
0
ファイル: anjuta-docman.c プロジェクト: tuxdna/anjuta
void
anjuta_docman_delete_all_markers (AnjutaDocman *docman, gint marker)
{
	GList *node;

	for (node = docman->priv->pages; node != NULL; node = g_list_next (node))
	{
		AnjutaDocmanPage *page;

		page = (AnjutaDocmanPage *) node->data;
		if (IANJUTA_IS_EDITOR (page->doc))
		{
			IAnjutaEditor* te;

			te = IANJUTA_EDITOR (page->doc);
			ianjuta_markable_delete_all_markers (IANJUTA_MARKABLE (te), marker, NULL);
		}
	}
}
コード例 #15
0
static IAnjutaEditor*
ieditor_factory_new_editor(IAnjutaEditorFactory* factory,
								GFile* file,
								const gchar* filename,
								GError** error)
{
	AnjutaPlugin* plugin = ANJUTA_PLUGIN(factory);
	SourceviewPlugin* splugin = ANJUTA_PLUGIN_SOURCEVIEW (plugin);
	gchar* current_style = g_settings_get_string (splugin->settings, SOURCEVIEW_STYLE);
	GtkSourceStyleSchemeManager* manager = gtk_source_style_scheme_manager_get_default();
	Sourceview* sv;
	sv = sourceview_new(file, filename, plugin);
	if (current_style)
		gtk_source_buffer_set_style_scheme (GTK_SOURCE_BUFFER (sv->priv->document),
											gtk_source_style_scheme_manager_get_scheme (manager,
																						current_style));
	g_free (current_style);
	return IANJUTA_EDITOR (sv);
}
コード例 #16
0
ファイル: search-box.c プロジェクト: kyoushuu/anjuta
static void
on_search_box_entry_changed (GtkWidget * widget, SearchBox * search_box)
{
	if (!search_box->priv->regex_mode)
	{
		GtkEntryBuffer* buffer = gtk_entry_get_buffer (GTK_ENTRY(widget));
		if (gtk_entry_buffer_get_length (buffer))
			search_box_incremental_search (search_box, TRUE, FALSE, TRUE);
		else
		{
			/* clear selection */
			IAnjutaIterable* cursor = 
				ianjuta_editor_get_position (IANJUTA_EDITOR (search_box->priv->current_editor),
				                             NULL);
			ianjuta_editor_selection_set (IANJUTA_EDITOR_SELECTION (search_box->priv->current_editor),
			                              cursor,
			                              cursor,
			                              FALSE, NULL);
		}
	}

	if (search_box->priv->highlight_all) search_box_highlight_all (search_box);
}
コード例 #17
0
ファイル: plugin.c プロジェクト: VujinovM/anjuta
static void
on_swap_activate (GtkAction* action, gpointer data)
{
    GFile* file;
    CppJavaPlugin *lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (data);
    IAnjutaDocumentManager* docman =
        anjuta_shell_get_interface (ANJUTA_PLUGIN(lang_plugin)->shell,
                                    IAnjutaDocumentManager,
                                    NULL);
    if (!lang_plugin->current_editor || !docman)
        return;

    file = language_support_get_header_file (
                                        IANJUTA_EDITOR (lang_plugin->current_editor));

    if (file)
    {
        ianjuta_document_manager_goto_file_line (docman,
                                                 file,
                                                 -1,
                                                 NULL);
        g_object_unref (file);
    }
}
コード例 #18
0
ファイル: plugin.c プロジェクト: VujinovM/anjuta
static void
on_glade_drop (IAnjutaEditor* editor,
               IAnjutaIterable* iterator,
               const gchar* signal_data,
               CppJavaPlugin* lang_plugin)
{
    GStrv split_signal_data = g_strsplit(signal_data, ":", 5);
    char *handler = split_signal_data[2];
    /**
     * Split signal data format:
     * widget = split_signaldata[0];
     * signal = split_signaldata[1];
     * handler = split_signaldata[2];
     * user_data = split_signaldata[3];
     * swapped = g_str_equal (split_signaldata[4], "1");
     */

    IAnjutaIterable *iter;
    iter = language_support_find_symbol (lang_plugin,
                                         IANJUTA_EDITOR (editor),
                                         handler);
    if (iter == NULL)
    {
        GFile *file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
        CppFileType filetype = get_filetype (file);
        language_support_add_c_callback (lang_plugin, editor, iterator, split_signal_data, filetype);
    } else {
        /* Symbol found, going there */
        ianjuta_editor_goto_line (editor, ianjuta_symbol_get_int (
                                                            IANJUTA_SYMBOL (iter),
                                                            IANJUTA_SYMBOL_FIELD_FILE_POS,
                                                            NULL), NULL);
        g_object_unref (iter);
    }
    g_strfreev (split_signal_data);
}
コード例 #19
0
ファイル: plugin.c プロジェクト: rosedu/anjuta
static void
on_editor_added (AnjutaPlugin *plugin, const gchar *name,
                 const GValue *value, gpointer data)
{
	PythonPlugin *lang_plugin;
	IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value));
	lang_plugin = ANJUTA_PLUGIN_PYTHON(plugin);

	
	if (IANJUTA_IS_EDITOR(doc))
	{
		lang_plugin->current_editor = G_OBJECT(doc);
	}
	else
	{
		lang_plugin->current_editor = NULL;
		return;
	}
	if (lang_plugin->current_editor)
	{
		IAnjutaEditor* editor = IANJUTA_EDITOR (lang_plugin->current_editor);
		GFile* current_editor_file = ianjuta_file_get_file (IANJUTA_FILE (editor), 
		                                                    NULL);
		
		if (current_editor_file)
		{		
			lang_plugin->current_editor_filename = g_file_get_path (current_editor_file);
			g_object_unref (current_editor_file);
		}
		
		install_support (lang_plugin);
		g_signal_connect (lang_plugin->current_editor, "language-changed",
		                  G_CALLBACK (on_editor_language_changed),
		                  plugin);
	}
}
コード例 #20
0
ファイル: parser-cxx-assist.c プロジェクト: VujinovM/anjuta
/**
 * parser_cxx_assist_parse_expression:
 * @assist: self,
 * @iter: current cursor position
 * @start_iter: return location for the start of the completion
 * 
 * Returns: An iter of a list of IAnjutaSymbols or NULL
 */
static IAnjutaIterable*
parser_cxx_assist_parse_expression (ParserCxxAssist* assist, IAnjutaIterable* iter, IAnjutaIterable** start_iter)
{
	IAnjutaEditor* editor = IANJUTA_EDITOR (assist->priv->iassist);
	IAnjutaIterable* res = NULL;
	IAnjutaIterable* cur_pos = ianjuta_iterable_clone (iter, NULL);
	gboolean op_start = FALSE;
	gboolean ref_start = FALSE;
	gchar* stmt = NULL;
	
	/* Cursor points after the current characters, move back */
	ianjuta_iterable_previous (cur_pos, NULL);
	
	/* Search for a operator in the current line */
	do 
	{
		gchar ch = ianjuta_editor_cell_get_char (IANJUTA_EDITOR_CELL(cur_pos),
		                                         0, NULL);
		
		if (parser_cxx_assist_is_expression_separator(ch, FALSE, iter)) {
			break;
		}

		if (ch == '.' || (op_start && ch == '-') || (ref_start && ch == ':'))
		{
			/* Found an operator, get the statement and the pre_word */
			IAnjutaIterable* pre_word_start = ianjuta_iterable_clone (cur_pos,
			                                                          NULL);
			IAnjutaIterable* pre_word_end = ianjuta_iterable_clone (iter, NULL);
			IAnjutaIterable* stmt_end = ianjuta_iterable_clone (pre_word_start,
			                                                    NULL);

			
			/* we need to pass to the parser all the statement included the last
			 * operator, being it "." or "->" or "::"
			 * Increase the end bound of the statement.
			 */
			ianjuta_iterable_next (stmt_end, NULL);
			if (op_start == TRUE || ref_start == TRUE)
				ianjuta_iterable_next (stmt_end, NULL);
				
			
			/* Move one character forward so we have the start of the pre_word
			 * and not the last operator */
			ianjuta_iterable_next (pre_word_start, NULL);
			/* If this is a two character operator, skip the second character */
			if (op_start)
			{
				ianjuta_iterable_next (pre_word_start, NULL);
			}
			
			parser_cxx_assist_update_pre_word (assist, ianjuta_editor_get_text (
			                                                   editor,
			                                                   pre_word_start,
			                                                   pre_word_end,
			                                                   NULL));

			/* Try to get the name of the variable */
			while (ianjuta_iterable_previous (cur_pos, NULL))
			{
				gchar word_ch = ianjuta_editor_cell_get_char (
				                        IANJUTA_EDITOR_CELL(cur_pos), 0, NULL);
				
				if (parser_cxx_assist_is_expression_separator(word_ch, FALSE,
				                                              cur_pos)) 
					break;				
			}
			ianjuta_iterable_next (cur_pos, NULL);
			stmt = ianjuta_editor_get_text (editor,
			                                cur_pos, stmt_end, NULL);
			*start_iter = pre_word_start;
			g_object_unref (stmt_end);
			g_object_unref (pre_word_end);
			break;
		}
		else if (ch == '>')
			op_start = TRUE;
		else if (ch == ':')
			ref_start = TRUE;
		else
		{
			op_start = FALSE;
			ref_start = FALSE;
		}
	}
	while (ianjuta_iterable_previous (cur_pos, NULL));

	if (stmt)
	{
		gint lineno;
		gchar *above_text;
		IAnjutaIterable* start;
		
		if (!assist->priv->editor_filename)
		{
			g_free (stmt);
			return NULL;
		}
		
		start = ianjuta_editor_get_start_position (editor, NULL);
		above_text = ianjuta_editor_get_text (editor, start, iter, NULL);
		g_object_unref (start);
		
		lineno = ianjuta_editor_get_lineno (editor, NULL);

		/* the parser works even for the "Gtk::" like expressions, so it 
		 * shouldn't be created a specific case to handle this.
		 */
		res = engine_parser_process_expression (stmt,
		                                        above_text,
		                                        assist->priv->editor_filename,
		                                        lineno);
		g_free (stmt);
	}
	g_object_unref (cur_pos);
	return res;
}
コード例 #21
0
ファイル: plugin.c プロジェクト: rosedu/anjuta
static void
install_support (PythonPlugin *lang_plugin)
{	
	IAnjutaLanguage* lang_manager =
		anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
									IAnjutaLanguage, NULL);
	IAnjutaSymbolManager* sym_manager = 
		anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
		                            IAnjutaSymbolManager,
		                            NULL);
	IAnjutaDocumentManager* docman = 
		anjuta_shell_get_interface (ANJUTA_PLUGIN (lang_plugin)->shell,
		                            IAnjutaDocumentManager,
		                            NULL);
		
	if (!lang_manager || !sym_manager || !docman)
		return;
	
	if (lang_plugin->support_installed)
		return;
	
	lang_plugin->current_language = 
		ianjuta_language_get_name_from_editor (lang_manager, 
											   IANJUTA_EDITOR_LANGUAGE (lang_plugin->current_editor), NULL);
	
	if (lang_plugin->current_language &&
		(g_str_equal (lang_plugin->current_language, "Python")))
	{
		g_signal_connect (lang_plugin->current_editor,
						  "char-added",
						  G_CALLBACK (on_editor_char_inserted_python),
						  lang_plugin);
	}
	else
	{
		return;
	}
	
	python_indent_init (lang_plugin);
	/* Disable editor intern auto-indent */
	ianjuta_editor_set_auto_indent (IANJUTA_EDITOR(lang_plugin->current_editor),
								    FALSE, NULL);
	
	if (IANJUTA_IS_EDITOR_ASSIST (lang_plugin->current_editor) )
	{
		AnjutaPlugin *plugin;		
		AnjutaUI *ui;
		IAnjutaEditorAssist* iassist;

		const gchar *project_root;
		gchar *editor_filename;		

		check_support (lang_plugin);
		
		plugin = ANJUTA_PLUGIN (lang_plugin);
		ui = anjuta_shell_get_ui (plugin->shell, NULL);
		iassist = IANJUTA_EDITOR_ASSIST (lang_plugin->current_editor);
		
		g_assert (lang_plugin->assist == NULL);

		project_root = ANJUTA_PLUGIN_PYTHON(plugin)->project_root_directory;
		editor_filename = ANJUTA_PLUGIN_PYTHON(plugin)->current_editor_filename;

		lang_plugin->assist = python_assist_new (iassist,
		                                         sym_manager,
		                                         docman,
		                                         lang_plugin->settings,
		                                         editor_filename,
		                                         project_root);
	}	

	if (IANJUTA_IS_EDITOR_GLADE_SIGNAL (lang_plugin->current_editor))
	{
		g_signal_connect (lang_plugin->current_editor,
		                  "drop-possible", G_CALLBACK (gtk_true), NULL);
		g_signal_connect (lang_plugin->current_editor,
		                  "drop", G_CALLBACK (on_glade_drop),
		                  lang_plugin);
	}

	lang_plugin->support_installed = TRUE;
}
コード例 #22
0
ファイル: anjuta-docman.c プロジェクト: tuxdna/anjuta
IAnjutaEditor *
anjuta_docman_goto_file_line_mark (AnjutaDocman *docman, GFile* file,
								   gint line, gboolean mark)
{
	IAnjutaDocument *doc;
	IAnjutaEditor *te;
	AnjutaDocmanPage *page;

	g_return_val_if_fail (file != NULL, NULL);

	if (!g_file_query_exists (file, NULL))
	{
		return NULL;
	}

	/* Save current uri and line in document history list */
	page = anjuta_docman_get_current_page (docman);
	if (page && page->doc && IANJUTA_IS_FILE (page->doc))
	{
		GFile* file = ianjuta_file_get_file (IANJUTA_FILE (page->doc), NULL);

		if (file)
		{
			gint line = 0;

			if (IANJUTA_IS_EDITOR (page->doc))
			{
				line = ianjuta_editor_get_lineno (IANJUTA_EDITOR (page->doc), NULL);
			}

			an_file_history_push (file, line);
		}
	}

	/* if possible, use a document that's already open */
	doc = anjuta_docman_get_document_for_file (docman, file);
	if (doc == NULL)
	{
		te = anjuta_docman_add_editor (docman, file, NULL);
		doc = IANJUTA_DOCUMENT (te);
	}
	else if (IANJUTA_IS_EDITOR (doc))
	{
		te = IANJUTA_EDITOR (doc);
	}
	else
	{
		doc = NULL;
		te = NULL;
	}

	if (te != NULL)
	{
		if (line >= 0)
		{
			ianjuta_editor_goto_line (te, line, NULL);
			if (mark && IANJUTA_IS_MARKABLE (doc))
			{
				ianjuta_markable_delete_all_markers (IANJUTA_MARKABLE (doc),
													IANJUTA_MARKABLE_LINEMARKER,
													NULL);
				ianjuta_markable_mark (IANJUTA_MARKABLE (doc), line,
									  IANJUTA_MARKABLE_LINEMARKER, NULL, NULL);
			}
		}
	}
	if (doc != NULL)
	{
		anjuta_docman_present_notebook_page (docman, doc);
		ianjuta_document_grab_focus (IANJUTA_DOCUMENT (doc), NULL);
	}

	return te;
}
コード例 #23
0
ファイル: plugin.c プロジェクト: rosedu/anjuta
static void 
iprovider_populate (IAnjutaProvider *obj, IAnjutaIterable* iter, GError **err)
{
	static GList *trash = NULL;
	JSLang *plugin = (JSLang*)obj;

	if (plugin->last) {
		g_object_unref (plugin->last);
	}

        plugin->last = ianjuta_iterable_clone(iter, NULL);

	if (!plugin->current_editor)
		return;
	gint depth;
	GList *suggestions = NULL;
	gchar *str = code_completion_get_str (IANJUTA_EDITOR (plugin->current_editor), FALSE);

	if (trash)
	{
		g_list_foreach (trash, (GFunc)g_free, NULL);
		g_list_free (trash);
		trash = NULL;
	}

	if (!str)
		return;

	g_assert (plugin->prefs);

	if (strlen (str) < g_settings_get_int (plugin->prefs, MIN_CODECOMPLETE))
	{
		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
		return;
	}

	gchar *file = file_completion (IANJUTA_EDITOR (plugin->current_editor), &depth);
	gint i;
	DEBUG_PRINT ("JSLang: Auto complete for %s (TMFILE=%s)", str, file);
	for (i = strlen (str) - 1; i; i--)
	{
		if (str[i] == '.')
			break;
	}
	if (i > 0)
	{
		suggestions = code_completion_get_list (plugin, file, g_strndup (str, i), depth);
	}
	else
		suggestions = code_completion_get_list (plugin, file, NULL, depth);
	if (suggestions)
	{
		GList *nsuggest = NULL;
                gint k;
		if (i > 0)
		{
			suggestions = filter_list (suggestions, str + i + 1);
			k = strlen (str + i + 1);
		} else
		{
			suggestions = filter_list (suggestions, str);
			k = strlen (str);
		}
		GList *i;
		for (; k > 0; k--)
			ianjuta_iterable_previous (plugin->last, NULL);

		for (i = suggestions; i; i = g_list_next(i)) {
			IAnjutaEditorAssistProposal* proposal = g_new0(IAnjutaEditorAssistProposal, 1);

			if (!i->data)
				continue;
	
			proposal->label = i->data;
			proposal->data = i->data;
			nsuggest = g_list_prepend (nsuggest, proposal);
		}
		ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  nsuggest,  TRUE, NULL);
		g_list_free (nsuggest);
                trash = suggestions;
		return;
	}
	ianjuta_editor_assist_proposals ( IANJUTA_EDITOR_ASSIST (plugin->current_editor), obj,  NULL,  TRUE, NULL);
}