Commit Graph

50 Commits

Author SHA1 Message Date
Sam Atkins
d4c051ece2 HexEditor: Add gaps between byte groups 2024-03-15 08:37:21 +00:00
Sam Atkins
4a2a40a3c8 HexEditor: Break bytes-per-row into numbers of groups of bytes 2024-03-15 08:37:21 +00:00
Sam Atkins
6850ef9014 HexEditor: Respond to font changes 2024-02-09 16:59:02 +00:00
Sam Atkins
3318563ad9 HexEditor: Size the offset area based on the text width
This gets rid of the last use of the offset_margin_width() magic number.

I initially tried using `character_width() * 10` and found it was not
accurate enough with between-character spacing, so instead this measures
a specific string. All offset strings should be the same width in a
fixed-width font.
2024-02-09 16:59:02 +00:00
Sam Atkins
0fdbdc5084 HexEditor: Use glyph_fixed_width() for character width 2024-02-09 16:59:02 +00:00
Sam Atkins
d3012f2df1 HexEditor: Share the code for updating the content size
And make setting the bytes_per_row a no-op if it's the same value.
2024-02-09 16:59:02 +00:00
Sam Atkins
c4dc150ed7 HexEditor: Extract some content-width calculations
We repeat the same calculations a lot, and it's easy to make mistakes.

m_address_bar_width and offset_margin_width() have basically the same
purpose, but both are a little wrong. This removes the former, but
we'll get to the latter soon.
2024-02-09 16:59:02 +00:00
Sam Atkins
8cac2e89a9 HexEditor: Store annotations in a Model
A model is necessary for displaying a list of them in the UI. We might
as well make that their home.
2024-01-30 23:34:49 +00:00
Sam Atkins
cbd28c9110 HexEditor: Add annotations system
Allow the user to highlight sections of the edited document, giving them
arbitrary background colors. These annotations can be created from a
selection, or by manually specifying the start and end offsets.
Annotations can be edited or deleted by right-clicking them.

Any color can be used for the background. Dark colors automatically make
the text white for easier readability. When creating a new annotation,
we use whatever color the user last picked as this is slightly more
likely to be the one they want.

Icons contributed by Cubic Love.

Co-authored-by: Cubic Love <7754483+cubiclove@users.noreply.github.com>
2024-01-14 13:45:02 +00:00
Sam Atkins
1168e46c1d HexEditor: Extract pixel-position-to-byte-offset code 2024-01-14 13:45:02 +00:00
Sam Atkins
84dd0ce1ae HexEditor: Wrap selection and behavior in a struct 2024-01-14 13:45:02 +00:00
tetektoza
c4c9971ed0 HexEditor: Change cursor type from caret to black box
This patch changes cursor type from caret to black box for both Hex and
Text modes, because right now the way how blinking caret looks like is
more closer to "insert" mode in similar editors, whereas the real
behavior of this cursor is more of a "replace" mode seen in similar
editors like GHex.
2023-12-27 09:22:09 +01:00
tetektoza
1ea675a9ec HexEditor: Remove blinking of the cursor 2023-12-27 09:22:09 +01:00
tetektoza
935aaab757 HexEditor: Port HexEditor to GML compilation 2023-12-08 01:06:09 +01:00
Andreas Kling
21db2b7b90 Everywhere: Remove NonnullOwnPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
689ca370d4 Everywhere: Remove NonnullRefPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling
b71c7a6e44 Userland: Use Font::pixel_size_rounded_up() instead of glyph_height()
The only remaining clients of this API are specific to bitmap fonts and
editing thereof.
2023-03-04 00:29:38 +01:00
MetallicSquid
eb27b397b8 HexEditor: Add selection strings to the value inspector
Strings include ASCII, UTF-8, and UTF-16

