mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:37:45 +00:00
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.
This commit is contained in:
parent
a54952795a
commit
8cac2e89a9
8 changed files with 157 additions and 46 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "AnnotationsModel.h"
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -20,15 +21,6 @@
|
|||
|
||||
constexpr Duration COMMAND_COMMIT_TIME = Duration::from_milliseconds(400);
|
||||
|
||||
struct Annotation {
|
||||
size_t start_offset { 0 };
|
||||
size_t end_offset { 0 };
|
||||
Gfx::Color background_color { Color::from_argb(0xfffce94f) };
|
||||
String comments {};
|
||||
|
||||
bool operator==(Annotation const& other) const = default;
|
||||
};
|
||||
|
||||
class HexDocument : public Weakable<HexDocument> {
|
||||
public:
|
||||
enum class Type {
|
||||
|
@ -50,14 +42,13 @@ public:
|
|||
virtual bool is_dirty() const;
|
||||
virtual void clear_changes() = 0;
|
||||
|
||||
ReadonlySpan<Annotation> annotations() const { return m_annotations; }
|
||||
void add_annotation(Annotation);
|
||||
void delete_annotation(Annotation const&);
|
||||
Optional<Annotation&> closest_annotation_at(size_t position);
|
||||
AnnotationsModel& annotations() { return *m_annotations; }
|
||||
|
||||
protected:
|
||||
HexDocument();
|
||||
|
||||
HashMap<size_t, u8> m_changes;
|
||||
Vector<Annotation> m_annotations;
|
||||
NonnullRefPtr<AnnotationsModel> m_annotations;
|
||||
};
|
||||
|
||||
class HexDocumentMemory final : public HexDocument {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue