After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766830 - Shortcut keys - duplicate
Shortcut keys - duplicate
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: editor
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-24 08:17 UTC by oly
Modified: 2016-06-17 19:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Bug 766830 - Shortcut keys - duplicate line (4.06 KB, patch)
2016-05-30 12:38 UTC, Raunaq
none Details | Review
Bug 766830 - Shortcut keys - duplicate line (4.15 KB, patch)
2016-05-30 15:34 UTC, Raunaq
none Details | Review
Bug 766830 - Shortcut keys - duplicate line (4.26 KB, patch)
2016-05-30 15:46 UTC, Raunaq
none Details | Review
Bug 766830 - Shortcut keys - duplicate line (4.50 KB, patch)
2016-06-01 08:21 UTC, Raunaq
none Details | Review
Bug 766830 - Shortcut keys - duplicate (4.42 KB, patch)
2016-06-01 16:13 UTC, Raunaq
none Details | Review
Bug 766830 - Shortcut keys - duplicate (4.42 KB, patch)
2016-06-01 18:30 UTC, Raunaq
committed Details | Review

Description oly 2016-05-24 08:17:36 UTC
trying Ctrl + D to duplicate a line does not work this seems to delete, this is not listed in the shortcut screen, and if thats delete whats duplicate and can that be added to the shortcut search ?

Can we duplicate a line yet and what's the keybinding ?
Comment 1 Christian Hergert 2016-05-24 08:40:59 UTC
In vim mode you would do `yyp`, but I don't think we have a keybinding for the "gedit" mode (our default mode).

Do you know what the duplicate line shortcut is in Gedit?
Comment 2 sébastien lafargue 2016-05-24 10:45:23 UTC
For a recap:

Geany use ctrl+d
Sublime Text use ctrl+shift+d
Atom use ctrl+shift+d
XCode use command+d
Eclipse ctrl+alt+up or down
Visual Studio, nothing specific

With Gedit, ctrl+d is already used to delete a line, but nothing specific
to duplicate it

Don't forget that under Gtk+, ctrl+shift+d is use to trigger the inspector if activated before
( from the cli or in gsettings )
Comment 3 oly 2016-05-24 11:59:04 UTC
so if its not currently available can we get it added to default mode, its extremely handy :) ?
Comment 4 sébastien lafargue 2016-05-27 09:11:26 UTC
We just need to agree on a currently free shortcut to use
Comment 5 Raunaq 2016-05-30 12:38:58 UTC
Created attachment 328724 [details] [review]
Bug 766830 - Shortcut keys - duplicate line

Added keybindings for duplicating a line. ctrl+alt+d is added as keyboard shortcut for duplicating a line.
Also added the keyboard shortcut in the shortcut window.
Comment 6 sébastien lafargue 2016-05-30 13:32:18 UTC
Review of attachment 328724 [details] [review]:

you need to do the paste part of this *duplicate line* action

::: data/ui/ide-shortcuts-window.ui
@@ +215,3 @@
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;&lt;alt&gt;d</property>
+                <property name="title" translatable="yes" context="shortcut window">Copy entire line to clipboard</property>

Duplicate entire line to clipboard

::: libide/ide-source-view.c
@@ +3061,3 @@
+  GtkTextView *text_view = (GtkTextView *)self;
+  GtkTextIter start, end;
+  g_autofree gchar *line;

please always set the g_auto_* macros to NULL

@@ +3075,3 @@
+
+  gtk_text_buffer_get_iter_at_mark (buffer, &start, cursor);
+  gtk_text_buffer_get_iter_at_mark (buffer, &end, cursor);

you can do: end = start

@@ +3081,3 @@
+
+  line = gtk_text_iter_get_text (&start, &end);
+  strcat(line, "\n");

use the g_strconcat or g_strcat API
Comment 7 Raunaq 2016-05-30 15:34:16 UTC
Created attachment 328751 [details] [review]
Bug 766830 - Shortcut keys - duplicate line

Added keybindings for duplicating a line. ctrl+alt+d is added as keyboard shortcut for duplicating a line.
Also added the keyboard shortcut in the shortcut window.

https://bugzilla.gnome.org/show_bug.cgi?id=766830

Bug 766830 - Shortcut keys - duplicate line