Co-authored-by: Andreas Krohn <hamburger1984@gmail.com>
2023-02-15 12:13:31 +00:00
Tim Schumacher
606a3982f3 LibCore: Move Stream-based file into the Core namespace 2023-02-13 00:50:07 +00:00
Lucas CHOLLET
a2dca2b762 HexEditor: Propagate errors when using "Save" 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
2bba743c24 HexEditor: Propagate errors when using "Save as" 2023-02-04 17:20:31 -07:00
Lucas CHOLLET
3d914247cc HexEditor: Port to Core::Stream 2023-02-04 17:20:31 -07:00
Sam Atkins
e181b1cb82 Userland: Use Core::Timer::create_foo() factory functions where possible 2023-01-12 11:25:51 +01:00
Arda Cinar
2dd7fa2d44 HexEditor: Handle some errors inside the editor
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-14 23:43:20 -07:00
kamp
8b0a464f5c HexEditor: Implement undo and redo actions 2022-11-01 12:07:28 +00:00
kamp
24f729d0ef HexEditor: Only mark window as modified when document is actually dirty 2022-11-01 12:07:28 +00:00
James Puleo
88cf40179d HexEditor: Make HexEditor::open_new_file fallible and reduce branching
Returning a `bool` is meaningless, so let's make it more expresive :^)
2022-08-03 10:12:11 -04:00
James Puleo
035d63f528 HexEditor: Remove unused readonly flag
`HexEditor::set_readonly` was never called, even though
`HexEditor::is_readonly` was occasionally queried -- so it's entirely
been removed.
2022-08-03 10:12:11 -04:00
Simon Wanner
206d6ece55 LibGfx: Move other font-related files to LibGfx/Font/ 2022-04-09 23:48:18 +02:00
Timothy Slater
604557c71b HexEditor: Add get_byte() method to HexEditor class 2022-04-07 16:55:20 +04:30
Timothy Slater
1b70c5f605 HexEditor: Add ability to set a selection range 2022-04-07 16:55:20 +04:30
Lenny Maiorani
160bda7228 Applications: Use default constructors/destructors
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-14 22:06:55 +00:00
Federico Guerinoni
932ce93fd7 HexEditor: Fix crash of copy action when selection is empty
Closes: #11925
2022-02-14 11:42:04 +01:00
Mustafa Quraish
aae96af812 HexEditor: Use FileSystemAccessClient::try_* APIs 2022-01-20 10:39:12 +01:00
Arne Elster
fd66dda1d7 HexEditor: Stream input files instead of keeping them in memory
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-12-23 23:25:47 -08:00
Arne Elster
be9a7057ff HexEditor: Give magic constants names
There are a lot of numbers just floating around in the code.
Give them proper names.
2021-11-01 01:48:51 +01:00
Arne Elster
4aab6ff839 HexEditor: Use size_t where applicable
File positions as well as selection positions should be size_t,
as they are never negative and can become quite big.
2021-11-01 01:48:51 +01:00
Arne Elster
41edc21a8e HexEditor: Show blinking caret at current position
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-11-01 01:48:51 +01:00
Mustafa Quraish
0f749681a9 Everywhere: Use my fancy new serenityos.org email :^) 2021-09-13 20:51:50 +00:00
Mustafa Quraish
8f2521ce52 HexEditor: Use FileSystemAccessClient, add unveils
Most of the code here is based off the implementation of how
TextEditor uses FileSystemAccessClient.
2021-09-04 03:32:58 +02:00
Brendan Coles
996f69a1b2 HexEditor: Fix off-by-one bugs in selected text length calculations
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-06-01 12:23:43 +02:00
Brendan Coles
90e9d1a0a1 HexEditor: Add find_all_strings() function 2021-05-29 16:26:12 +04:30
Brendan Coles
6aa766f8ca HexEditor: Add 'Find All' option to Find Dialog to find all matches 2021-05-27 22:57:17 +02:00
Brendan Coles
efef77a154 HexEditor: Add 'Go to Offset...' dialog 2021-05-23 18:13:49 +02:00
Brendan Coles
d1623350b5 HexEditor: Add 'Select All' action 2021-05-22 13:13:49 +04:30
Andreas Kling
d47f15ab8b LibGUI: Rename ScrollableWidget => AbstractScrollableWidget 2021-05-03 21:03:13 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Camisul
0678dab7dc HexEditor: Find
Added search submenu with options to find or find again.
Find allows to search for ASII string or sequence of Hex value.
2021-01-24 19:23:31 +01:00
Andreas Kling
1a08ac72ad LibC+Everywhere: Remove open_with_path_length() in favor of open()
This API was a mostly gratuitous deviation from POSIX that gave up some
portability in exchange for avoiding the occasional strlen().

I don't think that was actually achieving anything valuable, so let's
just chill out and have the same open() API as everyone else. :^)
2021-01-12 23:34:01 +01:00
Andreas Kling
dc28c07fa5 Applications: Move to Userland/Applications/ 2021-01-12 12:05:23 +01:00