SF.net SVN: geany-plugins: [119] trunk/geanylua

ntrel at users.sourceforge.net ntrel at xxxxx
Tue Jul 15 17:44:26 UTC 2008


Revision: 119
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=119&view=rev
Author:   ntrel
Date:     2008-07-15 10:44:25 -0700 (Tue, 15 Jul 2008)

Log Message:
-----------
Fix for GeanyEditor changes.

Modified Paths:
--------------
    trunk/geanylua/ChangeLog
    trunk/geanylua/glspi.h
    trunk/geanylua/glspi_app.c
    trunk/geanylua/glspi_doc.c
    trunk/geanylua/glspi_run.c
    trunk/geanylua/glspi_sci.c
    trunk/geanylua/glspi_ver.h

Modified: trunk/geanylua/ChangeLog
===================================================================
--- trunk/geanylua/ChangeLog	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/ChangeLog	2008-07-15 17:44:25 UTC (rev 119)
@@ -1,3 +1,6 @@
+July 15, 2008 (ntrel)
+  Fix for GeanyEditor changes.
+
 July 11, 2008 (ntrel)
   Use plugin_init(), plugin_cleanup().
   Add macro for main_widgets, fix project access.

Modified: trunk/geanylua/glspi.h
===================================================================
--- trunk/geanylua/glspi.h	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/glspi.h	2008-07-15 17:44:25 UTC (rev 119)
@@ -59,7 +59,7 @@
 
 #define DOC_REQUIRED \
 	GeanyDocument *doc = p_document->get_current();\
-	if (!(doc && doc->sci)) {return 0;}
+	if (!(doc && doc->is_valid)) {return 0;}
 
 
 #define SetTableValue(name,value,pusher) \

Modified: trunk/geanylua/glspi_app.c
===================================================================
--- trunk/geanylua/glspi_app.c	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/glspi_app.c	2008-07-15 17:44:25 UTC (rev 119)
@@ -12,6 +12,7 @@
 #define NEED_FAIL_ARG_TYPE
 #include "glspi.h"
 
+#include "editor.h"
 #include "templates.h"
 
 
@@ -580,9 +581,9 @@
 	}
 
 	if (prompt && doc && doc->is_valid ) {
-		gint fvl=sci_send_message(doc->sci,SCI_GETFIRSTVISIBLELINE, 0,0);
-		gint pos=p_sci->get_position_from_line(doc->sci, fvl+1);
-		sci_send_message(doc->sci,SCI_CALLTIPSHOW,pos+3, (gint)prompt);
+		gint fvl=sci_send_message(doc->editor->sci,SCI_GETFIRSTVISIBLELINE, 0,0);
+		gint pos=p_sci->get_position_from_line(doc->editor->sci, fvl+1);
+		sci_send_message(doc->editor->sci,SCI_CALLTIPSHOW,pos+3, (gint)prompt);
 	}
 	gdk_window_add_filter(main_widgets->window->window, keygrab_cb, &km);
 	do {
@@ -596,7 +597,7 @@
 
 	gdk_window_remove_filter(main_widgets->window->window, keygrab_cb, &km);
 	if (prompt && doc && doc->is_valid) {
-	p_sci->send_command(doc->sci, SCI_CALLTIPCANCEL);
+	p_sci->send_command(doc->editor->sci, SCI_CALLTIPCANCEL);
 	}
 	km.group=0; /* reset the hijacked flag before passing to GDK */
 	lua_pushstring(L, gdk_keyval_name(gdk_keymap_lookup_key(NULL, &km)));

Modified: trunk/geanylua/glspi_doc.c
===================================================================
--- trunk/geanylua/glspi_doc.c	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/glspi_doc.c	2008-07-15 17:44:25 UTC (rev 119)
@@ -7,8 +7,10 @@
 #define NEED_FAIL_ARG_TYPES
 #include "glspi.h"
 
+#include "editor.h"
 
 
+
 #define DOCS ((GeanyDocument**)(documents_array->pdata))
 #define NOTEBOOK GTK_NOTEBOOK(main_widgets->notebook)
 
@@ -66,7 +68,7 @@
 {
 	return (
 		(idx>=0) && ((guint)idx<documents_array->len) && DOCS[idx]->is_valid
-	) ? gtk_notebook_page_num(NOTEBOOK, GTK_WIDGET(DOCS[idx]->sci)):-1;
+	) ? gtk_notebook_page_num(NOTEBOOK, GTK_WIDGET(DOCS[idx]->editor->sci)):-1;
 }
 
 