Made the duplicate function like that in sublime text. Contents of clipboard arent changed.
Changed windows-shortcuts name.
Comment 8 Raunaq 2016-05-30 15:46:31 UTC
Created attachment 328752 [details] [review]
Bug 766830 - Shortcut keys - duplicate line

Added keybindings for duplicating a line. ctrl+alt+d is added as keyboard shortcut for duplicating a line.
Also added the keyboard shortcut in the shortcut window.

https://bugzilla.gnome.org/show_bug.cgi?id=766830

Bug 766830 - Shortcut keys - duplicate line

Made the duplicate function like that in sublime text. Contents of clipboard arent changed.
Changed windows-shortcuts name.

https://bugzilla.gnome.org/show_bug.cgi?id=766830

Had forgotten about setting the g_auto_* macros to NULL.
Comment 9 Raunaq 2016-06-01 08:21:06 UTC
Created attachment 328859 [details] [review]
Bug 766830 - Shortcut keys - duplicate line

Added keybindings for duplicating a line. ctrl+alt+d is added as keyboard shortcut for duplicating a line.
Also added the keyboard shortcut in the shortcut window.

https://bugzilla.gnome.org/show_bug.cgi?id=766830

Bug 766830 - Shortcut keys - duplicate line

Made the duplicate function like that in sublime text. Contents of clipboard arent changed.
Changed windows-shortcuts name.

https://bugzilla.gnome.org/show_bug.cgi?id=766830

Had forgotten about setting the g_auto_* macros to NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=766830

Bug 766830 - Shortcut keys - duplicate

Changed instances of copy to duplicate.
Avoided mem leak.
Comment 10 sébastien lafargue 2016-06-01 11:02:18 UTC
Review of attachment 328859 [details] [review]:

todo:
- fix the case where we are on an empty line
- take the selection into account
- cleanup the commit message, we don't need the development history

::: data/ui/ide-shortcuts-window.ui
@@ +215,3 @@
+                <property name="visible">1</property>
+                <property name="accelerator">&lt;ctrl&gt;&lt;alt&gt;d</property>
+                <property name="title" translatable="yes" context="shortcut window">Duplicate entire line to clipboard</property>

'Duplicate current line or selection' is more correct
Comment 11 Raunaq 2016-06-01 16:13:53 UTC
Created attachment 328903 [details] [review]
Bug 766830 - Shortcut keys - duplicate

Implemented function to duplicate entire line or selected text using keyboard binding ctrl+alt+d.
Also added the keybinding in shortcut window.
Comment 12 Christian Hergert 2016-06-01 17:52:10 UTC
Review of attachment 328903 [details] [review]:

::: data/keybindings/default.css
@@ -24,2 +24,3 @@
   bind "<ctrl>i" { "action" ("view", "goto-line", "") };
   bind "<ctrl>asciitilde" { "change-case" (toggle) };
+  bind "<ctrl><alt>d" { "duplicate-entire-line" ()};

space before }

::: data/ui/ide-shortcuts-window.ui
@@ -211,2 +211,5 @@
               </object>
             </child>
+            <child>
+              <object class="GtkShortcutsShortcut">
+                <property name="visible">1</property>

1 is fine, I didn't realize everything else was using it in this file.

::: libide/ide-source-view.c
@@ -3057,1 +3058,5 @@
 static void
+ide_source_view_real_duplicate_entire_line (IdeSourceView *self)
+{
+  GtkTextView *text_view = (GtkTextView *)self;
+  GtkTextIter start, end;

Use "begin" instead of "start" as it clashes with a libc symbol

@@ +3079,3 @@
+  if (selected)
+    {
+      duplicate_line = gtk_text_iter_get_text (&start, &end);

The signal is "duplicate-entire-line" yet this only duplicates the selection without adding a \n. Doesn't that seem strange?

@@ +3093,3 @@
+        {
+          text = gtk_text_iter_get_text (&start, &end);
+          duplicate_line = g_strconcat (text, "\n", NULL);

I think this is broken on the last line of the file. you'll get "foo" → "foofoo\n".

Do an insert of "\n" at end first and then the text (no need to do the concat first).
Comment 13 Raunaq 2016-06-01 18:30:47 UTC
Created attachment 328908 [details] [review]
Bug 766830 - Shortcut keys - duplicate

Implemented function to duplicate entire line or selected text using keyboard binding ctrl+alt+d.
Also added the keybinding in shortcut window.
Comment 14 Christian Hergert 2016-06-17 19:25:06 UTC
Thanks!