summaryrefslogtreecommitdiff
path: root/Userland/Applications/HexEditor/HexEditor.cpp
AgeCommit message (Collapse)Author
2023-05-23LibGfx+Everywhere: Change `Gfx::Rect` to be endpoint exclusiveJelle Raaijmakers
Previously, calling `.right()` on a `Gfx::Rect` would return the last column's coordinate still inside the rectangle, or `left + width - 1`. This is called 'endpoint inclusive' and does not make a lot of sense for `Gfx::Rect<float>` where a rectangle of width 5 at position (0, 0) would return 4 as its right side. This same problem exists for `.bottom()`. This changes `Gfx::Rect` to be endpoint exclusive, which gives us the nice property that `width = right - left` and `height = bottom - top`. It enables us to treat `Gfx::Rect<int>` and `Gfx::Rect<float>` exactly the same. All users of `Gfx::Rect` have been updated accordingly.
2023-02-15HexEditor: Add selection strings to the value inspectorMetallicSquid
Strings include ASCII, UTF-8, and UTF-16 Co-authored-by: Andreas Krohn <hamburger1984@gmail.com>
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-04HexEditor: Propagate errors from `HexDocumentFile::set_title()`Lucas CHOLLET
2023-02-04HexEditor: Propagate errors when using "Save"Lucas CHOLLET
2023-02-04HexEditor: Propagate errors when using "Save as"Lucas CHOLLET
2023-02-04HexEditor: Port to `Core::Stream`Lucas CHOLLET
2023-02-04HexEditor: Use the constructor patternLucas CHOLLET
2023-01-12Userland: Use Core::Timer::create_foo() factory functions where possibleSam Atkins
2022-12-14HexEditor: Handle some errors inside the editorArda Cinar
Specifically, the ones HexEditor::did_complete_action possibly raised in case creating an undo stack entry or pushing it onto the undo stack fails. In this case, an error popup is displayed and the modifications are undone. This removes 2 FIXMEs inside the code :^)
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-14HexEditor: Allow keydown events to propagate if they are not handledZaggy1024
2022-11-01HexEditor: Implement undo and redo actionskamp
2022-11-01HexEditor: Only mark window as modified when document is actually dirtykamp
2022-10-31HexEditor: Specify page skip size in multiples of the line heightpremek
2022-10-14HexEditor: Render selection background without gaps between rowsMart G
The selected region in HexEditor is indicated by rendering a different background color for the selected bytes. Previously this background was rendered so that the background rectangles were not contigous between different rows. This caused a high contrast pattern that interfered with the readability of the hexadecimal digits. Now the background is rendered as a single contiguous block.
2022-10-12HexEditor: Fix two off-by-one errorsMart G
The 'select all' feature now also selects the last byte of the document. The find function now also selects the last byte of a match.
2022-08-03HexEditor: Rename camel case variable names in `HexEditor::save_as`James Puleo
This also changes those variables to be references to the casted document type, instead of pointers.
2022-08-03HexEditor: Make `HexEditor::open_new_file` fallible and reduce branchingJames Puleo
Returning a `bool` is meaningless, so let's make it more expresive :^)
2022-08-03HexEditor: Remove unused readonly flagJames Puleo
`HexEditor::set_readonly` was never called, even though `HexEditor::is_readonly` was occasionally queried -- so it's entirely been removed.
2022-08-03HexEditor: Don't spam debug output when finding all stringsJames Puleo
For each string found we would output it, which was way too much noise :^)
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-11HexEditor: Gray-out null bytesKarol Kosek
This should improve an overall visibility of "meaningful" data. :^)
2022-04-09LibGfx: Move other font-related files to LibGfx/Font/Simon Wanner
2022-04-07HexEditor: Add get_byte() method to HexEditor classTimothy Slater
2022-04-07HexEditor: Add ability to set a selection rangeTimothy Slater
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-14HexEditor: Selection follows cursor while pressing shiftSamu698
This patch makes the HexEditor behaviour similar to the one of the text editor, this can be seen by pressing shift and the arrow keys
2022-03-14HexEditor: Fill selection sets only bytes inside selectionSamu698
Before this patch the fill selection command would set the selection and one byte after it
2022-03-14HexEditor: Copy as C code doesn't add trailing spacesSamu698
2022-02-20HexEditor: Add support for handling PageUp and PageDown key eventsLiav A
In such case, move the cursor up or down the amount of bytes per row, multiplied by the visible content rectangle height, if possible.
2022-02-20HexEditor: Reduce code duplication when handling key down eventsLiav A
Instead of having the same update block for each event we can use lambda functions to help updating the cursor when handling key down events.
2022-02-14Applications: Use default constructors/destructorsLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-02-14HexEditor: Fix copy {text/hex} to clipboardFederico Guerinoni
Now the copy action takes exactly the selected chars and not one more.
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-20HexEditor: Use FileSystemAccessClient::try_* APIsMustafa Quraish
2021-12-23HexEditor: Don't unnecessarily abbreviate variable namesArne Elster
There's enough line space to use readable variable names.
2021-12-23HexEditor: Scroll back to the top when opening another fileArne Elster
When a file is opened and scrolled to some position and the user opens another file, the current scroll position stays the same. That's disorienting. Therefore, when opening another file, scroll back to the top.
2021-12-23HexEditor: Stream input files instead of keeping them in memoryArne Elster
To support editing of large files it is an advantage to not load the entire file into memory but only load whatever is needed for display at the moment. To make it work, file access is abstracted into a socalled HexDocument, of which there two: a memory based and a file based one. The former can be used for newly created documents, the latter for file based editing. Hex documents now do track changes instead of the HexEditor. HexEditor only sets new values. This frees HexEditor of some responsibility.
2021-11-08LibCore: Use ErrorOr<T> for Core::File::open()Andreas Kling
2021-11-01HexEditor: Give magic constants namesArne Elster
There are a lot of numbers just floating around in the code. Give them proper names.
2021-11-01HexEditor: Use size_t where applicableArne Elster
File positions as well as selection positions should be size_t, as they are never negative and can become quite big.
2021-11-01HexEditor: Remove magic color constant for modified bytesArne Elster
The magic constant does not work together well with themes. As there does not seem to be a suitable palette color for this, simply invert the color.
2021-11-01HexEditor: Show blinking caret at current positionArne Elster
For better visibility of wether the editing focus is on the hex or the ascii view, render a blinking caret instead of a solid cell background. For that to work, it's also necessary to change the way selection works. The selection shouldn't extend to the current position but up to the byte before it.
2021-10-27Everywhere: Rename left/right-click to primary/secondaryFiliph Sandström
This resolves #10641.
2021-09-13Everywhere: Use my fancy new serenityos.org email :^)Mustafa Quraish
2021-09-04HexEditor: Use FileSystemAccessClient, add unveilsMustafa Quraish
Most of the code here is based off the implementation of how TextEditor uses FileSystemAccessClient.
2021-06-01HexEditor: Fix off-by-one bugs in selected text length calculationsBrendan Coles
find_and_highlight() selected +1 too many bytes. 'Select All' selected +1 too many bytes past the end of the buffer. Status bar 'Selected Bytes' count was off by -1 when more than zero bytes were selected.
2021-05-29HexEditor: Add find_all_strings() functionBrendan Coles