Comments (8)
I don't think it is the last character of the line, but the last ascii character of whatever selection.
from qhexview.
I think your suggestion is correct and what you define as redundant is just the standard behaviour.
Try with old and new code to highlight multiple lines.
You will see that the hex selection is always 3 char wide as each char is 2 nibbles and a space.
One could decide that the last space at the end of a line with selection is not part of the selection, but I maybe not.
Try to replace -1
with const int gap = factor == 3 ? -1 : 0;
and you will see a bad EOL behaviour.
I think removing -1 is the correct solution.
from qhexview.
The hex selection is always 3 char wide as each char is 2 nibbles and a space.
I see, indeed, this is not a bug but simply how hex area is designed to work.
Nevertheless, aesthetically, I think, it looks better when these two “empty” characters which separate Hex from Ascii areas are not touched by the selection.
Maybe @Dax89 put this “-1” on purpose to deal with this particular case at the end of the line, where only 2 characters instead of 3 need to be selected, forgetting that it messes up the Ascii area?
I see that applySelection() is called in 2 places, by drawHex() and drawAscii(). Perhaps “-1” could be reintroduced as some optional argument, used from the drawHex() call only?
Plus with this “-1” selection in hex area seems more natural. That is, it follows mouse cursor precisely. In the version without the “-1” the selection cursor is always one character ahead of the mouse cursor, which feels slightly odd.
from qhexview.
What do you want to happen when the selection spans multiple Hex lines?
Do you want the last (empty) character of a line to appear selected or not?
If you don't want it to be selected, then one must change this too
QHexView/document/qhexrenderer.cpp
Line 286 in 05d1cf7
QTextCursor::EndOfLine
but add a -1
there too.
Is this the rule you have in mind? only ever select the space if in between selected characters and never at the end of a line.
this is VSCode.
from qhexview.
... only ever select the space if in between selected characters and never at the end of a line.
this is VSCode.
Pretty much this, and the screenshot illustrates it too. I think it looks better this way.
from qhexview.
What about this?
I've updated the PR.
from qhexview.
Perfect, thank you!
The only small thing I’d change is removing braces after the if (factor == 3)
line:
And while we’re at it, perhaps the factor argument to applySelection
could be enum
instead of int
?
enum Factor {Ascii = 1, Hex = 3}
So one could write if (factor == Hex)
without the need to write the comment, and the function could be called this way instead applySelection (textcursor, line, Hex)
from qhexview.
I see that my previous small suggestion has made it to the code as well, the issue is now fully resolved, thanks!
from qhexview.
Related Issues (20)
- Hex display width and comments HOT 7
- Unsymmetric page-up vs page-down HOT 1
- Render artefacts on top right of Hex Table HOT 6
- Possible error
- Fractional QFont width on a Pi HOT 4
- Horizontal scroll bar issues HOT 4
- QHexView cannot build HOT 4
- QHexview displays the extension HOT 4
- support change font size using setFont(...) HOT 5
- Renderer does not work well with widget’s width HOT 5
- Add dataChanged signal HOT 1
- Optional radio buttons that switch mode (insert / overwrite) inside header HOT 1
- Configurable mouse wheel scroll speed HOT 1
- Non-blinking cursor HOT 2
- QHexView does not support Qt5.7 HOT 5
- QHexDocument::searchForward does not move the cursor past the first result
- QHexView 5.0 Development HOT 94
- Qt6 compatibility (5.0 branch) HOT 2
- 5.0 branch and Qt5 cmake compatibility HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qhexview.