Add document_index(), filetypes_index() array accessor functions to
the plugin API. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3310 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
		
							parent
							
								
									80b936037e
								
							
						
					
					
						commit
						5763dfbe2d
					
				@ -8,6 +8,10 @@
 | 
				
			|||||||
   the geanyfunctions.h macro works.
 | 
					   the geanyfunctions.h macro works.
 | 
				
			||||||
   Deprecate p_sci->send_message().
 | 
					   Deprecate p_sci->send_message().
 | 
				
			||||||
   Add scintilla_new() to the plugin API.
 | 
					   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>
 | 
					2008-12-02  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 | 
				
			||||||
 | 
				
			|||||||
@ -36,6 +36,8 @@ This allows the use of normal API function names in plugins. */
 | 
				
			|||||||
	p_document->set_filetype
 | 
						p_document->set_filetype
 | 
				
			||||||
#define document_close \
 | 
					#define document_close \
 | 
				
			||||||
	p_document->close
 | 
						p_document->close
 | 
				
			||||||
 | 
					#define document_index \
 | 
				
			||||||
 | 
						p_document->index
 | 
				
			||||||
#define editor_get_indent_prefs \
 | 
					#define editor_get_indent_prefs \
 | 
				
			||||||
	p_editor->get_indent_prefs
 | 
						p_editor->get_indent_prefs
 | 
				
			||||||
#define editor_create_widget \
 | 
					#define editor_create_widget \
 | 
				
			||||||
@ -226,6 +228,8 @@ This allows the use of normal API function names in plugins. */
 | 
				
			|||||||
	p_filetypes->detect_from_file
 | 
						p_filetypes->detect_from_file
 | 
				
			||||||
#define filetypes_lookup_by_name \
 | 
					#define filetypes_lookup_by_name \
 | 
				
			||||||
	p_filetypes->lookup_by_name
 | 
						p_filetypes->lookup_by_name
 | 
				
			||||||
 | 
					#define filetypes_index \
 | 
				
			||||||
 | 
						p_filetypes->index
 | 
				
			||||||
#define navqueue_goto_line \
 | 
					#define navqueue_goto_line \
 | 
				
			||||||
	p_navqueue->goto_line
 | 
						p_navqueue->goto_line
 | 
				
			||||||
#define main_reload_configuration \
 | 
					#define main_reload_configuration \
 | 
				
			||||||
 | 
				
			|||||||
