[gtksourceview] buffer: fix find_bracket_match() parameter name
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] buffer: fix find_bracket_match() parameter name
- Date: Thu, 22 Oct 2015 13:13:58 +0000 (UTC)
commit 094df1f8df52f9a7f8878c9419ab30557db25ff5
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Oct 16 11:06:28 2015 +0200
buffer: fix find_bracket_match() parameter name
@orig was a really bad name, since after calling the function, the iter
is moved to the matching bracket. @orig would have been fine if it was a
const param, but here it's an in/out param. So, @iter is a better name.
gtksourceview/gtksourcebuffer-private.h | 10 +++---
gtksourceview/gtksourcebuffer.c | 47 +++++++++++++++----------------
2 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer-private.h b/gtksourceview/gtksourcebuffer-private.h
index c6d89b9..b7d65be 100644
--- a/gtksourceview/gtksourcebuffer-private.h
+++ b/gtksourceview/gtksourcebuffer-private.h
@@ -60,17 +60,17 @@ gboolean _gtk_source_buffer_has_invalid_chars (GtkSourceBuffer
*buffer
G_GNUC_INTERNAL
GtkSourceBracketMatchType
- _gtk_source_buffer_find_bracket_match (GtkSourceBuffer *buffer,
- GtkTextIter *orig);
+ _gtk_source_buffer_find_bracket_match (GtkSourceBuffer *buffer,
+ GtkTextIter *pos);
G_GNUC_INTERNAL
-void _gtk_source_buffer_save_and_clear_selection (GtkSourceBuffer *buffer);
+void _gtk_source_buffer_save_and_clear_selection (GtkSourceBuffer *buffer);
G_GNUC_INTERNAL
-void _gtk_source_buffer_restore_selection (GtkSourceBuffer *buffer);
+void _gtk_source_buffer_restore_selection (GtkSourceBuffer *buffer);
G_GNUC_INTERNAL
-gboolean _gtk_source_buffer_is_undo_redo_enabled (GtkSourceBuffer *buffer);
+gboolean _gtk_source_buffer_is_undo_redo_enabled (GtkSourceBuffer *buffer);
G_END_DECLS
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index a46799a..73d5538 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -1176,22 +1176,19 @@ get_bracket_matching_context_class_mask (GtkSourceBuffer *buffer,
/* Note that we only look MAX_CHARS_BEFORE_FINDING_A_MATCH at most. */
static GtkSourceBracketMatchType
gtk_source_buffer_find_bracket_match_real (GtkSourceBuffer *buffer,
- GtkTextIter *orig)
+ GtkTextIter *pos)
{
GtkTextIter iter;
-
gunichar base_char;
gunichar search_char;
gunichar cur_char;
gint addition;
gint char_cont;
gint counter;
-
gboolean found;
-
gint cclass_mask;
- iter = *orig;
+ iter = *pos;
cur_char = gtk_text_iter_get_char (&iter);
@@ -1251,7 +1248,7 @@ gtk_source_buffer_find_bracket_match_real (GtkSourceBuffer *buffer,
if (found)
{
- *orig = iter;
+ *pos = iter;
return GTK_SOURCE_BRACKET_MATCH_FOUND;
}
@@ -1263,36 +1260,38 @@ gtk_source_buffer_find_bracket_match_real (GtkSourceBuffer *buffer,
return GTK_SOURCE_BRACKET_MATCH_NOT_FOUND;
}
-/* Note that we take into account both the character following the cursor and the
- * one preceding it. If there are brackets on both sides the one following the
- * cursor takes precedence.
+/* Moves @pos to the matching bracket, if found.
+ * Note that we take into account both the character following @pos and the one
+ * preceding it. If there are brackets on both sides, the one following @pos
+ * takes precedence.
*/
GtkSourceBracketMatchType
_gtk_source_buffer_find_bracket_match (GtkSourceBuffer *buffer,
- GtkTextIter *orig)
+ GtkTextIter *pos)
{
- GtkSourceBracketMatchType res;
+ GtkTextIter bracket_match;
+ GtkSourceBracketMatchType result;
- res = gtk_source_buffer_find_bracket_match_real (buffer, orig);
+ bracket_match = *pos;
+ result = gtk_source_buffer_find_bracket_match_real (buffer, &bracket_match);
- if (res != GTK_SOURCE_BRACKET_MATCH_FOUND)
+ if (result != GTK_SOURCE_BRACKET_MATCH_FOUND)
{
- GtkTextIter iter;
- iter = *orig;
+ bracket_match = *pos;
- if (!gtk_text_iter_starts_line (&iter) &&
- gtk_text_iter_backward_char (&iter))
+ if (!gtk_text_iter_starts_line (&bracket_match) &&
+ gtk_text_iter_backward_char (&bracket_match))
{
- res = gtk_source_buffer_find_bracket_match_real (buffer, &iter);
-
- if (res == GTK_SOURCE_BRACKET_MATCH_FOUND)
- {
- *orig = iter;
- }
+ result = gtk_source_buffer_find_bracket_match_real (buffer, &bracket_match);
}
}
- return res;
+ if (result == GTK_SOURCE_BRACKET_MATCH_FOUND)
+ {
+ *pos = bracket_match;
+ }
+
+ return result;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]