Update Scintilla keywords and highlighting when changing document tabs

This commit is contained in:
Matthew Brush 2011-10-19 01:29:10 -07:00
parent bb745e8f3b
commit 1a14e4869f
3 changed files with 36 additions and 0 deletions

View File

@ -632,6 +632,7 @@ void on_notebook1_switch_page_after(GtkNotebook *notebook, GtkNotebookPage *page
ui_document_show_hide(doc); /* update the document menu */
build_menu_update(doc);
sidebar_update_tag_list(doc, FALSE);
document_update_highlighting(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

View File

@ -2448,6 +2448,39 @@ static gboolean update_type_keywords(GeanyDocument *doc, gint lang)
}
/*
* Updates the keywords in a document and re-colourizes it.
*
* @param doc The document
*/
void document_update_highlighting(GeanyDocument *doc)
{
const GString *s = NULL;
ScintillaObject *sci;
gint keyword_idx;
g_return_if_fail(DOC_VALID(doc));
g_return_if_fail(IS_SCINTILLA(doc->editor->sci));
sci = doc->editor->sci;
/* get possibly cached list of keywords for the current language.
* we don't care whether the cached keywords have changed. */
get_project_typenames(&s, doc->file_type->lang);
if (s)
{
keyword_idx = editor_lexer_get_type_keyword_idx(sci_get_lexer(sci));
if (keyword_idx > 0)
{
sci_set_keywords(sci, keyword_idx, s->str);
queue_colourise(doc);
}
}
}
static void document_load_config(GeanyDocument *doc, GeanyFiletype *type,
gboolean filetype_changed)
{

View File

@ -235,6 +235,8 @@ void document_update_tag_list(GeanyDocument *doc, gboolean update);
void document_update_tag_list_in_idle(GeanyDocument *doc);
void document_update_highlighting(GeanyDocument *doc);
void document_set_encoding(GeanyDocument *doc, const gchar *new_encoding);
gboolean document_check_disk_status(GeanyDocument *doc, gboolean force);