[geany/geany-plugins] cf06a7: Merge pull request #358 from b4n/geanylua/less-deprecated
Jiří Techet
git-noreply at xxxxx
Thu Jun 9 09:42:10 UTC 2016
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Thu, 09 Jun 2016 09:42:10 UTC
Commit: cf06a71f55984ad39cb352a0f792da7a4d4af053
https://github.com/geany/geany-plugins/commit/cf06a71f55984ad39cb352a0f792da7a4d4af053
Log Message:
-----------
Merge pull request #358 from b4n/geanylua/less-deprecated
geanylua: Drop use of the most obvious deprecated Geany API
Modified Paths:
--------------
geanylua/glspi_doc.c
geanylua/glspi_sci.c
Modified: geanylua/glspi_doc.c
8 lines changed, 4 insertions(+), 4 deletions(-)
===================================================================
@@ -51,7 +51,7 @@ static gint filename_to_doc_idx(const gchar*fn)
{
if (fn && *fn) {
guint i;
- documents_foreach(i)
+ foreach_document(i)
{
if fncmp(fn,documents[i]->file_name) {return i; }
}
@@ -173,7 +173,7 @@ static gint glspi_documents(lua_State *L)
static gint glspi_count(lua_State* L)
{
guint i, n=0;
- documents_foreach(i)
+ foreach_document(i)
{
if (documents[i]->is_valid){n++;}
}
@@ -225,7 +225,7 @@ static gint glspi_open(lua_State* L)
}
}
if (!fn) {
- status=document_reload_file(documents[idx],NULL) ? idx : -1;
+ status=document_reload_force(documents[idx],NULL) ? idx : -1;
} else {
guint len=geany->documents_array->len;
GeanyDocument*doc=document_open_file(fn,FALSE,NULL,NULL);
@@ -235,7 +235,7 @@ static gint glspi_open(lua_State* L)
/* if len doesn't change, it means we are reloading an already open file */
/* ntrel: actually, len can stay the same when reusing invalid document slots. */
idx=document_get_current()->index;
- status=document_reload_file(documents[idx],NULL) ? idx : -1;
+ status=document_reload_force(documents[idx],NULL) ? idx : -1;
}
}
push_number(L,status+1);
Modified: geanylua/glspi_sci.c
26 lines changed, 6 insertions(+), 20 deletions(-)
===================================================================
@@ -19,16 +19,9 @@ static gint glspi_text(lua_State* L)
if (!doc) { return 0; }
if (0 == lua_gettop(L)) { /* Called with no args, GET the current text */
- gint len = sci_get_length(doc->editor->sci);
- gchar *txt = NULL;
- if (len>0) {
- txt = g_malloc0((guint)len+2);
- sci_get_text(doc->editor->sci, len+1, txt);
- lua_pushstring(L, (const gchar *) txt);
- g_free(txt);
- } else {
- lua_pushstring(L, "");
- }
+ gchar *txt = sci_get_contents(doc->editor->sci, -1);
+ lua_pushstring(L, txt ? txt : "");
+ g_free(txt);
return 1;
} else { /* Called with one arg, SET the current text */
const gchar*txt;
@@ -48,16 +41,9 @@ static gint glspi_selection(lua_State* L)
DOC_REQUIRED
if (0 == lua_gettop(L)) { /* Called with no args, GET the selection */
- gint len = sci_get_selected_text_length(doc->editor->sci);
- gchar *txt = NULL;
- if (len>0) {
- txt = g_malloc0((guint)(len+1));
- sci_get_selected_text(doc->editor->sci, txt);
- lua_pushstring(L, (const gchar *) txt);
- g_free(txt);
- } else {
- lua_pushstring(L, "");
- }
+ gchar *txt = sci_get_selection_contents(doc->editor->sci);
+ lua_pushstring(L, txt ? txt : "");
+ g_free(txt);
return 1;
} else { /* Called with one arg, SET the selection */
const gchar*txt=NULL;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Plugins-Commits
mailing list