From 8452643b9ea4043c6b3d2241caa48b847bf6e862 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Wed, 24 May 2006 02:10:02 -0500 Subject: [PATCH] Fixed priorities of brackets tags, so bold is really bold. For rule tags, apply style from context the match belongs to, not the rule's context. --- moo/mooedit/moohighlighter.c | 23 +++++++++++++++++++---- moo/mooedit/moolang.c | 2 +- moo/mooedit/mootext-private.h | 3 +++ moo/mooedit/mootextbuffer.c | 14 ++++++++++++++ moo/mooedit/tools.cfg | 6 +++--- 5 files changed, 40 insertions(+), 8 deletions(-) diff --git a/moo/mooedit/moohighlighter.c b/moo/mooedit/moohighlighter.c index 89619804..762b1444 100644 --- a/moo/mooedit/moohighlighter.c +++ b/moo/mooedit/moohighlighter.c @@ -236,19 +236,33 @@ create_tag (MooHighlighter *hl, CtxNode *match_node, MooRule *rule) { - GtkTextTag *tag; + GtkTextTag *tag, *cbt = NULL, *ibt = NULL; + GtkTextTagTable *table; if (!ctx_node->parent && !match_node && !rule) return NULL; tag = moo_syntax_tag_new (ctx_node, match_node, rule); - gtk_text_tag_table_add (gtk_text_buffer_get_tag_table (hl->buffer), tag); + table = gtk_text_buffer_get_tag_table (hl->buffer); + + gtk_text_tag_table_add (table, tag); g_object_unref (tag); +#if 1 + /* XXX */ + _moo_text_buffer_get_bracket_tags (MOO_TEXT_BUFFER (hl->buffer), &cbt, &ibt); + + if (ibt) + gtk_text_tag_set_priority (ibt, gtk_text_tag_table_get_size (table) - 2); + if (cbt) + gtk_text_tag_set_priority (cbt, gtk_text_tag_table_get_size (table) - 1); +#endif + _moo_lang_set_tag_style (rule ? rule->context->lang : ctx_node->ctx->lang, tag, - rule ? rule->context : ctx_node->ctx, +// rule ? rule->context : ctx_node->ctx, + ctx_node->ctx, rule, NULL); ctx_node->child_tags = g_slist_prepend (ctx_node->child_tags, tag); @@ -779,7 +793,8 @@ tag_set_scheme (G_GNUC_UNUSED gpointer whatever, _moo_lang_erase_tag_style (GTK_TEXT_TAG (tag)); _moo_lang_set_tag_style (tag->rule ? tag->rule->context->lang : tag->ctx_node->ctx->lang, GTK_TEXT_TAG (tag), - tag->rule ? tag->rule->context : tag->ctx_node->ctx, +// tag->rule ? tag->rule->context : tag->ctx_node->ctx, + tag->ctx_node->ctx, tag->rule, scheme); } } diff --git a/moo/mooedit/moolang.c b/moo/mooedit/moolang.c index 79c13eff..a812939c 100644 --- a/moo/mooedit/moolang.c +++ b/moo/mooedit/moolang.c @@ -467,7 +467,7 @@ _moo_lang_set_tag_style (MooLang *lang, { g_return_if_fail (lang != NULL && GTK_IS_TEXT_TAG (tag)); g_return_if_fail (ctx != NULL && ctx->lang == lang); - g_return_if_fail (!rule || rule->context == ctx); +// g_return_if_fail (!rule || rule->context == ctx); set_tag_style (lang, tag, ctx->style, scheme); diff --git a/moo/mooedit/mootext-private.h b/moo/mooedit/mootext-private.h index 2d409491..47250230 100644 --- a/moo/mooedit/mootext-private.h +++ b/moo/mooedit/mootext-private.h @@ -62,6 +62,9 @@ void _moo_text_buffer_tags_changed (MooTextBuffer *buffer, int first, int last); gpointer _moo_text_buffer_get_undo_stack (MooTextBuffer *buffer); +void _moo_text_buffer_get_bracket_tags (MooTextBuffer *buffer, + GtkTextTag **correct, + GtkTextTag **incorrect); G_END_DECLS diff --git a/moo/mooedit/mootextbuffer.c b/moo/mooedit/mootextbuffer.c index ab522327..6a950072 100644 --- a/moo/mooedit/mootextbuffer.c +++ b/moo/mooedit/mootextbuffer.c @@ -1313,6 +1313,20 @@ moo_text_buffer_set_bracket_mismatch_style (MooTextBuffer *buffer, } +void +_moo_text_buffer_get_bracket_tags (MooTextBuffer *buffer, + GtkTextTag **correct, + GtkTextTag **incorrect) +{ + g_return_if_fail (MOO_IS_TEXT_BUFFER (buffer)); + + if (correct) + *correct = buffer->priv->correct_match_tag; + if (incorrect) + *incorrect = buffer->priv->incorrect_match_tag; +} + + static gboolean parse_brackets (const char *string, gunichar **left_brackets, diff --git a/moo/mooedit/tools.cfg b/moo/mooedit/tools.cfg index 4b72fb9b..bb276aab 100644 --- a/moo/mooedit/tools.cfg +++ b/moo/mooedit/tools.cfg @@ -14,14 +14,14 @@ label: LaTeX lang: LaTeX command: shell options: need-save - latex $name + ${LATEX:-latex} $name action: ViewDVI label: View DVI lang: LaTeX -command: shell options: need-file, silent - kdvi $base.dvi & + ExecAsync('%s "%s.dvi"' % [$('LATEX_VIEWDVI', 'kdvi'), doc.base]); + ################################################################## # texinfo