/** * ianjuta_editor_insert: * @obj: Self * @position: Character position in editor where insert will take place. * @text: Text to append. * @length: Length of @text to use. * @err: Error propagation and reporting * * Inserts @length characters from @text buffer at given @position of * editor buffer. If @length is -1, the whole @text is used. */ void ianjuta_editor_insert (IAnjutaEditor *obj, IAnjutaIterable *position, const gchar *text, gint length, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); g_return_if_fail ((position == NULL) ||IANJUTA_IS_ITERABLE(position)); IANJUTA_EDITOR_GET_IFACE (obj)->insert (obj, position, text, length, err); }
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)); }
static void value_added_current_editor (AnjutaPlugin * plugin, const char *name, const GValue * value, gpointer data) { GObject *editor; GtkAction* macro_insert_action; AnjutaUI* ui = anjuta_shell_get_ui (plugin->shell, NULL); editor = g_value_get_object (value); if (!IANJUTA_IS_EDITOR(editor)) return; MacroPlugin *macro_plugin = ANJUTA_PLUGIN_MACRO (plugin); macro_insert_action = anjuta_ui_get_action (ui, "ActionGroupMacro", "ActionEditMacroInsert"); if (editor != NULL) { g_object_set (G_OBJECT (macro_insert_action), "sensitive", TRUE, NULL); macro_plugin->current_editor = editor; } else { g_object_set (G_OBJECT (macro_insert_action), "sensitive", FALSE, NULL); macro_plugin->current_editor = NULL; } }
/** * ianjuta_editor_goto_position: * @obj: Self * @position: Character position where carat will be moved. * @err: Error propagation and reporting * * Carat is moved to the given @position and text view is scrolled to * bring @position in viewable area of the editor. */ void ianjuta_editor_goto_position (IAnjutaEditor *obj, IAnjutaIterable *position, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); g_return_if_fail ((position == NULL) ||IANJUTA_IS_ITERABLE(position)); IANJUTA_EDITOR_GET_IFACE (obj)->goto_position (obj, position, err); }
/** * ianjuta_editor_set_popup_menu: * @obj: Self * @menu: Popupmenu * @err: Error propagation and reporting * * Set Editor popup menu. This is the menu shown in the editor when one * right-clicks on it. * */ void ianjuta_editor_set_popup_menu (IAnjutaEditor *obj, GtkWidget *menu, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); g_return_if_fail ((menu == NULL) ||GTK_IS_WIDGET(menu)); IANJUTA_EDITOR_GET_IFACE (obj)->set_popup_menu (obj, menu, err); }
void search_box_fill_search_focus (SearchBox* search_box, gboolean on_replace) { IAnjutaEditor* te = search_box->priv->current_editor; if (IANJUTA_IS_EDITOR (te) && !search_box->priv->regex_mode) { gchar *buffer; buffer = ianjuta_editor_selection_get (IANJUTA_EDITOR_SELECTION (te), NULL); if (buffer != NULL) { g_strstrip (buffer); if (*buffer != 0) { gtk_entry_set_text (GTK_ENTRY (search_box->priv->search_entry), buffer); gtk_editable_select_region (GTK_EDITABLE (search_box->priv->search_entry), 0, -1); } g_free (buffer); } } /* Toggle replace level (replace entry, replace buttons) of search box */ search_box_set_replace (search_box, on_replace); gtk_widget_grab_focus (search_box->priv->search_entry); }
/** * ianjuta_editor_line_from_position: * @obj: Self * @position: Position you want to know the line from * @err: Error propagation and reporting * * Get the line number in which @position locates. * Returns: Line which corresponds to @position * */ int ianjuta_editor_get_line_from_position (IAnjutaEditor *obj, IAnjutaIterable *position, GError **err) { g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), 0); g_return_val_if_fail ((position == NULL) ||IANJUTA_IS_ITERABLE(position), 0); return IANJUTA_EDITOR_GET_IFACE (obj)->get_line_from_position (obj, position, err); }
/** * ianjuta_editor_erase_range: * @obj: Self * @position_start: Start position of chars to erase. * @position_end: End position of chars to erase. * @err: Error propagation and reporting * * Erases the chars between positions pointed by @position_start and * @position_end. The character pointed by @position_start is included, * while pointed by @position_end is not include in the range. After * the erase operation, all active iters, except these two, are no * longer guranteed to be valid. At the end the operation, these two * iters point to the same position which is the position where erase * happend (usually the original @position_start position). */ void ianjuta_editor_erase (IAnjutaEditor *obj, IAnjutaIterable *position_start, IAnjutaIterable *position_end, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); g_return_if_fail ((position_start == NULL) ||IANJUTA_IS_ITERABLE(position_start)); g_return_if_fail ((position_end == NULL) ||IANJUTA_IS_ITERABLE(position_end)); IANJUTA_EDITOR_GET_IFACE (obj)->erase (obj, position_start, position_end, err); }
/** * ianjuta_editor_get_text: * @obj: Self * @begin: Begining iterator * @end: End iterator * @err: Error propagation and reporting * * Gets text characters beginning from @begin (including char * pointed by @begin) and ending with @end (excluding character * pointed by @end). The characters returned are utf-8 encoded. * The iterators @begin and @end could be in either order. The returned * text, however, is in right order. If both @begin and @end points * to the same position, NULL is returned. * * Returns: A buffer of utf-8 characters. * The returned buffer must be freed when no longer required. */ gchar* ianjuta_editor_get_text (IAnjutaEditor *obj, IAnjutaIterable *begin, IAnjutaIterable *end, GError **err) { g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL); g_return_val_if_fail ((begin == NULL) ||IANJUTA_IS_ITERABLE(begin), NULL); g_return_val_if_fail ((end == NULL) ||IANJUTA_IS_ITERABLE(end), NULL); return IANJUTA_EDITOR_GET_IFACE (obj)->get_text (obj, begin, end, err); }
static void on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name, const GValue *value, gpointer data) { CppJavaPlugin *lang_plugin; IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value)); lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin); if (IANJUTA_IS_EDITOR(doc)) lang_plugin->current_editor = G_OBJECT(doc); else { lang_plugin->current_editor = NULL; return; } if (IANJUTA_IS_EDITOR(lang_plugin->current_editor)) install_support (lang_plugin); g_signal_connect (lang_plugin->current_editor, "language-changed", G_CALLBACK (on_editor_language_changed), plugin); }
static void on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name, gpointer data) { JSLang *js_support_plugin; DEBUG_PRINT ("%s", "JSLang: Remove editor"); js_support_plugin = (JSLang*) plugin; if (IANJUTA_IS_EDITOR(js_support_plugin->current_editor)) uninstall_support (js_support_plugin); js_support_plugin->current_editor = NULL; }
static void on_value_removed_current_editor (AnjutaPlugin *plugin, const gchar *name, gpointer data) { CppJavaPlugin *lang_plugin; lang_plugin = ANJUTA_PLUGIN_CPP_JAVA (plugin); if (lang_plugin->current_editor) g_signal_handlers_disconnect_by_func (lang_plugin->current_editor, G_CALLBACK (on_editor_language_changed), plugin); if (IANJUTA_IS_EDITOR(lang_plugin->current_editor)) uninstall_support (lang_plugin); lang_plugin->current_editor = NULL; }
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); } }
void anjuta_docman_delete_all_indicators (AnjutaDocman *docman) { GList *node; for (node = docman->priv->pages; node; node = g_list_next (node)) { AnjutaDocmanPage *page; page = (AnjutaDocmanPage *) node->data; if (IANJUTA_IS_EDITOR (page->doc)) { ianjuta_markable_unmark (IANJUTA_MARKABLE (page->doc), -1, -1, NULL); } } }
/* 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); } }
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); } } }
/** * anjuta_docman_add_editor: * @docman: pointer to docman data struct * @uri: string with uri of file to edit, may be "" or NULL * @name: string with name of file to edit, may be absolute path or just a basename or "" or NULL * * Add a new editor, working on specified uri or filename if any * * Return value: the editor */ IAnjutaEditor * anjuta_docman_add_editor (AnjutaDocman *docman, GFile* file, const gchar *name) { IAnjutaEditor *te; IAnjutaEditorFactory* factory; factory = anjuta_shell_get_interface (docman->shell, IAnjutaEditorFactory, NULL); te = ianjuta_editor_factory_new_editor (factory, file, name, NULL); /* if file cannot be loaded, text-editor brings up an error dialog ? */ if (te != NULL) { if (IANJUTA_IS_EDITOR (te)) ianjuta_editor_set_popup_menu (te, docman->priv->popup_menu, NULL); anjuta_docman_add_document (docman, IANJUTA_DOCUMENT (te), file); } return te; }
static void on_value_added_current_editor (AnjutaPlugin *plugin, const gchar *name, const GValue *value, gpointer data) { JSLang *js_support_plugin; IAnjutaDocument* doc = IANJUTA_DOCUMENT(g_value_get_object (value)); DEBUG_PRINT ("%s", "JSLang: Add editor"); js_support_plugin = (JSLang*) plugin; if (IANJUTA_IS_EDITOR(doc)) js_support_plugin->current_editor = G_OBJECT(doc); else { js_support_plugin->current_editor = NULL; return; } install_support (js_support_plugin); }
/** * anjuta_apply_modeline: * @editor: #IAnjutaEditor object * * Check the editor buffer to find a mode line and update the indentation * settings if found. * * The mode line is special line used by the text editor to define settings for * the current file, typically indentation. Anjuta currently recognize two kinds * of mode line: * * Emacs mode line, on the first or the second line if the first one is a * shebang (#!) with the following format: * -*- key1: value1; key2: value2 -*- * * Vim mode line, one the first 5 or the last 5 lines with the following format: * vim:set key1=value1 key2=value2 * * Returns: %TRUE if a mode line has been found and applied. */ gboolean anjuta_apply_modeline (IAnjutaEditor *editor) { IndentationParams params = {CHECK_NEXT,0,0,0}; gint line; gchar *content = NULL; g_return_val_if_fail (IANJUTA_IS_EDITOR (editor), FALSE); /* Check the first lines */ for (line = 1; params.settings == CHECK_NEXT; line++) { g_free (content); content = get_editor_line (editor, line); if (content == NULL) return FALSE; params.settings = 0; if (parse_vim_modeline (¶ms, content, line)) break; if (parse_emacs_modeline (¶ms, content, line)) break; } /* Check the last lines */ if (params.settings == 0) params.settings = CHECK_NEXT; for (line = -1;params.settings == CHECK_NEXT; line--) { g_free (content); content = get_editor_line (editor, line); if (content == NULL) return FALSE; params.settings = 0; if (parse_vim_modeline (¶ms, content, line)) break; if (parse_emacs_modeline (¶ms, content, line)) break; } g_free (content); /* Set indentation settings */ return set_indentation (editor, ¶ms); }
static void install_support (JSLang *plugin) { const gchar *lang; IAnjutaLanguage* lang_manager; setPlugin (plugin); if (!IANJUTA_IS_EDITOR (plugin->current_editor)) return; lang_manager = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell, IAnjutaLanguage, NULL); if (!lang_manager) return; lang = ianjuta_language_get_name_from_editor (lang_manager, IANJUTA_EDITOR_LANGUAGE (plugin->current_editor), NULL); if (!lang || !g_str_equal (lang, "JavaScript")) return; DEBUG_PRINT ("%s", "JSLang: Install support"); ianjuta_editor_assist_add (IANJUTA_EDITOR_ASSIST(plugin->current_editor), IANJUTA_PROVIDER(plugin), NULL); }
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); } }
/** * ianjuta_editor_get_tabsize: * @obj: Self * @err: Error propagation and reporting * * Returns the tabsize (in spaces) currently used by the editor. * * Returns: tabsize in number of spaces */ gint ianjuta_editor_get_tabsize (IAnjutaEditor *obj, GError **err) { g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), -1); return IANJUTA_EDITOR_GET_IFACE (obj)->get_tabsize (obj, err); }
/** * ianjuta_editor_set_use_space: * @obj: Self * @use_spaces: TRUE to use spaces, FALSE to use tab char directly. * @err: Error propagation and reporting * * Sets if the editor should use spaces for filling up tab characters. */ void ianjuta_editor_set_use_spaces (IAnjutaEditor *obj, gboolean use_spaces, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); IANJUTA_EDITOR_GET_IFACE (obj)->set_use_spaces (obj, use_spaces, err); }
/** * ianjuta_editor_get_text_all: * @obj: Self * @err: Error propagation and reporting * * Gets all text characters in the editor. * The characters returned are utf-8 encoded. * * Returns: A buffer of utf-8 characters containing all text from editor. * The returned buffer must be freed when no longer required. */ gchar* ianjuta_editor_get_text_all (IAnjutaEditor *obj, GError **err) { g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), NULL); return IANJUTA_EDITOR_GET_IFACE (obj)->get_text_all (obj, err); }
/** * ianjuta_editor_set_tabsize: * @obj: Self * @tabsize: Tabsize in spaces * @err: Error propagation and reporting * * Sets the tabsize of the editor. */ void ianjuta_editor_set_tabsize (IAnjutaEditor *obj, gint tabsize, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); IANJUTA_EDITOR_GET_IFACE (obj)->set_tabsize (obj, tabsize, err); }
/** * ianjuta_editor_set_auto_indent: * @obj: Self * @auto_indent: TRUE to enable auto-indent, FALSE to disable * * Sets whether the editor should auto-indent itself. A plugin that does * custom auto-indent can set this to false and override the preferences * setting */ void ianjuta_editor_set_auto_indent (IAnjutaEditor *obj, gboolean auto_indent, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); IANJUTA_EDITOR_GET_IFACE (obj)->set_auto_indent (obj, auto_indent, err); }
/** * ianjuta_editor_append: * @obj: Self * @text: Text to append. * @length: Length of @text to use. * @err: Error propagation and reporting * * Appends @length characters from @text buffer at the end of editor * buffer. If @length is -1, the whole @text is used. @length is in bytes. */ void ianjuta_editor_append (IAnjutaEditor *obj, const gchar *text, gint length, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); IANJUTA_EDITOR_GET_IFACE (obj)->append (obj, text, length, err); }
/** * ianjuta_editor_goto_start: * @obj: Self * @err: Error propagation and reporting * * Carat is moved to the begining of editor and text view is scrolled to * bring it in viewable area of the editor. */ void ianjuta_editor_goto_start (IAnjutaEditor *obj, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); IANJUTA_EDITOR_GET_IFACE (obj)->goto_start (obj, err); }
/** * ianjuta_editor_get_use_spaces: * @obj: Self * @err: Error propagation and reporting * * Returns if the editor uses spaces for filling up tab characters. * * Returns: TRUE if yes, FALSE if no. */ gboolean ianjuta_editor_get_use_spaces (IAnjutaEditor *obj, GError **err) { g_return_val_if_fail (IANJUTA_IS_EDITOR(obj), FALSE); return IANJUTA_EDITOR_GET_IFACE (obj)->get_use_spaces (obj, err); }
/** * ianjuta_editor_goto_line: * @obj: Self * @lineno: line number where carat will be moved. * @err: Error propagation and reporting * * Carat is moved to the given @lineno line and text view is scrolled to * bring it in viewable area of the editor. */ void ianjuta_editor_goto_line (IAnjutaEditor *obj, gint lineno, GError **err) { g_return_if_fail (IANJUTA_IS_EDITOR(obj)); IANJUTA_EDITOR_GET_IFACE (obj)->goto_line (obj, lineno, err); }