[anjuta-extras] scintilla: bgo #571816 – Scintilla no longer highlights typedefs
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta-extras] scintilla: bgo #571816 – Scintilla no longer highlights typedefs
- Date: Tue, 28 Jul 2009 19:41:40 +0000 (UTC)
commit d56cdb1476ab98ec13f2383df0f2e1002860f6b8
Author: Sandro Vitenti <sandro isoftware com br>
Date: Tue Jul 28 21:40:42 2009 +0200
scintilla: bgo #571816 â?? Scintilla no longer highlights typedefs
plugins/scintilla/aneditor-priv.h | 2 +-
plugins/scintilla/aneditor.cxx | 58 +++-------------------
plugins/scintilla/properties/styles.properties | 4 +-
plugins/scintilla/text_editor.c | 64 +++++++++++++++++++++++-
plugins/scintilla/text_editor.h | 6 ++
5 files changed, 79 insertions(+), 55 deletions(-)
---
diff --git a/plugins/scintilla/aneditor-priv.h b/plugins/scintilla/aneditor-priv.h
index 8e24098..cd3ab95 100644
--- a/plugins/scintilla/aneditor-priv.h
+++ b/plugins/scintilla/aneditor-priv.h
@@ -370,7 +370,7 @@ protected:
SString FindLanguageProperty(const char *pattern,
const char *defaultValue="");
void ReadPropertiesInitial();
- void ReadProperties(const char* fileForExt);
+ void ReadProperties(const char* fileForExt, char **typedef_hl);
long SendEditor(unsigned int msg, unsigned long wParam=0, long lParam=0);
long SendEditorString(unsigned int msg, unsigned long wParam,
const char *s);
diff --git a/plugins/scintilla/aneditor.cxx b/plugins/scintilla/aneditor.cxx
index 92a67fe..ed3f039 100644
--- a/plugins/scintilla/aneditor.cxx
+++ b/plugins/scintilla/aneditor.cxx
@@ -1734,7 +1734,7 @@ long AnEditor::Command(int cmdID, long wParam, long lParam) {
break;
case ANE_SETHILITE:
- ReadProperties((char*)wParam);
+ ReadProperties((char*)wParam, (char **)lParam);
SendEditor(SCI_COLOURISE, 0, -1);
break;
@@ -2489,7 +2489,7 @@ SString AnEditor::FindLanguageProperty(const char *pattern, const char *defaultV
return ret;
}
-void AnEditor::ReadProperties(const char *fileForExt) {
+void AnEditor::ReadProperties(const char *fileForExt, char **typedef_hl) {
//DWORD dwStart = timeGetTime();
if (fileForExt)
strcpy (fileName, fileForExt);
@@ -2519,61 +2519,17 @@ void AnEditor::ReadProperties(const char *fileForExt) {
SString kw2 = props->GetNewExpand("keywords3.", fileNameForExtension.c_str());
SendEditorString(SCI_SETKEYWORDS, 2, kw2.c_str());
/* For C/C++ projects, get list of typedefs for colorizing */
- /* TODO: Either remove or port to IAnjutaSymbolManager */
-#if 0
if (SCLEX_CPP == lexLanguage)
{
- const TMWorkspace *workspace = tm_get_workspace();
-
- /* Assign global keywords */
- if ((workspace) && (workspace->global_tags))
- {
- GPtrArray *g_typedefs = tm_tags_extract(workspace->global_tags
- , tm_tag_typedef_t | tm_tag_struct_t | tm_tag_class_t);
- if ((g_typedefs) && (g_typedefs->len > 0))
- {
- GString *s = g_string_sized_new(g_typedefs->len * 10);
- for (guint i = 0; i < g_typedefs->len; ++i)
- {
- if (!(TM_TAG(g_typedefs->pdata[i])->atts.entry.scope))
- {
- g_string_append(s, TM_TAG(g_typedefs->pdata[i])->name);
- g_string_append_c(s, ' ');
- }
- }
- SendEditorString(SCI_SETKEYWORDS, 3, s->str);
- g_string_free(s, TRUE);
- }
- g_ptr_array_free(g_typedefs, TRUE);
- }
-
- /* Assign project keywords */
- if ((workspace) && (workspace->work_object.tags_array))
+ if (typedef_hl != NULL)
{
- GPtrArray *typedefs = tm_tags_extract(workspace->work_object.tags_array
- , tm_tag_typedef_t | tm_tag_struct_t | tm_tag_class_t);
- if ((typedefs) && (typedefs->len > 0))
- {
- GString *s = g_string_sized_new(typedefs->len * 10);
- for (guint i = 0; i < typedefs->len; ++i)
- {
- if (!(TM_TAG(typedefs->pdata[i])->atts.entry.scope))
- {
- if (TM_TAG(typedefs->pdata[i])->name)
- {
- g_string_append(s, TM_TAG(typedefs->pdata[i])->name);
- g_string_append_c(s, ' ');
- }
- }
- }
- SendEditorString(SCI_SETKEYWORDS, 1, s->str);
- g_string_free(s, TRUE);
- }
- g_ptr_array_free(typedefs, TRUE);
+ if (typedef_hl[0] != NULL)
+ SendEditorString(SCI_SETKEYWORDS, 3, typedef_hl[0]);
+ if (typedef_hl[1] != NULL)
+ SendEditorString(SCI_SETKEYWORDS, 1, typedef_hl[1]);
}
}
else
-#endif
{
SString kw1 = props->GetNewExpand("keywords2.", fileNameForExtension.c_str());
SendEditorString(SCI_SETKEYWORDS, 1, kw1.c_str());
diff --git a/plugins/scintilla/properties/styles.properties b/plugins/scintilla/properties/styles.properties
index 57da701..c7cff00 100644
--- a/plugins/scintilla/properties/styles.properties
+++ b/plugins/scintilla/properties/styles.properties
@@ -6545,12 +6545,14 @@ keywords.$(file.patterns.yaml)=true false yes no
style.cpp.14=$(style.anjuta.regex)
# Doc Comment Line: line comments beginning with /// or //!.
style.cpp.15=$(style.anjuta.comment)
-# Keywords2
+# Local type
style.cpp.16=$(style.anjuta.localkeyword)
# Comment keyword
style.cpp.17=$(style.anjuta.comment)
# Comment keyword error
style.cpp.18=$(style.anjuta.comment)
+# Global type
+ style.cpp.19=$(style.anjuta.syskeyword)
diff --git a/plugins/scintilla/text_editor.c b/plugins/scintilla/text_editor.c
index 8c00ffa..a0408e6 100644
--- a/plugins/scintilla/text_editor.c
+++ b/plugins/scintilla/text_editor.c
@@ -60,6 +60,7 @@
#include <libanjuta/interfaces/ianjuta-indicable.h>
#include <libanjuta/interfaces/ianjuta-print.h>
#include <libanjuta/interfaces/ianjuta-document.h>
+#include <libanjuta/interfaces/ianjuta-symbol-manager.h>
#include "properties.h"
#include "text_editor.h"
@@ -684,9 +685,14 @@ text_editor_hilite_one (TextEditor * te, AnEditorID editor_id,
}
else if (te->uri)
{
- gchar *basename;
+ gchar *basename, *typedef_hl[2];
basename = g_path_get_basename (te->uri);
- aneditor_command (editor_id, ANE_SETHILITE, (glong) basename, 0);
+ text_editor_get_typedef_hl (te, typedef_hl);
+ aneditor_command (editor_id, ANE_SETHILITE, (glong) basename, (glong) typedef_hl);
+ if (typedef_hl[0] != NULL)
+ g_free (typedef_hl[0]);
+ if (typedef_hl[1] != NULL)
+ g_free (typedef_hl[1]);
g_free (basename);
}
else if (te->filename)
@@ -714,6 +720,60 @@ text_editor_hilite (TextEditor * te, gboolean override_by_pref)
}
void
+text_editor_get_typedef_hl (TextEditor * te, gchar **typedef_hl)
+{
+ IAnjutaSymbolManager *manager = anjuta_shell_get_interface (te->shell,
+ IAnjutaSymbolManager, NULL);
+ IAnjutaIterable *iter;
+
+ /* Get global typedefs */
+ iter = ianjuta_symbol_manager_search (manager, IANJUTA_SYMBOL_TYPE_TYPEDEF,
+ TRUE, IANJUTA_SYMBOL_FIELD_SIMPLE,
+ NULL, TRUE, TRUE, TRUE, -1, -1, NULL);
+ if (iter)
+ {
+ ianjuta_iterable_first (iter, NULL);
+ if (ianjuta_iterable_get_length (iter, NULL) > 0)
+ {
+ GString *s = g_string_sized_new(ianjuta_iterable_get_length (iter, NULL) * 10);
+ do {
+ IAnjutaSymbol *symbol = IANJUTA_SYMBOL (iter);
+ const gchar *sname = ianjuta_symbol_get_name (symbol, NULL);
+ g_string_append(s, sname);
+ g_string_append_c(s, ' ');
+ } while (ianjuta_iterable_next (iter, NULL));
+ typedef_hl[0] = g_string_free(s, FALSE);
+ }
+ g_object_unref (iter);
+ }
+ else
+ typedef_hl[0] = NULL;
+
+ /* Get local typedefs */
+ iter = ianjuta_symbol_manager_search (manager, IANJUTA_SYMBOL_TYPE_TYPEDEF,
+ TRUE, IANJUTA_SYMBOL_FIELD_SIMPLE,
+ NULL, TRUE, TRUE, FALSE, -1, -1, NULL);
+ if (iter)
+ {
+ ianjuta_iterable_first (iter, NULL);
+ if (ianjuta_iterable_get_length (iter, NULL) > 0)
+ {
+ GString *s = g_string_sized_new(ianjuta_iterable_get_length (iter, NULL) * 10);
+ do {
+ IAnjutaSymbol *symbol = IANJUTA_SYMBOL (iter);
+ const gchar *sname = ianjuta_symbol_get_name (symbol, NULL);
+ g_string_append(s, sname);
+ g_string_append_c(s, ' ');
+ } while (ianjuta_iterable_next (iter, NULL));
+ typedef_hl[1] = g_string_free(s, FALSE);
+ }
+ g_object_unref (iter);
+ }
+ else
+ typedef_hl[1] = NULL;
+}
+
+void
text_editor_set_zoom_factor (TextEditor * te, gint zfac)
{
text_editor_command (te, ANE_SETZOOM, zfac, 0);
diff --git a/plugins/scintilla/text_editor.h b/plugins/scintilla/text_editor.h
index 9f199b3..1339f2f 100644
--- a/plugins/scintilla/text_editor.h
+++ b/plugins/scintilla/text_editor.h
@@ -150,6 +150,12 @@ void text_editor_set_hilite_type (TextEditor * te, const gchar *file_extension);
void text_editor_hilite (TextEditor *te, gboolean force);
/*
+ * Get list of global (in typedef_hl[0]) and local (in typedef_hl[1]) type
+ * names
+ */
+void text_editor_get_typedef_hl (TextEditor * te, gchar **typedef_hl);
+
+/*
* Set the zoom factor. Zoom factor basically increases or decreases the
* text font size by a factor of (2*zfac)
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]