SF.net SVN: geany:[3310] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Dec 3 18:03:54 UTC 2008
Revision: 3310
http://geany.svn.sourceforge.net/geany/?rev=3310&view=rev
Author: ntrel
Date: 2008-12-03 18:03:54 +0000 (Wed, 03 Dec 2008)
Log Message:
-----------
Add document_index(), filetypes_index() array accessor functions to
the plugin API.
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/geanyfunctions.h
trunk/src/document.c
trunk/src/document.h
trunk/src/filetypes.c
trunk/src/filetypes.h
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/ChangeLog 2008-12-03 18:03:54 UTC (rev 3310)
@@ -8,6 +8,10 @@
the geanyfunctions.h macro works.
Deprecate p_sci->send_message().
Add scintilla_new() to the plugin API.
+ * src/plugindata.h, src/filetypes.c, src/filetypes.h, src/document.c,
+ src/plugins.c, src/document.h, plugins/geanyfunctions.h:
+ Add document_index(), filetypes_index() array accessor functions to
+ the plugin API.
2008-12-02 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/plugins/geanyfunctions.h
===================================================================
--- trunk/plugins/geanyfunctions.h 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/plugins/geanyfunctions.h 2008-12-03 18:03:54 UTC (rev 3310)
@@ -36,6 +36,8 @@
p_document->set_filetype
#define document_close \
p_document->close
+#define document_index \
+ p_document->index
#define editor_get_indent_prefs \
p_editor->get_indent_prefs
#define editor_create_widget \
@@ -226,6 +228,8 @@
p_filetypes->detect_from_file
#define filetypes_lookup_by_name \
p_filetypes->lookup_by_name
+#define filetypes_index \
+ p_filetypes->index
#define navqueue_goto_line \
p_navqueue->goto_line
#define main_reload_configuration \
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/src/document.c 2008-12-03 18:03:54 UTC (rev 3310)
@@ -2470,14 +2470,14 @@
}
-/* useful debugging function (usually debug macros aren't enabled so can't use
- * documents[idx]) */
-#ifdef GEANY_DEBUG
-GeanyDocument *doc_at(gint idx)
+/** Accessor function for @ref GeanyData::documents_array items.
+ * @warning Always check the returned document is valid (@c doc->is_valid).
+ * @param idx @c documents_array index.
+ * @return The document, or @c NULL if @a idx is out of range. */
+GeanyDocument *document_index(gint idx)
{
return (idx >= 0 && idx < (gint) documents_array->len) ? documents[idx] : NULL;
}
-#endif
/* create a new file and copy file content and properties */
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/src/document.h 2008-12-03 18:03:54 UTC (rev 3310)
@@ -112,10 +112,8 @@
extern GPtrArray *documents_array;
-/**
- * This wraps documents_array so it can be used with C array syntax.
- * Example: documents[0]->sci = NULL;
- **/
+/* Wrap documents_array so it can be used with C array syntax.
+ * Example: documents[0]->sci = NULL; */
#define documents ((GeanyDocument **)documents_array->pdata)
/** Check that the @a doc_ptr document still exists (has not been closed).
@@ -160,6 +158,8 @@
void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type);
+GeanyDocument *document_index(gint idx);
+
GeanyDocument *document_find_by_sci(ScintillaObject *sci);
gint document_get_notebook_page(GeanyDocument *doc);
Modified: trunk/src/filetypes.c
===================================================================
--- trunk/src/filetypes.c 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/src/filetypes.c 2008-12-03 18:03:54 UTC (rev 3310)
@@ -1432,3 +1432,14 @@
g_key_file_free(userconfig);
}
+
+/** Accessor function for @ref GeanyData::filetypes_array items.
+ * Example: @code ft = filetypes_index(GEANY_FILETYPES_C); @endcode
+ * @param idx @c filetypes_array index.
+ * @return The filetype, or @c NULL if @a idx is out of range. */
+GeanyFiletype *filetypes_index(gint idx)
+{
+ return (idx >= 0 && idx < (gint) filetypes_array->len) ? filetypes[idx] : NULL;
+}
+
+
Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/src/filetypes.h 2008-12-03 18:03:54 UTC (rev 3310)
@@ -158,6 +158,8 @@
void filetypes_read_extensions(void);
+GeanyFiletype *filetypes_index(gint idx);
+
GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc);
GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/src/plugindata.h 2008-12-03 18:03:54 UTC (rev 3310)
@@ -45,7 +45,7 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
- GEANY_API_VERSION = 114,
+ GEANY_API_VERSION = 115,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
@@ -246,6 +246,7 @@
void (*set_text_changed) (struct GeanyDocument *doc, gboolean changed);
void (*set_filetype) (struct GeanyDocument *doc, struct GeanyFiletype *type);
gboolean (*close) (GeanyDocument *doc);
+ struct GeanyDocument* (*index)(gint idx);
}
DocumentFuncs;
@@ -452,6 +453,7 @@
{
GeanyFiletype* (*detect_from_file) (const gchar *utf8_filename);
GeanyFiletype* (*lookup_by_name) (const gchar *name);
+ GeanyFiletype* (*index)(gint idx);
/* Remember to convert any filetype_id arguments to GeanyFiletype pointers in any
* appended functions */
}
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-12-03 13:36:45 UTC (rev 3309)
+++ trunk/src/plugins.c 2008-12-03 18:03:54 UTC (rev 3310)
@@ -126,7 +126,8 @@
&document_set_encoding,
&document_set_text_changed,
&document_set_filetype,
- &document_close
+ &document_close,
+ &document_index
};
static EditorFuncs editor_funcs = {
@@ -268,10 +269,10 @@
&highlighting_get_style
};
-
static FiletypeFuncs filetype_funcs = {
&filetypes_detect_from_file,
- &filetypes_lookup_by_name
+ &filetypes_lookup_by_name,
+ &filetypes_index
};
static NavQueueFuncs navqueue_funcs = {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list