[ghex] Revert "HexWidget: Del/Bksp should only alter payload length in insert mode"



commit a66586b979d931189f46683e4033b3cbc99d7538
Author: Logan Rathbone <poprocks gmail com>
Date:   Thu Sep 8 11:40:51 2022 -0400

    Revert "HexWidget: Del/Bksp should only alter payload length in insert mode"
    
    This reverts commit 0cafa03f9b72aefc8755fcecc4d774357bea0681.
    
    See #50, !36

 src/gtkhex.c | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 1fa828c..763c8a4 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -1813,18 +1813,9 @@ key_press_cb (GtkEventControllerKey *controller,
        switch(keyval)
        {
                case GDK_KEY_BackSpace:
-                       if (self->cursor_pos > 0)
-                       {
-                               if (self->insert)
-                                       hex_document_set_data (self->document, self->cursor_pos - 1,
-                                                       0, 1, NULL, TRUE);
-                               else
-                               {
-                                       char zero = 0;
-                                       hex_document_set_data (self->document, self->cursor_pos - 1,
-                                                       1, 1, &zero, TRUE);
-                               }
-
+                       if (self->cursor_pos > 0) {
+                               hex_document_set_data (self->document, self->cursor_pos - 1,
+                                               0, 1, NULL, TRUE);
                                if (self->selecting)
                                        self->selecting = FALSE;
                                hex_widget_set_cursor (self, self->cursor_pos - 1);
@@ -1833,18 +1824,9 @@ key_press_cb (GtkEventControllerKey *controller,
                        break;
 
                case GDK_KEY_Delete:
-                       if (self->cursor_pos < payload_size)
-                       {
-                               if (self->insert)
-                                       hex_document_set_data (self->document, self->cursor_pos,
-                                                       0, 1, NULL, TRUE);
-                               else
-                               {
-                                       char zero = 0;
-                                       hex_document_set_data (self->document, self->cursor_pos,
-                                                       1, 1, &zero, TRUE);
-                               }
-
+                       if (self->cursor_pos < payload_size) {
+                               hex_document_set_data (self->document, self->cursor_pos,
+                                               0, 1, NULL, TRUE);
                                hex_widget_set_cursor (self, self->cursor_pos);
                                ret = GDK_EVENT_STOP;
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]