SF.net SVN: geany: [571] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Jul 16 22:02:47 UTC 2006


Revision: 571
Author:   eht16
Date:     2006-07-16 15:02:31 -0700 (Sun, 16 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=571&view=rev

Log Message:
-----------
Moved HTML entities from sci_cb.h to data/html_entities.tags.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/Makefile.am
    trunk/src/callbacks.c
    trunk/src/highlighting.c
    trunk/src/main.c
    trunk/src/sci_cb.c
    trunk/src/sci_cb.h
    trunk/src/utils.c

Added Paths:
-----------
    trunk/data/html_entities.tags
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/ChangeLog	2006-07-16 22:02:31 UTC (rev 571)
@@ -8,6 +8,9 @@
  * src/utils.c: Simplified locale detection and little speed up.
  * src/main.c, src/document.c, src/geany.h:
    Removed code for alternative scrolling(it was not better).
+ * src/sci_cb.c, src/callbacks.c, src/utils.c, src/highlighting.c,
+   src/main.c, data/html_entities.tags, Makefile.am:
+   Moved HTML entities from sci_cb.h to data/html_entities.tags.
 
 
 2006-07-16  Nick Treleaven  <nick.treleaven at btinternet.com>

Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/Makefile.am	2006-07-16 22:02:31 UTC (rev 571)
@@ -11,6 +11,7 @@
 	data/global.tags \
 	data/php.tags \
 	data/latex.tags \
+	data/html_entities.tags \
 	data/filetypes.*
 
 uninstall-local:
@@ -31,6 +32,7 @@
 	$(INSTALL_DATA) data/global.tags $(DESTDIR)$(pkgdatadir); \
 	$(INSTALL_DATA) data/php.tags $(DESTDIR)$(pkgdatadir); \
 	$(INSTALL_DATA) data/latex.tags $(DESTDIR)$(pkgdatadir); \
+	$(INSTALL_DATA) data/html_entities.tags $(DESTDIR)$(pkgdatadir); \
 	$(INSTALL_DATA) COPYING $(DESTDIR)$(pkgdatadir)/GPL-2; \
 	for file in $(srcdir)/data/*; do \
 	  if test -f $$file; then \

Added: trunk/data/html_entities.tags
===================================================================
--- trunk/data/html_entities.tags	                        (rev 0)
+++ trunk/data/html_entities.tags	2006-07-16 22:02:31 UTC (rev 571)
@@ -0,0 +1,95 @@
+# each of the following lines represent a html entity
+# used in HTML and PHP files when typing &...
+Á
+Â
+æ
+Æ
+À
+α
+&
+å
+Å
+Ã
+ä
+Ä
+•
+ç
+Ç
+¢
+©
+¤
+°
+÷
+É
+ê
+Ê
+è
+È
+∅
+ë
+Ë
+€
+&frac12;
+&frac14;
+&frac34;
+>
+Í
+î
+Î
+ì
+Ì
+∞
+∈
+ï
+Ï
+∗
+<
+µ
+−
+ 
+ñ
+Ñ
+ó
+Ó
+ô
+Ô
+ò
+Ò
+ω
+Ω
+ª
+º
+ø
+Ø
+õ
+Õ
+ö
+Ö
+¶
+π
+±
+£
+∏
+∝
+"
+®
+§
+∑
+&sup1;
+&sup2;
+&sup3;
+ß
+×
+™
+ú
+Ú
+û
+Û
+ù
+Ù
+¨
+ü
+Ü
+ý
+¥
+ÿ

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/src/callbacks.c	2006-07-16 22:02:31 UTC (rev 571)
@@ -123,6 +123,7 @@
 	styleset_free_styles();
 	templates_free_templates();
 	tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));
+	g_strfreev(html_entities);
 	g_free(app->configdir);
 	g_free(app->search_text);
 	g_free(app->editor_font);

Modified: trunk/src/highlighting.c
===================================================================
--- trunk/src/highlighting.c	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/src/highlighting.c	2006-07-16 22:02:31 UTC (rev 571)
@@ -25,12 +25,14 @@
 #include "SciLexer.h"
 #include "geany.h"
 #include "highlighting.h"
+#include "sci_cb.h"
 #include "utils.h"
 
 
 static style_set *types[GEANY_MAX_FILE_TYPES] = { NULL };
 static gboolean global_c_tags_loaded = FALSE;
 static gboolean global_php_tags_loaded = FALSE;
+static gboolean global_html_tags_loaded = FALSE;
 static gboolean global_latex_tags_loaded = FALSE;
 
 
@@ -785,6 +787,12 @@
 		tm_workspace_load_global_tags(GEANY_DATA_DIR G_DIR_SEPARATOR_S "php.tags", 6);
 		global_php_tags_loaded = TRUE;
 	}
+	// load global tags file for HTML entities autocompletion
+	if (! app->ignore_global_tags && ! global_html_tags_loaded)
+	{
+		html_entities = utils_read_file_in_array(GEANY_DATA_DIR G_DIR_SEPARATOR_S "html_entities.tags");
+		global_html_tags_loaded = TRUE;
+	}
 
 	g_key_file_free(config);
 	g_key_file_free(config_home);

Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/src/main.c	2006-07-16 22:02:31 UTC (rev 571)
@@ -48,6 +48,7 @@
 #include "treeviews.h"
 #include "notebook.h"
 #include "keybindings.h"
+#include "sci_cb.h"
 
 #ifdef HAVE_VTE
 # include "vte.h"
@@ -225,10 +226,11 @@
 #ifdef HAVE_VTE
 	app->lib_vte			= lib_vte;
 #endif
-	app->ignore_global_tags 					= ignore_global_tags;
-	app->tm_workspace							= tm_get_workspace();
-	app->recent_queue							= g_queue_new();
-	app->opening_session_files					= FALSE;
+	app->ignore_global_tags 		= ignore_global_tags;
+	app->tm_workspace				= tm_get_workspace();
+	app->recent_queue				= g_queue_new();
+	app->opening_session_files		= FALSE;
+	html_entities					= NULL;
 
 	app->window = create_window1();
 	app->new_file_menu = gtk_menu_new();

Modified: trunk/src/sci_cb.c
===================================================================
--- trunk/src/sci_cb.c	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/src/sci_cb.c	2006-07-16 22:02:31 UTC (rev 571)
@@ -438,21 +438,25 @@
 
 	if (*root == '&' && lexer == SCLEX_HTML)
 	{	// HTML entities auto completion
-		gchar **ents = g_strsplit(sci_cb_html_entities, " ", 0);
-		guint i, j = 0, ents_len = g_strv_length(ents);
-		GString *words = g_string_sized_new(60);
+		guint i, j = 0;
+		GString *words;
 
-		for (i = 0; i < ents_len; i++)
+		if (html_entities == NULL) return FALSE;
+
+		words = g_string_sized_new(500);
+		for (i = 0; ; i++)
 		{
-			if (! strncmp(ents[i], root, rootlen))
+			if (html_entities[i] == NULL) break;
+			else if (html_entities[i][0] == '#') continue;
+
+			if (! strncmp(html_entities[i], root, rootlen))
 			{
 				if (j++ > 0) g_string_append_c(words, ' ');
-				g_string_append(words, ents[i]);
+				g_string_append(words, html_entities[i]);
 			}
 		}
-		SSM(sci, SCI_AUTOCSHOW, rootlen, (sptr_t) words->str);
+		if (words->len > 0) SSM(sci, SCI_AUTOCSHOW, rootlen, (sptr_t) words->str);
 		g_string_free(words, TRUE);
-		g_strfreev(ents);
 	}
 	else
 	{	// PHP, LaTeX, C and C++ tag autocompletion

Modified: trunk/src/sci_cb.h
===================================================================
--- trunk/src/sci_cb.h	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/src/sci_cb.h	2006-07-16 22:02:31 UTC (rev 571)
@@ -23,6 +23,9 @@
 #define GEANY_SCI_CB_H 1
 
 
+gchar **html_entities;
+
+
 // callback func called by all editors when a signals arises
 void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
 
@@ -52,14 +55,4 @@
 
 void sci_cb_auto_close_bracket(ScintillaObject *sci, gint pos, gchar c);
 
-#define sci_cb_html_entities "  " & < >  Ü™ € • ∞ ∝ ∗\
- − ∑ ∏ ∈ ∅ π Ω ω α ÿ ý\
- ÷ ø ù ú û ü ä å æ ç\
- è ê ë ì î ï ñ ò ó ô\
- õ ö ¢ £ ¤ ¥ § ¨ © ª ® °\
- ± &sup2; &sup3; &frac34; À Á Â Ã Ä Å\
- Æ Ç È É Ê &frac12; &frac14; º &sup1; ¶\
- µ Ë Ì Í Î Ï Ñ Ò Ó Ô\
- Õ Ö × Ø Ù Ú Û"
-
 #endif

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-07-16 21:31:09 UTC (rev 570)
+++ trunk/src/utils.c	2006-07-16 22:02:31 UTC (rev 571)
@@ -2517,3 +2517,21 @@
 	utils_widget_show_hide(lookup_widget(app->window, "separatortoolitem9"), app->pref_toolbar_show_undo);
 }
 
+
+gchar **utils_read_file_in_array(const gchar *filename)
+{
+	gchar **result = NULL;
+	gchar *data;
+
+	if (filename == NULL) return NULL;
+
+	g_file_get_contents(filename, &data, NULL, NULL);
+
+	if (data != NULL)
+	{
+		result = g_strsplit_set(data, "\r\n", -1);
+	}
+
+	return result;
+}
+


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