[gtksourceview/gnome-3-18] buffer: make code a bit clearer for the context class mask
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gnome-3-18] buffer: make code a bit clearer for the context class mask
- Date: Sat, 23 Apr 2016 12:34:02 +0000 (UTC)
commit b599d4cd053ce083e7038a17cf4e4ad7daf35f0c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Oct 16 11:36:18 2015 +0200
buffer: make code a bit clearer for the context class mask
- Move the variable inside the function, so there is one less global
variable.
- Use G_N_ELEMENTS().
- Better function and variable names.
gtksourceview/gtksourcebuffer.c | 40 ++++++++++++++++++++------------------
1 files changed, 21 insertions(+), 19 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index 2a5cc49..34abb36 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -1143,31 +1143,33 @@ gtk_source_buffer_real_delete_range (GtkTextBuffer *buffer,
}
}
-/* This describes a mask of relevant context classes for highlighting matching
- * brackets. Additional classes can be added below.
- */
-static const gchar *cclass_mask_definitions[] = {
- "comment",
- "string",
-};
-
static gint
-get_context_class_mask (GtkSourceBuffer *buffer,
- GtkTextIter *iter)
+get_bracket_matching_context_class_mask (GtkSourceBuffer *buffer,
+ GtkTextIter *iter)
{
+ gint mask = 0;
guint i;
- gint ret = 0;
- for (i = 0; i < sizeof (cclass_mask_definitions) / sizeof (gchar *); ++i)
+ /* This describes a mask of relevant context classes for highlighting
+ * matching brackets.
+ */
+ const gchar *cclass_mask_definitions[] = {
+ "comment",
+ "string",
+ };
+
+ for (i = 0; i < G_N_ELEMENTS (cclass_mask_definitions); ++i)
{
- gboolean hasclass = gtk_source_buffer_iter_has_context_class (buffer,
- iter,
- cclass_mask_definitions[i]);
+ gboolean has_class;
+
+ has_class = gtk_source_buffer_iter_has_context_class (buffer,
+ iter,
+ cclass_mask_definitions[i]);
- ret |= hasclass << i;
+ mask |= has_class << i;
}
- return ret;
+ return mask;
}
/* Note that we only look MAX_CHARS_BEFORE_FINDING_A_MATCH at most. */
@@ -1193,7 +1195,7 @@ gtk_source_buffer_find_bracket_match_real (GtkSourceBuffer *buffer,
cur_char = gtk_text_iter_get_char (&iter);
base_char = cur_char;
- cclass_mask = get_context_class_mask (buffer, &iter);
+ cclass_mask = get_bracket_matching_context_class_mask (buffer, &iter);
search_char = bracket_pair (base_char, &addition);
@@ -1214,7 +1216,7 @@ gtk_source_buffer_find_bracket_match_real (GtkSourceBuffer *buffer,
cur_char = gtk_text_iter_get_char (&iter);
++char_cont;
- current_mask = get_context_class_mask (buffer, &iter);
+ current_mask = get_bracket_matching_context_class_mask (buffer, &iter);
/* Check if we lost a class, which means we don't look any
further */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]