1
0
mirror of synced 2025-01-11 13:52:15 +01:00

1598 Commits

Author SHA1 Message Date
WerWolv
7cc99c6fc9 impr: Added better notes to the settings tabs in the pattern editor view 2024-12-23 21:26:22 +01:00
paxcut
20cb74364f
fix: Jumpy text editor scrolling (#2023)
Two major improvements:
1) see through scrollbars when not hovered.
2) un-scrollable line numbers.

Also enlarged display region by eliminating padding. There is still a
problem with lines jumping when the scrollbar is dragged but it is
limited to one line and probably due to floating point error for scroll
bar number. It is much less noticeable than the previous jumping which
could involve several pages.

---------

Co-authored-by: WerWolv <werwolv98@gmail.com>
2024-12-23 20:14:42 +01:00
WerWolv
1c5a50c8d8 impr: Added better file open error messages to the file provider 2024-12-23 14:07:35 +01:00
WerWolv
470523cc86 fix: Jittery scrolling in Text Editor 2024-12-23 11:44:34 +01:00
WerWolv
f6bc3d4650 impr: Replace more assert() calls with IM_ASSERT() 2024-12-23 11:22:20 +01:00
WerWolv
41b1228d31 fix: Make sure all text editor members are correctly initialized 2024-12-23 11:21:39 +01:00
paxcut
2cb4462274
impr: Better top margin handling for text editor. (#2021)
The top margin changes when popups block some portion on the screen.
Previously it was implemented adding blank lines at the bottom which
created problems if the windows was scrolled all the way to the bottom
and the popups were issued. The newer implementation doesn't use spaces
and simply resets the top of the window to be higher making the popup
interaction with the window more natural (no text disappears on the
lines the popup overlaps the text). changes can be identified form the
variables mTopMargin,mOldTopMargin and mNewTopMargin.

Unfortunately those changes revealed problems in cursor navigation that
needed to be addressed. Namely, the window will scroll up and down on
the line before last/second line at the top and similar problems for the
left and right. Those changes correspond to the function
EnsureCUrsorVisible()

Fixing those reveled yet more problems with scrolling past the end of
the file using the keyboard which required adding some more variables
and functions to support the correct handling, You find those changes in
the function MoveDown.

I also renamed some variables that had the wrong casing and fixed the
pasting but that is missing one line.
2024-12-23 10:35:53 +01:00
WerWolv
f931beb49a impr: Make inserting bytes at the start of the file with insert mode work better 2024-12-23 01:33:52 +01:00
WerWolv
5fcb737559 fix: Only update widgets of settings that were changed
Fixed crashing on exit and speeds up settings writes
2024-12-20 21:23:19 +01:00
WerWolv
5a360eb614 patterns: Updated pattern language 2024-12-18 20:33:05 +01:00
paxcut
4a74bd78fd
fix: Console either printed no newlines or printed extra ones. (#2016)
The reason for the error were the text preprocessor added to deal with
tabs was created to process entire files, not just lines or words. In
that context it cleaned trailing new lines if any existed but in the new
role that's not only unwanted but erroneous.

### Problem description
After that was fixed the console started to add two empty lines between
each output line. When splitting a string using new lines you need to
not add a new line to the last line created. Even if the text ends in an
end line, the split screen code is set to not discard empty lines.

### Implementation description
The fixes are straightforward.
2024-12-18 20:19:18 +01:00
WerWolv
0f53656952 build: Small ImPlot3D fixes to make it build on all platforms 2024-12-18 20:18:27 +01:00
WerWolv
9ca40d3651 build: Added ImPlot3D 2024-12-17 23:51:45 +01:00
WerWolv
ab12503f62 patterns: Drastically improved time it takes to find favorites 2024-12-17 23:37:39 +01:00
paxcut
b446d7fd4a
impr: Make scrolling in pattern editor feel less janky (#2009)
I have implemented a fix that makes the scrollbars behave like they do
in VScode. Vertically you can scroll past the end of the file until only
the last line can be seen at the top. The horizontal bar behaves as if
every line was the same length which is the length of the longest line
in the file. Not only this creates a better user experience, but it also
fixes the annoying flicker that occurs when scrolling through large
files. Also, I have switched all the old draw calls to render text to
regular TextUnformatted calls which adds extra stability to the
resulting display.

To implement the behavior I added a dummy widget with the desired
dimensions.
2024-12-17 22:44:40 +01:00
paxcut
a79d3e28ca
fix: Crashes when getting tabs into text editor (#2008)
This time it may be for good. 


### Implementation description
As requested I added the preprocessing functionality into the pattern
editor. I had to duplicate a few functions and update the c++ library to
version 20. but now I can make sure the pattern editor doesn't see a tab
again. I also removed the preprocessor from where it was before because
it is not needed anymore. The changes were tested using a file that used
tabs for all its white space. The file was pasted into the pattern
editor and imported as well. I both cases no crashes occurred and the
files had no tabs on them.
2024-12-17 21:36:00 +01:00
WerWolv
fbb4f65735 patterns: Updated pattern language 2024-12-17 21:34:18 +01:00
WerWolv
a527a7f0b0 patterns: Updated pattern language 2024-12-16 21:32:19 +01:00
WerWolv
bb99b9a0ef fix: Shortcuts acting as duplicates in settings 2024-12-16 20:26:04 +01:00
WerWolv
313e59d7f9 fix: Shortcuts applying to multiple views at once 2024-12-16 20:14:26 +01:00
WerWolv
a07c79efcb fix: Pattern editor shortcuts being set to use CTRL on macOS 2024-12-15 22:39:24 +01:00
WerWolv
89090b25e3 impr: Various shortcut improvements 2024-12-15 21:44:43 +01:00
WerWolv
79ded38434 patterns: Updated pattern language 2024-12-15 14:12:27 +01:00
WerWolv
ee4bb33b0a impr: Display sub menus for shortcut settings 2024-12-15 11:54:10 +01:00
WerWolv
c46dea4c9e impr: Update settings menu values when settings are changed 2024-12-15 11:12:56 +01:00
WerWolv
6184bbeae2 build: Updated libwolv 2024-12-14 23:55:04 +01:00
WerWolv
21506578f5 impr: Removed more instanced of codecvt 2024-12-14 22:39:07 +01:00
WerWolv
f39f395393 impr: Replace codecvt with libwolv conversion functions 2024-12-14 22:20:48 +01:00
WerWolv
7f75706584 impr: Replace hex::unused with std::ignore 2024-12-14 21:35:54 +01:00
WerWolv
3f316e42f2 build: Remove unavailable warning flags from gcc builds 2024-12-14 21:35:42 +01:00
WerWolv
992f18b94b impr: Optimize build times a bit 2024-12-14 19:15:49 +01:00
Nik
040a606b39
feat: Added various custom built-in types to the pattern language (#1991) 2024-12-14 16:52:36 +01:00
Roman
d9a7f40eb4
fix: Shortcuts not being disabled correctly when menu items are disabled (#1992)
Fix crash on UNDO/REDO shortcut press when in "title screen"

### Problem description
ImHex crashes when (by default CTRL + Z/Y) undo/redo is pressed when on
"title"/"starting" screen (no file open, tested on Windows release build
and Linux [WSL] from-source build).

This is due to the shortcut's callback being called even if the
`provider` is `nullptr`. (see `createEditMenu` function).
Theoretically, this is prevented by the `enabledCallback` function
passsed to `addMenuItem`. In this case, though,
`addMenuItem` correctly propagates `enabledCallback` to menu item
creation but does not pass `enabledCallback` to
shortcut creation. Thus, when handling shortcuts, `enabledCallback` is
not used at all and the shortcut's callback
can be called in contradiction with its preconditions. (specified by
`enabledCallback`)

### Implementation description
The implementation wraps the callback in a check that decides whether
the shortcut is enabled or not.

(see changed files)
```c++
        auto callbackIfEnabled  = [enabledCallback, function]{ if (enabledCallback()) { function(); } };
```

This function is then passed along instead of the `function` (shortcut's
callback).

Alternatively, we can check for `nullptr` in the callback directly. This
would require modification of `createEditMenu`'s contents.
(I did not choose this implementation because I do not think it
addresses the root of the issue).

### Screenshots
None

### Additional things
I'm not sure how big of a deal it is but I am unsure whether I can
capture (`[enabledCallback, function]`) by reference or not.
2024-12-14 16:51:40 +01:00
paxcut
8d123da847
feat: Added goto line popup to text editors (#1984)
Since the popup is fairly small I opted for a straight addition parallel
to the find/replace. To make code more clear the functions that create
each popup were coalesced and made their interface simpler. That forced
a reorganization of the data processing which translates to a larger
number of changes than usual. Most of those changes are just moving some
action from one function to another.

The old method to identify popups using the size and position of the
window was dropped in favor of one based on child windows and using
their names for a much easier and robust identification.

Added specialized functions to text editor to jump to a line or to given
coordinates with a simple interface that simplifies older code that
performed the same task.

Because this PR modifies heavily the same code as the previous PR (1983)
it is also included here to make merging easier.

---------

Co-authored-by: Nik <werwolv98@gmail.com>
2024-12-14 16:50:45 +01:00
WerWolv
a1e399aa1a fix: Use after free in Text Editor when copying ErrorHoverBoxes 2024-12-09 14:39:46 +01:00
WerWolv
e1dfdd9400 fix: Missing include 2024-12-09 00:05:36 +01:00
paxcut
cf09029847
feat: Added clickable links to error messages in the pattern editor (#1988)
Errors printed in the console can be clicked to have the cursor jump to
the source code line where the error is at.

The mouse cursor changes its shape to indicate which parts of the error
message can be clicked on the console. When the cursor jumps, the text
editor takes the focus away from the console and it scrolls the window
to make the line with the error is visible if it isn't. This code uses
the function created for the go-to PR but adds code to switch focus to
the target. When the codes are merged please keep both the part that
jumps the cursor and the part that sets the focus.

---------

Co-authored-by: Nik <werwolv98@gmail.com>
2024-12-06 22:45:36 +01:00
BioTheWolff
2dcaf2c77b
fix: Various achievements issues (Edit the Hex, ROM Hacks) (#1985)
### Problem description
As described in #1846:
- the `Edit the Hex` achievement doesn't unlock when it should
- the `ROM Hacks` achievement is not using event-driven architecture
(the functions call `unlockAchievement` themselves)

### Implementation description
Firstly, for the `Edit the Hex` achievement:
- replaced the old event listener on `EventPatchCreated` with a listener
on `EventProviderDataModified`, which picks up bytes changes
- ensured the provider data change comes from a File provider, else
unlocking the achievement wouldn't make sense
- *Note*: a discovered side effect is that the "Fill" function modifies
the provider byte per byte (with a for loop)
- there is no use in testing the size of the data change, as it is
always 1 byte
- the Fill function could probably be reworked to fill in whole regions
at a time?

About the `ROM Hacks` achievement:
- implemented the new, still unused `EventPatchCreated` event.
- signal signature is `const unsigned char *, u64, const IPSKind`:
buffer pointer, buffer size, and IPS kind (IPS/IPS32)
- make use of the `::post` and `::subscribe` methods on said event to
unlock the achievement
- **WARNING::behaviour change**: the event's `post` signal has been
moved in the success branch of the IPS generation condition, meaning
that achievement will only unlock if IPS patch export has worked. I felt
it would make more sense than unlocking an achievement on an error, if
there was any to raise.

---------

Signed-off-by: BioTheWolff <47079795+BioTheWolff@users.noreply.github.com>
2024-12-06 00:36:42 +01:00
Justus Garbe
3c73f88a52
fix: AES ECB mode in Data processor not working at all (#1986)
Fix the AES ECB mode in the data processor along with some other misc
fixes:
- Fixed nullpointer node not working
- Fixed crypto module incorrectly using mbedtls api
- Fixed crypto module ignoring mbedtls errors
- Fixed silently ignoring of errors in AES node
2024-12-05 20:56:43 +01:00
paxcut
8acdc19be4
fix: Pattern Editor context menus being entries greyed out when they shouldn't be (#1983)
Some context menu entries that were available as shortcuts were greyed
out. This PR aims to fix them and improve how context menus work for the
text editor and the console. The improvements include:
- automatic focus on right click
- automatic selection on right click. If selected text is right-clicked
then copy, cut and find will use the selection, if no selection is
clicked but there is text were right-clicked, then the word will be
selected and used. If right-clicking empty space copy and cut will be
greyed out and find will start empty.
- similar functionality now exists for the console as well except the
menu has fewer options due to it being read-only.
- added esc to close console context menu
2024-12-05 19:34:51 +01:00
WerWolv
5948a74ad1 fix: Multiple memory corruption issues 2024-12-05 16:36:27 +01:00
WerWolv
807f1fb561 patterns: Updated pattern language 2024-12-02 21:16:35 +01:00
paxcut
d45e0d1cac
impr: Replace all asserts with IM_ASSERT in the Text Editor (#1979)
All asserts in TextEditor.cpp were replaced with IM_ASSERTs so that if
they are hit ImHex won't crash and give a nice popup message instead.
2024-12-02 20:21:57 +01:00
WerWolv
7623610704 build: Updated dependencies 2024-12-01 23:24:57 +01:00
WerWolv
485ce887ea patterns: Updated pattern language 2024-12-01 17:38:59 +01:00
paxcut
21ae88702f
fix: Empty text editor has no cursor. (#1976)
Even if focus is given to the pattern editor the cursor will not show
until the editor contains printable chars.

### Problem description
I was using the wrong condition to enter the loop that skipped the
default empty document.

### Implementation description
The fix was to check if there are lines of text that need to be
processed even if they are empty.
2024-12-01 09:58:37 +01:00
BobSmun
0ff1bb392c
fix: CRC64 parameters being limited to 32bit (#1975)
This addresses #1974
2024-11-30 18:35:03 +01:00
WerWolv
01af2f364c patterns: Updated pattern language 2024-11-30 13:49:27 +01:00
paxcut
a639dddd19
impr: Turned static variables into member variable in the Text Editor (#1973)
to avoid potential problems in the future if opening several popup
windows at the same time becomes possible.
2024-11-29 20:44:56 +01:00
WerWolv
caae5c9711 fix: Move visualizer drawer to correct library 2024-11-29 17:37:02 +01:00