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.
Added the ui namespace and broke the main rendering function into a set
of smaller functions. Reorganized the header code separating functions
into rough groups that eventually will be in separate files.
Where one door opens, another one closes (said someone) and in this
situation i mean view, because there's no event for closing a view only
opening one, so please add this :c
### Problem description
Simply adds an **EventViewClosed** to match the pre-existing
**EventViewOpened**. Also fixes the issue where EventViewOpened wouldn't
trigger for windows that were popups (even if they are technically a
View.
### Implementation description
I mirrored the current functionality of EventViewOpened for closing.
---------
Co-authored-by: paxcut <53811119+paxcut@users.noreply.github.com>
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.
Currently setting the time interval to auto save the project has no
effect other than creating one initial save if the input file is
unsaved. When a file is created and not saved it remains in a dirty
state which prevented setting the state of the autosaved project to
needing to be saved. Fixed by decoupling the state of the provider from
the state of the autosave. When a provider is detected as being dirty it
always makes the autosave as being needed once the time interval has
elapsed.
feat: Implemented the menus on the main menu bar that will be available
when the text editor has focus. It allows you to load and save patterns
using open and save and will tack changes if files on disk are modified
externally. It also only opens the file chooser the first time you save
a pattern file and subsequent changes save to the same file.
If you want to save into another file and have the new file be tracked
you can use Save As. Finally, export doesn't track the file on disk at
all. this feature uses the same changes tracker class used elsewhere in
imHex.
fix: Changed the defaults of various shortcuts that were using Alt + a
key to avoid possible problems with some keyboards. Shouldn't affect end
users as their shortcuts are loaded from internal file but those who
complain about the Alt key misbehaving will be asked to reset the keys
to the new defaults. In addition, all globally accessible shortcuts were
added the Allow while typing flag so that they can be used in any field
that accepts text.
New menu entries were added for debugging to make the pattern editor and
the hex editor menus more like each other.
Finally, the call to RegisterMainMenuEntries() when initializing views
was moved to occur after the call to registerViews() so that menus are
not repeated when set for different views.
With only one menu entry and having set it to use the text editor then
the console losses that functionality. Since both the console and the
text editor are on the same view, it follows that they must share the
menu entries. In some cases it is necessary to determine which of the
two editors needs to be processed inside the menu entry itself.
Also an error that caused the creation of invalid coordinates when
console is still empty was fixed by setting coordinates to 0,0 for empty
files. Another problem was that left clicking on the console didn't
select the word under the cursor but it does when left clicking on the
text editor. Now it works in both.
The menu entries on the console were removed completely and swapped with
a call to obtain the default 'edit' menu for the context popup. Also,
the console in write-only, so some of the entries like `Paste` or
`Replace` must be greyed out.
This PR is only to fix the bugs that exist currently. More work is still
needed for:
1) Removing the remaining shortcuts and creating new menu entries for
them and
2) Adding support for `Open` and `Save` in the pattern editor with path
tracking.
I tested all combinations of menus and shorcuts with console and pattern
editor and there were no problems I could detect.
The problem was that imported files didn't have token sequences to
obtain the UDT variables. The fix was to create maps from the file name
to the token sequence and then process each imported file to obtain all
the variables needed. Function variables are skipped since they can be
part of the code.
There are also some minor code style corrections and a fix in the text
editor where the last line of a selection was not being deleted.
Users can now synchronize the content of the pattern editor with a file
on disk when exporting a pattern. Any modifications made in the pattern
editor are automatically saved to the file and when the pattern editor
gains focus it will automatically load any changes to the file on disk.
This feature is brand new and can have unforeseen problems so test it
fully before risking losing work.
Added major changes to how the text editor handles utf8 characters with
the added ability to obtain them using the [] operator and column
coordinates as indices. Sanitize coordinates was renamed to Set
Coordinates and can be used instead of the constructor to guarantee no
out of range asserts and/or exceptions. Improved move left and right
readability and cursor accuracy when clicking. Fixed single character
selection by double-clicking it. Deleted old and unused code and other
changes that I can't remember about atm.
These changes are part of an effort aimed at removing tabs from ImHex
that started some time ago. Here text preprocessing is removed from all
the places were it was done before and moved to the places where files
are read that go in the pattern editor with two notable exceptions.
1) Pattern import reads patterns in order to present a list that can be
filtered.That can safely ignore preprocessing since only needs to get
information needed to filter.
2) The pattern editor can incorporate text from the clipboard so that
needs to be preprocessed as well.
find/replace is unable to add tabs or carriage returns so this should
cover all angles.
Added clion-like bracket matching feature with shortcut to go to the
other one. Also improved some cumbersome repeated function call.
Added support for using negative indices in coordinates so -1 is the last
line or column, -2 the previous, etc..
Pattern library has fixes for column errors being incorrectly set for lines
containing tabs that are not replaced by 4 spaces.
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
This pr updates the pattern language library to include two fixes.
The first fix deal with local variables that are children of a
structure, a union, a bitfield or an array losing their offsets when the
parent's `setOffset()` is called.
The second fix is that local variables of unions were being used as size
contributors of the patterns place with said unions.
Further details may be found in the pattern language pull requests for
the files listed as changed in the PL submodule in this pr.
A while back there were some changes to the pattern language library
that changed the way shared_pointers are created using
shared_from_this(). Unfortunatelly the changes were not complete and
various bugs were created among them 2234, json type not working, unable
to export files, static arrays of bitfields,... The cause of the errors
was that in class Pattern the member m_parent was left as a raw pointer
and it needs to be handled by shared pointers. Also there were some
cases in which share pointers were needed but unique pointers were used
instead. Both cause crashes when shared_from_this is used on pointers
that are not managed by shared_ptr. Another source of errors were
infinite loops of clone and reference that caused stack overflow. The
fixes include making m_parent a weak pointer, turning unique pointers
into shared pointers and moving codefrom the copy constructors into
clone to break the infinite loops.These changes are the bare minimum
needed to bring the pattern language back to the full functionality that
it had before shared_from_this was introduced or at least thats the
hope.