GNOME Bugzilla – Bug 564372
ghex reports the wrong number of bytes selected
Last modified: 2009-02-12 21:44:04 UTC
Please describe the problem: When you select three bytes in ghex the status bar says "2 bytes selected". This is easy to spot for small selections but at some point I was trying to find out where the next section header in an ELF began (those are 64 bytes long) and this bug got me really confused. Steps to reproduce: 1. 2. 3. Actual results: Expected results: Does this happen every time? Other information:
Created attachment 124575 [details] [review] patch that fixes this bug by correctly calculating the number of bytes in the selection
This does seem to improve things when selecting with the mouse, but there are still some bugs when selecting values using the keyboard rather than the mouse. For example, open a file, put the cursor on the first byte, hold down shift, and press right arrow several times. The reported selection count seems to be too low by 1 byte. Now, with shift still held down, press left arrow to de-select one more byte. strangely, the selection count in the status bar actually increases, so now instead of being too low by 1, the count is too high by one.
Created attachment 128007 [details] [review] updated patch (fixes both mouse and keyboard use cases) As it turns out the keyboard and mouse scenarios where broken due to pretty different reasons. After fiddling around with various ways of solving the keyboard selection bytes problem I think the cleanest fix is to emit the cursor_moved signal slightly later. Here is an updated patch that should fix both mouse and keyboard scenarios completely.
Thanks a lot for looking into this. I've committed your change, except the part that changed the status bar text (so that we don't lose existing translations). r1226
*** Bug 411572 has been marked as a duplicate of this bug. ***
*** Bug 571542 has been marked as a duplicate of this bug. ***