SF.net SVN: geany: [1754] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sat Jul 28 10:27:43 UTC 2007


Revision: 1754
          http://geany.svn.sourceforge.net/geany/?rev=1754&view=rev
Author:   eht16
Date:     2007-07-28 03:27:42 -0700 (Sat, 28 Jul 2007)

Log Message:
-----------
Rename editor_auto_forif() in editor_auto_complete().
Allow using auto completion in PHP files outside of the PHP tags, generally in comments, for news files without filetype and on non-empty lines.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/editor.c
    trunk/src/editor.h
    trunk/src/keybindings.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-27 11:56:50 UTC (rev 1753)
+++ trunk/ChangeLog	2007-07-28 10:27:42 UTC (rev 1754)
@@ -1,3 +1,12 @@
+2007-07-28  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/editor.c, src/editor.h, src/keybindings.c:
+   Rename editor_auto_forif() in editor_auto_complete().
+   Allow using auto completion in PHP files outside of the PHP tags,
+   generally in comments, for news files without filetype and on
+   non-empty lines.
+
+
 2007-07-27  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * plugins/demoplugin.c, plugins/htmlchars.c, plugins/classbuilder.c,

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2007-07-27 11:56:50 UTC (rev 1753)
+++ trunk/src/editor.c	2007-07-28 10:27:42 UTC (rev 1754)
@@ -1133,13 +1133,15 @@
 	gchar *lindent;
 	gchar *whitespace;
 	gint step, str_len;
+	gint ft_id = FILETYPE_ID(doc_list[idx].file_type);
 	GHashTable *specials;
 	ScintillaObject *sci = doc_list[idx].sci;
 
 	str = g_strdup(word);
 	g_strstrip(str);
 
-	pattern = ac_find_completion_by_name(doc_list[idx].file_type->name, str);
+	pattern = ac_find_completion_by_name(filetypes[ft_id]->name, str);
+	geany_debug("-%s- -%s-", word, pattern);
 	if (pattern == NULL || pattern[0] == '\0')
 	{
 		utils_free_pointers(str, pattern, NULL); // free pattern in case it is ""
@@ -1201,15 +1203,13 @@
 }
 
 
-gboolean editor_auto_forif(gint idx, gint pos)
+gboolean editor_auto_complete(gint idx, gint pos)
 {
 	gboolean result = FALSE;
-	gchar *word;
 	gint lexer, style;
-	gint i;
 	ScintillaObject *sci;
 
-	if (! DOC_IDX_VALID(idx) || doc_list[idx].file_type == NULL)
+	if (! DOC_IDX_VALID(idx))
 		return FALSE;
 
 	sci = doc_list[idx].sci;
@@ -1219,40 +1219,17 @@
 
 	lexer = SSM(sci, SCI_GETLEXER, 0, 0);
 	style = SSM(sci, SCI_GETSTYLEAT, pos - 2, 0);
-	// return, if we are in a comment
-	if (is_comment(lexer, style))
-		return FALSE;
-	// never auto complete in a PHP file outside of the <? ?> tags
-	if (lexer == SCLEX_HTML && ! (style >= SCE_HPHP_DEFAULT && style <= SCE_HPHP_OPERATOR))
-		return FALSE;
 
-	// get the current line contents
-	word = sci_get_line(sci, SSM(sci, SCI_LINEFROMPOSITION, pos, 0));
+	editor_find_current_word(sci, pos, current_word, sizeof current_word, NULL);
 
-	/* check that the chars before the current word are only whitespace (on this line).
-	 * this prevents completion of '} while ' */
-	i = strlen(word) - 1;
-	while (i >= 0 && isspace(word[i])) i--;	// skip trailing whitespace
-	while (i >= 0 && isalpha(word[i])) i--;	// find pos before keyword
-	while (i >= 0 && word[i] != '\n' && word[i] != '\r') // we want to stay in this line('\n' check)
-	{
-		if (! isspace(word[i]))
-		{
-			g_free(word);
-			return FALSE;
-		}
-		i--;
-	}
-
 	// prevent completion of "for "
 	if (! isspace(sci_get_char_at(sci, pos - 1))) // pos points to the line end char so use pos -1
 	{
 		sci_start_undo_action(sci);	// needed because we insert a space separately from construct
-		result = ac_complete_constructs(idx, pos, word);
+		result = ac_complete_constructs(idx, pos, current_word);
 		sci_end_undo_action(sci);
 	}
 
-	utils_free_pointers(word, NULL);
 	return result;
 }
 

Modified: trunk/src/editor.h
===================================================================
--- trunk/src/editor.h	2007-07-27 11:56:50 UTC (rev 1753)
+++ trunk/src/editor.h	2007-07-28 10:27:42 UTC (rev 1754)
@@ -104,7 +104,7 @@
 
 void editor_close_block(gint idx, gint pos);
 
-gboolean editor_auto_forif(gint idx, gint pos);
+gboolean editor_auto_complete(gint idx, gint pos);
 
 void editor_auto_latex(gint idx, gint pos);
 

Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c	2007-07-27 11:56:50 UTC (rev 1753)
+++ trunk/src/keybindings.c	2007-07-28 10:27:42 UTC (rev 1754)
@@ -632,7 +632,7 @@
 			gint pos = sci_get_current_position(sci);
 
 			if (editor_prefs.auto_complete_constructs)
-				return editor_auto_forif(idx, pos);
+				return editor_auto_complete(idx, pos);
 		}
 	}
 	return FALSE;


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



More information about the Commits mailing list