mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
Improve bookmark API
This commit is contained in:
31
plugins/libimhex/source/api/imhex_api.cpp
Normal file
31
plugins/libimhex/source/api/imhex_api.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/helpers/shared_data.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
void ImHexApi::Bookmarks::add(Region region, std::string_view name, std::string_view comment, u32 color) {
|
||||
Entry entry;
|
||||
|
||||
entry.region = region;
|
||||
|
||||
entry.name.reserve(name.length());
|
||||
entry.comment.reserve(comment.length());
|
||||
std::copy(name.begin(), name.end(), std::back_inserter(entry.name));
|
||||
std::copy(comment.begin(), comment.end(), std::back_inserter(entry.comment));
|
||||
|
||||
entry.color = color;
|
||||
|
||||
EventManager::post(Events::AddBookmark, &entry);
|
||||
}
|
||||
|
||||
void ImHexApi::Bookmarks::add(u64 addr, size_t size, std::string_view name, std::string_view comment, u32 color) {
|
||||
Bookmarks::add(Region{addr, size}, name, comment, color);
|
||||
}
|
||||
|
||||
std::list<ImHexApi::Bookmarks::Entry>& ImHexApi::Bookmarks::getEntries() {
|
||||
return SharedData::bookmarkEntries;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user