Skip to content

Instantly share code, notes, and snippets.

@codebrainz
Created January 3, 2012 18:08
Show Gist options
  • Select an option

  • Save codebrainz/1556120 to your computer and use it in GitHub Desktop.

Select an option

Save codebrainz/1556120 to your computer and use it in GitHub Desktop.
Re-highlight type keywords on tab page switch
diff --git a/src/callbacks.c b/src/callbacks.c
index 7abd6b0..78c1023 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -621,6 +621,7 @@ G_MODULE_EXPORT void on_notebook1_switch_page_after(GtkNotebook *notebook, GtkNo
ui_document_show_hide(doc); /* update the document menu */
build_menu_update(doc);
sidebar_update_tag_list(doc, FALSE);
+ document_highlight_tags(doc);
/* We delay the check to avoid weird fast, unintended switching of notebook pages when
* the 'file has changed' dialog is shown while the switch event is not yet completely
diff --git a/src/document.c b/src/document.c
index cfbd8eb..2117d00 100644
--- a/src/document.c
+++ b/src/document.c
@@ -523,9 +523,9 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
new_idx = documents_array->len;
g_ptr_array_add(documents_array, doc);
}
-
+
doc = documents[new_idx];
-
+
/* initialize default document settings */
doc->priv = g_new0(GeanyDocumentPrivate, 1);
doc->index = new_idx;
@@ -2215,9 +2215,6 @@ void document_update_tags(GeanyDocument *doc)
{
guchar *buffer_ptr;
gsize len;
- GString *keywords_str;
- gchar *keywords;
- gint keyword_idx;
g_return_if_fail(DOC_VALID(doc));
g_return_if_fail(app->tm_workspace != NULL);
@@ -2276,6 +2273,16 @@ void document_update_tags(GeanyDocument *doc)
tm_source_file_buffer_update(doc->tm_file, buffer_ptr, len, TRUE);
sidebar_update_tag_list(doc, TRUE);
+ document_highlight_tags(doc);
+}
+
+
+/* Re-highlights type keywords without re-parsing the whole document. */
+void document_highlight_tags(GeanyDocument *doc)
+{
+ GString *keywords_str;
+ gchar *keywords;
+ gint keyword_idx;
/* some filetypes support type keywords (such as struct names), but not
* necessarily all filetypes for a particular scintilla lexer. this
diff --git a/src/document.h b/src/document.h
index e87d83a..13bbd65 100644
--- a/src/document.h
+++ b/src/document.h
@@ -237,6 +237,8 @@ void document_update_tags(GeanyDocument *doc);
void document_update_tag_list_in_idle(GeanyDocument *doc);
+void document_highlight_tags(GeanyDocument *doc);
+
void document_set_encoding(GeanyDocument *doc, const gchar *new_encoding);
gboolean document_check_disk_status(GeanyDocument *doc, gboolean force);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment