]> Pileus Git - ~andy/gtk/commitdiff
Bug 526234 - make shift+ctrl+del delete till the end of line
authorPaolo Borelli <pborelli@katamail.com>
Tue, 12 Aug 2008 17:21:13 +0000 (17:21 +0000)
committerPaolo Borelli <pborelli@src.gnome.org>
Tue, 12 Aug 2008 17:21:13 +0000 (17:21 +0000)
2008-08-12  Paolo Borelli  <pborelli@katamail.com>

Bug 526234 - make shift+ctrl+del delete till the end of line

* gtk/gtktextview.c: add shift+ctrl+del and shift+ctrl+backspace
keyboard shortcuts to delete to the end/start of the current line.

svn path=/trunk/; revision=21103

ChangeLog
gtk/gtktextview.c

index 8d87436342bbb63e528f632a8e26f170238f7d8a..8514302f61d332c7d6b579625c7e064891471afd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-12  Paolo Borelli  <pborelli@katamail.com>
+
+       Bug 526234 - make shift+ctrl+del delete till the end of line
+
+       * gtk/gtktextview.c: add shift+ctrl+del and shift+ctrl+backspace
+       keyboard shortcuts to delete to the end/start of the current line.
+
 2008-08-12  Michael Natterer  <mitch@imendio.com>
 
        * gtk/gtklinkbutton.c (set_link_color): bail out if there is no
index 0ac3c2e46ff5163de462b8da006b660c7ca62d7c..9af93c89de7831a59ff320575e8b3a2d5736baa1 100644 (file)
@@ -1130,6 +1130,21 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
                                G_TYPE_ENUM, GTK_DELETE_WORD_ENDS,
                                G_TYPE_INT, -1);
 
+  gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+                               "delete_from_cursor", 2,
+                               G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
+                               G_TYPE_INT, 1);
+
+  gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+                               "delete_from_cursor", 2,
+                               G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
+                               G_TYPE_INT, 1);
+
+  gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK | GDK_CONTROL_MASK,
+                               "delete_from_cursor", 2,
+                               G_TYPE_ENUM, GTK_DELETE_PARAGRAPH_ENDS,
+                               G_TYPE_INT, -1);
+
   /* Cut/copy/paste */
 
   gtk_binding_entry_add_signal (binding_set, GDK_x, GDK_CONTROL_MASK,
@@ -5480,26 +5495,42 @@ gtk_text_view_delete_from_cursor (GtkTextView   *text_view,
       break;
 
     case GTK_DELETE_PARAGRAPH_ENDS:
-      /* If we're already at a newline, we need to
-       * simply delete that newline, instead of
-       * moving to the next one.
-       */
-      if (gtk_text_iter_ends_line (&end))
+      if (count > 0)
         {
-          gtk_text_iter_forward_line (&end);
-          --count;
-        }
+          /* If we're already at a newline, we need to
+           * simply delete that newline, instead of
+           * moving to the next one.
+           */
+          if (gtk_text_iter_ends_line (&end))
+            {
+              gtk_text_iter_forward_line (&end);
+              --count;
+            }
 
-      while (count > 0)
-        {
-          if (!gtk_text_iter_forward_to_line_end (&end))
-            break;
+          while (count > 0)
+            {
+              if (!gtk_text_iter_forward_to_line_end (&end))
+                break;
 
-          --count;
+              --count;
+            }
         }
+      else if (count < 0)
+        {
+          if (gtk_text_iter_starts_line (&start))
+            {
+              gtk_text_iter_backward_line (&start);
+              if (!gtk_text_iter_ends_line (&end))
+                gtk_text_iter_forward_to_line_end (&start);
+            }
+          else
+            {
+              gtk_text_iter_set_line_offset (&start, 0);
+            }
+          ++count;
 
-      /* FIXME figure out what a negative count means
-         and support that */
+          gtk_text_iter_backward_lines (&start, -count);
+        }
       break;
 
     case GTK_DELETE_PARAGRAPHS: