[gnome-builder] editor: implement select-line action
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: implement select-line action
- Date: Thu, 25 Sep 2014 05:17:01 +0000 (UTC)
commit 2c9f694cbd787f444f266e7151205afe06ba19e3
Author: Christian Hergert <christian hergert me>
Date: Wed Sep 24 22:16:56 2014 -0700
editor: implement select-line action
This can be activated with <Control>L with the default keybindings.
src/editor/gb-editor-commands.c | 30 ++++++++++++++++++++++++++++++
src/resources/keybindings/default.ini | 1 +
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-commands.c b/src/editor/gb-editor-commands.c
index f529080..05e4bfa 100644
--- a/src/editor/gb-editor-commands.c
+++ b/src/editor/gb-editor-commands.c
@@ -791,6 +791,35 @@ gb_editor_commands_trim_trailing_space (GbEditorWorkspace *workspace,
}
static void
+gb_editor_commands_select_line (GbEditorWorkspace *workspace,
+ GbEditorTab *tab)
+{
+ GbEditorTabPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+ GtkTextIter iter;
+ GtkTextIter end;
+ guint line;
+
+ g_assert (GB_IS_EDITOR_WORKSPACE (workspace));
+ g_assert (GB_IS_EDITOR_TAB (tab));
+
+ priv = tab->priv;
+
+ buffer = GTK_TEXT_BUFFER (priv->document);
+
+ insert = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+ line = gtk_text_iter_get_line (&iter);
+ gtk_text_buffer_get_iter_at_line (buffer, &iter, line);
+ gtk_text_buffer_get_iter_at_line (buffer, &end, line);
+ while (!gtk_text_iter_ends_line (&end))
+ if (!gtk_text_iter_forward_char (&end))
+ break;
+ gtk_text_buffer_select_range (buffer, &iter, &end);
+}
+
+static void
gb_editor_commands_activate (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
@@ -840,6 +869,7 @@ gb_editor_commands_init (GbEditorWorkspace *workspace)
{ "reformat", gb_editor_commands_reformat, TRUE },
{ "save", gb_editor_commands_save, TRUE },
{ "save-as", gb_editor_commands_save_as, TRUE },
+ { "select-line", gb_editor_commands_select_line, TRUE },
{ "trim-trailing-space", gb_editor_commands_trim_trailing_space, TRUE },
{ NULL }
};
diff --git a/src/resources/keybindings/default.ini b/src/resources/keybindings/default.ini
index 15ebd45..516d77e 100644
--- a/src/resources/keybindings/default.ini
+++ b/src/resources/keybindings/default.ini
@@ -22,3 +22,4 @@ reformat = <Control><Shift>R
save = <Control>S
save-as = <Control><Shift>S
toggle-preview = <Control><Alt>P
+select-line = <Control>L
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]