SF.net SVN: geany: [1323] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Feb 23 13:26:07 UTC 2007
Revision: 1323
http://svn.sourceforge.net/geany/?rev=1323&view=rev
Author: ntrel
Date: 2007-02-23 05:26:06 -0800 (Fri, 23 Feb 2007)
Log Message:
-----------
Speed up loading multiple C-like files when restoring session or
loading command-line files at startup by ensuring documents are
only colourised once.
Also prevent re-colourising C-like documents after saving a file
unless the list of typenames has changed.
Add document_delay_colourise(), document_colourise_all().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
trunk/src/document.h
trunk/src/keyfile.c
trunk/src/main.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-02-23 12:49:27 UTC (rev 1322)
+++ trunk/ChangeLog 2007-02-23 13:26:06 UTC (rev 1323)
@@ -1,3 +1,14 @@
+2007-02-23 Nick Treleaven <nick.treleaven at btinternet.com>
+
+ * src/keyfile.c, src/document.c, src/document.h, src/main.c:
+ Speed up loading multiple C-like files when restoring session or
+ loading command-line files at startup by ensuring documents are
+ only colourised once.
+ Also prevent re-colourising C-like documents after saving a file
+ unless the list of typenames has changed.
+ Add document_delay_colourise(), document_colourise_all().
+
+
2007-02-20 Enrico Troeger <enrico.troeger at uvena.de>
* src/sci_cb.c, src/sci_cb.c:
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2007-02-23 12:49:27 UTC (rev 1322)
+++ trunk/src/document.c 2007-02-23 13:26:06 UTC (rev 1323)
@@ -64,7 +64,11 @@
/* dynamic array of document elements to hold all information of the notebook tabs */
GArray *doc_array;
+/* Whether to colourise the document straight after styling settings are changed.
+ * (e.g. when filetype is set or typenames are updated) */
+static gboolean delay_colourise = FALSE;
+
/* Returns -1 if no text found or the new range endpoint after replacing. */
static gint
document_replace_range(gint idx, const gchar *find_text, const gchar *replace_text,
@@ -73,6 +77,7 @@
static void document_undo_clear(gint idx);
static void document_redo_add(gint idx, guint type, gpointer data);
+static gboolean update_type_keywords(ScintillaObject *sci);
/* returns the index of the notebook page which has the given filename
@@ -1400,16 +1405,28 @@
}
-/* Returns: whether sci_colourise has been called for sci */
+/* Returns: TRUE if any scintilla type keywords were updated.
+ * sci can be NULL to update if necessary (non-NULL can save time if only one
+ * document was changed) */
static gboolean update_type_keywords(ScintillaObject *sci)
{
gboolean ret = FALSE;
- if (sci_cb_lexer_get_type_keyword_idx(sci_get_lexer(sci)) != -1)
+ if (sci == NULL || sci_cb_lexer_get_type_keyword_idx(sci_get_lexer(sci)) != -1)
{
guint n;
+ static GString *last_typenames = NULL;
GString *s = get_project_typenames();
+ if (s && last_typenames && g_string_equal(s, last_typenames))
+ {
+ g_string_free(s, TRUE);
+ return FALSE; // avoid unnecessary recolourising
+ }
+ // keep typename list for next time
+ if (last_typenames)
+ g_string_free(last_typenames, TRUE);
+ last_typenames = s;
if (s == NULL) return FALSE;
for (n = 0; n < doc_array->len; n++)
@@ -1423,13 +1440,14 @@
if (keyword_idx > 0)
{
sci_set_keywords(wid, keyword_idx, s->str);
- sci_colourise(wid, 0, -1);
- if (sci == wid)
- ret = TRUE;
+ if (! delay_colourise)
+ {
+ sci_colourise(wid, 0, -1);
+ }
+ ret = TRUE;
}
}
}
- g_string_free(s, TRUE);
}
return ret;
}
@@ -1461,9 +1479,11 @@
}
document_update_tag_list(idx, TRUE);
- colourise &= ! update_type_keywords(doc_list[idx].sci);
- if (colourise)
- sci_colourise(doc_list[idx].sci, 0, -1);
+ if (! delay_colourise)
+ {
+ if (colourise && ! update_type_keywords(doc_list[idx].sci))
+ sci_colourise(doc_list[idx].sci, 0, -1);
+ }
}
@@ -1965,3 +1985,33 @@
return DOC_IDX_VALID(idx) ? &doc_list[idx] : NULL;
}
#endif
+
+
+void document_delay_colourise()
+{
+ g_return_if_fail(delay_colourise == FALSE);
+
+ delay_colourise = TRUE;
+}
+
+
+void document_colourise_all()
+{
+ guint n;
+
+ g_return_if_fail(delay_colourise == TRUE);
+
+ // update typenames if necessary
+ update_type_keywords(NULL);
+
+ for (n = 0; n < doc_array->len; n++)
+ {
+ ScintillaObject *sci = doc_list[n].sci;
+
+ if (sci)
+ sci_colourise(sci, 0, -1);
+ }
+ delay_colourise = FALSE;
+}
+
+
Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h 2007-02-23 12:49:27 UTC (rev 1322)
+++ trunk/src/document.h 2007-02-23 13:26:06 UTC (rev 1323)
@@ -230,4 +230,9 @@
GdkColor *document_get_status(gint idx);
+
+void document_delay_colourise();
+
+void document_colourise_all();
+
#endif
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2007-02-23 12:49:27 UTC (rev 1322)
+++ trunk/src/keyfile.c 2007-02-23 13:26:06 UTC (rev 1323)
@@ -501,6 +501,8 @@
guint x, pos, y, len;
gboolean ret = FALSE, failure = FALSE;
+ document_delay_colourise();
+
i = app->tab_order_ltr ? 0 : (session_files->len - 1);
while (TRUE)
{
@@ -561,6 +563,7 @@
if (i < 0) break;
}
}
+ document_colourise_all();
g_ptr_array_free(session_files, TRUE);
if (failure)
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-02-23 12:49:27 UTC (rev 1322)
+++ trunk/src/main.c 2007-02-23 13:26:06 UTC (rev 1323)
@@ -490,6 +490,8 @@
if (argc <= 1) return FALSE;
+ document_delay_colourise();
+
for(i = 1; i < argc; i++)
{
gchar *filename = get_argv_filename(argv[i]);
@@ -522,6 +524,7 @@
}
g_free(filename);
}
+ document_colourise_all();
return TRUE;
}
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