[ghex] HexWidget: Del/Bksp should only alter payload length in insert mode
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex] HexWidget: Del/Bksp should only alter payload length in insert mode
- Date: Fri, 22 Jul 2022 19:25:59 +0000 (UTC)
commit 0cafa03f9b72aefc8755fcecc4d774357bea0681
Author: Logan Rathbone <poprocks gmail com>
Date: Fri Jul 22 14:02:46 2022 -0500
HexWidget: Del/Bksp should only alter payload length in insert mode
src/gtkhex.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index 763c8a4..f54e000 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -1813,9 +1813,18 @@ key_press_cb (GtkEventControllerKey *controller,
switch(keyval)
{
case GDK_KEY_BackSpace:
- if (self->cursor_pos > 0) {
- hex_document_set_data (self->document, self->cursor_pos - 1,
- 0, 1, NULL, TRUE);
+ 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->selecting)
self->selecting = FALSE;
hex_widget_set_cursor (self, self->cursor_pos - 1);
@@ -1824,9 +1833,20 @@ key_press_cb (GtkEventControllerKey *controller,
break;
case GDK_KEY_Delete:
- if (self->cursor_pos < payload_size) {
- hex_document_set_data (self->document, self->cursor_pos,
- 0, 1, NULL, TRUE);
+ 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);
+ }
+
+// hex_document_set_data (self->document, self->cursor_pos,
+// 0, self->insert, 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]