Revision: 1869 http://geany.svn.sourceforge.net/geany/?rev=1869&view=rev Author: ntrel Date: 2007-09-11 09:05:03 -0700 (Tue, 11 Sep 2007)
Log Message: ----------- Add reload_file() document function to the plugin API.
Modified Paths: -------------- trunk/ChangeLog trunk/src/document.c trunk/src/document.h trunk/src/plugindata.h trunk/src/plugins.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-09-11 15:21:11 UTC (rev 1868) +++ trunk/ChangeLog 2007-09-11 16:05:03 UTC (rev 1869) @@ -9,6 +9,8 @@ without the idx for reloading or pos arguments. Replace str_replace() with string_replace_all() in the plugin API. Add utils_string_replace_all(), taking a GString argument. + * src/plugindata.h, src/document.c, src/plugins.c, src/document.h: + Add reload_file() document function to the plugin API.
2007-09-10 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/document.c =================================================================== --- trunk/src/document.c 2007-09-11 15:21:11 UTC (rev 1868) +++ trunk/src/document.c 2007-09-11 16:05:03 UTC (rev 1869) @@ -825,6 +825,7 @@ /* To open a new file, set idx to -1; filename should be locale encoded. * To reload a file, set the idx for the document to be reloaded; filename should be NULL. * pos is the cursor position, which can be overridden by --line and --column. + * forced_enc can be NULL to detect the file encoding. * Returns: idx of the opened file or -1 if an error occurred. * * When opening more than one file, either: @@ -1022,17 +1023,21 @@ }
-gint document_reload_file(gint idx, const gchar *forced_enc) +/* Reload document with index idx. + * forced_enc can be NULL to detect the file encoding. + * Returns: TRUE if successful. */ +gboolean document_reload_file(gint idx, const gchar *forced_enc) { gint pos = 0;
if (! DOC_IDX_VALID(idx)) - return -1; + return FALSE;
// try to set the cursor to the position before reloading pos = sci_get_current_position(doc_list[idx].sci); - return document_open_file_full(idx, NULL, pos, doc_list[idx].readonly, + idx = document_open_file_full(idx, NULL, pos, doc_list[idx].readonly, doc_list[idx].file_type, forced_enc); + return (idx != -1); }
Modified: trunk/src/document.h =================================================================== --- trunk/src/document.h 2007-09-11 15:21:11 UTC (rev 1868) +++ trunk/src/document.h 2007-09-11 16:05:03 UTC (rev 1869) @@ -143,7 +143,7 @@ const gchar *forced_enc);
-gint document_reload_file(gint idx, const gchar *forced_enc); +gboolean document_reload_file(gint idx, const gchar *forced_enc);
/* This saves the file.
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2007-09-11 15:21:11 UTC (rev 1868) +++ trunk/src/plugindata.h 2007-09-11 16:05:03 UTC (rev 1869) @@ -71,7 +71,7 @@
/* The API version should be incremented whenever any plugin data types below are * modified. */ -static const gint api_version = 17; +static const gint api_version = 18;
/* The ABI version should be incremented whenever existing fields in the plugin * data types below have to be changed or reordered. It should stay the same if fields @@ -179,6 +179,7 @@ void (*open_files)(const GSList *filenames, gboolean readonly, struct filetype *ft, const gchar *forced_enc); gboolean (*remove)(guint page_num); + gboolean (*reload_file)(gint idx, const gchar *forced_enc); } DocumentFuncs;
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2007-09-11 15:21:11 UTC (rev 1868) +++ trunk/src/plugins.c 2007-09-11 16:05:03 UTC (rev 1869) @@ -79,7 +79,8 @@ &document_save_file, &document_open_file, &document_open_files, - &document_remove + &document_remove, + &document_reload_file };
static ScintillaFuncs sci_funcs = {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.