Modified: trunk/geanylua/glspi_run.c
===================================================================
--- trunk/geanylua/glspi_run.c	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/glspi_run.c	2008-07-15 17:44:25 UTC (rev 119)
@@ -48,8 +48,8 @@
 {
 	GeanyDocument* doc=p_document->get_current();
 	if ( doc && doc->is_valid ) {
-		gdk_window_invalidate_rect(GTK_WIDGET(doc->sci)->window, NULL, TRUE);
-		gdk_window_process_updates(GTK_WIDGET(doc->sci)->window, TRUE);
+		gdk_window_invalidate_rect(GTK_WIDGET(doc->editor->sci)->window, NULL, TRUE);
+		gdk_window_process_updates(GTK_WIDGET(doc->editor->sci)->window, TRUE);
 	}
 }
 
@@ -84,7 +84,7 @@
 	GeanyDocument *doc=p_document->open_file(fn, FALSE, NULL, NULL);
 	if (doc) {
 		if (doc->is_valid) {
-			ScintillaObject*sci=doc->sci;
+			ScintillaObject*sci=doc->editor->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_sci.c
===================================================================
--- trunk/geanylua/glspi_sci.c	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/glspi_sci.c	2008-07-15 17:44:25 UTC (rev 119)
@@ -21,13 +21,13 @@
 
 	GeanyDocument *doc = p_document->get_current();
 
-	if ((!doc) || (!doc->sci)) { return 0; }
+	if (!doc) { return 0; }
 	if (0 == lua_gettop(L)) { /* Called with no args, GET the current text */
-		gint len = p_sci->get_length(doc->sci);
+		gint len = p_sci->get_length(doc->editor->sci);
 		gchar *txt = NULL;
 		if (len>0) {
 			txt = g_malloc0((guint)len+2);
-			p_sci->get_text(doc->sci, len+1, txt);
+			p_sci->get_text(doc->editor->sci, len+1, txt);
 			lua_pushstring(L, (const gchar *) txt);
 			g_free(txt);
 		} else {
@@ -40,7 +40,7 @@
 			return FAIL_STRING_ARG(1);
 		}
 		txt = lua_tostring(L, 1);
-		p_sci->set_text(doc->sci, txt);
+		p_sci->set_text(doc->editor->sci, txt);
 		return 0;
 	}
 }
@@ -52,11 +52,11 @@
 
 	DOC_REQUIRED
 	if (0 == lua_gettop(L)) { /* Called with no args, GET the selection */
-		gint len = p_sci->get_selected_text_length(doc->sci);
+		gint len = p_sci->get_selected_text_length(doc->editor->sci);
 		gchar *txt = NULL;
 		if (len>0) {
 			txt = g_malloc0((guint)(len+1));
-			p_sci->get_selected_text(doc->sci, txt);
+			p_sci->get_selected_text(doc->editor->sci, txt);
 			lua_pushstring(L, (const gchar *) txt);
 			g_free(txt);
 		} else {
@@ -67,7 +67,7 @@
 		const gchar*txt=NULL;
 		if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); }
 		txt = lua_tostring(L, 1);
-		p_sci->replace_sel(doc->sci, txt);
+		p_sci->replace_sel(doc->editor->sci, txt);
 		return 0;
 	}
 }
