Commit Graph

163 Commits

Author SHA1 Message Date
paxcut 1676342e28
Various fixes for pattern editor (#2561)
- Fix for vertical scroll bar being too far to the left.
- Fix constructor not initializing from const char pointer properly
- maxcolumn not being set for console text lines causing crashes on
empty pattern evaluation
- A replacement using replace all is now undone in one step.
- Find/replace no longer need to have enter or return key to accept
text. You can use arrows or shortcuts.
- More efficient search replace implementation with plans to add even
faster.
- Tooltips added to find/replace window
- Providers now save both horizontal and vertical scroll positions when
switching to another one and restore them when switching back. This is
independent to the cursor position which is also saved.
- Pattern editor no longer takes focus when changing providers via a tab
click. This has the effect that menus won't change by just clicking on a
tab.
- Small fixes and code refactoring.
2025-12-13 05:23:16 -07:00
WerWolv 62732de227 fix: Gaps in-between hex editor highlighting on specific scalings 2025-12-12 22:04:15 +01:00
WerWolv ab95cdf3e5 fix: Minimap not allowing scrolling as far as the scroll bar 2025-12-12 17:19:57 +01:00
paxcut bfa9788099
impr: Various fixes and improvements to the pattern editor (#2559)
- fixed crash when utf8 chars were present in text editor
- fixed unable to scroll when cursor at line 1
- removed dependencies on thext editor that were not being used.

I had to go back to the old code (old for me) and fit in the changes
that were applied to the new code.That was only possible by
incorporating some of the new structural differences to the text editor.
This created new bugs and crashes that I ve have fixed but there may be
ones that I couldn't find in the very small amount of time I could spend
testing so that this commit wouldn't be delayed. If more crashes are
found due to the mixing of old and new code they should be resolved when
the new code is brought in.
2025-12-12 16:27:26 +01:00
WerWolv 6427f53b5a feat: Add endian option to Sum hash 2025-12-07 22:18:34 +01:00
WerWolv 95f010395c fix: Pressing enter while in insert mode not behaving correctly 2025-12-06 16:11:28 +01:00
WerWolv da755ec75b feat: Added pattern context menu for copy and edit 2025-12-01 21:25:57 +01:00
WerWolv 1ab1f7ada0 fix: Comparison between literal and optional 2025-12-01 20:35:55 +01:00
WerWolv f4753a5bd8
feat: Added hex editor minimap option to shade cells based on the byte's value 2025-12-01 19:37:36 +01:00
WerWolv 980438008c
fix: Crashes and usability issues with the pattern tree filter 2025-12-01 19:35:22 +01:00
Zackary Newman 67efea6444
Fix segfault when opening recent file with pattern sync; Don't show p… (#2448)
…attern selection popup when pattern is already open

This PR does two things. Most importantly, it fixes a segfault that can
be caused by opening a recent file with pattern sync enabled.
Secondly, it makes it so that the pattern selection popup does not
appear if you already have text in the pattern editor for a given
provider (due to CLI args, a project file, pattern sync, etc.). If you
open a file normally, that text field is empty and the popup will appear
so you can select a pre-made pattern like usual.
2025-09-13 21:10:38 -07:00
WerWolv c1619820c7 impr: Jump to top of selection instead of the bottom
Fixes #2354
2025-09-10 20:50:27 +02:00
WerWolv a0326c4371 impr: Properly align buttons in pattern data view 2025-09-08 19:52:12 +02:00
paxcut d08853df8c
fix: No scrolling on jumping to error source. (#2438)
When I implemented the changes to allow creating breakpoints without
losing focus in the pattern editor and without forcing it to scroll to
the cursor position I broke the code that ensures the cursor is visible
after being moved to the source code that caused the error. All I needed
to do is to explicitly set the argument because the default is to not
scroll to the cursor when focus is given to the pattern editor
2025-09-07 12:31:09 -07:00
paxcut d8dd287cdf
fix: Fixed ImHex crashing when using ctrl-backspace on empty file. (#2433)
Editor was attempting to delete non-existent chars which is UB. Fixed by
checking before deleting. Also fixed was a problem created by having to
press enter to change the search string which advanced the selection to
the first match. In the next step one would expect that pressing enter
on the replace field would replace the selected item but was replacing
the item found after he first.

This was fixed by always replacing the current selection first. If the
replacement is the same as the searched term then replacing won't
advance the cursor, but if they are different then the current match
will no longer exist so it would search fora new one.
2025-09-05 02:28:11 -07:00
paxcut d62b64c27a
Fixes for next release. (#2430)
I forgot I also had comments switched to italics done easily thanks to
WerWolv's addition that lets you push and pop them.
2025-09-02 17:29:33 -07:00
paxcut 52952652de
Fixes for next release. (#2429)
Attempt to fix WerWolv's strange off by one problem when using the
mouse. Added a popup question for files that contain long lines (>1024
bytes). Also improved the handling of large lines, so it won't stall the
app. May also contain other smaller issue fixes.
2025-09-02 15:30:50 -07:00
WerWolv 715e970d99 fix: Last column in text editor not being selectable 2025-08-31 16:59:40 +02:00
paxcut c8caf6124e
Fix: Very long lines in text editor could make it hang. (#2426)
Fixed by only processing text that's visible.

Also fixed the cursor jumping to breakpoint line when selected by
clicking the line number and added highlighting of the current editing
line. An optimization that caches the number of utf-8 chars in each line
was included as well.
Finally, an error that caused ImHex to crash if a pattern was saved as
itself was also fixed.
2025-08-30 20:01:05 -07:00
WerWolv a063eb96c6 fix: Markdown elements overflowing window width 2025-08-27 21:27:47 +02:00
WerWolv c1a14cb4d4 impr: Ensure that wrapped text doesn't end up wrapping at every character 2025-08-25 21:22:43 +02:00
WerWolv 0178ba014a fix: Region picker widget overflowing in many views 2025-08-24 16:29:36 +02:00
Nik d012ad08f8
feat: Added proper Markdown renderer (#2415) 2025-08-20 20:37:44 +02:00
WerWolv fbde2942de build: Refactor ContentRegistry into multiple separate files 2025-08-14 21:22:03 +02:00
WerWolv d920718b44 build: Refactor ImHexAPI into multiple separate files 2025-08-14 20:16:40 +02:00
WerWolv b5a3a8b4c2 impr: Rewrite Localization Manager to use more standard format and load localizations on the fly 2025-08-12 18:00:10 +02:00
WerWolv 25c8f4b588 fix: Jump to certain array-member patterns not working
Fixes #2398
2025-08-11 21:46:47 +02:00
paxcut 50f1fe2b2d
improv: moved text editor to the ui plugin. (#2397)
Reorganized source code into files named in the fashion of imhex and
split large functions into smaller ones. Moved all function definitions
out of the header except for one-liners. All variable types were
switched to use imHex standard (u8,...) and removed duplicated functions
that were needed when the text editor was isolated.

Minor improvements to find/replace while making sure they still worked
with utf-8 chars.
2025-08-10 14:35:21 -07:00
WerWolv d683c04519 fix: ID and layout issues with static array members in the pattern data view
Fixes #2393
2025-08-09 14:09:32 +02:00
WerWolv 9cff9043ee impr: Remove hex::format, improve format and logging type safety 2025-08-06 20:02:23 +02:00
paxcut d429424f67
improv: refactor text editor to follow imhex style. (#2382)
Also fixes two bugs:
1) error messages not staying visible
2) uncaught exception when struct name is duplicated.

A lot of the code using coordinates for start and end has been moved to
use Selections instead. Created more string manipulation code that uses
utf8 indices aka Coordinates directly. This makes implementing editing
functions easier by not having to go back and forth from string indices
to char indices and back. Currently, the substring, erase and []
operator support coordinates and str indices.
2025-08-06 01:01:07 -07:00
WerWolv e05825b9f4 feat: Added extended/unprintable ASCII character display toggle to hex editor 2025-08-05 23:33:02 +02:00
WerWolv 95465e2fc3 fix: Tree expand working differently for favorites and static arrays in the pattern data view 2025-08-05 17:57:59 +02:00
paxcut 56d1e2670e
fix: segment numbers are still being cutoff. (#2370)
I noticed that an earlier fix was missing parenthesis, so I checked a
file of a big size and used a segment size of 1 and only 3 digits were
being displayed in spite of needing 6.
2025-08-02 23:44:35 -07:00
WerWolv 29354f0bcb fix: Hex Editor segment numbers being cut off 2025-08-02 17:30:49 +02:00
WerWolv 83d92dde35 build: Update VSCode Icons font 2025-07-30 23:17:13 +02:00
WerWolv be6a90675b fix: Some cell visualizer types not updating their values correctly 2025-07-26 11:58:30 +02:00
WerWolv e0180b718f feat: Added simplified pattern value editor 2025-07-24 23:29:13 +02:00
WerWolv 0e720a1e02 fix: Hex editor insert mode inserting or removing too many bytes 2025-07-24 19:28:46 +02:00
WerWolv f6860015eb fix: Rendering of insert cursor in hex editor 2025-07-24 18:13:02 +02:00
paxcut 24732b304b
fix: more problems with bytes per row. (#2338)
The scrollbar, mini map and the segment delimiters were also using the
incorrect bytes per row value when changing data size forced a change in
the number of bytes per row. From the definition of the new value it
follows that bytesPerRow/bytesPercell == m_bytesPerRow/bytesPerCell, so
it is not necessary to switch it when it is divided by that quantity.
2025-07-16 13:23:14 -07:00
paxcut 5ea021d57a
fix: fix for issue 2334 (#2337)
The error was that if `m_bytesPerRow` was not divisible by the number of
bytes per column then ImHex would crash but wouldn't crash if it was.
When `m_bytesPerRow` is not equal to the resultant bytes per row
obtained by the product of column count and bytes per column, then the
later bytes per row were be allocated but the former bytes per row were
being written causing heap corruption and crashes.

Instead of resetting `m_bytePerRow` when it can't be used, a new
variable (`bytesPerRow`) is created with the correct value and used in
the rest of the function. This way if the user goes back to choose a
data size that divides the old `m_bytesPerRow` then the number would
still be available and not overwritten. Test indicate that this approach
works and previous crashes are eliminated while producing the desired
output.
2025-07-15 23:55:52 -07:00
paxcut e7a2729d36
feat: semantic syntax highlights for pattern editor. (#2214)
allows the ability to assign colors to global placed and non-placed
variables, pattern, local and calculated pointer variables, template
arguments, function variables and arguments, etc etc etc. It
accomplishes this using the parser and the token sequence generated by
the lexer. It still uses the original colorizing code but the underlying
data holding the pattern has been updated to be easier to use and to
debug. The changes are too numerous to cite here.It is a big but
necessary step to bring the pattern editor to a somewhat useful state.
There may be one commit in the pattern language repo needed to be able
to run this code
2025-07-11 22:47:56 -07:00
WerWolv da2aa85a8a build: Fix cppcheck issues 2025-07-10 13:57:08 +02:00
Nik d1840a2184
build: Update ImGui to v1.92.1 (#2325)
Update ImGui to the latest version and rewrite most of the font handling
code
2025-07-10 10:00:39 +02:00
WerWolv 11e70511e6 build: Fix plugin SDK issues 2025-05-29 18:19:20 +02:00
WerWolv 7067ffafe7 patterns: Display pattern errors in red in the pattern data view 2025-05-25 11:46:41 +02:00
WerWolv 145c88db31 patterns: Updated pattern language
Fixes #2266
2025-05-25 11:00:59 +02:00
WerWolv bd8c4e807c fix: Remove extra pixel from Hex Editor selection frame 2025-05-24 16:19:13 +02:00
Stephen Hewitt f729d36214
fix: Crash when sorting for value fields in pattern data view, fix HTML export encoding (#2242)
<!--
Please provide as much information as possible about what your PR aims
to do.
PRs with no description will most likely be closed until more
information is provided.
If you're planing on changing fundamental behaviour or add big new
features, please open a GitHub Issue first before starting to work on
it.
If it's not something big and you still want to contact us about it,
feel free to do so !
-->

### Problem description
This is a fix for the ImHex bug "ImHex crashes when analysing any PE
file #2221"

### Implementation description
This is a fix for the ImHex bug "ImHex crashes when analysing any PE
file #2221". The fix requires changes to the Pattern Language and the
ImHex UI. Revision would be wise. We want to avoid collateral damage.
It's a big code base and I'm new to it and the compilers/build-systems
used. And the bug is complex and low-level. I suspect this will fix
other random crashes. The problem is caused by two issues:
- The std::sort algorithm conjuring up garbage due to the sorting
criteria not being a strict weak ordering. See
[this](https://github.com/Voultapher/sort-research-rs/blob/main/writeup/sort_safety/text.md)
link.
- We sort shared_ptr&lt;ptrn::Pattern&gt; by pointer value, and the
object is a clone. In essence we're changing the values as we're
sorting.
 
Fixes #2221

### IMPORTANT
I'm not sure how "plugins/builtin/source/content/data_formatters.cpp"
got into the PR. Been trying for an hour to rectify. I'm not a Git
expert (the last time I used source control seriously SourceSafe was a
thing) please ignore that file. It's a fix for another PR I submitted. I
suspect I stuffed up the branching and merging.

---------

Co-authored-by: Nik <werwolv98@gmail.com>
2025-05-17 20:50:21 +00:00