[gtksourceview/gtksourceview-5-4] gutterlines: include quark for selected lines
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/gtksourceview-5-4] gutterlines: include quark for selected lines
- Date: Thu, 28 Apr 2022 00:38:44 +0000 (UTC)
commit 54a4239cafb86b9e0087648563ee233ba339338e
Author: Christian Hergert <chergert redhat com>
Date: Wed Apr 27 17:07:26 2022 -0700
gutterlines: include quark for selected lines
This was missing from the implementation by accident it appears.
gtksourceview/gtksourcegutterlines.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
---
diff --git a/gtksourceview/gtksourcegutterlines.c b/gtksourceview/gtksourcegutterlines.c
index 327b8b89..1a92120f 100644
--- a/gtksourceview/gtksourcegutterlines.c
+++ b/gtksourceview/gtksourcegutterlines.c
@@ -114,9 +114,12 @@ _gtk_source_gutter_lines_new (GtkTextView *text_view,
GtkTextBuffer *buffer;
GtkTextMark *mark;
GtkTextIter iter;
+ GtkTextIter sel_begin, sel_end;
gboolean single_line;
guint cursor_line;
guint i;
+ int first_selected = -1;
+ int last_selected = -1;
g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), NULL);
g_return_val_if_fail (begin != NULL, NULL);
@@ -128,6 +131,13 @@ _gtk_source_gutter_lines_new (GtkTextView *text_view,
g_return_val_if_fail (gtk_text_iter_get_buffer (begin) == buffer, NULL);
g_return_val_if_fail (gtk_text_iter_get_buffer (end) == buffer, NULL);
+ if (gtk_text_buffer_get_selection_bounds (buffer, &sel_begin, &sel_end))
+ {
+ gtk_text_iter_order (&sel_begin, &sel_end);
+ first_selected = gtk_text_iter_get_line (&sel_begin);
+ last_selected = gtk_text_iter_get_line (&sel_end);
+ }
+
if (gtk_text_iter_compare (begin, end) > 0)
{
const GtkTextIter *tmp = begin;
@@ -249,6 +259,11 @@ _gtk_source_gutter_lines_new (GtkTextView *text_view,
quark_set_add (&info.classes, q_cursor_line);
}
+ if G_UNLIKELY (i >= first_selected && i <= last_selected)
+ {
+ quark_set_add (&info.classes, q_selected);
+ }
+
g_array_append_val (lines->lines, info);
if G_UNLIKELY (!gtk_text_iter_forward_line (&iter) &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]