1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +00:00

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>
This commit is contained in:
Sam Atkins 2024-01-10 19:49:40 +00:00 committed by Sam Atkins
parent 1168e46c1d
commit cbd28c9110
13 changed files with 378 additions and 4 deletions

View file

@ -451,6 +451,12 @@ ErrorOr<void> HexEditorWidget::initialize_menubar(GUI::Window& window)
}));
edit_menu->add_action(*m_fill_selection_action);
edit_menu->add_separator();
edit_menu->add_action(GUI::Action::create(
"Add Annotation",
Gfx::Bitmap::load_from_file("/res/icons/16x16/annotation-add.png"sv).release_value_but_fixme_should_propagate_errors(),
[this](GUI::Action&) { m_editor->show_create_annotation_dialog(); },
this));
edit_menu->add_separator();
edit_menu->add_action(*m_copy_hex_action);
edit_menu->add_action(*m_copy_text_action);
edit_menu->add_action(*m_copy_as_c_code_action);