@@ -82,7 +82,7 @@
 	gboolean rectsel=FALSE;
 	DOC_REQUIRED
 	if (0==argc) {
-		rectsel=sci_send_message(doc->sci, SCI_SELECTIONISRECTANGLE, 0, 0);
+		rectsel=sci_send_message(doc->editor->sci, SCI_SELECTIONISRECTANGLE, 0, 0);
 	}
 
 	lua_getglobal(L, LUA_MODULE_NAME);
@@ -99,8 +99,8 @@
 		}
 	}
 	if (0==argc) {
-		sel_end=p_sci->get_current_position(doc->sci);
-		sel_start=sci_send_message(doc->sci, SCI_GETANCHOR, 0, 0);
+		sel_end=p_sci->get_current_position(doc->editor->sci);
+		sel_start=sci_send_message(doc->editor->sci, SCI_GETANCHOR, 0, 0);
 		push_number(L, sel_start);
 		push_number(L, sel_end);
 		return 2;
@@ -113,14 +113,14 @@
 			if (!lua_isnumber(L, 2)) { return FAIL_NUMERIC_ARG(2); }
 			sel_end=lua_tonumber(L,2);
 		}
-		sci_send_message(doc->sci,
+		sci_send_message(doc->editor->sci,
 			SCI_SETSELECTIONMODE, rectsel?SC_SEL_RECTANGLE:SC_SEL_STREAM, 0);
-		p_sci->set_current_position(doc->sci, sel_end, FALSE);
-		sci_send_message(doc->sci, SCI_SETANCHOR, sel_start, 0);
-		p_sci->ensure_line_is_visible(doc->sci,
-			p_sci->get_line_from_position(doc->sci, sel_end));
-		p_sci->scroll_caret(doc->sci);
-		sci_send_message(doc->sci,
+		p_sci->set_current_position(doc->editor->sci, sel_end, FALSE);
+		sci_send_message(doc->editor->sci, SCI_SETANCHOR, sel_start, 0);
+		p_sci->ensure_line_is_visible(doc->editor->sci,
+			p_sci->get_line_from_position(doc->editor->sci, sel_end));
+		p_sci->scroll_caret(doc->editor->sci);
+		sci_send_message(doc->editor->sci,
 			SCI_SETSELECTIONMODE, rectsel?SC_SEL_RECTANGLE:SC_SEL_STREAM, 0);
 		return 0;
 	}
@@ -131,7 +131,7 @@
 static gint glspi_height(lua_State* L)
 {
 	DOC_REQUIRED
-	push_number(L, p_sci->get_line_count(doc->sci));
+	push_number(L, p_sci->get_line_count(doc->editor->sci));
 	return 1;
 }
 
@@ -140,7 +140,7 @@
 static gint glspi_length(lua_State* L)
 {
 	DOC_REQUIRED
-	push_number(L, p_sci->get_length(doc->sci));
+	push_number(L, p_sci->get_length(doc->editor->sci));
 	return 1;
 }
 
@@ -151,11 +151,11 @@
 {
 	DOC_REQUIRED
 	if (lua_gettop(L)==0) {
-		push_number(L,p_sci->get_current_position(doc->sci));
+		push_number(L,p_sci->get_current_position(doc->editor->sci));
 		return 1;
 	} else {
 		if (!lua_isnumber(L,1)) { return FAIL_NUMERIC_ARG(1); }
-		p_sci->set_current_position(doc->sci,(gint)lua_tonumber(L,1),TRUE);
+		p_sci->set_current_position(doc->editor->sci,(gint)lua_tonumber(L,1),TRUE);
 		return 0;
 	}
 }
@@ -173,19 +173,19 @@
 		case 0:
 		case 1:
 			if (argc==0) {
-				pos=p_sci->get_current_position(doc->sci);
+				pos=p_sci->get_current_position(doc->editor->sci);
 			} else {
 				if (!lua_isnumber(L,1)) { return FAIL_NUMERIC_ARG(1); }
 				pos=lua_tonumber(L,1);
 				if ( pos < 0 ) {
 					pos=0;
 				} else {
-					len=p_sci->get_length(doc->sci);
+					len=p_sci->get_length(doc->editor->sci);
 					if ( pos >= len ) { pos=len-1; }
 				}
 			}
-			line=p_sci->get_line_from_position(doc->sci,pos);
-			col=p_sci->get_col_from_position(doc->sci,pos);
+			line=p_sci->get_line_from_position(doc->editor->sci,pos);
+			col=p_sci->get_col_from_position(doc->editor->sci,pos);
 			push_number(L,line+1);
 			push_number(L,col);
 			return 2;
@@ -196,17 +196,17 @@
 			if ( line < 1 ) {
 				line=1;
 			} else {
-				cnt=p_sci->get_line_count(doc->sci);
+				cnt=p_sci->get_line_count(doc->editor->sci);
 				if ( line > cnt ) { line=cnt; }
 			}
 			col=lua_tonumber(L,2);
 			if ( col < 0 ) {
 				col=0;
 			} else {
-				len=p_sci->get_line_length(doc->sci,line);
+				len=p_sci->get_line_length(doc->editor->sci,line);
 				if (col>=len) {col=len-1;}
 			}
-			pos=p_sci->get_position_from_line(doc->sci,line-1)+col;
+			pos=p_sci->get_position_from_line(doc->editor->sci,line-1)+col;
 			push_number(L,pos);
 			return 1;
 	}
