eteran / edb-debugger

edb is a cross-platform AArch32/x86/x86-64 debugger.
GNU General Public License v2.0
2.69k stars 323 forks source link

Can't use backspace in some cases in Edit Binary String dialog #324

Open 10110111 opened 8 years ago

10110111 commented 8 years ago

To reproduce:

  1. Select some multibyte instruction in disassembly view
  2. Put cursor in Hex field right before e.g. second byte (i.e. after separating space)
  3. Press backspace
  4. See nothing worked

This naturally occurs when you e.g. delete bytes in the middle of the string instead of the end.

Interestingly, if I do the opposite — i.e. press Delete when the cursor is before space, the cursor is moved forward. Although it doesn't actually delete anything, I can at least press Delete once again and get the char deleted.

Ideally, the spaces there should be nothing more than spacers, i.e. something invisible to keyboard navigation & editing process. Namely, pressing Delete before space should place the cursor after that space and delete char forward, and pressing Backspace after space should place the cursor before that space and delete the char backward.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29596527-can-t-use-backspace-in-some-cases-in-edit-binary-string-dialog?utm_campaign=plugin&utm_content=tracker%2F14326212&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F14326212&utm_medium=issues&utm_source=github).
eteran commented 8 years ago

Yea, I remember these from when I first implemented this dialog. It proved to be very tricky to get right with Qt validators. I think the only way to get the "perfect" behavior is essentially do as you suggest and have the widget separate data from presentation. Internally, it should just know about hex digits, but then when it displays, at that point it would choose to display the spaces strictly as visual spacers.