Revision: 99 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=99&view=rev Author: ntrel Date: 2008-07-02 09:45:28 -0700 (Wed, 02 Jul 2008)
Log Message: ----------- Update to use document pointers. Update MY_GEANY_API_VER now we use p_document->close(). Update for new PLUGIN_ macro names. Add comment about reloading in glspi_open().
Modified Paths: -------------- trunk/geanylua/ChangeLog trunk/geanylua/geanylua.c trunk/geanylua/glspi_doc.c trunk/geanylua/glspi_run.c trunk/geanylua/glspi_ver.h
Modified: trunk/geanylua/ChangeLog =================================================================== --- trunk/geanylua/ChangeLog 2008-07-01 13:32:37 UTC (rev 98) +++ trunk/geanylua/ChangeLog 2008-07-02 16:45:28 UTC (rev 99) @@ -1,3 +1,9 @@ +July 2, 2008 (ntrel) + Update to use document pointers. + Update MY_GEANY_API_VER now we use p_document->close(). + Update for new PLUGIN_ macro names. + Add comment about reloading in glspi_open(). + July 1, 2008 (ntrel) Begin updating for Geany 0.15 API changes. Use main_widgets instead of old app.
Modified: trunk/geanylua/geanylua.c =================================================================== --- trunk/geanylua/geanylua.c 2008-07-01 13:32:37 UTC (rev 98) +++ trunk/geanylua/geanylua.c 2008-07-02 16:45:28 UTC (rev 99) @@ -48,10 +48,10 @@ #define MKPATH(dir) g_build_path(G_DIR_SEPARATOR_S, dir, "plugins", "geanylua", SUPPORT_LIB, NULL);
PLUGIN_EXPORT -VERSION_CHECK(MY_GEANY_API_VER) +PLUGIN_VERSION_CHECK(MY_GEANY_API_VER)
PLUGIN_EXPORT -PLUGIN_INFO(PLUGIN_NAME, PLUGIN_DESC, PLUGIN_VER, PLUGIN_AUTHOR) +PLUGIN_SET_INFO(PLUGIN_NAME, PLUGIN_DESC, PLUGIN_VER, PLUGIN_AUTHOR)
PLUGIN_EXPORT GeanyFunctions *geany_functions;
Modified: trunk/geanylua/glspi_doc.c =================================================================== --- trunk/geanylua/glspi_doc.c 2008-07-01 13:32:37 UTC (rev 98) +++ trunk/geanylua/glspi_doc.c 2008-07-02 16:45:28 UTC (rev 99) @@ -74,7 +74,7 @@ /* Returns the filename of the specified document, or NULL on bad index */ static const gchar* doc_idx_to_filename(gint idx) { if ( (idx >= 0 ) && ( ((guint)idx) < doc_array->len ) ) { - document *doc=&g_array_index(doc_array, document, idx); + document *doc=g_ptr_array_index(doc_array, idx); if (doc) { return doc->file_name?doc->file_name:GEANY_STRING_UNTITLED; } } return NULL; @@ -175,7 +175,7 @@ { guint i, n=0; for (i=0; i<doc_array->len; i++) { - if (((document*)&(doc_array->data[i]))->is_valid){n++;} + if (DOCS[i]->is_valid){n++;} } push_number(L,n); return 1; @@ -188,13 +188,15 @@ gboolean status=FALSE; if (lua_gettop(L)==0){ DOC_REQUIRED - status=p_document->save_file(p_document->get_cur_idx(), TRUE); + status=p_document->save_file(p_document->get_current(), TRUE); } else { if (lua_isnumber(L,1)) { - status=p_document->save_file((gint)lua_tonumber(L,1)-1, TRUE); + gint idx=(gint)lua_tonumber(L,1)-1; + status=p_document->save_file(DOCS[idx], TRUE); } else { if (lua_isstring(L,1)) { - status=p_document->save_file(filename_to_doc_idx(lua_tostring(L,1)), TRUE); + gint idx=filename_to_doc_idx(lua_tostring(L,1)); + status=p_document->save_file(DOCS[idx], TRUE); } else { return FAIL_STR_OR_NUM_ARG(1); } } } @@ -212,7 +214,7 @@
if (lua_gettop(L)==0) { DOC_REQUIRED - idx=p_document->get_cur_idx(); + idx=p_document->get_current()->index; } else { if (lua_isnumber(L,1)) { idx=lua_tonumber(L,1)-1; @@ -223,15 +225,17 @@ } } if (!fn) { - status=p_document->reload_file(idx,NULL) ? idx : -1; + status=p_document->reload_file(DOCS[idx],NULL) ? idx : -1; } else { guint len=doc_array->len; - status=p_document->open_file(fn,FALSE,NULL,NULL); + GeanyDocument*doc=p_document->open_file(fn,FALSE,NULL,NULL); + status=doc?doc->index:-1; if ( (status>=0) && (len==doc_array->len)) { /* if len doesn't change, it means we are reloading an already open file */ - idx=p_document->get_cur_idx(); - status=p_document->reload_file(idx,NULL) ? idx : -1; + /* ntrel: actually, len can stay the same when reusing invalid document slots. */ + idx=p_document->get_current()->index; + status=p_document->reload_file(DOCS[idx],NULL) ? idx : -1; } } push_number(L,status+1); @@ -245,13 +249,15 @@ gboolean status=FALSE; if (lua_gettop(L)==0){ DOC_REQUIRED - status=p_document->remove((guint)p_document->get_cur_idx()); + status=p_document->close(p_document->get_current()); } else { if (lua_isnumber(L,1)) { - status=p_document->remove((guint)lua_tonumber(L,1)-1); + guint idx=(guint)lua_tonumber(L,1)-1; + status=p_document->close(DOCS[idx]); } else { if (lua_isstring(L,1)) { - status=p_document->remove((guint)filename_to_doc_idx(lua_tostring(L,1))); + guint idx=(guint)filename_to_doc_idx(lua_tostring(L,1)); + status=p_document->close(DOCS[idx]); } else { return FAIL_STR_OR_NUM_ARG(1); } } }
Modified: trunk/geanylua/glspi_run.c =================================================================== --- trunk/geanylua/glspi_run.c 2008-07-01 13:32:37 UTC (rev 98) +++ trunk/geanylua/glspi_run.c 2008-07-02 16:45:28 UTC (rev 99) @@ -81,11 +81,10 @@
static gboolean glspi_goto_error(gchar *fn, gint line) { - gint idx=p_document->open_file(fn, FALSE, NULL, NULL); - if (idx>=0) { - document doc=g_array_index(doc_array,document,idx); - if (doc.is_valid) { - ScintillaObject*sci=doc.sci; + GeanyDocument *doc=p_document->open_file(fn, FALSE, NULL, NULL); + if (doc) { + if (doc->is_valid) { + ScintillaObject*sci=doc->sci; if (sci) { gint pos=p_sci->get_position_from_line(sci,line-1); p_sci->set_current_position(sci,pos,TRUE);
Modified: trunk/geanylua/glspi_ver.h =================================================================== --- trunk/geanylua/glspi_ver.h 2008-07-01 13:32:37 UTC (rev 98) +++ trunk/geanylua/glspi_ver.h 2008-07-02 16:45:28 UTC (rev 99) @@ -14,7 +14,7 @@
#define PLUGIN_AUTHOR "Jeff Pohlmeyer"
-#define MY_GEANY_API_VER 50 +#define MY_GEANY_API_VER 73
#define LUA_MODULE_NAME "geany"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.