@@ -221,9 +221,9 @@
 		return FAIL_BOOL_ARG(1);
 	}
 	if (lua_toboolean(L,1)) {
-		p_sci->start_undo_action(doc->sci);
+		p_sci->start_undo_action(doc->editor->sci);
 	} else {
-		p_sci->end_undo_action(doc->sci);
+		p_sci->end_undo_action(doc->editor->sci);
 	}
 	return 0;
 }
@@ -241,13 +241,13 @@
 		if (!lua_isnumber(L,1)) { return FAIL_NUMERIC_ARG(1); }
 		pos=lua_tonumber(L,1);
 	} else {
-		pos = p_sci->get_current_position(doc->sci);
+		pos = p_sci->get_current_position(doc->editor->sci);
 	}
-	linenum = p_sci->get_line_from_position(doc->sci, pos);
-	bol = p_sci->get_position_from_line(doc->sci, linenum);
+	linenum = p_sci->get_line_from_position(doc->editor->sci, pos);
+	bol = p_sci->get_position_from_line(doc->editor->sci, linenum);
 	bow = pos - bol;
 	eow = pos - bol;
-	text=p_sci->get_line(doc->sci, linenum);
+	text=p_sci->get_line(doc->editor->sci, linenum);
 	lua_getglobal(L, LUA_MODULE_NAME);
 	if ( lua_istable(L, -1) ) {
 		lua_pushstring(L,tokenWordChars);
@@ -278,9 +278,9 @@
 */
 static gchar* get_line_text(GeanyDocument*doc,gint linenum)
 {
-	gint count=p_sci->get_line_count(doc->sci);
+	gint count=p_sci->get_line_count(doc->editor->sci);
 	if ((linenum>0)&&(linenum<=count)) {
-		gchar *text=p_sci->get_line(doc->sci, linenum-1);
+		gchar *text=p_sci->get_line(doc->editor->sci, linenum-1);
 		return text?text:g_strdup("");
 	} else {
 		return FALSE;
@@ -435,7 +435,7 @@
 	} else {
 		gint n;
 		for (n=0; n<count; n++) {
-			p_sci->send_command(doc->sci,scicmd);
+			p_sci->send_command(doc->editor->sci,scicmd);
 		}
 	}
 	return 0;
@@ -461,17 +461,17 @@
 
 	switch (lua_gettop(L)) {
 		case 0:
-			start=p_sci->get_selection_start(doc->sci);
-			stop=p_sci->get_selection_end(doc->sci);
+			start=p_sci->get_selection_start(doc->editor->sci);
+			stop=p_sci->get_selection_end(doc->editor->sci);
 			if (start>stop) { swap(&start,&stop); }
-			if (start!=stop) p_sci->send_command(doc->sci, SCI_COPY);
+			if (start!=stop) p_sci->send_command(doc->editor->sci, SCI_COPY);
 			push_number(L, stop-start);
 			return 1;
 		case 1:
 			if (!lua_isstring(L,1)) {return FAIL_STRING_ARG(1);}
 			content=lua_tostring(L,1);
 			len=strlen(content);
-			if (len) { sci_send_message(doc->sci,SCI_COPYTEXT,len,(gint)content); }
+			if (len) { sci_send_message(doc->editor->sci,SCI_COPYTEXT,len,(gint)content); }
 			push_number(L, len);
 			return 1;
 		default:
@@ -482,7 +482,7 @@
 			if (start<0) { return FAIL_UNSIGNED_ARG(1); }
 			if (stop <0) { return FAIL_UNSIGNED_ARG(2); }
 			if (start>stop) { swap(&start,&stop); }
-			if (start!=stop) sci_send_message(doc->sci,SCI_COPYRANGE,start,stop);
+			if (start!=stop) sci_send_message(doc->editor->sci,SCI_COPYRANGE,start,stop);
 			push_number(L, stop-start);
 			return 1;
 	}
@@ -494,12 +494,12 @@
 {
 	gint start,stop,len;
 	DOC_REQUIRED
-	start=p_sci->get_selection_start(doc->sci);
-	stop=p_sci->get_selection_end(doc->sci);
-	len=p_sci->get_length(doc->sci);
+	start=p_sci->get_selection_start(doc->editor->sci);
+	stop=p_sci->get_selection_end(doc->editor->sci);
+	len=p_sci->get_length(doc->editor->sci);
 	if (start>stop) {swap(&start,&stop); }
-	if (start!=stop) {p_sci->send_command(doc->sci, SCI_CUT); }
-	push_number(L,len-p_sci->get_length(doc->sci));
+	if (start!=stop) {p_sci->send_command(doc->editor->sci, SCI_CUT); }
+	push_number(L,len-p_sci->get_length(doc->editor->sci));
 	return 1;
 }
 
@@ -510,10 +510,10 @@
 static gint glspi_paste(lua_State* L)
 {
 	DOC_REQUIRED
-	if (sci_send_message(doc->sci,SCI_CANPASTE,0,0)) {
-		gint len=p_sci->get_length(doc->sci);
-		p_sci->send_command(doc->sci,SCI_PASTE);
-		push_number(L,p_sci->get_length(doc->sci)-len);
+	if (sci_send_message(doc->editor->sci,SCI_CANPASTE,0,0)) {
+		gint len=p_sci->get_length(doc->editor->sci);
+		p_sci->send_command(doc->editor->sci,SCI_PASTE);
+		push_number(L,p_sci->get_length(doc->editor->sci)-len);
 	} else {
 		lua_pushnil(L);
 	}
@@ -527,12 +527,12 @@
 	gint pos;
 	DOC_REQUIRED
 	if (lua_gettop(L)==0) {
-		pos=p_sci->get_current_position(doc->sci);
+		pos=p_sci->get_current_position(doc->editor->sci);
 	} else {
 		if ( !lua_isnumber(L,1) ) {return FAIL_NUMERIC_ARG(1);}
 		pos=lua_tonumber(L,1);
 	}
-	push_number(L,p_sci->find_bracematch(doc->sci,pos));
+	push_number(L,p_sci->find_bracematch(doc->editor->sci,pos));
 	return 1;
 }
 
@@ -544,12 +544,12 @@
 	gint pos;
 	DOC_REQUIRED
 	if (lua_gettop(L)==0) {
-		pos=p_sci->get_current_position(doc->sci);
+		pos=p_sci->get_current_position(doc->editor->sci);
 	} else {
 		if ( !lua_isnumber(L,1) ) {return FAIL_NUMERIC_ARG(1);}
 		pos=lua_tonumber(L,1);
 	}
-	push_number(L,p_sci->get_char_at(doc->sci,pos));
+	push_number(L,p_sci->get_char_at(doc->editor->sci,pos));
 	return 1;
 }
 
@@ -709,19 +709,19 @@
 		case SLT_TEXTRANGE: return FAIL_API;
 		case SLT_STRINGRESULT: 
 			if ((he->msgid==SCI_GETTEXT)&&(wparam==0)) {
-				wparam=sci_send_message(doc->sci, SCI_GETLENGTH, 0,0);
+				wparam=sci_send_message(doc->editor->sci, SCI_GETLENGTH, 0,0);
 			}
 			switch (he->msgid) {
 				case SCI_GETTEXT:
 					if (wparam==0){
-						wparam=sci_send_message(doc->sci, SCI_GETLENGTH, 0,0);
+						wparam=sci_send_message(doc->editor->sci, SCI_GETLENGTH, 0,0);
 					} else { wparam++; }
 					break;
 				case SCI_GETCURLINE:
 					if (wparam>0) { wparam++; }
 					break;
 			}
-			bufsize=sci_send_message(doc->sci, he->msgid, wparam, 0);
+			bufsize=sci_send_message(doc->editor->sci, he->msgid, wparam, 0);
 			if (bufsize) {
 				resultbuf=g_malloc0((guint)(bufsize+1));
 				lparam=GPOINTER_TO_INT(resultbuf);
@@ -736,20 +736,20 @@
 	}
 	switch (he->result) {
 		case SLT_VOID:
-			sci_send_message(doc->sci, he->msgid, wparam, lparam);
+			sci_send_message(doc->editor->sci, he->msgid, wparam, lparam);
 			lua_pushnil(L);
 			return 1;
 		case SLT_INT:
 			if (he->lparam==SLT_STRINGRESULT) {
-				sci_send_message(doc->sci, he->msgid, wparam, lparam);
+				sci_send_message(doc->editor->sci, he->msgid, wparam, lparam);
 				lua_pushstring(L,resultbuf);
 				g_free(resultbuf);
 			} else {
-				push_number(L, sci_send_message(doc->sci, he->msgid, wparam, lparam));
+				push_number(L, sci_send_message(doc->editor->sci, he->msgid, wparam, lparam));
 			}
 			return 1;
 		case SLT_BOOL:
-			lua_pushboolean(L, sci_send_message(doc->sci, he->msgid, wparam, lparam));		
+			lua_pushboolean(L, sci_send_message(doc->editor->sci, he->msgid, wparam, lparam));		
 			return 1;
 		default:return FAIL_API;
 	}
@@ -805,7 +805,7 @@
 		lua_pop(L, 1);
 	}
 
-	if (sci_send_message(doc->sci,SCI_FINDTEXT,flags,GPOINTER_TO_INT(&ttf))!=-1) {
+	if (sci_send_message(doc->editor->sci,SCI_FINDTEXT,flags,GPOINTER_TO_INT(&ttf))!=-1) {
 		push_number(L,ttf.chrgText.cpMin);
 		push_number(L,ttf.chrgText.cpMax);
 		g_free(ttf.lpstrText);

Modified: trunk/geanylua/glspi_ver.h
===================================================================
--- trunk/geanylua/glspi_ver.h	2008-07-12 11:54:09 UTC (rev 118)
+++ trunk/geanylua/glspi_ver.h	2008-07-15 17:44:25 UTC (rev 119)
@@ -14,7 +14,7 @@
 
 #define PLUGIN_AUTHOR "Jeff Pohlmeyer"
 
-#define MY_GEANY_API_VER 75
+#define MY_GEANY_API_VER 78
 
 #define LUA_MODULE_NAME "geany"
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list