[gnome-builder] allow selecting a search match
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] allow selecting a search match
- Date: Tue, 24 Mar 2015 00:29:38 +0000 (UTC)
commit 4174a13cd537e761591a7ac4d2d92c747a99f689
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 19 21:40:09 2015 -0700
allow selecting a search match
data/keybindings/vim.css | 16 ++++++++--------
libide/ide-source-view.c | 20 ++++++++++++++++----
libide/ide-source-view.h | 1 +
src/editor/gb-editor-frame-actions.c | 4 ++--
src/editor/gb-editor-frame-private.h | 1 +
5 files changed, 28 insertions(+), 14 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index cf1195f..60e4b06 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -244,20 +244,20 @@
"movement" (previous-match-modifier, 0, 0, 1)
"clear-modifier" () };
- bind "n" { "move-search" (down, 0, 1, 1, 1) };
- bind "<shift>n" { "move-search" (up, 0, 0, 1, 1) };
+ bind "n" { "move-search" (down, 0, 0, 1, 1, 1) };
+ bind "<shift>n" { "move-search" (up, 0, 0, 0, 1, 1) };
bind "numbersign" { "movement" (previous-word-end, 0, 1, 1)
"movement" (next-word-start, 0, 1, 0)
"movement" (next-word-end, 1, 0, 1)
"set-search-text" ("", 1)
- "move-search" (up, 0, 0, 1, 1) };
+ "move-search" (up, 0, 0, 0, 1, 1) };
bind "asterisk" { "movement" (previous-word-end, 0, 1, 1)
"movement" (next-word-start, 0, 1, 0)
"movement" (next-word-end, 1, 0, 1)
"set-search-text" ("", 1)
- "move-search" (down, 0, 1, 1, 1) };
+ "move-search" (down, 0, 0, 1, 1, 1) };
/* page movements */
bind "<ctrl>b" { "movement" (page-up, 0, 0, 1)
@@ -1023,8 +1023,8 @@
bind "b" { "movement" (previous-word-start, 1, 1, 1) };
bind "<shift>b" { "movement" (previous-full-word-start, 1, 1, 1) };
- bind "n" { "move-search" (down, 1, 1, 1, 1) };
- bind "<shift>n" { "move-search" (up, 1, 0, 1, 1) };
+ bind "n" { "move-search" (down, 1, 0, 1, 1, 1) };
+ bind "<shift>n" { "move-search" (up, 1, 0, 0, 1, 1) };
bind "numbersign" { "save-insert-mark" ()
"movement" (previous-word-end, 0, 1, 1)
@@ -1032,7 +1032,7 @@
"movement" (next-word-end, 1, 0, 1)
"set-search-text" ("", 1)
"restore-insert-mark" ()
- "move-search" (up, 1, 0, 1, 1) };
+ "move-search" (up, 1, 0, 0, 1, 1) };
bind "asterisk" { "save-insert-mark" ()
"movement" (previous-word-end, 0, 1, 1)
@@ -1040,7 +1040,7 @@
"movement" (next-word-end, 1, 0, 1)
"set-search-text" ("", 1)
"restore-insert-mark" ()
- "move-search" (down, 1, 1, 1, 1) };
+ "move-search" (down, 1, 0, 1, 1, 1) };
bind "<ctrl>b" { "movement" (page-up, 1, 0, 1) };
bind "<ctrl>f" { "movement" (page-down, 1, 0, 1) };
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index bf5c4f7..34b68fc 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -152,6 +152,7 @@ typedef struct
IdeSourceView *self;
guint is_forward : 1;
guint extend_selection : 1;
+ guint select_match : 1;
guint exclusive : 1;
} SearchMovement;
@@ -262,17 +263,21 @@ static SearchMovement *
search_movement_new (IdeSourceView *self,
gboolean is_forward,
gboolean extend_selection,
+ gboolean select_match,
gboolean exclusive,
gboolean use_count)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
SearchMovement *mv;
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
mv = g_new0 (SearchMovement, 1);
mv->ref_count = 1;
mv->self = g_object_ref (self);
mv->is_forward = !!is_forward;
mv->extend_selection = !!extend_selection;
+ mv->select_match = !!select_match;
mv->exclusive = !!exclusive;
mv->count = use_count ? MAX (priv->count, 1) : 1;
@@ -3094,11 +3099,13 @@ ide_source_view__search_forward_cb (GObject *object,
return;
}
- if (!mv->exclusive)
+ if (!mv->exclusive && !mv->select_match)
gtk_text_iter_forward_char (&begin);
if (mv->extend_selection)
gtk_text_buffer_move_mark (buffer, insert, &begin);
+ else if (mv->select_match)
+ gtk_text_buffer_select_range (buffer, &begin, &end);
else
gtk_text_buffer_select_range (buffer, &begin, &begin);
@@ -3150,11 +3157,13 @@ ide_source_view__search_backward_cb (GObject *object,
return;
}
- if (mv->exclusive)
+ if (mv->exclusive && !mv->select_match)
gtk_text_iter_forward_char (&begin);
if (mv->extend_selection)
gtk_text_buffer_move_mark (buffer, insert, &begin);
+ else if (mv->select_match)
+ gtk_text_buffer_select_range (buffer, &begin, &end);
else
gtk_text_buffer_select_range (buffer, &begin, &begin);
@@ -3169,6 +3178,7 @@ static void
ide_source_view_real_move_search (IdeSourceView *self,
GtkDirectionType dir,
gboolean extend_selection,
+ gboolean select_match,
gboolean exclusive,
gboolean apply_count,
gboolean word_boundaries)
@@ -3213,7 +3223,8 @@ ide_source_view_real_move_search (IdeSourceView *self,
is_forward = (dir == GTK_DIR_DOWN) || (dir == GTK_DIR_RIGHT);
- mv = search_movement_new (self, is_forward, extend_selection, exclusive, apply_count);
+ mv = search_movement_new (self, is_forward, extend_selection, select_match,
+ exclusive, apply_count);
if (is_forward)
{
@@ -5093,11 +5104,12 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
NULL, NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
- 5,
+ 6,
GTK_TYPE_DIRECTION_TYPE,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
+ G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
gSignals [PASTE_CLIPBOARD_EXTENDED] =
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 219055f..2374408 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -238,6 +238,7 @@ struct _IdeSourceViewClass
void (*move_search) (IdeSourceView *self,
GtkDirectionType dir,
gboolean extend_selection,
+ gboolean select_match,
gboolean exclusive,
gboolean apply_count,
gboolean at_word_boundaries);
diff --git a/src/editor/gb-editor-frame-actions.c b/src/editor/gb-editor-frame-actions.c
index 6b236e7..2e78ace 100644
--- a/src/editor/gb-editor-frame-actions.c
+++ b/src/editor/gb-editor-frame-actions.c
@@ -43,7 +43,7 @@ gb_editor_frame_actions_next_search_result (GSimpleAction *action,
g_assert (GB_IS_EDITOR_FRAME (self));
- g_signal_emit_by_name (self->source_view, "move-search", GTK_DIR_DOWN, FALSE, FALSE, FALSE);
+ g_signal_emit_by_name (self->source_view, "move-search", GTK_DIR_DOWN, FALSE, TRUE, FALSE, FALSE);
}
static void
@@ -55,7 +55,7 @@ gb_editor_frame_actions_previous_search_result (GSimpleAction *action,
g_assert (GB_IS_EDITOR_FRAME (self));
- g_signal_emit_by_name (self->source_view, "move-search", GTK_DIR_UP, FALSE, FALSE, FALSE);
+ g_signal_emit_by_name (self->source_view, "move-search", GTK_DIR_UP, FALSE, TRUE, FALSE, FALSE);
}
static const GActionEntry GbEditorFrameActions[] = {
diff --git a/src/editor/gb-editor-frame-private.h b/src/editor/gb-editor-frame-private.h
index f789578..20528d9 100644
--- a/src/editor/gb-editor-frame-private.h
+++ b/src/editor/gb-editor-frame-private.h
@@ -36,6 +36,7 @@ struct _GbEditorFrame
GtkScrolledWindow *scrolled_window;
GtkRevealer *search_revealer;
GdTaggedEntry *search_entry;
+ GdTaggedEntryTag *search_entry_tag;
IdeSourceView *source_view;
gulong cursor_moved_handler;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]