@ -2470,14 +2470,14 @@ GdkColor *document_get_status_color(GeanyDocument *doc)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* useful debugging function (usually debug macros aren't enabled so can't use
 | 
					/** Accessor function for @ref GeanyData::documents_array items.
 | 
				
			||||||
 * documents[idx]) */
 | 
					 * @warning Always check the returned document is valid (@c doc->is_valid).
 | 
				
			||||||
#ifdef GEANY_DEBUG
 | 
					 * @param idx @c documents_array index.
 | 
				
			||||||
GeanyDocument *doc_at(gint idx)
 | 
					 * @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;
 | 
						return (idx >= 0 && idx < (gint) documents_array->len) ? documents[idx] : NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* create a new file and copy file content and properties */
 | 
					/* create a new file and copy file content and properties */
 | 
				
			||||||
 | 
				
			|||||||
@ -112,10 +112,8 @@ struct GeanyDocument
 | 
				
			|||||||
extern GPtrArray *documents_array;
 | 
					extern GPtrArray *documents_array;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/* Wrap documents_array so it can be used with C array syntax.
 | 
				
			||||||
 *  This wraps documents_array so it can be used with C array syntax.
 | 
					 * Example: documents[0]->sci = NULL; */
 | 
				
			||||||
 *  Example: documents[0]->sci = NULL;
 | 
					 | 
				
			||||||
 **/
 | 
					 | 
				
			||||||
#define documents ((GeanyDocument **)documents_array->pdata)
 | 
					#define documents ((GeanyDocument **)documents_array->pdata)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** Check that the @a doc_ptr document still exists (has not been closed).
 | 
					/** Check that the @a doc_ptr document still exists (has not been closed).
 | 
				
			||||||
@ -160,6 +158,8 @@ void document_set_text_changed(GeanyDocument *doc, gboolean changed);
 | 
				
			|||||||
void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type);
 | 
					void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GeanyDocument *document_index(gint idx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GeanyDocument *document_find_by_sci(ScintillaObject *sci);
 | 
					GeanyDocument *document_find_by_sci(ScintillaObject *sci);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gint document_get_notebook_page(GeanyDocument *doc);
 | 
					gint document_get_notebook_page(GeanyDocument *doc);
 | 
				
			||||||
 | 
				
			|||||||
@ -1432,3 +1432,14 @@ void filetypes_read_extensions(void)
 | 
				
			|||||||
	g_key_file_free(userconfig);
 | 
						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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -158,6 +158,8 @@ void filetypes_init_types(void);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void filetypes_read_extensions(void);
 | 
					void filetypes_read_extensions(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GeanyFiletype *filetypes_index(gint idx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc);
 | 
					GeanyFiletype *filetypes_detect_from_document(GeanyDocument *doc);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
 | 
					GeanyFiletype *filetypes_detect_from_extension(const gchar *utf8_filename);
 | 
				
			||||||
 | 
				
			|||||||
@ -45,7 +45,7 @@
 | 
				
			|||||||
enum {
 | 
					enum {
 | 
				
			||||||
	/** The Application Programming Interface (API) version, incremented
 | 
						/** The Application Programming Interface (API) version, incremented
 | 
				
			||||||
	 * whenever any plugin data types are modified or appended to. */
 | 
						 * 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
 | 
						/** The Application Binary Interface (ABI) version, incremented whenever
 | 
				
			||||||
	 * existing fields in the plugin data types have to be changed or reordered. */
 | 
						 * existing fields in the plugin data types have to be changed or reordered. */
 | 
				
			||||||
@ -246,6 +246,7 @@ typedef struct DocumentFuncs
 | 
				
			|||||||
	void		(*set_text_changed) (struct GeanyDocument *doc, gboolean changed);
 | 
						void		(*set_text_changed) (struct GeanyDocument *doc, gboolean changed);
 | 
				
			||||||
	void		(*set_filetype) (struct GeanyDocument *doc, struct GeanyFiletype *type);
 | 
						void		(*set_filetype) (struct GeanyDocument *doc, struct GeanyFiletype *type);
 | 
				
			||||||
	gboolean	(*close) (GeanyDocument *doc);
 | 
						gboolean	(*close) (GeanyDocument *doc);
 | 
				
			||||||
 | 
						struct GeanyDocument*	(*index)(gint idx);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
DocumentFuncs;
 | 
					DocumentFuncs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -452,6 +453,7 @@ typedef struct FiletypeFuncs
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	GeanyFiletype*	(*detect_from_file) (const gchar *utf8_filename);
 | 
						GeanyFiletype*	(*detect_from_file) (const gchar *utf8_filename);
 | 
				
			||||||
	GeanyFiletype*	(*lookup_by_name) (const gchar *name);
 | 
						GeanyFiletype*	(*lookup_by_name) (const gchar *name);
 | 
				
			||||||
 | 
						GeanyFiletype*	(*index)(gint idx);
 | 
				
			||||||
	/* Remember to convert any filetype_id arguments to GeanyFiletype pointers in any
 | 
						/* Remember to convert any filetype_id arguments to GeanyFiletype pointers in any
 | 
				
			||||||
	 * appended functions */
 | 
						 * appended functions */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -126,7 +126,8 @@ static DocumentFuncs doc_funcs = {
 | 
				
			|||||||
	&document_set_encoding,
 | 
						&document_set_encoding,
 | 
				
			||||||
	&document_set_text_changed,
 | 
						&document_set_text_changed,
 | 
				
			||||||
	&document_set_filetype,
 | 
						&document_set_filetype,
 | 
				
			||||||
	&document_close
 | 
						&document_close,
 | 
				
			||||||
 | 
						&document_index
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static EditorFuncs editor_funcs = {
 | 
					static EditorFuncs editor_funcs = {
 | 
				
			||||||
@ -268,10 +269,10 @@ static HighlightingFuncs highlighting_funcs = {
 | 
				
			|||||||
	&highlighting_get_style
 | 
						&highlighting_get_style
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
static FiletypeFuncs filetype_funcs = {
 | 
					static FiletypeFuncs filetype_funcs = {
 | 
				
			||||||
	&filetypes_detect_from_file,
 | 
						&filetypes_detect_from_file,
 | 
				
			||||||
	&filetypes_lookup_by_name
 | 
						&filetypes_lookup_by_name,
 | 
				
			||||||
 | 
						&filetypes_index
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static NavQueueFuncs navqueue_funcs = {
 | 
					static NavQueueFuncs navqueue_funcs = {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user